Author Topic: Put value into flash memory Bootloader Area  (Read 4113 times)

Offline FABRIZIO

  • Newbie
  • *
  • Posts: 5
    • View Profile
Put value into flash memory Bootloader Area
« on: October 16, 2018, 10:37:32 AM »
Hi all,
 I have to put four values within a certain flash memory area and I have to do it within the UTaskerSerialBoot project. The microcontroller used is Kinetis KEAZN64.
For example: put 0x01 0x02 0x03 0x04 in memory locations 0x00001FFC - 0x00001FFD - 0x00001FFE - 0x00001FFF.
Is it possible to do this in the Task project?
Which is the most suitable system? and in which files of the Task project enter the change?
Thank you
Fabrizio

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Put value into flash memory Bootloader Area
« Reply #1 on: October 16, 2018, 12:34:21 PM »
Fabrizio

You will need to change the linker script file to do this but you can copy the method used for locating the Flash configuration area.

1. [simplified for GCC but see original code for other compilers]
// Flash configuration - this is linked at address 0x00000400 (when working with standalone-build)
//
const KINETIS_FLASH_CONFIGURATION __attribute__((section(".f_config"))) __flash_config
= {
    KINETIS_FLASH_CONFIGURATION_BACKDOOR_KEY,
    KINETIS_FLASH_CONFIGURATION_PROGRAM_PROTECTION,
    KINETIS_FLASH_CONFIGURATION_SECURITY,
    KINETIS_FLASH_CONFIGURATION_NONVOL_OPTION,
    KINETIS_FLASH_CONFIGURATION_EEPROM_PROT,
    KINETIS_FLASH_CONFIGURATION_DATAFLASH_PROT
};



2. In the linker script file you need to add a section that is referenced by the __attribute__ (.f_config) in above case
  .f_config ALIGN(__Fconfig_segment_start__ , 4) :
  {
    __flash_config = .;
    KEEP(*(.f_config .f_config.*))
  }


This will put your const values into a section.
Note the KEEP() which informs that linker that it should ALWAYS put the values there, even if it doesn't think that they are being used.

3. The physical address range of the section then also needs to be define in the linker script
  __Fconfig_segment_start__ = 0x00000400;
  __Fconfig_segment_end__  = 0x0000040f;


In the case of the flash configuration it starts at 0x400 and can be 0x10 bytes long


If you do the equivalent for a new section/segment you will be able to locate const values there.

Good luck

Regards

Mark


Offline FABRIZIO

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Put value into flash memory Bootloader Area
« Reply #2 on: October 16, 2018, 03:11:12 PM »
Done...   all ok!
Thank you very much. Fabrizio

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Put value into flash memory Bootloader Area
« Reply #3 on: October 16, 2018, 05:25:43 PM »
 :)