Skip to content

Commit 10183d5

Browse files
authored
Merge pull request #2371 from dhalbert/ld-cleanup
Parameterize flash storage layout for atmel-samd and nrf
2 parents bcd03ed + ef2ef7a commit 10183d5

File tree

216 files changed

+949
-2152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

216 files changed

+949
-2152
lines changed

locale/circuitpython.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2019-12-12 14:51-0500\n"
11+
"POT-Creation-Date: 2019-12-12 15:51-0500\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"

main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void cleanup_after_vm(supervisor_allocation* heap) {
204204

205205
bool run_code_py(safe_mode_t safe_mode) {
206206
bool serial_connected_at_start = serial_connected();
207-
#ifdef CIRCUITPY_AUTORELOAD_DELAY_MS
207+
#if CIRCUITPY_AUTORELOAD_DELAY_MS > 0
208208
if (serial_connected_at_start) {
209209
serial_write("\n");
210210
if (autoreload_is_enabled()) {

ports/atmel-samd/Makefile

Lines changed: 11 additions & 6 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.
@@ -301,12 +301,17 @@ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE))
301301
$(addprefix shared-module/, $(SRC_SHARED_MODULE)) \
302302
$(addprefix shared-module/, $(SRC_SHARED_MODULE_INTERNAL))
303303

304+
# There may be duplicates between SRC_COMMON_HAL_EXPANDED and SRC_SHARED_MODULE_EXPANDED,
305+
# because a few modules have files both in common-hal/ and shared-modules/.
306+
# Doing a $(sort ...) removes duplicates as part of sorting.
307+
SRC_COMMON_HAL_SHARED_MODULE_EXPANDED = $(sort $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED))
308+
309+
304310
SRC_S = supervisor/$(CHIP_FAMILY)_cpu.s
305311

306312
OBJ = $(PY_O) $(SUPERVISOR_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
307313
OBJ += $(addprefix $(BUILD)/, $(SRC_ASF:.c=.o))
308-
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_EXPANDED:.c=.o))
309-
OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o))
314+
OBJ += $(addprefix $(BUILD)/, $(SRC_COMMON_HAL_SHARED_MODULE_EXPANDED:.c=.o))
310315
ifeq ($(INTERNAL_LIBM),1)
311316
OBJ += $(addprefix $(BUILD)/, $(SRC_LIBM:.c=.o))
312317
endif
@@ -319,10 +324,10 @@ SRC_QSTR_PREPROCESSOR += peripherals/samd/$(CHIP_FAMILY)/clocks.c
319324

320325
all: $(BUILD)/firmware.bin $(BUILD)/firmware.uf2
321326

322-
$(BUILD)/firmware.elf: $(OBJ)
327+
$(BUILD)/firmware.elf: $(OBJ) $(GENERATED_LD_FILE)
323328
$(STEPECHO) "LINK $@"
324-
$(Q)$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
325-
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(LD_FILE)
329+
$(Q)$(CC) -o $@ $(LDFLAGS) $(OBJ) -Wl,--start-group $(LIBS) -Wl,--end-group
330+
$(Q)$(SIZE) $@ | $(PYTHON3) $(TOP)/tools/build_memory_info.py $(GENERATED_LD_FILE)
326331

327332
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
328333
$(STEPECHO) "Create $@"

ports/atmel-samd/bindings/samd/Clock.c

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,263 @@ const mp_obj_type_t samd_clock_type = {
163163
.print = samd_clock_print,
164164
.locals_dict = (mp_obj_t)&samd_clock_locals_dict,
165165
};
166+
167+
#ifdef SAMD21
168+
169+
#ifdef SAMD21_EXPOSE_ALL_CLOCKS
170+
CLOCK_SOURCE(XOSC);
171+
CLOCK_SOURCE(GCLKIN);
172+
CLOCK_SOURCE(GCLKGEN1);
173+
CLOCK_SOURCE(OSCULP32K);
174+
#endif
175+
CLOCK_SOURCE(OSC32K);
176+
CLOCK_SOURCE(XOSC32K);
177+
#ifdef SAMD21_EXPOSE_ALL_CLOCKS
178+
CLOCK_SOURCE(OSC8M);
179+
CLOCK_SOURCE(DFLL48M);
180+
CLOCK_SOURCE(DPLL96M);
181+
182+
CLOCK_GCLK_(SYSCTRL, DFLL48);
183+
CLOCK_GCLK_(SYSCTRL, FDPLL);
184+
CLOCK_GCLK_(SYSCTRL, FDPLL32K);
185+
CLOCK_GCLK(WDT);
186+
#endif
187+
CLOCK_GCLK(RTC);
188+
#ifdef SAMD21_EXPOSE_ALL_CLOCKS
189+
CLOCK_GCLK(EIC);
190+
CLOCK_GCLK(USB);
191+
CLOCK_GCLK_(EVSYS, 0);
192+
CLOCK_GCLK_(EVSYS, 1);
193+
CLOCK_GCLK_(EVSYS, 2);
194+
CLOCK_GCLK_(EVSYS, 3);
195+
CLOCK_GCLK_(EVSYS, 4);
196+
CLOCK_GCLK_(EVSYS, 5);
197+
CLOCK_GCLK_(EVSYS, 6);
198+
CLOCK_GCLK_(EVSYS, 7);
199+
CLOCK_GCLK_(EVSYS, 8);
200+
CLOCK_GCLK_(EVSYS, 9);
201+
CLOCK_GCLK_(EVSYS, 10);
202+
CLOCK_GCLK_(EVSYS, 11);
203+
CLOCK(SERCOMx_SLOW, 1, 19);
204+
CLOCK_GCLK_(SERCOM0, CORE);
205+
CLOCK_GCLK_(SERCOM1, CORE);
206+
CLOCK_GCLK_(SERCOM2, CORE);
207+
CLOCK_GCLK_(SERCOM3, CORE);
208+
CLOCK_GCLK_(SERCOM4, CORE);
209+
CLOCK_GCLK_(SERCOM5, CORE);
210+
CLOCK(TCC0_TCC1, 1, 26);
211+
CLOCK(TCC2_TCC3, 1, 27);
212+
CLOCK(TC4_TC5, 1, 28);
213+
CLOCK(TC6_TC7, 1, 29);
214+
CLOCK_GCLK(ADC);
215+
CLOCK_GCLK_(AC, DIG);
216+
CLOCK_GCLK_(AC, ANA);
217+
CLOCK_GCLK(DAC);
218+
CLOCK_GCLK(PTC);
219+
CLOCK_GCLK_(I2S, 0);
220+
CLOCK_GCLK_(I2S, 1);
221+
222+
CLOCK(SYSTICK, 2, 0);
223+
#endif
224+
225+
STATIC const mp_rom_map_elem_t samd_clock_global_dict_table[] = {
226+
#ifdef SAMD21_EXPOSE_ALL_CLOCKS
227+
CLOCK_ENTRY(XOSC),
228+
CLOCK_ENTRY(GCLKIN),
229+
CLOCK_ENTRY(GCLKGEN1),
230+
CLOCK_ENTRY(OSCULP32K),
231+
#endif
232+
CLOCK_ENTRY(OSC32K),
233+
CLOCK_ENTRY(XOSC32K),
234+
#ifdef SAMD21_EXPOSE_ALL_CLOCKS
235+
CLOCK_ENTRY(OSC8M),
236+
CLOCK_ENTRY(DFLL48M),
237+
CLOCK_ENTRY(DPLL96M),
238+
CLOCK_ENTRY_(SYSCTRL, DFLL48),
239+
CLOCK_ENTRY_(SYSCTRL, FDPLL),
240+
CLOCK_ENTRY_(SYSCTRL, FDPLL32K),
241+
CLOCK_ENTRY(WDT),
242+
#endif
243+
CLOCK_ENTRY(RTC),
244+
#ifdef SAMD21_EXPOSE_ALL_CLOCKS
245+
CLOCK_ENTRY(EIC),
246+
CLOCK_ENTRY(USB),
247+
CLOCK_ENTRY_(EVSYS, 0),
248+
CLOCK_ENTRY_(EVSYS, 1),
249+
CLOCK_ENTRY_(EVSYS, 2),
250+
CLOCK_ENTRY_(EVSYS, 3),
251+
CLOCK_ENTRY_(EVSYS, 4),
252+
CLOCK_ENTRY_(EVSYS, 5),
253+
CLOCK_ENTRY_(EVSYS, 6),
254+
CLOCK_ENTRY_(EVSYS, 7),
255+
CLOCK_ENTRY_(EVSYS, 8),
256+
CLOCK_ENTRY_(EVSYS, 9),
257+
CLOCK_ENTRY_(EVSYS, 10),
258+
CLOCK_ENTRY_(EVSYS, 11),
259+
CLOCK_ENTRY(SERCOMx_SLOW),
260+
CLOCK_ENTRY_(SERCOM0, CORE),
261+
CLOCK_ENTRY_(SERCOM1, CORE),
262+
CLOCK_ENTRY_(SERCOM2, CORE),
263+
CLOCK_ENTRY_(SERCOM3, CORE),
264+
CLOCK_ENTRY_(SERCOM4, CORE),
265+
CLOCK_ENTRY_(SERCOM5, CORE),
266+
CLOCK_ENTRY(TCC0_TCC1),
267+
CLOCK_ENTRY(TCC2_TCC3),
268+
CLOCK_ENTRY(TC4_TC5),
269+
CLOCK_ENTRY(TC6_TC7),
270+
CLOCK_ENTRY(ADC),
271+
CLOCK_ENTRY_(AC, DIG),
272+
CLOCK_ENTRY_(AC, ANA),
273+
CLOCK_ENTRY(DAC),
274+
CLOCK_ENTRY(PTC),
275+
CLOCK_ENTRY_(I2S, 0),
276+
CLOCK_ENTRY_(I2S, 1),
277+
278+
CLOCK_ENTRY(SYSTICK),
279+
#endif
280+
};
281+
MP_DEFINE_CONST_DICT(samd_clock_globals, samd_clock_global_dict_table);
282+
283+
#endif // SAMD21
284+
285+
#ifdef SAMD51
286+
287+
288+
289+
#include <instance/can0.h>
290+
#include <instance/can1.h>
291+
#include <instance/i2s.h>
292+
#include <instance/sdhc1.h>
293+
#include <instance/sercom6.h>
294+
#include <instance/sercom7.h>
295+
#include <instance/tcc4.h>
296+
297+
CLOCK_SOURCE(XOSC0);
298+
CLOCK_SOURCE(XOSC1);
299+
CLOCK_SOURCE(GCLKIN);
300+
CLOCK_SOURCE(GCLKGEN1);
301+
CLOCK_SOURCE(OSCULP32K);
302+
CLOCK_SOURCE(XOSC32K);
303+
CLOCK_SOURCE(DFLL);
304+
CLOCK_SOURCE(DPLL0);
305+
CLOCK_SOURCE(DPLL1);
306+
307+
CLOCK_GCLK_(OSCCTRL, DFLL48);
308+
CLOCK_GCLK_(OSCCTRL, FDPLL0);
309+
CLOCK_GCLK_(OSCCTRL, FDPLL1);
310+
CLOCK_GCLK_(OSCCTRL, FDPLL032K); // GCLK_OSCCTRL_FDPLL1_32K, GCLK_SDHC0_SLOW, GCLK_SDHC1_SLOW, GCLK_SERCOM[0..7]_SLOW
311+
CLOCK_GCLK(EIC);
312+
CLOCK_GCLK_(FREQM, MSR);
313+
// 6: GCLK_FREQM_REF
314+
CLOCK_GCLK_(SERCOM0, CORE);
315+
CLOCK_GCLK_(SERCOM1, CORE);
316+
CLOCK(TC0_TC1, 1, 9);
317+
CLOCK_GCLK(USB);
318+
CLOCK_GCLK_(EVSYS, 0);
319+
CLOCK_GCLK_(EVSYS, 1);
320+
CLOCK_GCLK_(EVSYS, 2);
321+
CLOCK_GCLK_(EVSYS, 3);
322+
CLOCK_GCLK_(EVSYS, 4);
323+
CLOCK_GCLK_(EVSYS, 5);
324+
CLOCK_GCLK_(EVSYS, 6);
325+
CLOCK_GCLK_(EVSYS, 7);
326+
CLOCK_GCLK_(EVSYS, 8);
327+
CLOCK_GCLK_(EVSYS, 9);
328+
CLOCK_GCLK_(EVSYS, 10);
329+
CLOCK_GCLK_(EVSYS, 11);
330+
CLOCK_GCLK_(SERCOM2, CORE);
331+
CLOCK_GCLK_(SERCOM3, CORE);
332+
CLOCK(TCC0_TCC1, 1, 25);
333+
CLOCK(TC2_TC3, 1, 26);
334+
CLOCK_GCLK(CAN0);
335+
CLOCK_GCLK(CAN1);
336+
CLOCK(TCC2_TCC3, 1, 29);
337+
CLOCK(TC4_TC5, 1, 30);
338+
// CLOCK_GCLK(PDEC);
339+
// CLOCK_GCLK(AC);
340+
// CLOCK_GCLK(CCL);
341+
CLOCK_GCLK_(SERCOM4, CORE);
342+
CLOCK_GCLK_(SERCOM5, CORE);
343+
CLOCK_GCLK_(SERCOM6, CORE);
344+
CLOCK_GCLK_(SERCOM7, CORE);
345+
CLOCK_GCLK(TCC4);
346+
CLOCK(TC6_TC7, 1, 39);
347+
CLOCK_GCLK(ADC0);
348+
CLOCK_GCLK(ADC1);
349+
CLOCK_GCLK(DAC);
350+
CLOCK_GCLK_(I2S, 0);
351+
CLOCK_GCLK_(I2S, 1);
352+
// CLOCK_GCLK(SDHC0);
353+
// CLOCK_GCLK(SDHC1);
354+
// 47: GCLK_CM4_TRACE
355+
356+
CLOCK(SYSTICK, 2, 0);
357+
CLOCK(CPU, 2, 1);
358+
CLOCK(RTC, 2, 2);
359+
360+
361+
STATIC const mp_rom_map_elem_t samd_clock_global_dict_table[] = {
362+
CLOCK_ENTRY(XOSC0),
363+
CLOCK_ENTRY(XOSC1),
364+
CLOCK_ENTRY(GCLKIN),
365+
CLOCK_ENTRY(GCLKGEN1),
366+
CLOCK_ENTRY(OSCULP32K),
367+
CLOCK_ENTRY(XOSC32K),
368+
CLOCK_ENTRY(DFLL),
369+
CLOCK_ENTRY(DPLL0),
370+
CLOCK_ENTRY(DPLL1),
371+
372+
CLOCK_ENTRY_(OSCCTRL, DFLL48),
373+
CLOCK_ENTRY_(OSCCTRL, FDPLL0),
374+
CLOCK_ENTRY_(OSCCTRL, FDPLL1),
375+
CLOCK_ENTRY_(OSCCTRL, FDPLL032K),
376+
CLOCK_ENTRY(EIC),
377+
CLOCK_ENTRY_(FREQM, MSR),
378+
CLOCK_ENTRY_(SERCOM0, CORE),
379+
CLOCK_ENTRY_(SERCOM1, CORE),
380+
CLOCK_ENTRY(TC0_TC1),
381+
CLOCK_ENTRY(USB),
382+
CLOCK_ENTRY_(EVSYS, 0),
383+
CLOCK_ENTRY_(EVSYS, 1),
384+
CLOCK_ENTRY_(EVSYS, 2),
385+
CLOCK_ENTRY_(EVSYS, 3),
386+
CLOCK_ENTRY_(EVSYS, 4),
387+
CLOCK_ENTRY_(EVSYS, 5),
388+
CLOCK_ENTRY_(EVSYS, 6),
389+
CLOCK_ENTRY_(EVSYS, 7),
390+
CLOCK_ENTRY_(EVSYS, 8),
391+
CLOCK_ENTRY_(EVSYS, 9),
392+
CLOCK_ENTRY_(EVSYS, 10),
393+
CLOCK_ENTRY_(EVSYS, 11),
394+
CLOCK_ENTRY_(SERCOM2, CORE),
395+
CLOCK_ENTRY_(SERCOM3, CORE),
396+
CLOCK_ENTRY(TCC0_TCC1),
397+
CLOCK_ENTRY(TC2_TC3),
398+
CLOCK_ENTRY(CAN0),
399+
CLOCK_ENTRY(CAN1),
400+
CLOCK_ENTRY(TCC2_TCC3),
401+
CLOCK_ENTRY(TC4_TC5),
402+
// CLOCK_ENTRY(PDEC),
403+
// CLOCK_ENTRY(AC),
404+
// CLOCK_ENTRY(CCL),
405+
CLOCK_ENTRY_(SERCOM4, CORE),
406+
CLOCK_ENTRY_(SERCOM5, CORE),
407+
CLOCK_ENTRY_(SERCOM6, CORE),
408+
CLOCK_ENTRY_(SERCOM7, CORE),
409+
CLOCK_ENTRY(TCC4),
410+
CLOCK_ENTRY(TC6_TC7),
411+
CLOCK_ENTRY(ADC0),
412+
CLOCK_ENTRY(ADC1),
413+
CLOCK_ENTRY(DAC),
414+
CLOCK_ENTRY_(I2S, 0),
415+
CLOCK_ENTRY_(I2S, 1),
416+
// CLOCK_ENTRY(SDHC0),
417+
// CLOCK_ENTRY(SDHC1),
418+
419+
CLOCK_ENTRY(SYSTICK),
420+
CLOCK_ENTRY(CPU),
421+
CLOCK_ENTRY(RTC),
422+
};
423+
MP_DEFINE_CONST_DICT(samd_clock_globals, samd_clock_global_dict_table);
424+
425+
#endif // SAMD51

ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77

88
#define MICROPY_HW_LED_STATUS (&pin_PB23)
99

10-
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
11-
12-
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
13-
1410
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
1511
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
1612

ports/atmel-samd/boards/arduino_mkr1300/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LD_FILE = boards/samd21x18-bootloader.ld
21
USB_VID = 0x2341
32
USB_PID = 0x8053
43
USB_PRODUCT = "Arduino MKR1300"

ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#define MICROPY_PORT_B (0)
66
#define MICROPY_PORT_C (0)
77

8-
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
9-
10-
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
11-
128
#define DEFAULT_I2C_BUS_SCL (&pin_PA09)
139
#define DEFAULT_I2C_BUS_SDA (&pin_PA08)
1410

ports/atmel-samd/boards/arduino_mkrzero/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LD_FILE = boards/samd21x18-bootloader.ld
21
USB_VID = 0x239A
32
USB_PID = 0x8050
43
USB_PRODUCT = "Arduino MKRZero"

ports/atmel-samd/boards/arduino_zero/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
#define MICROPY_PORT_B (PORT_PB03)
1111
#define MICROPY_PORT_C (0)
1212

13-
#define CIRCUITPY_INTERNAL_NVM_SIZE 256
14-
15-
#define BOARD_FLASH_SIZE (0x00040000 - 0x2000 - 0x010000 - CIRCUITPY_INTERNAL_NVM_SIZE)
16-
1713
#define DEFAULT_I2C_BUS_SCL (&pin_PA23)
1814
#define DEFAULT_I2C_BUS_SDA (&pin_PA22)
1915

ports/atmel-samd/boards/arduino_zero/mpconfigboard.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
LD_FILE = boards/samd21x18-bootloader.ld
21
USB_VID = 0x2341
32
USB_PID = 0x824D
43
USB_PRODUCT = "Arduino Zero"

0 commit comments

Comments
 (0)