Skip to content

Commit f2bfbab

Browse files
committed
atmel-samd: Save space by not creating default files on the FS and by only keeping LED flashing code when LEDs are present.
1 parent 1598e44 commit f2bfbab

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

atmel-samd/main.c

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) {
5353
}
5454
}
5555

56-
// TODO(tannewt): Remove these default files in favor a very simple README with
57-
// a url to all of the files that ship on boards.
58-
59-
static const char fresh_code_txt[] =
60-
"# code.txt -- put your code here!\r\n"
61-
;
62-
63-
static const char fresh_readme_txt[] =
64-
"https://learn.adafruit.com/category/micropython\r\n"
65-
;
66-
6756
extern void flash_init_vfs(fs_user_mount_t *vfs);
6857

6958
// we don't make this function static because it needs a lot of stack and we
@@ -91,38 +80,18 @@ void init_flash_fs(void) {
9180
vfs->flags &= ~FSUSER_USB_WRITEABLE;
9281

9382
res = f_mkfs("/flash", 0, 0);
94-
if (res == FR_OK) {
95-
// success creating fresh LFS
96-
} else {
97-
printf("PYB: can't create flash filesystem\n");
83+
if (res != FR_OK) {
9884
MP_STATE_PORT(fs_user_mount)[0] = NULL;
9985
return;
10086
}
10187

10288
// set label
10389
f_setlabel("MICROPYTHON");
10490

105-
// create empty code.txt
106-
FIL fp;
107-
f_open(&fp, "/flash/code.txt", FA_WRITE | FA_CREATE_ALWAYS);
108-
UINT n;
109-
f_write(&fp, fresh_code_txt, sizeof(fresh_code_txt) - 1 /* don't count null terminator */, &n);
110-
f_close(&fp);
111-
112-
// TODO(tannewt): Create an .inf driver file for Windows.
113-
114-
// create readme file
115-
f_open(&fp, "/flash/README.txt", FA_WRITE | FA_CREATE_ALWAYS);
116-
f_write(&fp, fresh_readme_txt, sizeof(fresh_readme_txt) - 1 /* don't count null terminator */, &n);
117-
f_close(&fp);
118-
11991
if (usb_writeable) {
12092
vfs->flags |= FSUSER_USB_WRITEABLE;
12193
}
122-
} else if (res == FR_OK) {
123-
// mount successful
124-
} else {
125-
printf("PYB: can't mount flash\n");
94+
} else if (res != FR_OK) {
12695
MP_STATE_PORT(fs_user_mount)[0] = NULL;
12796
return;
12897
}
@@ -242,8 +211,9 @@ bool start_mp(void) {
242211
#endif
243212

244213
// Wait for connection or character.
245-
new_status_color(ALL_DONE);
246214
bool cdc_enabled_before = false;
215+
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
216+
new_status_color(ALL_DONE);
247217
uint32_t pattern_start = ticks_ms;
248218

249219
uint32_t total_exception_cycle = 0;
@@ -267,6 +237,7 @@ bool start_mp(void) {
267237
if (result.return_code == PYEXEC_EXCEPTION) {
268238
total_exception_cycle = EXCEPTION_TYPE_LENGTH_MS * 3 + LINE_NUMBER_TOGGLE_LENGTH * digit_sum + LINE_NUMBER_TOGGLE_LENGTH * num_places;
269239
}
240+
#endif
270241
while (true) {
271242
#ifdef MICROPY_VM_HOOK_LOOP
272243
MICROPY_VM_HOOK_LOOP
@@ -292,6 +263,7 @@ bool start_mp(void) {
292263
}
293264
cdc_enabled_before = mp_cdc_enabled;
294265

266+
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
295267
uint32_t tick_diff = ticks_ms - pattern_start;
296268
if (result.return_code != PYEXEC_EXCEPTION) {
297269
// All is good. Ramp ALL_DONE up and down.
@@ -366,6 +338,9 @@ bool start_mp(void) {
366338
new_status_color(BLACK);
367339
}
368340
}
341+
#else
342+
(void) found_main; // Pretend to use found_main so the compiler doesn't complain.
343+
#endif
369344
}
370345
}
371346

0 commit comments

Comments
 (0)