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.

RTOS/66AK2G02: Is there an example of routing printf to UART2?

Part Number: 66AK2G02
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Can someone point me to an example of connecting printf() to one of the UART's in K2G with the DSP-BIOS system?

  • Hi Chuck,

    I've forwarded this to the softwre experts. Their feedback should be posted here.

    BR
    Tsvetolin Shulev
  • (Seems to have missed most of my post on the first try)

    Thank you. I found the UART page from http://processors.wiki.ti.com/index.php/Processor_SDK_RTOS_Software_Developer_Guide.

    When I try to build the uart_test or other examples, I find that the PA module (Packet Accelerator) is missing from my K2G release (C:\ti\pdk_k2g_1_0_1).

    While the "uart_test" opens as a CCS project, the UART examples don't appear to be CCS projects.

    My goal is to use printf efficiently on the ARM running TI-RTOS.

  • Looking further, I see that the uart_test program is for the DSP.  I need to control the UART from the ARM.  I see that examples like drv\uart\example\uart_polling_mode_app includes makefiles and has an armv7 directory.  But the makefile fails with errors like:

    C:\ti\pdk_k2g_1_0_1\packages\ti\drv\uart\example\uart_polling_mode_app>gmake
    makefile:2: ../../../../Rules.make: No such file or directory
    makefile:32: C:\ti\pdk_k2g_1_0_1\packages/ti/build/makerules/common.mk: No such file or directory
    gmake: *** No rule to make target `C:\ti\pdk_k2g_1_0_1\packages/ti/build/makerules/common.mk'.  Stop.

    Since I find no "Rules.make" in my directory, this must not be complete.

  • Hi,

    UART has nothing to do with PA module. If you want to build the UART example on ARM, run command like: C:\ti\pdk_k2g_1_0_x\packages>pdkProjectCreate.bat K2G evmK2G little uart arm

    You will get several CCS projects under ti\pdk_k2g_1_0_x\packages\MyExampleProjects, then just import into CCS and build, my log FYI:


    **** Build of configuration Debug for project UART_BasicExample_evmK2G_armTestproject ****

    "C:\\ti_6_1_3\\ccsv6\\utils\\bin\\gmake" -k all
    'Building file: C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/k2g/armv7/bios/uart_arm.cfg'
    'Invoking: XDCtools'
    "C:/ti/xdctools_3_32_00_06_core/xs" --xdcpath="C:/ti/bios_6_45_01_29/packages;C:/ti/pdk_k2g_1_0_3/packages;C:/ti/ndk_2_24_03_35/packages;C:/ti_6_1_3/ccsv6/ccs_base;" xdc.tools.configuro -o configPkg -t gnu.targets.arm.A15F -p ti.platforms.evmTCI66AK2G02 -r debug -c "C:/ti_6_1_3/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3" "C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/k2g/armv7/bios/uart_arm.cfg"
    making package.mak (because of package.bld) ...
    generating interfaces for package configPkg (because package/package.xdc.inc is older than package.xdc) ...
    configuring uart_arm.xa15fg from package/cfg/uart_arm_pa15fg.cfg ...
    generating custom ti.sysbios library makefile ...
    Linking with library ti.board:./lib/evmK2G/a15/release/ti.board.aa15fg
    Linking with library ti.drv.i2c:./lib/k2g/a15/release/ti.drv.i2c.aa15fg
    Linking with library ti.drv.uart:./lib/k2g/a15/release/ti.drv.uart.profiling.aa15fg
    Linking with library ti.utils.profiling:./lib/a15/release/ti.utils.profiling.aa15fg
    Linking with library ti.csl:./lib/k2g/a15/release/ti.csl.aa15fg
    Linking with library ti.osal:./lib/tirtos/k2g/a15/release/ti.osal.aa15fg
    Starting build of library sources ...
    making C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/k2g/armv7/bios/src/sysbios/sysbios.aa15fg ...
    gmake[1]: Entering directory `C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/k2g/armv7/bios/src/sysbios'
    gmake[1]: Nothing to be done for `all'.
    gmake[1]: Leaving directory `C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/k2g/armv7/bios/src/sysbios'
    Build of libraries done.
    cla15fg package/cfg/uart_arm_pa15fg.c ...
    'Finished building: C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/k2g/armv7/bios/uart_arm.cfg'
    ' '
    'Building file: C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/src/main_uart_test.c'
    'Invoking: GNU Compiler'
    "C:/ti_6_1_3/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc.exe" -c -mcpu=cortex-a15 -mtune=cortex-a15 -marm -mfloat-abi=hard -Dk2g02 -Darm0 -DSOC_K2G -DEVM_K2G -I"C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart" -I"C:/ti/pdk_k2g_1_0_3/packages" -I"/packages" -I"C:/ti_6_1_3/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/arm-none-eabi/include" -g -gdwarf-3 -gstrict-dwarf -Wall -c -finstrument-functions -MMD -MP -MMD -MP -MF"main_uart_test.d" -MT"main_uart_test.o" -o"main_uart_test.o" @"configPkg/compiler.opt" "C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/src/main_uart_test.c"
    C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/src/main_uart_test.c: In function 'UART_test_print_test_desc':
    C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/src/main_uart_test.c:1066:5: warning: format '%d' expects argument of type 'int', but argument 3 has type 'int32_t' [-Wformat=]
    sprintf(testId, "%d", test->testId);
    ^
    C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/src/main_uart_test.c:1066:5: warning: format '%d' expects argument of type 'int', but argument 3 has type 'int32_t' [-Wformat=]
    'Finished building: C:/ti/pdk_k2g_1_0_3/packages/ti/drv/uart/test/src/main_uart_test.c'
    ' '
    'Building target: UART_BasicExample_evmK2G_armTestproject.out'
    'Invoking: GNU Linker'
    "C:/ti_6_1_3/ccsv6/tools/compiler/gcc-arm-none-eabi-4_9-2015q3/bin/arm-none-eabi-gcc.exe" -mfloat-abi=hard -Dk2g02 -Darm0 -DSOC_K2G -DEVM_K2G -g -gdwarf-3 -gstrict-dwarf -Wall -Wl,-Map,"UART_BasicExample_evmK2G_armTestproject.map" -nostartfiles -static -Wl,--gc-sections -L"C:/ti/bios_6_45_01_29/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/fpu" -L"/packages/gnu/targets/arm/libs/install-native/arm-none-eabi/lib/fpu" -Wl,--defsym,ARM_CORE=1 -Wl,--defsym,STACKSIZE=0x10000 -Wl,--defsym,HEAPSIZE=0x400 -o"UART_BasicExample_evmK2G_armTestproject.out" "./main_uart_test.o" -Wl,-T"configPkg/linker.cmd" -Wl,--start-group -lrdimon -lgcc -lm -lnosys -lc -Wl,--end-group
    'Finished building target: UART_BasicExample_evmK2G_armTestproject.out'

    Then you can load and run.

    Regards, Eric
  • Thank you very much. This is quite helpful. I have run the example and it works.
    Has anyone already created an stream using this to connect to printf? Or is that "an exercise left to the student?"
  • Indeed, the "getting started" document should point to this and to processors.wiki.ti.com/.../Processor_SDK_-_Create_PDK_projects

  • Chuck,

    Thanks for the feedback. I have added the PDK Project Create wiki article to the getting started guide under examples and demonstrations:

    As far as using UART for printf is concerned, all the examples in the PDK use UART for sending log messages to the serial terminal on the PC.

    Please refer to the code provided in all the driver examples. Please refer to how this is implemented in SPI driver test code under

    C:\ti\PSDK_32_preGA\pdk_k2g_1_0_4\packages\ti\drv\spi\test\src

    the file, SPI_log.h defines a MACRO SPI_log which is defined as

    #ifndef IO_CONSOLE
    #define SPI_log                UART_printf
    #else
    #define SPI_log                printf
    #endif

    UART_printf is a function implemented in the UART driver that directs printf messages to UART. In order to do this, you will need to call the Board_Init API in board library with the following settings:

     /* Call board init functions */
        Board_initCfg boardCfg;
    
    boardCfg = BOARD_INIT_PINMUX_CONFIG |
            BOARD_INIT_MODULE_CLOCK |
            BOARD_INIT_UART_STDIO;
        Board_init(boardCfg);

    After this you will need to link to the UART driver and either create a MACRO like SPI_log or API UART_printf to send logs to the serial console at 115.2kbps.

    Regards,

    Rahul

     

  • Thanks, this is exactly what I am doing.  Though I am further changing the init to go to UART 2 as UART 0 is already in use by the application.

    UART_printf() seems not to support %f and %s.  What I'm looking to do (and I'll get there) is to install the UART functions into the STDIO stream so that the real printf() works.

  • OK, I've got the UART stuff working great. But I want to route the standard printf() and gets() to this UART. I see that printf() is typically routed to the CCS console and I understand that
    var SemiHost = xdc.useModule('ti.sysbios.rts.gnu.SemiHostSupport');
    in the .cfg file is an important part of this. This tells me that TI has a mechanism beyond standard gcc.

    Searching your wiki brings me to this:
    processors.wiki.ti.com/.../BIOS_FAQs

    But when I install UART_puts as the outputFxn, I get
    xdc.runtime.Error.raise: terminating execution
    and the exception dump printed over and over on my UART's console. Placing a breakpoint in my custom outputFxn, I see that the first call

    Can you point me to what is required to plug into this interface? Or maybe I shouldn't be using SysMin?
  • Chuck,

    Ok, It looks like you are trying to override the printf() and gets() functions from the standard compiler IO function. I don`t think this is something that the TI RTOS Semihosting configuration. Adding that module to the configuration simply adds rdimon GCC library as you can see from the file SemiHostingSupport.xdc in that package.

    In order to over ride printf, can you remove Semihosting from the configuration and use GCC compile time flags -fno-builtin-fprintf and  -fno-builtin-printf. If you now define a local printf function to route output to UART, the compiler should ignore the printf from the runtime GNU library. I haven`t tried this my self but this has been known to work on some GNU forums.

    Hope this helps.

    Regards,

    Rahul

     

  • This is a fine answer.  Thank you.