@@ -332,8 +332,9 @@ int main(void) {
332332 qstr_init ();
333333 mp_init ();
334334 mp_obj_list_init (mp_sys_path , 0 );
335- mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR_0_colon__slash_ ));
336- mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR_0_colon__slash_lib ));
335+ mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR_ )); // current dir (or base dir of the script)
336+ mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR__slash_flash ));
337+ mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR__slash_flash_slash_lib ));
337338 mp_obj_list_init (mp_sys_argv , 0 );
338339
339340 readline_init ();
@@ -344,15 +345,15 @@ int main(void) {
344345 // local filesystem init
345346 {
346347 // try to mount the flash
347- FRESULT res = f_mount (& fatfs0 , "0: " , 1 );
348+ FRESULT res = f_mount (& fatfs0 , "/flash " , 1 );
348349 if (reset_mode == 3 || res == FR_NO_FILESYSTEM ) {
349350 // no filesystem, or asked to reset it, so create a fresh one
350351
351352 // LED on to indicate creation of LFS
352353 led_state (PYB_LED_R2 , 1 );
353354 uint32_t start_tick = HAL_GetTick ();
354355
355- res = f_mkfs ("0: " , 0 , 0 );
356+ res = f_mkfs ("/flash " , 0 , 0 );
356357 if (res == FR_OK ) {
357358 // success creating fresh LFS
358359 } else {
@@ -361,19 +362,19 @@ int main(void) {
361362
362363 // create empty main.py
363364 FIL fp ;
364- f_open (& fp , "0: /main.py" , FA_WRITE | FA_CREATE_ALWAYS );
365+ f_open (& fp , "/flash /main.py" , FA_WRITE | FA_CREATE_ALWAYS );
365366 UINT n ;
366367 f_write (& fp , fresh_main_py , sizeof (fresh_main_py ) - 1 /* don't count null terminator */ , & n );
367368 // TODO check we could write n bytes
368369 f_close (& fp );
369370
370371 // create .inf driver file
371- f_open (& fp , "0: /pybcdc.inf" , FA_WRITE | FA_CREATE_ALWAYS );
372+ f_open (& fp , "/flash /pybcdc.inf" , FA_WRITE | FA_CREATE_ALWAYS );
372373 f_write (& fp , fresh_pybcdc_inf , sizeof (fresh_pybcdc_inf ) - 1 /* don't count null terminator */ , & n );
373374 f_close (& fp );
374375
375376 // create readme file
376- f_open (& fp , "0: /README.txt" , FA_WRITE | FA_CREATE_ALWAYS );
377+ f_open (& fp , "/flash /README.txt" , FA_WRITE | FA_CREATE_ALWAYS );
377378 f_write (& fp , fresh_readme_txt , sizeof (fresh_readme_txt ) - 1 /* don't count null terminator */ , & n );
378379 f_close (& fp );
379380
@@ -387,14 +388,14 @@ int main(void) {
387388 }
388389 }
389390
390- // make sure we have a 0: /boot.py
391+ // make sure we have a /flash /boot.py
391392 {
392393 FILINFO fno ;
393394#if _USE_LFN
394395 fno .lfname = NULL ;
395396 fno .lfsize = 0 ;
396397#endif
397- FRESULT res = f_stat ("0: /boot.py" , & fno );
398+ FRESULT res = f_stat ("/flash /boot.py" , & fno );
398399 if (res == FR_OK ) {
399400 if (fno .fattrib & AM_DIR ) {
400401 // exists as a directory
@@ -411,7 +412,7 @@ int main(void) {
411412 uint32_t start_tick = HAL_GetTick ();
412413
413414 FIL fp ;
414- f_open (& fp , "0: /boot.py" , FA_WRITE | FA_CREATE_ALWAYS );
415+ f_open (& fp , "/flash /boot.py" , FA_WRITE | FA_CREATE_ALWAYS );
415416 UINT n ;
416417 f_write (& fp , fresh_boot_py , sizeof (fresh_boot_py ) - 1 /* don't count null terminator */ , & n );
417418 // TODO check we could write n bytes
@@ -424,21 +425,25 @@ int main(void) {
424425 }
425426
426427 // root device defaults to internal flash filesystem
427- uint root_device = 0 ;
428+ f_chdrive ( "/flash" ) ;
428429
429430#if defined(USE_DEVICE_MODE )
430431 usb_storage_medium_t usb_medium = USB_STORAGE_MEDIUM_FLASH ;
431432#endif
432433
433434#if MICROPY_HW_HAS_SDCARD
434- // if an SD card is present then mount it on 1: /
435+ // if an SD card is present then mount it on /sd /
435436 if (reset_mode == 1 && sdcard_is_present ()) {
436- FRESULT res = f_mount (& fatfs1 , "1: " , 1 );
437+ FRESULT res = f_mount (& fatfs1 , "/sd " , 1 );
437438 if (res != FR_OK ) {
438439 printf ("[SD] could not mount SD card\n" );
439440 } else {
440441 // use SD card as root device
441- root_device = 1 ;
442+ f_chdrive ("/sd" );
443+
444+ // TODO these should go before the /flash entries in the path
445+ mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR__slash_sd ));
446+ mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR__slash_sd_slash_lib ));
442447
443448 if (first_soft_reset ) {
444449 // use SD card as medium for the USB MSD
@@ -453,17 +458,12 @@ int main(void) {
453458 (void )first_soft_reset ;
454459#endif
455460
456- // run <root>:/ boot.py, if it exists
461+ // run boot.py, if it exists
457462 if (reset_mode == 1 ) {
458- const char * boot_file ;
459- if (root_device == 0 ) {
460- boot_file = "0:/boot.py" ;
461- } else {
462- boot_file = "1:/boot.py" ;
463- }
464- FRESULT res = f_stat (boot_file , NULL );
463+ const char * boot_py = "boot.py" ;
464+ FRESULT res = f_stat (boot_py , NULL );
465465 if (res == FR_OK ) {
466- if (!pyexec_file (boot_file )) {
466+ if (!pyexec_file (boot_py )) {
467467 flash_error (4 );
468468 }
469469 }
@@ -518,20 +518,18 @@ int main(void) {
518518
519519 // now that everything is initialised, run main script
520520 if (reset_mode == 1 && pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL ) {
521- vstr_t * vstr = vstr_new ();
522- vstr_printf (vstr , "%d:/" , root_device );
521+ const char * main_py ;
523522 if (pyb_config_main == MP_OBJ_NULL ) {
524- vstr_add_str ( vstr , "main.py" ) ;
523+ main_py = "main.py" ;
525524 } else {
526- vstr_add_str ( vstr , mp_obj_str_get_str (pyb_config_main ) );
525+ main_py = mp_obj_str_get_str (pyb_config_main );
527526 }
528- FRESULT res = f_stat (vstr_str ( vstr ) , NULL );
527+ FRESULT res = f_stat (main_py , NULL );
529528 if (res == FR_OK ) {
530- if (!pyexec_file (vstr_str ( vstr ) )) {
529+ if (!pyexec_file (main_py )) {
531530 flash_error (3 );
532531 }
533532 }
534- vstr_free (vstr );
535533 }
536534
537535#if MICROPY_HW_ENABLE_CC3K
0 commit comments