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.

MSP430F5529: Pre-build steps in code composer studio for MSP430

Part Number: MSP430F5529

Hello,

I have written a C program that reads from a CSV file and generates a .h header file. 


I want to compile this C code as a pre-build step and include the generated .h file in the code composer studio project build process that generates the binary to be flashed on MSP430.

I know this can be done under project properties -> build -> steps -> pre build

What I'm not sure of is how to write the command.
Basically I'm looking to do something as so :

gcc csv_to_header.c -o csv_to_header 
./csv_to_header

Please advise how to do this as a pre build step. Any resources available for this? I could find some info on TI, but it's mostly high level stuff and doesn't give the details of command to be used.
TIA.

  • To my mind in the makefile ( in the gcc directory) add a rule to make the .h file, and have it execute your commands, then make the main executable depend on the .h file, then when you build the main executable, it will build the .h and run your command.

    And now on my desk top - and checking my msp430 build environment - and it very rarely uses makefiles! Indeed my build there is just a shell script! So guess you may not use makes files for building (alas I rarely use CCS - I usually work from the command line ...)

    Anyway *if* you do use makes files, then a rule line:

    input.h: input.csv csv_to_header
        ./csv_header
    
    csv_to_header: csv_to_header.c
        gcc csv_to_header.c -o csv_to_header

  • Hello,

    Please advise how to do this as a pre build step

    The pre-build step will simply pass the entire step to the system console for execution. So you can call the compiler to build the C file as you normally would do from the command line. I assume the CCS project already references the header file so as long as the pre-build step is successful and the header file is generated in the location that is expected by the project, this should work.

    Thanks

    ki

  • This is probably what I'm looking to do. Let me test this approach. Will let you know. 

    So guess you may not use makes files for building (alas I rarely use CCS - I usually work from the command line ...)

    Also, I was kinda curious, how do you build and flash CCS projects from command line? Do you manually compile and link each source file?

    Indeed my build there is just a shell script!

    What do you put in the shell script?

  • So you can call the compiler to build the C file as you normally would do from the command line

    Since MSP devices use 21.6.0.LTS compiler, will the compile command be: cl430 csv_to_header.c -o csv_to_header  Instead of gcc??

  • Hmm - doesn't seem to want to attach the script - I'll keep working on it.

    Its quite embarrassing really - I just assembled all the commands I needed, to check I had them correct. Should have moved it to a make file, but looks like then never was done. As all my code was in one file (and a separate header) - it was only a few commands.

    I'd say if familiar with makefiles, and you are doing it from the command line, then make is the way to go. I like that its easy to config so "make" compiles the executable, and "make flash" flashes it to the device.


    #!/bin/bash

    msp430-elf-gcc -I /home/summers/msp430/include -I /home/summers/msp430/msp430-elf/include -O2 -D__MSP430F5529__ -mmcu=MSP430F5529 -ffunction-sections -fdata-sections -c sinlookupuart.c -o gcc/sinlookupuart.o
    msp430-elf-gcc -T /home/summers/msp430/include/msp430f5529.ld -L /home/summers/msp430/include -mmcu=MSP430F5529 -Wl,--gc-sections gcc/sinlookupuart.o -o gcc/sinlookupuart.out
    msp430-elf-objcopy -O ihex gcc/sinlookupuart.out gcc/sinlookupuart.hex
    LD_LIBRARY_PATH=/usr/local/lib ../../../ti/MSPFlasher_1.3.20/MSP430Flasher -n MSP430F5529 -w gcc/sinlookupuart.hex -v -z [VCC]

    exit

  • gcc csv_to_header.c -o csv_to_header 

    csv_to_header is viewed as a custom utility.  It is typically built outside of CCS, using some other method.  Because csv_to_header executes on the host system, it is built with a hosted compiler such as gcc.  

    ./csv_to_header

    This step is typically executed as a pre-build step in CCS.  Visit that link for the details and examples.  Note it supports multiple commands.  That said, if one or more of those commands are complicated, it may make sense to put those commands in a batch file or script, then invoke that as the pre-build step.

    Thanks and regards,

    -George

**Attention** This is a public forum