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/TM4C1294NCPDT: GCC Bootloader Linker Script and Guidance

Part Number: TM4C1294NCPDT
Other Parts Discussed in Thread: ENERGIA

Tool/software: Code Composer Studio

Hello.

I've been wracking my brain for the past few days trying to figure out how to write a linker script for a RAM based bootloader. I have my main application firmware written with some mixed C/C++ code (Energia libraries mostly) and the linker and startup script for that works fine.

I realize there are examples for the bootloader in the tivaware/bootloader directory. Only, none of them are for GCC...

Perhaps I should explain my intent. I wish to have a RAM based bootloader leverage Petite FatFS for mounting an SD card, and flashing application firmware from a .bin file.

I don't even know where to begin on this in a simple sense... Code Composer Studio and TI's Compiler are so very different from GCC. I have found example code elsewhere on these forums, but they are all either for different IDE's or incomplete.

I have so many questions...

When a .S (Assembly startup file) is used, how does ccs know to use it?

How can a linker script/startup code be written if the bootloader has no main?

One of my biggest questions: How can I learn Why a GNU linker-script for C is different than one for C++? How can I learn how to write one? I guess I'm not finding the reference material I need.

I've read the Bootloader Users' Guide, and it says "bl_link.ld - The linker script used when the codered, gcc, or sourcerygxx compiler is being used to build the boot loader." and yet when I open that file, the top says "bl_link.ld - Scatter file for Gnu tools" ... What is a scatter file?

Is there an example somewhere containing BOTH a RAM-based bootloader with full source, linker-script, and startup file, for GNU GCC, as well as a matching Application project to be loaded by the former? Or perhaps instructions on building the same? I'd like to use CCS to upload the code, with GNU GCC as compiler and linker, and retain the ability to debug the same...

This is frustrating me to no end. I certainly hope I'm only missing a few things. Thanks in advance.

  • Hi Phil,
    Which .S file are you referring to? If you are seeing the startup_rvmdk.K then this is the startup file for use with the Keil's uVision tool chain.

    I myself is not an expert in GCC. I normally use only CCS. However, I find below link on how to use the GCC compiler and linker.
    gcc.gnu.org/.../Building_Cross_Toolchains_with_gcc

    I think scatter file for GNU is just equivalent to the linker command file as for CCS where it mainly instructs the linker on how to allocate code sections into specific areas of memory and combine object file sections.

    Have you tried out the TivaWare bootloader examples? I will suggest you first try the example (i.e. the UART based bootloader) and be familiar with the TivaWare bootloader.
  • I think you were referring to the bl_startup_ccs.s instead of the startup_rvmdk.S file, correct?

    If you look at the bl_link_ccs.cmd file you will see something like below where the .intvecs section is being grouped with the rest of the sections and they are allocated to the FLASH (starting at 0x0) as the load address and 0x20000000 as the run address. Once the bootloader is programmed into the flash and started, one of the routines is to copy bootloader code to 0x20000000 and execute from RAM (starting at 0x20000000).

    SECTIONS
    {
    GROUP
    {
    .intvecs
    .text
    .const
    .data

    } load = FLASH, run = 0x20000000, LOAD_START(init_load), RUN_START(init_run), SIZE(init_size)


    Now if you go to the bl_startup_ccs.s file you will see the section .intvecs being created and all the subsequent lines of code being part of the .intvecs section where they will be allocated to the FLASH memory per linker command file allocation as mentioned above.

    ;;*****************************************************************************
    ;;
    ;; This portion of the file goes into interrupt vectors section
    ;;
    ;;*****************************************************************************
    .sect ".intvecs"