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.

Can't link MSP430 Assembly code

Other Parts Discussed in Thread: MSP430FR5739

Champs,

Help, I'm dead in the water!!!

This has to be pilot error admittedly; but what am I not seeing?  I blatantly plagarized this from the MSP430 example code page- tryoing to get an assembly project to work in CCS 5.  The issue is real simple; there's the code (which you don't need to really care about what it does)

;******************************************************************************
;   MSP430FR57xx Demo - Configure MCLK for 8MHz operation
;
;   Description: Configure ACLK = SMCLK = MCLK = 8MHz
;
;           MSP430FR57x
;         ---------------
;     /|\|               |
;      | |               |
;      --|RST            |
;        |               |
;        |               |  
;        |          P2.0 |---> ACLK = MCLk = 8MHz
;
;   Tyler Witt
;   Texas Instruments Inc.
;   September 2011
;   Built with Code Composer Studio V4.2
;******************************************************************************
 .cdecls C,LIST,  "msp430fr5739.h"

;------------------------------------------------------------------------------
            .global main
            .text                              ; Program reset
;------------------------------------------------------------------------------
main
_RESET       mov.w   #1DFEh,SP               ; Initialize stack pointer
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
            mov.b    #0xA5,&CSCTL0_H
            bis.w    #DCOFSEL0+DCOFSEL1,&CSCTL1 ; Set max DCO setting
            mov.w    #SELA_3+SELS_3+SELM_3,&CSCTL2 ; ACLK = MCLK = DCO
            mov.w    #DIVA_0+DIVS_0+DIVM_0,&CSCTL3 ; set all dividers

            clr.b    &P2OUT                    ; output ACLK
            bis.b    #BIT0,&P2DIR
            bis.b    #BIT0,&P2SEL1
            bis.b    #BIT0,&P2SEL0
            
Mainloop    jmp        Mainloop                ; endless loop
            nop                                ; for debug
            
;------------------------------------------------------------------------------
;           Interrupt Vectors
;------------------------------------------------------------------------------
            .sect   ".reset"                ; MSP430 RESET Vector
            .short  main                   ;
            .end

and the error is, when it links:

<Linking>
"../lnk_msp430fr5739.cmd", line 192: error #10099-D: program will not fit into
   available memory.  placement with alignment fails for section ".reset" size
   0x4 .  Available memory ranges:
   RESET        size: 0x2          unused: 0x2          max hole: 0x2       
error #10010: errors encountered during linking; "MSP430PixelFormatter2.out"
   not built

WHAT!?!?!?  I agree the MSP430 reset vector is in fact 16-bits; but the whole address space is only 16-bits; so there's no way that it's taking 4-bytes to specify the reset vector.  I don't get it; .reset has 1 value, a .short (2 bytes); with the address of main in it; why does the linker think it's taking 4 bytes.  You can obviously reproduce this with any MSP430 example as far as I can tell; I technically used the UCS example # 1 above but this isn't a code-related issue.  I let CCS choose the default command file for linking; but it's right as near as I can tell; .reset SHOULD be 2 bytes long because its at the top of memory. 

  • Do you include any library? Teh runtime lib may add something to the reset 'vector' (which is actually a 2-byte segment for the linker),so you got two addresses put wher eonly one fits.

    The FR series requires some specific setup for the access control (what's program memory, what's data memory). Maybe this code is automatically linked and occupies the reset vector. In this case, you don't need to fill-in your own reset vector and main is automatically called by this startup code.
    I agree, normally, ASM programs shouldn't have startup code, but then, the FR57xx is special with its memory handling.

    Doi you get a map file that perhaps shows you the failed placement?

  • I didn't add any libraries myself- it's a stand-alone assembly language file; BUT; I think that's the problem.  CCS doesn't have a 'assembly only' style projct; so I think it tries to add some RTS libary when it creates the project.  I can't see it directly in the project options; but there are admittedly about 30 options and I know of what about 6 of them actually do.

    And I never got a .map file because it never linked correctly.  I eventually worked around this by just trying some stuff; and the 'bullet' was to actually just delete the .reset section from the SOURCE code.  I wasn't 100% comfortable with this since it would seem I'm now relying on some magic in the linker to get the address of main into the reset vector; but it did seem to:

    1) stop the linker from complaining, and

    2) when I launched CCS; it did load up to main and the program ran; plus

    3) it seems to work withou the debugger attached

    So I think my generic comment comes to this- maybe our example code from msp430.com, whewre I pulled this; should have a readme or something explaining what needs to happen to build assembly projects.  he code examples are really just source (whic his fine by the way- these ARE a FANTASTIC resource); it's just in this case there's not really an option to have CCS create an 'assembly' type project- even when I did this I had to delete main.c and copy in the .asm file; and there is obvsiouly some extra step involved that I don't quite get yet.  I think there should probably be a more correct way of getting thr linker to be happy than to hav to delete the .reset section from the source.  I know in the C6000-type parts we used to have a command line option to specify the code entry point- I culdn't find that digging through the options I saw in the CCS command line; but in any case; a simple readme.txt for the assembly directory in the code examples might help here.

  • I do not know how to use (nor care to use) CCS.

    I think in your case, the "project" automatically assumes that you are using c. As a consequence it automatically generated a reset vector to automatically point to the c-start-up-code (which you do not need).

    I do drive an automobile with "automatic" transmission. But I still have manual control to put it in "P, R, N, or D". If that manual control were also automated, I would be afraid to drive it least it would automatically back me to a wall.

  • When making a new project, you should choose "Empty Assembly-only project". In addition, if you are using CCSv5.2, you probably need to change the format of the output file from ELF to COFF. Go to Properties > General > Advanced Settings set the Output format to "legacy COFF" if it is already set to eabi(ELF). Does this fix your issue? I think CCS 5.2 changed the default to ELF instead of COFF. Alternately, you can leave the output format as ELF and use .retain - see this forum post; http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/p/176351/637520.aspx#637520

    Regards,

    Katie

**Attention** This is a public forum