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.

CCS/AM4376: ARM GCC Compiler .data init code

Part Number: AM4376
Other Parts Discussed in Thread: AM4379

Tool/software: Code Composer Studio

Using the latest PDK recommended GCC for AM437x on bare metal. I see code to zero out the .BSS section but nothing to init the .data section (copy from ROM to RAM). Can someone please point me to the code that does this? 

  • Hi,

    I am not sure what template or example code you are using, but traditionally you need to:

    - Use the AT> operator on the .data memory section that defines the destination (VMA) and the original (LMA) addresses

    - define global symbols at the boundaries of both the .data and the non-volatile memory sections the linker script (__data_start__, __data_end__, etc.).

    - Create a C or ASM function that is called upon the initialization and copies the data using the symbols defined above.  

    I haven't done this on the baremetal initialization files provided with CCS (startup_ARMCA9.S and AM437x.lds, located under CCS_INSTALL_DIR/ccs/ccs_base/arm/include), but a very generic example is shown in the AT ( ldadr ) section at the following reference:

    https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_chapter/ld_3.html#SEC21 

    Hope this helps,

    Rafael 

  • Thanks for the answer, I didn't find it in startup_ARMC9.S or _start from crt0.S (I'm using gcc-arm-none-eabi-7-2018-q2-update from the PDK and a test helloworld program from CCS10 to see the startup sequence). So seems like this has to be done manually. 

  • Arun,

    I worked on this a bit. Using a simple Hello world project from the CCS Project Wizard (menu File --> New --> CCS Project) I modified both the startup_ARMCA9.S and the AM437x.lds files to acommodate a section copy from DDR to L3OCMC0. 

    Please check the attached project. I allocated an array (located in the file testdataset_32KB.h) to a separate memory section .edata which has different Load (LMA) and Virtual (VMA) memory addresses (in GNU LD lingo).

    The routine that performs the copy is inside the startup_ARMCA9.S and uses symbols created by the linker to delimit the range of the memory to be copied. 

    I tested the code on a AM4379 IDK but it is generic enough to run on other AM437x development boards as well. 

    Hope this helps,

    Rafael

    Relocation_test_A9.zip 

  • Thanks Rafael.