Skip to content

Commit 013c840

Browse files
committed
working on all ports
1 parent d628d2a commit 013c840

19 files changed

Lines changed: 189 additions & 100 deletions

File tree

ports/atmel-samd/Makefile

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ endif
157157

158158

159159

160-
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
160+
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
161161
LIBS := -lgcc -lc
162162

163163
# Use toolchain libm if we're not using our own.
@@ -324,19 +324,10 @@ SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY)/clocks.c
324324

325325
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
326326

327-
LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE)))
328-
329-
# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk.
330-
# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE,
331-
# because it may include other template files.
332-
$(LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld
333-
$(STEPECHO) "GEN $@"
334-
$(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld
335-
336-
$(BUILD)/firmware.elf: $(OBJ) $(LD_FILE)
327+
$(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
337328
$(STEPECHO) "LINK $@"
338329
$(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group
339-
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
330+
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE)
340331

341332
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
342333
$(STEPECHO) "Create $@"

ports/atmel-samd/boards/common.template.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ MEMORY
66
FLASH_BOOTLOADER (rx): ORIGIN = ${BOOTLOADER_START_ADDR}, LENGTH = ${BOOTLOADER_SIZE}
77

88
FLASH_FIRMWARE (rx) : ORIGIN = ${CIRCUITPY_FIRMWARE_START_ADDR}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE}
9-
FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE}
10-
FLASH_CONFIG (r) : ORIGIN = ${CIRCUITPY_INTERNAL_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_CONFIG_SIZE}
119
FLASH_FILESYSTEM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE}
10+
FLASH_CONFIG (r) : ORIGIN = ${CIRCUITPY_INTERNAL_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_CONFIG_SIZE}
11+
FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE}
1212

1313
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = ${RAM_SIZE}
1414
}

ports/atmel-samd/mpconfigport.h

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@
8181
#endif
8282

8383
// If CIRCUITPY is internal, use half of flash for it.
84-
#ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE
85-
#if INTERNAL_FLASH_FILESYSTEM
86-
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2)
87-
#else
88-
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0)
84+
#if INTERNAL_FLASH_FILESYSTEM
85+
#ifndef CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE
86+
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (FLASH_SIZE/2)
8987
#endif
88+
#else
89+
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (0)
9090
#endif
9191

9292
// HSRAM_SIZE is defined in the ASF4 include files for each SAMD51 chip.
@@ -135,9 +135,9 @@
135135
//
136136
// bootloader (8 or 16kB)
137137
// firmware
138+
// internal CIRCUITPY flash filesystem (optional)
138139
// internal config, used to store crystalless clock calibration info (optional)
139140
// microntroller.nvm (optional)
140-
// internal CIRCUITPY flash filesystem (optional)
141141

142142
// Define these regions starting up from the bottom of flash:
143143

@@ -147,18 +147,43 @@
147147

148148
// Define these regions start down from the top of flash:
149149

150-
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \
151-
(FLASH_SIZE - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE)
152-
153150
#define CIRCUITPY_INTERNAL_NVM_START_ADDR \
154-
(CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_INTERNAL_NVM_SIZE)
151+
(FLASH_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE)
155152

156153
#define CIRCUITPY_INTERNAL_CONFIG_START_ADDR \
157154
(CIRCUITPY_INTERNAL_NVM_START_ADDR - CIRCUITPY_INTERNAL_CONFIG_SIZE)
158155

156+
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR \
157+
(CIRCUITPY_INTERNAL_CONFIG_START_ADDR - CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE)
158+
159159
// The firmware space is the space left over between the fixed lower and upper regions.
160160
#define CIRCUITPY_FIRMWARE_SIZE \
161-
(CIRCUITPY_INTERNAL_CONFIG_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR)
161+
(CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR - CIRCUITPY_FIRMWARE_START_ADDR)
162+
163+
#if BOOTLOADER_START_ADDR % FLASH_PAGE_SIZE != 0
164+
#error BOOTLOADER_START_ADDR must be on a flash page boundary.
165+
#endif
166+
167+
#if CIRCUITPY_INTERNAL_NVM_START_ADDR % FLASH_PAGE_SIZE != 0
168+
#error CIRCUITPY_INTERNAL_NVM_START_ADDR must be on a flash page boundary.
169+
#endif
170+
#if CIRCUITPY_INTERNAL_NVM_SIZE % FLASH_PAGE_SIZE != 0
171+
#error CIRCUITPY_INTERNAL_NVM_SIZE must be a multiple of FLASH_PAGE_SIZE.
172+
#endif
173+
174+
#if CIRCUITPY_INTERNAL_CONFIG_START_ADDR % FLASH_PAGE_SIZE != 0
175+
#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be on a flash page boundary.
176+
#endif
177+
#if CIRCUITPY_INTERNAL_CONFIG_SIZE % FLASH_PAGE_SIZE != 0
178+
#error CIRCUITPY_INTERNAL_CONFIG_SIZE must be a multiple of FLASH_PAGE_SIZE.
179+
#endif
180+
181+
#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR % FLASH_PAGE_SIZE != 0
182+
#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be on a flash page boundary.
183+
#endif
184+
#if CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE % FLASH_PAGE_SIZE != 0
185+
#error CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE must be a multiple of FLASH_PAGE_SIZE.
186+
#endif
162187

163188
#if CIRCUITPY_FIRMWARE_SIZE < 0
164189
#error No space left in flash for firmware after specifying other regions!

ports/atmel-samd/peripherals

ports/cxd56/boards/spresense/mpconfigboard.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ USB_VID = 0x054c
22
USB_PID = 0x0bc2
33
USB_PRODUCT = "Spresense"
44
USB_MANUFACTURER = "Sony"
5+
6+
INTERNAL_FLASH_FILESYSTEM = 1

ports/nrf/Makefile

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ ifneq ($(SD), )
6363
include bluetooth/bluetooth_common.mk
6464
endif
6565

66-
FROZEN_MPY_DIR = freeze
67-
6866
CROSS_COMPILE = arm-none-eabi-
6967

7068
FATFS_DIR = lib/oofatfs
@@ -92,7 +90,7 @@ INC += -I../../supervisor/shared/usb
9290
ifeq ($(DEBUG), 1)
9391
CFLAGS += -ggdb3 -Og
9492
else
95-
CFLAGS += -Os -DNDEBUG
93+
CFLAGS += -Os -DNDEBUG -ggdb3
9694
CFLAGS += -flto -flto-partition=none
9795
endif
9896

@@ -118,7 +116,7 @@ CFLAGS += \
118116
# TODO: check this
119117
CFLAGS += -D__START=main
120118

121-
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
119+
LDFLAGS = $(CFLAGS) -nostartfiles -fshort-enums -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
122120
LIBS := -lgcc -lc
123121

124122
LDFLAGS += -mthumb -mcpu=cortex-m4
@@ -193,15 +191,16 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE))
193191
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
194192
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
195193

196-
SRC_S = supervisor/cpu.s
194+
# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED,
195+
# because a few modules have files both in common-hal/ and shared-modules/.
196+
# Doing a $(sort ...) removes duplicates as part of sorting.
197+
SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED))
197198

198-
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py')
199-
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
199+
SRC_S = supervisor/cpu.s
200200

201201
OBJ += $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
202202
OBJ += $(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o))
203-
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
204-
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
203+
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
205204
ifeq ($(INTERNAL_LIBM),1)
206205
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
207206
endif
@@ -219,19 +218,10 @@ SRC_QSTR_PREPROCESSOR +=
219218

220219
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
221220

222-
LD_FILE = $(BUILD)/$(notdir $(patsubst %.template.ld,%.ld,$(LD_TEMPLATE_FILE)))
223-
224-
# ld_defines.pp is generated from ld_defines.c. See py/mkrules.mk.
225-
# Run gen_ld_files.py over ALL *.template.ld files, not just LD_TEMPLATE_FILE,
226-
# because it may include other template files.
227-
$(LD_FILE): $(BUILD)/ld_defines.pp boards/*.template.ld
228-
$(STEPECHO) "GEN $@"
229-
$(Q)$(PYTHON3) $(TOP)/tools/gen_ld_files.py --defines $< --out_dir $(BUILD) boards/*.template.ld
230-
231-
$(BUILD)/firmware.elf: $(OBJ)
221+
$(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
232222
$(STEPECHO) "LINK $@"
233-
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
234-
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
223+
$(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group
224+
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE)
235225

236226
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
237227
$(STEPECHO) "Create $@"
@@ -273,7 +263,7 @@ else ifeq ($(FLASHER), pyocd)
273263

274264
flash: $(BUILD)/firmware.hex
275265
pyocd-flashtool -t $(MCU_VARIANT) $< --sector_erase
276-
#pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR)
266+
# pyocd-tool -t $(MCU_VARIANT) erase $(BOOT_SETTING_ADDR)
277267
pyocd-tool -t $(MCU_VARIANT) write32 $(BOOT_SETTING_ADDR) 0x00000001
278268
pyocd-tool -t $(MCU_VARIANT) reset
279269

ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
#define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground Bluefruit"
3131
#define MICROPY_HW_MCU_NAME "nRF52840"
3232

33-
#define FLASH_SIZE (0x100000)
34-
#define FLASH_PAGE_SIZE (4096)
35-
3633
#define MICROPY_HW_LED_STATUS (&pin_P1_14)
3734

3835
// Unusually, board does not have a 32 kHz xtal. Nearly all boards do.

ports/nrf/boards/common.template.ld

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ MEMORY
99
/* nRF SoftDevice */
1010
FLASH_MBR (rx) : ORIGIN = ${MBR_START_ADDR}, LENGTH = ${MBR_SIZE}
1111
FLASH_SD (rx) : ORIGIN = ${SD_FLASH_START_ADDR}, LENGTH = ${SD_FLASH_SIZE}
12-
FLASH_ISR (rx) : ORIGIN = ${CIRCUITPY_ISR_START_ADDR}, LENGTH = ${CIRCUITPY_ISR_LENGTH}
12+
FLASH_ISR (rx) : ORIGIN = ${ISR_START_ADDR}, LENGTH = ${ISR_SIZE}
1313
FLASH_FIRMWARE (rx) : ORIGIN = ${CIRCUITPY_FIRMWARE_START_ADDR}, LENGTH = ${CIRCUITPY_FIRMWARE_SIZE}
14+
FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE}
1415
FLASH_BLE_CONFIG (r) : ORIGIN = ${CIRCUITPY_BLE_CONFIG_START_ADDR}, LENGTH = ${CIRCUITPY_BLE_CONFIG_SIZE}
1516
FLASH_NVM (r) : ORIGIN = ${CIRCUITPY_INTERNAL_NVM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_NVM_SIZE}
16-
FLASH_FATFS (r) : ORIGIN = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_START_ADDR}, LENGTH = ${CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE}
1717
FLASH_BOOTLOADER (rx) : ORIGIN = ${BOOTLOADER_START_ADDR}, LENGTH = ${BOOTLOADER_SIZE}
1818
FLASH_BOOTLOADER_SETTINGS (r) : ORIGIN = ${BOOTLOADER_SETTINGS_START_ADDR}, LENGTH = ${BOOTLOADER_SETTINGS_SIZE}
1919
RAM (xrw) : ORIGIN = 0x20004000, LENGTH = 0x03C000 /* 240 KiB */
@@ -32,10 +32,6 @@ _estack = ORIGIN(RAM) + LENGTH(RAM);
3232
_ram_end = ORIGIN(RAM) + LENGTH(RAM);
3333
_heap_end = 0x20020000; /* tunable */
3434

35-
/* Flash region for File System */
36-
__fatfs_flash_start_addr = ORIGIN(FLASH_FATFS);
37-
__fatfs_flash_length = LENGTH(FLASH_FATFS);
38-
3935
/* define output sections */
4036
SECTIONS
4137
{

ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@
3030
#define MICROPY_HW_BOARD_NAME "Adafruit Feather nRF52840 Express"
3131
#define MICROPY_HW_MCU_NAME "nRF52840"
3232

33-
#define FLASH_SIZE (0x100000)
34-
#define FLASH_PAGE_SIZE (4096)
35-
3633
#define MICROPY_HW_NEOPIXEL (&pin_P0_16)
3734

3835
#define MICROPY_HW_LED_STATUS (&pin_P1_15)

ports/nrf/boards/itsybitsy_nrf52840_express/mpconfigboard.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#define MICROPY_HW_BOARD_NAME "Adafruit ItsyBitsy nRF52840 Express"
44
#define MICROPY_HW_MCU_NAME "nRF52840"
55

6-
#define FLASH_SIZE (0x100000)
7-
#define FLASH_PAGE_SIZE (4096)
8-
96
#define MICROPY_HW_LED_STATUS (&pin_P0_06)
107

118
#define MICROPY_HW_APA102_MOSI (&pin_P0_08)

0 commit comments

Comments
 (0)