EEPROM – Flash

Sysprogs forums Forums VisualGDB EEPROM – Flash

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10434
    bruno
    Participant

    Hi,

    I’m trying to write to and read from flash(stm32F105RB) – to store data like an EEPROM.

    I have already set the liker script(STM32F105RB_flash.lds):

    MEMORY
    {
    FLASH (RX) : ORIGIN = 0x08000000, LENGTH = 126K
    SRAM (RWX) : ORIGIN = 0x20000000, LENGTH = 64K
    EEPROM (RWX) : ORIGIN = 0x0803F800, LENGTH = 2K
    }

    SECTIONS
    {
    .user_data :
    {
    . = ALIGN(4);
    *(.user_data)
    . = ALIGN(4);
    } > EEPROM

    My code is like:

    __attribute__((__section__(“.user_data”)))  uint8_t userConfig;

    /*Write*/

    HAL_FLASH_Unlock();
    __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR);
    FLASH_PageErase(0x0803F800);  //page 127
    userConfig = 0;
    HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, (uint32_t) userConfig, data);
    HAL_FLASH_Lock();

    //read

    uint32_t test = *((uint16_t *)0x0803F800);

    It compiles Ok. But when i try do flash:

     

    compare-sections
    &”compare-sections\n”
    ~”Section .user_data, range 0x803f800 — 0x803f804: MIS-MATCHED!\n”
    ~”Section .isr_vector, range 0x8000000 — 0x80001e4: matched.\n”
    ~”Section .text, range 0x80001e4 — 0x801315c: matched.\n”

     

     

     

     

     

    #10438
    support
    Keymaster

    Hi,

    Please check the OpenOCD window for errors related to FLASH programming. This should explain why the initial programming fails.

    Please also double-check that you are not comparing the .user_data section after it is rewritten by your program and no longer matches the contents recorded in the ELF file.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.