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.

Changing MSP430 startup adress

 

Hello,

 

A basic question about MSP430,

is it possible to change the startup adress of the MSP430 code in CCS

or is it possible to change the Start adress to a known address.

 

 

Regards.

  • Usually, the linker picks a suitable start address based on the segment definitions in its command file (which is specific to the MSP used).

    In C, you jsut write a main funciton and the linker will put it somewhere and do all the necessary stuff. Including addign some startup code that initializes variables, then pointeing th ereset bvector to this startup code and jumping from this code to the beginning of your main

    However, you can manually set teh reset vector to point to any symbol or address you want and the MSP will jump there after reset.
    To place your code there, you can change the linker command file and define a segment that suits your needs and put your code into this segment, or you can specify a fixed address for the code (in assembly, the ORG directive). In C, thsi is compiler specific, as the C standard does not include this kind of manipulation.

    However, usually, there is no need at all to care for the location, unless you're doing something very specific.
    For further, more specific info, you should provide information why you want to mess with the memory mapping of your code.

  • paddu said:
    is it possible to change the Start adress to a known address

    If you look at your project's memory map (/debug/[project].map), in the .text section you'll see an entry like:

    00002a0a    00000016     main.obj (.text:main)

    The first number is the main function's address.

     

    If you want to start your project at a certain memory location, you can edit the project's linker file.  There will be a section like this:

     

    MEMORY
    {

    ...
    FLASH                   : origin = 0x1100, length = 0xE900

    By default the origin is at the start of the device's program memory, so there's usually no need to change it.  However, it's as easy as changing the origin to your new starting address and updating the length appropriately.

     

  • Hi,

    Thank you all for the reply,

    Actually we want to change the startup address(_c_int00) to a different location.

    like the one mentioned here in the below link.

    http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/67507.aspx

    But I am confused and I couldn't find any standard procedure mentioned in the CCS user guide or Compiler User guides.

    From an old website I found the procedure in case of IAR as below.

    1. Copy cstartup.s43 to your own project directory.
    2. Edit it to suit your needs (__low_level_init is in it)
    3. Assemble it
    4. Add "-A cstartup" to your project's XCL file.
    5. Link it
    Please let me know if  there is some procedure like this for CCSv4 also.
    Regards.
    Paddu.

    
    
    
    
    
    

     

  • paddu said:
    we want to change the startup address(_c_int00) to a different location

    And the question still is: why? I didn't ask this becaus I'm curious, but because the solution depends on the purpose. The right way for one purpose will lead you into trouble for a different purpose.

     

  • I am just guessing, paddu might want a different c-startup routine, instead of a different location for c-startup routine.

  • Thank you for the comments,

     

    Actually our customer's application has a requirement for two sorts of program in the flash.

    Other than the main program(the actual application) , they need a start up program which checks the checksum of the 

    main program and transfers the control to main program if there is no problem with the checksum.

     

    I thought, in order to make the verification routine to be apart of the rest of the code to be verified.

     

    I am sorry for the above confusion,

    after studying other posts I think that there is no need to change the startup routine

    and using linker command file we can place the main program and the verification routine

    into different flash locations.

     

    Please let me if there a better way of implementation.

     

    PS: Just for the curiosity I would like to know what is the easiest way change the startup address(_c_int00) 

        to a different location.

     

    Regards.

    paddu.

     

     

  • paddu said:
    Actually our customer's application has a requirement for two sorts of program in the flash.

    Okay, that's a number you can work with.

    Putting two C programs into one MSP isn't a good idea since both programs usually have their own vector table usage etc. Of course one could switch between the two tables by reprogramming the vector table, but this is dangerous since during reprogramming the table, any power fail will leave the device unresposible.
    There are MSPs which can move the vector table to the end of ram, so a 'supervisor' can switch programs. This requires, however, soem effort.

    Usually it is much, much easier to join the two programs into one.

    paddu said:
    Other than the main program(the actual application) , they need a start up program which checks the checksum of the main program and transfers the control to main program if there is no problem with the checksum.

    Why not just doing the check at the start of the main program? Who checks the integrityof the check program before starting it? And the integrity of the check program checker?
    You can as well just include the check into the start of main.

    And all problems are gone with a snap.

     

  • Hi Jens,

     

    Thank you for the information.

     

    Actually the application itself would be updated through USB (DFU).

    There are a possiblities that the application program is not updated 

    properly or any other issue that would that the application program is corrupted,

    so after the application is updated we need to check the integrity of that program.

     

    So if we have a separate start up program in a flash area 

    which is not updated through DFU, we can check the integrity of the updated

    main application.

     

    Regarding the vector table, I think we can make a copy of the original vector table

    and place it in the appplication area.

    After power up, the start up code checks if application program has any problem

    and makes a indirect jump to the copied vector table and runs the main program from there.

     

    But I haven't tried to implement it yet,

    please let me know if there is any application or any reference to implement this kind of application.

     

    Regards.

    Paddu.

  • One thing you may want to try is using the linker command file to partition off a section of the flash memory for each application, and possibly the vector tables.  Be aware of the starting address for each flash segment when you do this, or you may accidentally erase unintended data when you re-flash the memory (see the "flash memory controller" chapter of the MSP430 user guide).

  • paddu said:
    Actually the application itself would be updated through USB

    So you wnt sort of a boot strap loader (BSL) with integrity check.

    There have been many threads about this inthe past, with all pros and cons. Search the board for them.

    Personally, I have written something similar:

    The currently loaded applicaiotn contains the code to receive the update data. it is stored in an unused part of flash. Once complete, the applciaiton resets itself.
    There is a small 1k BSL sitting at the top of the 64k addressrange. It has a vector table that points to a jumptable and soem code. The code is started on every reset and checks the storage area for a valid copy of a new firmware. If there is one, it starts copying over the data. After done, it clears the storage area. So if it is ever interrupted, it will just start again copying. And if ther eis no valid data, it will just start the applicaiton.
    The code, however, is written in assembly language (smaller and more efficient for this job, and no second startup code etc.).
    There are three drawbacks:
    1) the linker command script has been altered to put the applicaiton vector table 1k below where it will originally be
    2) all interrupts have a few more cycles latency, as they first jump to a jumptable in the BSL, which then does an indirect jump to the applciation ISR. This is necessary since the upper 1k will never be updated, including the vector table, so the system is always ina usable state.
    3) the applicaiton cannot grow larger than 50% of available flash.

    The advantages are:
    1) The load function can be part of the applicaiton and as complex as one wants.
    2) the device will always be operational. Either the old applicaiton is still operational, or there is a valid new version in storage and will be copied sooner or later, even if the process is interrupted many times. The BSL is never touched or replaced.

    On some newer MSPs, you can replace te default BSL that (almost) all MSPs have by your own customized version. This way, things can get much easier, as the BSL has an entry that is always called after a power-up (even before the reset vector is called). So integrity check can happen here and if it fails, the loader can be auto-activated for a new download. Of course this code fit into the BSL area, which is not too large.

**Attention** This is a public forum