S7G2-DK - Access flash for savings logs/settings

I'm using S7G2 and I would like to save some settings (or, say, few variables) to flash so that I can restore it on next reboot.

 

Please let me know if someone has an example, or any guidance would be much appreciated.

  • Hello gnk,

    Here is a 'QSPI HAL Module Guide' for SK-S7G2 but for overview it also may be useful for DK.
    www.renesas.com/.../D6001438.html

    Best regards,
    masj

  • In reply to masj:

    Is this for QSPI flash? I wanted to use the internal flash... How can I make a variable as non-volatile by keeping it in internal flash? Thanks
  • In reply to gnk:

    Hello gnk,

    There is also available a MG for internal flash:
    www.renesas.com/.../D6001407.html

    Best regards,
    masj
  • In reply to masj:

    Thanks Masj. I just came across this link: renesasrulz.com/.../26508

    Here it's mentioned that we can place a variable in flash by using BSP_PLACE_IN_SECTION(".data_flash_xyz")

    Do you know how we can do this? Does this needs the HAL flash driver to be added? Is there a procedure to do this?

    Thanks
  • In reply to gnk:

    Hello gnk,

    In that case Flash Driver may be used for writing settings to data flash area. You don't need to use flash read api function every time you want to get values of that data provided you place variables in data_flash section.

    For example you want to have a structure containing some configuration values located in data_flash memory section:
    board_config_t board_config BSP_PLACE_IN_SECTION(".data_flash");

    Now you can update that block of memory with new configuration values using Flash Driver API function write. But when you want to get that values you just use structure:

    uint32_t tmp = board_config.cfg_field_1;

    I recommend you HAL Flash Driver Module Guide. There is a nice example of using code flash and data flash.

    Best regards,
    masj