This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Confused by rom_model, NOLOAD, NOINIT, C auto init and C zero init and how they all work together.

I am designing an application where we compile our code and link it with code from 2 TP (third party) sources. 

I am attempting to edit a linker.cmd file to place the RAM variables from the third party sources into specific memory areas so that we can use the MPU to ensure the TP code will not change any of our data and vice versa.  

Placing the RAM variables is no problem what is causing me problems is making sure the TP .bss and .data sections are properly auto and zero initialized. 

I am somewhat confused by the documentation of NOLOAD, to me if you are using rom_model all RAM sections should be NOLOAD but making some sections NOLOAD seems to supress auto initialization. 

I am having problem using --zero_init=on as this will zero init our stack, after we have started using it.  The call to __TI_auto_init uses the stack at the same time zeros it and thus cannot return.  I wanted to apply NOINIT to the stack section but it seems you can apply only 1 special section type to a section and it already type NOLOAD.  

Am I correct in that the special sections types affect auto and zero initialization and if yes can I get a better explanation of how.  

Can I apply both NOLOAD and NOINIT to a section, and if yes what is the syntax? 

Using ARM code generation tools 5.1.1.

 

  • The NOLOAD section property has nothing to do with variable initialization.  Read about it in this wiki article.  

    I don't see why you need to do anything special regarding variable initialization.  You've got this part right ...

    James Donahue said:
    Placing the RAM variables is no problem

    ROM model initialization should take care of the remaining details with no issues.  

    Thanks and regards,

    -George

  •   The wiki article does provide some clarity but I could follow the NOLOAD example presented well enough to decide if all RAM sections when using rom_model should be NOLOAD.  It sure looks to me that NOLOAD does affect auto-initialization see the following example of from out linker.cmd and resulting Map file.  Other than that I also cannot see the affect of leaving NOLOAD off in all RAM sections.   It looks like --rom_model by itself keeps RAM sections out of the output and from being loaded. 
      
            .epbi_ram_data:
            {
                XXXX_BASE_MM_PBC_ToXxx.out(.data)
                . = align(4);
                TestCode.47R(.data)
                . = align(4);
                *(.epbi_app_ram_data)
                . = align(4);
            }
         
      As you can see in the map file a copy table is created for this section.
      
    .cinit     0    000d7a00    00000500    
                      000d7a00    00000008     (__TI_handler_table)
                      000d7a08    00000018     (__TI_cinit_table)
                      000d7a20    00000221     (.cinit..xxx_epb_ram_data.load) [load image, compression = rle]
                      000d7c41    00000007     --HOLE-- [fill = a4a4a4a4]
                      000d7c48    0000000e     (.cinit..epbi_ram_data.load) [load image, compression = rle]
                      000d7c56    00000002     --HOLE-- [fill = a4a4a4a4]
                      000d7c58    000002a8     (.cinit..app_ram_data.load) [load image]

      
      .epbi_ram_data: type = NOLOAD
            {
                XXXX_BASE_MM_PBC_ToXxx.out(.data)
                . = align(4);
                TestCode.47R(.data)
                . = align(4);
                *(.epbi_app_ram_data)
                . = align(4);
            }
     
      Looking at the map file you can see no copy table is created for this section.  If you look in the debugger the variables are not initialized.
      
    .cinit     0    000d7a00    000004e8    
                      000d7a00    00000008     (__TI_handler_table)
                      000d7a08    00000010     (__TI_cinit_table)
                      000d7a18    00000221     (.cinit..xxx_epb_ram_data.load) [load image, compression = rle]
                      000d7c39    00000007     --HOLE-- [fill = a4a4a4a4]
                      000d7c40    000002a8     (.cinit..app_ram_data.load) [load image]

         

  • Please stop using NOLOAD.  It is not correct for your situation.  NOLOAD is for modeling parts of the system that, in some separate step, are burned into ROM or Flash.  That is simply not the case here.  Once you have removed NOLOAD, please re-evaluate everything.

    Thanks and regards,

    -George