Nuvoton
/
NuMaker-mbed-bootloader-example
NuMaker bootloader with SD mode
Diff: main.cpp
- Revision:
- 7:90af0e9f9fa4
- Parent:
- 6:4dc994a04a99
--- a/main.cpp Thu Feb 25 10:17:10 2021 +0800 +++ b/main.cpp Mon Mar 13 02:08:34 2023 +0000 @@ -1,9 +1,10 @@ #include "mbed.h" -#if defined(TARGET_NUMAKER_PFM_NUC472) || defined(TARGET_NUMAKER_PFM_M487) +#if defined(TARGET_NUMAKER_PFM_NUC472) || defined(TARGET_NUMAKER_PFM_M487) || defined(TARGET_NUMAKER_IOT_M467) #include "NuSDBlockDevice.h" #else #include "SDBlockDevice.h" #endif +#include "FlashSimBlockDevice.h" #include "FATFileSystem.h" #define SD_MOUNT_PATH "sd" @@ -13,8 +14,10 @@ #error "target.restrict_size must be set for your target in mbed_app.json" #endif -#if defined(TARGET_NUMAKER_PFM_NUC472) || defined(TARGET_NUMAKER_PFM_M487) -NuSDBlockDevice sd; +#if defined(TARGET_NUMAKER_PFM_NUC472) || defined(TARGET_NUMAKER_PFM_M487) || defined(TARGET_NUMAKER_IOT_M467) +NuSDBlockDevice *bd_ = new NuSDBlockDevice(); +// Add flash-simulate layer on top of NUSD not implementing "erase" characteristic +FlashSimBlockDevice *bd = new FlashSimBlockDevice(bd_); #else //Pin order: MOSI, MISO, SCK, CS SDBlockDevice sd(MBED_CONF_APP_SD_CARD_MOSI, MBED_CONF_APP_SD_CARD_MISO, @@ -27,8 +30,7 @@ int main() { - sd.init(); - fs.mount(&sd); + int err = fs.mount(bd); #ifdef MBED_MAJOR_VERSION printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); #endif @@ -46,8 +48,7 @@ } fs.unmount(); - sd.deinit(); - + printf("Starting application\r\n"); mbed_start_application(POST_APPLICATION_ADDR);