AnsweredAssumed Answered

placing variable in ROM on exact location(using FRDM KE06)

Question asked by Mark de Groot on Feb 15, 2016
Latest reply on Feb 22, 2016 by Mark de Groot

Hi,

 

Does anyone know how to place a variable on a exact location in ROM?

 

I tried the following methods:

volatile int bootStatus __attribute__((at(0xC0))) = 0x66;

 

int variable2 __attribute__((section(".id_firmware.__at_0xe2"))) = 10;

 

const int x1 __attribute__((at(0x200))) = 10; /* RO */

 

__attribute__ ((section(".id_firmware"))) uint32_t aap = 0x11223344;

this one doesn't write the memory on itself but when referring to it in the main on this way:

aap = aap;

it will place the data in opposite order (44332211) and the program gets a hard_fault interrupt.

 

memory layout in linker file is as follows:

MEMORY {
  m_interrupts               (RX)     : ORIGIN = 0x00000000, LENGTH = 0x000000C0
  my_id_firmware          (RX)     : ORIGIN = 0x000000c0, LENGTH = 0x00000340
  m_text                  (RX)     : ORIGIN = 0x00000410, LENGTH = 0x00002BF0
  m_data                  (RW)     : ORIGIN = 0x1FFFF000, LENGTH = 0x00004000
  m_cfmprotrom            (RX)     : ORIGIN = 0x00000400, LENGTH = 0x00000010
}

/* Define output sections */
SECTIONS
{


  /* The startup code goes first into INTERNAL_FLASH */
  .interrupts :
  {
    __vector_table = .;
    . = ALIGN(4);
    KEEP(*(.vectortable)) /* Startup code */
    . = ALIGN(4);
  } > m_interrupts

    /* Section created to relocate code in specific Flash address */
    .id_firmware :
    {
        . = ALIGN(4);
        *(.myROM)
        . = ALIGN(4);
    } > my_id_firmware

 

 

The only thing I want is to hardcode a few variables in ROM so that I can access them from a bootloader program as well as the actual firmware program.

 

I am using MKE06Z128LK4 Microcontroller

 

I would be really great if someone can help me!

Outcomes