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.

Linker error: cannot mix noinit sections with sections that require initialization.

Other Parts Discussed in Thread: MSP430FR2433

Hi,

My team recently supported a customer issue regarding compiling code that uses the .TI.persistent section. On compiler v15 this project compiled clean. However, with v21.6.0 LTS it fails with this message:

Invoking: MSP430 Linker
"C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-msp430_21.6.0.LTS/bin/cl430" -vmspx --use_hw_mpy=F5 --advice:hw_config=all --define=CTPL_STACK_SIZE=160 --define=__MSP430FR2433__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --abi=eabi --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"calendar_tamper_detect_gui_ccs.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccs1110/ccs/ccs_base/msp430/include" -i"C:/ti/ccs1110/ccs/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-msp430_21.6.0.LTS/lib" -i"C:/ti/ccs1110/ccs/tools/compiler/ti-cgt-msp430_21.6.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="calendar_tamper_detect_gui_ccs_linkInfo.xml" --use_hw_mpy=F5 --rom_model -o "calendar_tamper_detect_gui_ccs.out" "./Source/GUIComm_JSON.obj" "./Source/RTC_Calendar.obj" "./Source/callbacks_JSON.obj" "./Source/ctpl_msp430fr2433.obj" "./Source/ctpl_pre_init.obj" "./Source/main.obj" "./Source/MSP430_GUI/MSP430_GUI.obj" "./Source/MSP430_GUI/jsmn/jsmn.obj" "./Source/MSP430_HAL/HAL_GUIComm_UART.obj" "./fram-utilities/ctpl/ctpl.obj" "./fram-utilities/ctpl/ctpl_low_level.obj" "./fram-utilities/ctpl/ctpl_low_level_macros.obj" "./fram-utilities/ctpl/peripherals/ctpl_adc.obj" "./fram-utilities/ctpl/peripherals/ctpl_adc10_b.obj" "./fram-utilities/ctpl/peripherals/ctpl_adc12_b.obj" "./fram-utilities/ctpl/peripherals/ctpl_captio.obj" "./fram-utilities/ctpl/peripherals/ctpl_comp_d.obj" "./fram-utilities/ctpl/peripherals/ctpl_comp_e.obj" "./fram-utilities/ctpl/peripherals/ctpl_crc16.obj" "./fram-utilities/ctpl/peripherals/ctpl_crc32.obj" "./fram-utilities/ctpl/peripherals/ctpl_cs.obj" "./fram-utilities/ctpl/peripherals/ctpl_dmax_3.obj" "./fram-utilities/ctpl/peripherals/ctpl_dmax_6.obj" "./fram-utilities/ctpl/peripherals/ctpl_ecomp.obj" "./fram-utilities/ctpl/peripherals/ctpl_eusci_a.obj" "./fram-utilities/ctpl/peripherals/ctpl_eusci_b.obj" "./fram-utilities/ctpl/peripherals/ctpl_fram.obj" "./fram-utilities/ctpl/peripherals/ctpl_lcd_c.obj" "./fram-utilities/ctpl/peripherals/ctpl_lcd_e.obj" "./fram-utilities/ctpl/peripherals/ctpl_mpu.obj" "./fram-utilities/ctpl/peripherals/ctpl_mpy32.obj" "./fram-utilities/ctpl/peripherals/ctpl_pmm.obj" "./fram-utilities/ctpl/peripherals/ctpl_port.obj" "./fram-utilities/ctpl/peripherals/ctpl_port_int.obj" "./fram-utilities/ctpl/peripherals/ctpl_rc.obj" "./fram-utilities/ctpl/peripherals/ctpl_ref_a.obj" "./fram-utilities/ctpl/peripherals/ctpl_rtc.obj" "./fram-utilities/ctpl/peripherals/ctpl_rtc_b.obj" "./fram-utilities/ctpl/peripherals/ctpl_rtc_c.obj" "./fram-utilities/ctpl/peripherals/ctpl_sac.obj" "./fram-utilities/ctpl/peripherals/ctpl_sfr.obj" "./fram-utilities/ctpl/peripherals/ctpl_sys.obj" "./fram-utilities/ctpl/peripherals/ctpl_timer_2.obj" "./fram-utilities/ctpl/peripherals/ctpl_timer_3.obj" "./fram-utilities/ctpl/peripherals/ctpl_timer_5.obj" "./fram-utilities/ctpl/peripherals/ctpl_timer_7.obj" "./fram-utilities/ctpl/peripherals/ctpl_tri.obj" "./fram-utilities/ctpl/peripherals/ctpl_wdt_a.obj" "../lnk_msp430fr2433.cmd"  -llibmath.a -llibc.a 
<Linking>
error #10367-D: output section ".TI.persistent" cannot mix noinit sections with sections that require initialization.
   NOINIT sections:
   - .TI.persistent:ctpl_PORTA_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_PORTB_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_FRAM_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_PMM_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_CS_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_SYS_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_SFR_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_RTC_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_MPY32_storage:ctpl_msp430fr2433.obj
   - .TI.persistent:ctpl_WDT_A_storage:ctpl_msp430fr2433.obj
   Sections not specified as NOINIT:
   - .TI.persistent:ctpl_low_level.obj
warning #10419-D: "ALL_FRAM" contains both ".cinit" and ".TI.persistent"; compression "lzss" can not be performed for ".TI.persistent"
error #10010: errors encountered during linking; "calendar_tamper_detect_gui_ccs.out" not built

I believe the code the linker is erring on resides in two files:

# ctpl_msp430fr2433.c

#if defined(__TI_COMPILER_VERSION__)
#pragma PERSISTENT(ctpl_PORTA_storage)
#elif defined(__IAR_SYSTEMS_ICC__)
__persistent
#endif
uint16_t ctpl_PORTA_storage[CTPL_PORT_INT_STORAGE_LENGTH] = {0};

; ctpl_low_level.asm

; FRAM stack copy
ctpl_stackCopy      .usect ".TI.persistent",CTPL_STACK_SIZE,2

; RAM copy
    .if $defined(CTPL_RAM_SIZE)
ctpl_ramCopy        .usect ".TI.persistent",CTPL_RAM_SIZE,2
    .endif

; Low level state variables
ctpl_mode           .usect ".TI.persistent",2,2
ctpl_state          .usect ".TI.persistent",2,2
ctpl_stackUsage     .usect ".TI.persistent",2,2

The linker message says it cannot mix NOINIT and non-NOINIT data inside .TI.persistent (although I'm assuming that the message regards persistent data as NOINIT). 

Is it possible to mark the symbols defined by the .usect as NOINIT? Or is there a better way to work around this?

CCS project:

calendar_tamper_detect_gui_ccs.zip

Regards,

Evan

  • The most straightforward way to restore the behavior of the older compiler is to suppress this diagnostic ...

    error #10367-D: output section ".TI.persistent" cannot mix noinit sections with sections that require initialization.

    The -D in the diagnostic identifier means it is discretionary, which means you can change how the tools handle it.  In this case, since you are OK with uninitialized variables and sections going in .TI.persistent, add the option --diag_suppress=10367.  A screen shot is below.  Be sure you add a note in an appropriate place which explains this option setting, maybe with a link to this forum thread.

    For further details on controlling linker diagnostics, please search the MSP430 assembly tools manual for the sub-chapter titled Control Linker Diagnostics.

    Thanks and regards,

    -George

  • Thanks George, this worked for me.

    Regards,

    Evan