Jump to content

Alternative super small CRT for msp430-elf-gcc 4.9.1

Recommended Posts

So now that that CCS 6 includes a "released" msp430-elf-gcc, I thought I'd share my ultra small c-runtime startup code as an exported CCS project.  This will be useful to those who want to use the free msp430-elf-gcc with the smaller chips like an msp430g2231.  Also, it is an exercise to see if I can share exported CCS project files that will be usable in Windows even though I'm using CCS v6 on linux.


Just download the attached zip file and then use the "Import Project" button on the "Getting Started" page in CCS.  It should import the zip file into a new project in your workspace called "blink_g2231" (make sure you don't already have a project with that name in your workspace). Hopefully all my settings will stick and you can build and debug to generate a version of code that is only 92 bytes. The normal c-runtime produces a file that is about 498 bytes for this same main.c.  With this project, the normal c-runtime is replaced with a handful of assembler instructions and checks a few settings in the link properties to disable the one supplied with msp430-elf-gcc.


This code assumes you are using the latest msp430-elf-gcc Will Cooper just announced yesterday (8-14-2014). The new version is available on the App Center page in CCS. Just click on the "MSP430 GCC" badge and press the "Select" to and install software to update.


In the attached project you will find three source files: main.c, _start.S and iomacros_fixed.h.  _start.S takes the place of the normal c-runtime and just does the minimum to get ready before starting your main() function.  The assembler code makes the assumption that your main function never returns to further reduce the c-runtime overhead code.  The file iomacros_fixed.h provides a modified iomacros.h that defines the SFR macros so the the header can be included in msp430 assembler files.


I've used the _start.S with the msp430fr5969 also. So it isn't limited to the msp430g series.  If you want to have more control over your c-runtime this might be something you might take a look at.




[edit]: BTW I'm using an msp430f5529 launchpad as a programmer / debugger on linux. I used jumper wires to connect a version 1.4

msp430g2231 launchpad.  This works great!


Link to post
Share on other sites

So it turns out this is a waste of time ...


using the -minrt flag provided to the link phase accomplishes the same thing ... discovered when I ran:


 $ msp430-elf-gcc --target-help




[Edit: Although, it is truly a min run-time. It does initialize .data section if you have some, but doesn't include the code to if you don't, same for the .bss values to zero]

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...