Home > Blockchain >  If there is a const variable in my c code and Linker script has RO data is present in flash, how can
If there is a const variable in my c code and Linker script has RO data is present in flash, how can

Time:09-26

   LR_HEADER 0x08001800 NOCOMPRESS ALIGN 2048 0x800 ;size = 2kB
    {
      ER_HEADER 0x08001800 FIXED ALIGN 2048 0x800
      {
        *(:gdef:image_hdr)
      }
    }
    

    {
      ;//**********************************
      ;/// all RO Data in the Application (flash)
      ;//**********************************
      ER_RO_APPLICATION 0x08002000 0x1C800
      {
        *.o (RESET,  First)
        *(InRoot$$Sections)
        .ANY ( RO)
      }
    
      ;ER_VECTOR_TABLE 0x20000000 EMPTY 0xC0                                         ; 512 Byte-placeholder for vector table of application (SRAM)
      ;{
      ;}
    
      NIRAM 0x200000C0 UNINIT                                                       ; Placeholder for NIRAM for bootloader-application-communication (SRAM)
      {
        *.o(NIRAM)
      }
    
      ER_STACKS  0                                                                  ; Stack and OS / task stacks (SRAM)
      {
        ;stm32f0xx_startup.o(STACK,  FIRST)
        *.o(STACK,  FIRST)
        ; rtx_cfg.o(.bss)
        *rtx_cfg*.o(.bss)
      }
    
      ER_RW_APPLICATION  0                                                          
      {
        .ANY( RW,  ZI)
      }
    }
    
    

    LR_CHECKSUM  0x0 NOCOMPRESS ALIGN 4 0x4
    {
      ER_CRC32  0 0x4
      {
        ; application_crc.o(:gdef:APPCRC_ulCRC32)
        *application_crc*.o(:gdef:APPCRC_ulCRC32)
      }
    }
    
    
    ; Load Region "FLASH"
    ; In diesem Bereich wird der Flash-Pool der Applikation verwaltet
    ; die Größe ist so zu wählen, dass der Parameterbereich im Anschluss noch Platz findet

    
    

This is the piece of my linker script. And I want some configuration to be placed in Flash, so that next time my MCU starts it fetches the address to the reset vector and jumps to the application from the bootloader. And I want to change this data, which is present configuration section flash(which I will create).

How can I modify a variable which is in Flash without using flash drivers to modify it.?

CodePudding user response:

How can I modify a variable which is in Flash without using flash drivers to modify it.?

You can't. Your program needs to erase the FLASH segment and program it again. It cant be done any other way.

  • Related