Move g_fmi_on_fmi.init() call function


I'm tring to implement program the flash entirely on S7G2, without bootloader.

I put all functions into internal RAM (PC never come back into flash) and if I try to program first 64K of flash it works, then I reset my CPU.

If I want to program more flash blocks, the system don't erase blocks becouse the g_fmi_data table is already into flash.

So, I add this table into ld script file to put it on internal RAM.

Now, my problem is that the call g_fmi_on_fmi.init() into SystemInit() is made before ram initialization bsp_section_copy(),

and the table g_fmi_data is not already initialized, so the system read a wrong table.

Can I move g_fmi_on_fmi.init() after ram initialization (in someway)?



  • The FMI table is used by the CGC driver that is used in bsp_clock_init() and g_ioport_on_ioport.init() so just moving the call to g_fmi_on_fmi.init() won't solve the issue.

    I see 2 possible ways to proceed :-

    1) Initialise the FMI table in the call to R_BSP_WarmStart(BSP_WARM_START_PRE_C); that occurs before g_fmi_on_fmi.init() (Just provide your own version of R_BSP_WarmStart() to override the default weakly referenced one).

    2) Edit the file system_S7G2.c and put the API calls in an order that works (you can exclude the original file from the build, and make a copy in the src\ directory and edit that copy)
  • In reply to Jeremy:

    Hi Jeremy, I choose option 2.
    Thanks a lot for your help.