OpenNuvoton / M031BSP

BSP for M031 Series MCU
Apache License 2.0
15 stars 16 forks source link

ISP app for 2K LDROM size #4

Closed jeromeDms closed 2 years ago

jeromeDms commented 2 years ago

Hi I'm using M032FC1AE with LDRom size of 2K only. I tried to compile ISP USB Mass storage example but the resulting code size is 3.8K, or 3.1K when optimized for size. Is there something that can be improved in this code to fit into 2K ? On the other hand, what ISP app could fit into 2K ? Thanks.

kchuang1 commented 2 years ago

Hi It is hard to shrink the ISP USB code into 2KB. Please select another M032 part with 4K LDROM.

jeromeDms commented 2 years ago

Our hardware is already done using the M032FC1AE. I then plan to do as follow, please confirm is feasible to you :

Is this correct to you ?

kchuang1 commented 2 years ago

Hi,

It's correct. You can find an similar example at below link https://www.nuvoton.com/tool-and-software/application-software/example-code/

key word M031 to find this sample "M031 Multi-Application Jump"

jeromeDms commented 2 years ago

Great ! I just checked this example. It actually boots from LDRom and jump to App1 or App2 depending on user choice.

Is there a way to always boot from App1 and decide to jump to App2 by reading a flag at a fixed address where both App1 and App2 could access ?

In other words, how can I reserve one word at a fixed address and make sure the App will not be linked to this address ?

kchuang1 commented 2 years ago

Please refer the Nuvoton NuMicro ICP Prgrammer User Guide.pdf which guide you to boot from APROM by User Configuration Setting.

It is dependent on your application to reserve one word on the flash. Due to flash character, it can be program from 1 to 0 but unable change from 0 to 1 if not erase. If you want change the flag frequently, please note it.

jeromeDms commented 2 years ago

thanks !

jeromeDms commented 2 years ago

One more question. We want to add a flag at a fixed memory address to mention if the app is valid or not (The bootloader will read that flag and decide to jump to application if the flag is valid).

I can see :

/----------------------------------------------------------------------------------------------------------/ / Define Base Address / /----------------------------------------------------------------------------------------------------------/

define FMC_APROM_BASE 0x00000000UL /!< APROM base address \hideinitializer /

define FMC_LDROM_BASE 0x00100000UL /!< LDROM Base Address \hideinitializer /

define FMC_SPROM_BASE 0x00200000UL /!< SPROM Base Address \hideinitializer /

define FMC_CONFIG_BASE 0x00300000UL /!< CONFIG Base Address \hideinitializer /

define FMC_USER_CONFIG_0 0x00300000UL /!< User Config 0 address \hideinitializer /

define FMC_USER_CONFIG_1 0x00300004UL /!< User Config 1 address \hideinitializer /

define FMC_USER_CONFIG_2 0x00300008UL /!< User Config 2 address \hideinitializer /

Can we use FMC_USER_CONFIG_0 to store this flag ? Is there a user part in those registers where we can store a flag ?

Both the app and bootloader must be able to read/write this area, and I do not see anything in the data sheets that could prevent us from using this flash area to store the flag. thanks

kchuang1 commented 2 years ago

Due to the USER CONFIG store the important information for booting, it is not preferred to store the flag over there. You can try to save the flag at data flash area.

jeromeDms commented 2 years ago

Ok thanks for the answer. I'm not using LDRom to store my bootloader. I'll then use this LDROM to write my flag.

I assume here the LDROM can be read/write from the program running in APROM. Is this true ? Thanks

kchuang1 commented 2 years ago

Yes. You can use FMC_Read(...) function or refer BSP SampleCode/StdDriver/FMC_RW sample for it.

jeromeDms commented 2 years ago

thanks for your support