0

How do you set a few bytes of flash to be programmed by the flash programmer during programming of the mcu to be a certain value using msp GCC toolchain? For example, TI C/C++ compiler toolchain, includes assembler, and the following lines of assembly set the memory locations to the desired values:

;----------------------------------------------------------------------
 .sect ".BSLSIG"
 .retain
;----------------------------------------------------------------------
                 .word       0xFFFF         ; 0x17F0
BslProtectVecLoc .word       BSL_Protect    ; 0x17F2 adress of function
PBSLSigLoc       .word       03CA5h         ; 0x17F4 1st BSL signature
SBSLSigLoc       .word       0C35Ah         ; 0x17F6 2nd BSL signature
                 .word       0xFFFF         ; 0x17F8
BslEntryLoc      .word       BSL_Entry_JMP  ; 0x17FA BSL_Entry_JMP

Is there a way to do something similar using msp GCC toolchain?

user1135541
  • 1,781
  • 3
  • 19
  • 41

1 Answers1

1

The GNU assembler has the same mechanisms. For example, here is how the MSP430 startup code puts the address of the startup code into the reset vector:

        .section ".resetvec", "a"
__msp430_resetvec_hook:
        .word   __crt0_start

As with the TI compiler, this requires the section (here: .resetvec) to be defined in the linker script.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • 1
    I think it's not necessary to change the linker script, at it's possible to set the start address of a section in linker parameters: `LDFLAGS += "-Wl,--section-start=.resetvec=0x5000"`. And section attributes can be set in GNU C using the `__attribute__ ((section (".resetvec")))` syntax. – kfx Sep 02 '16 at 16:18
  • Is it possible to do the same thing, but use GCC C compiler? – user1135541 Sep 02 '16 at 17:39
  • @kfx How can you set section *attributes* in C? – CL. Sep 02 '16 at 19:06
  • @user1135541 See kfx's comment. – CL. Sep 02 '16 at 19:06
  • May be able to do this `const uint16_t __attrib__(__attribute__((section(".BSLSigLoc"), used)) SigLocVar = 0xC35A3CA5;` but I am not 100% sure yet – user1135541 Sep 02 '16 at 19:09