AnsweredAssumed Answered

How to use printf in NHS3100 project?

Question asked by Arna Lee on Mar 13, 2018
Latest reply on Mar 22, 2018 by Dries Moors
Hi Sir,
I read "LPCXpresso_IDE_User_Guide.pdf" which talks about printf as below:
---------------------------
Semihosting C Project
• Creates a simple “Hello World” project, with the main() routine containing a printf() call, which will cause the text to be displayed within the Console View of the LPCXpresso IDE. This is implemented using “semihosting” functionality. For more details, please see the FAQ at
http://www.lpcware.com/content/faq/lpcxpresso/using-printf
---------------------------
But when I click the link above, the content is NOT available and it is linked to another web address "https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/lpc-cortex-m-mcus:LPC-ARM-CORTEX-M-MCUS".
Could you advice how I can access the link "http://www.lpcware.com/content/faq/lpcxpresso/using-printf" for the content?
I want to use printf function to trace the routine but I met problem.
For example, I tried as below:
---
#include<stdio.h>
// ...
printf("LED Toggle\r\n");
--------------
But the compiling errors happened:
*******
12:43:23 **** Incremental Build of configuration Debug for project app_demo_dp_blinky ****
make -r all
Building file: ../src/mainblinky.c
Invoking: MCU C Compiler
arm-none-eabi-gcc -std=c99 -DDEBUG -D__CODE_RED -DCORE_M0PLUS -D__REDLIB__ -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_chip_nss" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_board_dp" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\app_demo_dp_blinky\inc" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_board_dp\inc" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_chip_nss\inc" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\mods" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\app_demo_dp_blinky\mods" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_board_dp\mods" -I"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_chip_nss\mods" -include"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_chip_nss\mods\chip_sel.h" -include"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_board_dp\mods\board_sel.h" -include"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\app_demo_dp_blinky\mods\app_sel.h" -O0 -g3 -pedantic -Wall -Wextra -Wconversion -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -mcpu=cortex-m0plus -mthumb -D__REDLIB__ -specs=redlib.specs -MMD -MP -MF"src/mainblinky.d" -MT"src/mainblinky.o" -MT"src/mainblinky.d" -o "src/mainblinky.o" "../src/mainblinky.c"
Finished building: ../src/mainblinky.c
 
Building target: app_demo_dp_blinky.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_board_dp\Debug" -L"C:\Users\Bitse\Documents\LPCXpresso_8.1.4_606\workspace\lib_chip_nss\Debug" -Xlinker -Map="app_demo_dp_blinky.map" -Xlinker --gc-sections -mcpu=cortex-m0plus -mthumb -T "app_demo_dp_blinky_Debug.ld" -o "app_demo_dp_blinky.axf"  ./src/crp.o ./src/mainblinky.o   -llib_board_dp -llib_chip_nss
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(fpprintf.o): In function `printf':
fpprintf.c:(.text.printf+0x38): undefined reference to `__sys_write'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(_deferredlazyseek.o): In function `__flsbuf':
_deferredlazyseek.c:(.text.__flsbuf+0x88): undefined reference to `__sys_istty'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(_writebuf.o): In function `_Cwritebuf':
_writebuf.c:(.text._Cwritebuf+0x16): undefined reference to `__sys_flen'
_writebuf.c:(.text._Cwritebuf+0x26): undefined reference to `__sys_seek'
_writebuf.c:(.text._Cwritebuf+0x3c): undefined reference to `__sys_write'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(alloc.o): In function `_Csys_alloc':
alloc.c:(.text._Csys_alloc+0xe): undefined reference to `__sys_write'
alloc.c:(.text._Csys_alloc+0x12): undefined reference to `__sys_appexit'
c:/nxp/lpcxpresso_8.1.4_606/lpcxpresso/tools/bin/../lib/gcc/arm-none-eabi/5.2.1/../../../../arm-none-eabi/lib/armv6-m\libcr_c.a(fseek.o): In function `fseek':
fseek.c:(.text.fseek+0x18): undefined reference to `__sys_istty'
fseek.c:(.text.fseek+0x3c): undefined reference to `__sys_flen'
collect2.exe: error: ld returned 1 exit status
make: *** [app_demo_dp_blinky.axf] Error 1
12:43:24 Build Finished (took 856ms)
***************
Sorry I am a new comer for NXP NHS3100 and LPCXpresso development.
Look forward to your guide.
Many thanks,
Arna

Outcomes