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.

CCS/MSP432P401R: Printf doesn't work!

Part Number: MSP432P401R

Tool/software: Code Composer Studio

Hi,

I'm trying to switch the compiler on my project from TI to GNU Linaro. The first thing that doesn't work in my code after transition is the printf function.

Here is my very simple example:

/* DriverLib Includes */
#include <ti/devices/msp432p4xx/driverlib/driverlib.h>

/* Standard Includes */
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include <stdio.h>

int main(void)
{
    volatile uint32_t ii;

    /* Halting the Watchdog */
    MAP_WDT_A_holdTimer();

    puts("Hello, world!\n");
    printf("test\n");

    /* Configuring P1.0 as output */
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);

    while (1)
    {
        /* Delay Loop */
        for(ii=0;ii<5000;ii++)
        {
        }

        MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);
    }
}

However, I don't see any output from the debugger? Does this have to do with Stack and Heap size? If so, how do I change them?

If not, I appreciate if you can share your experience with GNU compiler.

Thanks.

  • Hello,

        Here is some additional information including Stack and Heap settings; link.  

    This example uses System_printf.

    Regards,

    Chris

  • Here is some additional information including Stack and Heap settings; link

    Hi Chris,

    Thanks for the reply. The link that you sent is empty.

    Could you please send me the link again.

    Best.

  • Sorry about that.  Please let me know if there is still a problem

    Regards,

    Chris

  • I guessed maybe the issue is heap or stack size. This is my linker filer. Based on this, I'm not sure what is the current size of the heap and stack and how to increase them.

    MEMORY
    {
        MAIN_FLASH (RX) : ORIGIN = 0x00000000, LENGTH = 0x00040000
        INFO_FLASH (RX) : ORIGIN = 0x00200000, LENGTH = 0x00004000
        SRAM_CODE  (RWX): ORIGIN = 0x01000000, LENGTH = 0x00010000
        SRAM_DATA  (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
    }
    
    REGION_ALIAS("REGION_TEXT", MAIN_FLASH);
    REGION_ALIAS("REGION_INFO", INFO_FLASH);
    REGION_ALIAS("REGION_BSS", SRAM_DATA);
    REGION_ALIAS("REGION_DATA", SRAM_DATA);
    REGION_ALIAS("REGION_STACK", SRAM_DATA);
    REGION_ALIAS("REGION_HEAP", SRAM_DATA);
    REGION_ALIAS("REGION_ARM_EXIDX", MAIN_FLASH);
    REGION_ALIAS("REGION_ARM_EXTAB", MAIN_FLASH);
    
    
    SECTIONS {
    
        /* section for the interrupt vector area                                 */
        PROVIDE (_intvecs_base_address =
            DEFINED(_intvecs_base_address) ? _intvecs_base_address : 0x0);
    
        .intvecs (_intvecs_base_address) : AT (_intvecs_base_address) {
            KEEP (*(.intvecs))
        } > REGION_TEXT
    
        /* The following three sections show the usage of the INFO flash memory  */
        /* INFO flash memory is intended to be used for the following            */
        /* device specific purposes:                                             */
        /* Flash mailbox for device security operations                          */
        PROVIDE (_mailbox_base_address = 0x200000);
    
        .flashMailbox (_mailbox_base_address) : AT (_mailbox_base_address) {
            KEEP (*(.flashMailbox))
        } > REGION_INFO
    
        /* TLV table for device identification and characterization              */
        PROVIDE (_tlv_base_address = 0x00201000);
    
        .tlvTable (_tlv_base_address) (NOLOAD) : AT (_tlv_base_address) {
            KEEP (*(.tlvTable))
        } > REGION_INFO
    
        /* BSL area for device bootstrap loader                                  */
        PROVIDE (_bsl_base_address = 0x00202000);
    
        .bslArea (_bsl_base_address) : AT (_bsl_base_address) {
            KEEP (*(.bslArea))
        } > REGION_INFO
    
        PROVIDE (_vtable_base_address =
            DEFINED(_vtable_base_address) ? _vtable_base_address : 0x20000000);
    
        .vtable (_vtable_base_address) : AT (_vtable_base_address) {
            KEEP (*(.vtable))
        } > REGION_DATA
    
        .text : {
            CREATE_OBJECT_SYMBOLS
            KEEP (*(.text))
            *(.text.*)
            . = ALIGN(0x4);
            KEEP (*(.ctors))
            . = ALIGN(0x4);
            KEEP (*(.dtors))
            . = ALIGN(0x4);
            __init_array_start = .;
            KEEP (*(.init_array*))
            __init_array_end = .;
            KEEP (*(.init))
            KEEP (*(.fini*))
        } > REGION_TEXT AT> REGION_TEXT
    
        .rodata : {
            *(.rodata)
            *(.rodata.*)
        } > REGION_TEXT AT> REGION_TEXT
    
        .ARM.exidx : {
            __exidx_start = .;
            *(.ARM.exidx* .gnu.linkonce.armexidx.*)
            __exidx_end = .;
        } > REGION_ARM_EXIDX AT> REGION_ARM_EXIDX
    
        .ARM.extab : {
            KEEP (*(.ARM.extab* .gnu.linkonce.armextab.*))
        } > REGION_ARM_EXTAB AT> REGION_ARM_EXTAB
    
        __etext = .;
    
        .data : {
            __data_load__ = LOADADDR (.data);
            __data_start__ = .;
            KEEP (*(.data))
            KEEP (*(.data*))
            . = ALIGN (4);
            __data_end__ = .;
        } > REGION_DATA AT> REGION_TEXT
    
        .bss : {
            __bss_start__ = .;
            *(.shbss)
            KEEP (*(.bss))
            *(.bss.*)
            *(COMMON)
            . = ALIGN (4);
            __bss_end__ = .;
        } > REGION_BSS AT> REGION_BSS
    
        .heap : {
            __heap_start__ = .;
            end = __heap_start__;
            _end = end;
            __end = end;
            KEEP (*(.heap))
            __heap_end__ = .;
            __HeapLimit = __heap_end__;
        } > REGION_HEAP AT> REGION_HEAP
    
        .stack (NOLOAD) : ALIGN(0x8) {
            _stack = .;
            KEEP(*(.stack))
        } > REGION_STACK AT> REGION_STACK
    	
    	__StackTop = ORIGIN(REGION_STACK) + LENGTH(REGION_STACK);
        PROVIDE(__stack = __StackTop);
    }
    

  • Hello,

    With a little bit of help from the internet (one reference here) I was able to get printf working with GNU Linaro toolchain with code similar to yours. 

    The main changes I made are the following:

    1) In Project Properties->Build->GNU Linker->Miscellaneous, add the option --specs=rdimon.specs.

    This enables semihosting for the GNU ARM libraries. Semihosting is the mechanism that enables code running on an ARM target to communicate and use the Input/Output facilities on a host computer that is running a debugger.

    2) In the linker file .lds, modify the .heap section to add the __end__ symbol:

    .heap : {
    __heap_start__ = .;
    end = __heap_start__;
    _end = end;
    __end = end;
    __end__ = end;
    KEEP (*(.heap))
    __heap_end__ = .;
    __HeapLimit = __heap_end__;
    } > REGION_HEAP AT> REGION_HEAP


    After this I was able to see the printf output in the CCS console.

    Hopefully this works for you as well. 

  • Thanks for your response AartiG. I tried this, however, the project doesn't compile.

    This is so weird since we are using the same example code. What is your SDK version?

    BTW, here is my output log if it helps.

    **** Build of configuration Debug for project gpio_toggle_output_MSP_EXP432P401R_nortos_gcc ****
    
    /home/mehrdadh/ti/ccsv8/utils/bin/gmake -k -j 8 all -O 
     
    Building file: "../gcc/startup_msp432p401r_gcc.c"
    Invoking: GNU Compiler
    "/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -march=armv7e-m -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__MSP432P401R__ -DDeviceFamily_MSP432P401x -I"/home/mehrdadh/workspace_v8/gpio_toggle_output_MSP_EXP432P401R_nortos_gcc" -I"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source" -I"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source/third_party/CMSIS/Include" -I"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/newlib-nano" -I"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include" -Og -ffunction-sections -fdata-sections -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF"gcc/startup_msp432p401r_gcc.d" -MT"gcc/startup_msp432p401r_gcc.o" -std=c99  -o"gcc/startup_msp432p401r_gcc.o" "../gcc/startup_msp432p401r_gcc.c"
    Finished building: "../gcc/startup_msp432p401r_gcc.c"
     
    Building file: "../gpio_toggle_output.c"
    Invoking: GNU Compiler
    "/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -march=armv7e-m -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__MSP432P401R__ -DDeviceFamily_MSP432P401x -I"/home/mehrdadh/workspace_v8/gpio_toggle_output_MSP_EXP432P401R_nortos_gcc" -I"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source" -I"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source/third_party/CMSIS/Include" -I"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/newlib-nano" -I"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include" -Og -ffunction-sections -fdata-sections -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF"gpio_toggle_output.d" -MT"gpio_toggle_output.o" -std=c99  -o"gpio_toggle_output.o" "../gpio_toggle_output.c"
    Finished building: "../gpio_toggle_output.c"
     
    Building file: "../system_msp432p401r.c"
    Invoking: GNU Compiler
    "/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc" -c -mcpu=cortex-m4 -march=armv7e-m -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -D__MSP432P401R__ -DDeviceFamily_MSP432P401x -I"/home/mehrdadh/workspace_v8/gpio_toggle_output_MSP_EXP432P401R_nortos_gcc" -I"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source" -I"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source/third_party/CMSIS/Include" -I"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include/newlib-nano" -I"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/include" -Og -ffunction-sections -fdata-sections -g -gdwarf-3 -gstrict-dwarf -Wall -MMD -MP -MF"system_msp432p401r.d" -MT"system_msp432p401r.o" -std=c99  -o"system_msp432p401r.o" "../system_msp432p401r.c"
    Finished building: "../system_msp432p401r.c"
     
    Building target: "gpio_toggle_output_MSP_EXP432P401R_nortos_gcc.out"
    Invoking: GNU Linker
    "/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc" -D__MSP432P401R__ -DDeviceFamily_MSP432P401x -Og -ffunction-sections -fdata-sections -g -gdwarf-3 -gstrict-dwarf -Wall -march=armv7e-m -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Wl,-Map,"gpio_toggle_output_MSP_EXP432P401R_nortos_gcc.map" -static -Wl,--gc-sections -L"/home/mehrdadh/ti/simplelink_msp432p4_sdk_3_20_00_06/source" -L"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard" -L"/home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib" -march=armv7e-m -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 --specs=rdimon.specs -o"gpio_toggle_output_MSP_EXP432P401R_nortos_gcc.out" "./gpio_toggle_output.o" "./system_msp432p401r.o" "./gcc/startup_msp432p401r_gcc.o" -Wl,-T"../test.lds"  -l:"ti/display/lib/display.am4fg" -l:"ti/grlib/lib/gcc/m4f/grlib.a" -l:"third_party/spiffs/lib/gcc/m4f/spiffs.a" -l:"ti/drivers/lib/drivers_msp432p401x.am4fg" -l:"third_party/fatfs/lib/gcc/m4f/fatfs.a" -l:"ti/devices/msp432p4xx/driverlib/gcc/msp432p4xx_driverlib.a" -lgcc -lc -lm -lnosys 
    makefile:152: recipe for target 'gpio_toggle_output_MSP_EXP432P401R_nortos_gcc.out' failed
    /home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/librdimon.a(rdimon-syscalls.o): In function `_lseek':
    syscalls.c:(.text._lseek+0x0): multiple definition of `_lseek'
    /home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libnosys.a(lseek.o):lseek.c:(.text._lseek+0x0): first defined here
    /home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/librdimon.a(rdimon-syscalls.o): In function `_close':
    syscalls.c:(.text._close+0x0): multiple definition of `_close'
    /home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libnosys.a(close.o):close.c:(.text._close+0x0): first defined here
    /home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/librdimon.a(rdimon-syscalls.o): In function `_isatty':
    syscalls.c:(.text._isatty+0x0): multiple definition of `_isatty'
    /home/mehrdadh/ti/ccsv8/tools/compiler/gcc-arm-none-eabi-7-2017-q4-major/arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard/libnosys.a(isatty.o):isatty.c:(.text._isatty+0x0): first defined here
    collect2: error: ld returned 1 exit status
    gmake[1]: *** [gpio_toggle_output_MSP_EXP432P401R_nortos_gcc.out] Error 1
    gmake: *** [all] Error 2
    makefile:148: recipe for target 'all' failed
    
    **** Build Finished ****
    

  • Sorry. I had missed one step. Add the rdimon library to the --library list.

  • Thank you so much! It worked.

**Attention** This is a public forum