MSPM0G3519: Linker Command File Preprocessing

Part Number: MSPM0G3519

Hi guys,

I am working with mspm0g3519 controler i want to build two different files with different load address. and for that i have done change in .cmd file. using #ifdef-#else-#endif i am selecting load address. MACRO use in .cmd file is set in Makefile. but that selection not working, as for both file load address remain same. is there any other way to implement this conditional code selection in linker file. because standard condiftional compilers ( c ) not usefull here.

  • Hi Mehul, thanks for the question! Can you send over a snapshot of your .cmd where you are setting this up?

  • #ifdef __APP_MODE_BOOTLOADER__
      #define FLASH_APP_OFFSET   0x00014900    // Application starts after bootloader
      #define FLASH_APP_LEN      0x00020000    // 128 KiB for application
    #else
      #define FLASH_APP_OFFSET   0x00000000    // Standalone - starts at flash base
      #define FLASH_APP_LEN      0x00080000    // 512 KiB (full flash available)
    #endif

    10.4.3. Command File Preprocessing Options — TI Arm Clang Compiler Tools User's Guide this is what i got online from TI website. help me to understand any thing wrt this point i can use here in my case?

  • Hi Mehul, yes you can use #ifdef and #else conditional directives in a linker script to build different files with different load addresses, but it requires running the C preprocessor (CPP) as a separate step in your build process. A simpler approach supported CCS for the MSPM0, is to use separate build configurations (e.g., "APP_MODE_BOOTLOADER", "NON_APP_MODE_BOOTLOADER"). Each configuration can be set to use a different, complete linker script file that has the load addresses already defined.

    There are quite a few tutorials on how to properly do the first option, but you would essentially create a linker script template using the directives you mention above, then you would need to add a step in the makefile to run the C preprocessor and defining the right macro via a cmd line flag. Lastly you would need to use the generated linker script in your final linking command.

    Hope this helps!

    -Brian