Jump to content
scompo

Stellaris launchpad gcc makefile, startup file and linker script BSD

Recommended Posts

Thanks for the info!

 

I have also played a bit with the assembly startup code included in CMSIS. It builds, but instead of calling main() when it finishes startup, it calls start(). Maybe I'm missing something, because CMSIS examples use the standard main() function as C entry point.

Share this post


Link to post
Share on other sites

I think TI is listening...

 

 

http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/t/230468.aspx

 

Also the Energia folks appear to have worked with TI to resolve some of the other issues...

 

https://github.com/energia/Energia/blob/stellarpad/hardware/lm4f/cores/lm4f/startup_gcc.c

 

The linker script energia is using is their own. But may be helpful https://github.com/energia/Energia/blob/stellarpad/hardware/lm4f/cores/lm4f/lm4fcpp.ld

 

Finally since you mentioned the FIR examples in CMSIS i infer you are wanting the DSP libraries?  Check this app note which is CCS specific but may help some, Also EuphonisTI uses the DSP Library for his stuff.  http://hackaday.com/2012/09/06/frequency-analyzer-built-from-the-new-stellaris-launchpad/

Share this post


Link to post
Share on other sites

Thanks for the info!

 

It's good to know TI is going to correct the license terms for the Makefiles. I hope they also do so for the startup code and the linker script!

 

I'll try the code from Energia ASAP, but I'm very busy lately. Real life can be extremely time consuming :(

Share this post


Link to post
Share on other sites

I had some time to play with this again. The Energia files use startup_gcc.c file from TI, so it still has the license problems, right?

 

I have been trying to debug scompo's files, and I think the problem is in the linker script. I suspect the initialization is wrong. I have done some modifications to it, and browsed the labels involved in variable initialization in the generated .map file. This is what I found:

 

1.- If I leave the linker script as is (have a look to _end_text, _start_data and _end_data labels): http://pastebin.com/T6MuCaEi

    Then the generated .map file allocates _end_text in the .rodata section, and I suppose this is wrong. Also _end_data is allocated in the .vtable section, and I suppose this is also wrong (but I'm not sure on this): http://pastebin.com/gT70MYxs

 

2.- If I modify the _end_text and _end_data labels like this: http://pastebin.com/Uq6QMcAe

    Then to me it looks like _end_data is properly placed, at the end of the .data section, just where .bss starts. But something strange happens with _end_text. I expected it to be at the same location .rodata section is, but it's not, it's in the middle of the .rodata section: http://pastebin.com/sZRt7Ycz

 

Can this be the problem? How can I fix it?

Share this post


Link to post
Share on other sites

FINALLY I got some time to debug this, and found the problems. Now I have a working CMSIS arm-fir-example, built with GCC and the modified startup files by scompo. There were two problems in the linker script:

  1. The sections to include in memory were defined as ".sec_name.*", instead of the correct ".sec_name*". The extra dot (.) allowed sections like ".data.blockSize" to be included, but left out ".data" section.
  2. When I corrected problem 1, the startup code still failed to initialize variables in .data. While debugging, I noticed all the initialized variables were shifted 4 bytes in RAM (e.g., if a variable should be initialized at RAM 0x20000000 with value 32, the value 32 was copied to 0x20000004). The problem was with the directive that instructs the linker to store initialization data at flash. .data section definition was:

 

 

    .data :
    {
     _start_data = .;
        *(.data*)
        *(vtable)
        _end_data = .;
    }>RAM AT >FLASH

 

I changed it to:
 

 

   .data : AT(_end_text)
    {
    _start_data = .;
        *(.data*)
        *(vtable)
        _end_data = .;
    }>RAM

And now everything works flawlessly :)

 

In case anyone is interested, here is the the modified and working LM4F.ld linker script. Enjoy!

Share this post


Link to post
Share on other sites

I got linker script working in a different way. I think you need to include sections like *(.data) but also *(.text) as well as *(.text.*).

I also added some section that I found floating around in the .map file. Their sizes are 0 so they didn't have any effect yet, but might in the future. (I also posted a comment on your blog about this).

 

I didn't need to remove the AT >FLASH for this to work.

 

My version is here: http://pastebin.com/AcxwFW6S

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×