how to add printf with console s32k144

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to add printf with console s32k144

414 Views
alice_thanks
Contributor III

i use gcc 10.2, don't have ewl_c9x, how i can enable printf with uart port 

alice_thanks_0-1713775746610.png

alice_thanks_2-1713776071743.jpeg

 

i see there is link:

use below configure,

alice_thanks_1-1713776024739.png

 

https://community.nxp.com/t5/S32-Design-Studio-Knowledge-Base/Example-S32K-printf-implementation-S32...

 

0 Kudos
9 Replies

396 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @alice_thanks,

You can use NewLib/NewLib Nano with Debugger Console I/O support with GCC 10.2:

Julin_AragnM_0-1713827251633.png

Julin_AragnM_1-1713827256692.png

or downgrade the toolchain version (6.3) and use EWL:

Julin_AragnM_3-1713827270797.png

Julin_AragnM_5-1713827322488.png

Best regards,
Julián

 

0 Kudos

386 Views
alice_thanks
Contributor III

how to modify it when the project already created ?

BTW, if use GCC 10.2, we need still add uart driver code ?

like below code ? 

but there is error , fatal error: ewl_misra_types.h: No such file or directory

#include <string.h>
#include <stdint.h>
#include <stdbool.h>
 
#include <stdio.h>
#include "ewl_misra_types.h"
#include "file_struc.h"
 
 
int_t __write_console(__file_handle handle, uchar_t * buffer, size_t * count)
{
(void)(handle);
 
    uint32_t bytesRemain;
    size_t bytes=*count;
 
    LPUART_DRV_SendData(INST_LPUART1, buffer, bytes);
    while(LPUART_DRV_GetTransmitStatus(INST_LPUART1, &bytesRemain) != STATUS_SUCCESS);
 
    return 0;
}
 
0 Kudos

337 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @alice_thanks,

No, that driver is for EWL console support.

I believe some changes are needed if you want to change an existing project's toolchain, such as the included paths in project settings, but I would suggest creating an application project and porting the application code to the new project.

Julin_AragnM_0-1713887413728.pngJulin_AragnM_1-1713887529618.png

Best regards,
Julián

 

0 Kudos

302 Views
alice_thanks
Contributor III

if still use gcc 10.2, do you steps to add printf with console, is it only need configure,

alice_thanks_0-1713924091038.png

is there any other code we need add ? can you show the full steps with gcc 10.2 console printf ?

0 Kudos

300 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @alice_thanks,

You can refer to the following post: Solved: how to use the printf function in S32DS.3.5 ? - NXP Community

Best regards,
Julián

0 Kudos

266 Views
alice_thanks
Contributor III

i want use the real uart print with terminal, you link only work with  semihosting console.

i already add this code, but no print on my terminal, please check , thanks!

int _write(int file, char *ptr, int len)
{
uint32_t bytesRemain;
size_t bytes=len;
unsigned char ret_car[]={"\r"};
LPUART_DRV_SendData(INST_LPUART1, ptr, bytes);
while(LPUART_DRV_GetTransmitStatus(INST_LPUART1, &bytesRemain) != STATUS_SUCCESS);
LPUART_DRV_SendData(INST_LPUART1, ret_car, 1);
while(LPUART_DRV_GetTransmitStatus(INST_LPUART1, &bytesRemain) != STATUS_SUCCESS);
return len;
}

 

alice_thanks_1-1714011951259.png

 

alice_thanks_0-1714011901496.png

 

alice_thanks_2-1714012011554.png

 

alice_thanks_3-1714012050280.png

 

0 Kudos

163 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @alice_thanks,

You can use the example you posted. This example was designed for an older SDK, which can be flashed in S32DS.2018.R1 or you can create a new project (selecting GCC 6.3 compiler and EWL library) and copy over the configuration from the original post:

Julin_AragnM_0-1714166809841.png

I've shared the ported project for S32DS3.5 RTD3.0.0.

Best regards,
Julián

0 Kudos

374 Views
alice_thanks
Contributor III

if switch gcc , there will some error below, could you help to check 

Building target: lpi2c_master_s32k144.elf
Invoking: Standard S32DS C Linker
arm-none-eabi-gcc -o "lpi2c_master_s32k144.elf" "@lpi2c_master_s32k144.args"
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: ./SDK/platform/drivers/src/interrupt/interrupt_manager.o: in function `INT_SYS_InstallHandler':
C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__VECTOR_RAM'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__VECTOR_TABLE'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__DATA_ROM'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__DATA_END'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:46: lpi2c_master_s32k144.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.

11:19:43 Build Failed. 5 errors, 0 warnings. (took 28s.674ms)

0 Kudos

341 Views
alice_thanks
Contributor III

if switch the gcc tool, then rebuild project, always have these error, what is the problem ?

alice_thanks_0-1713839094163.png

 

Building target: lpi2c_master_s32k144.elf
Invoking: Standard S32DS C Linker
arm-none-eabi-gcc -o "lpi2c_master_s32k144.elf" "@lpi2c_master_s32k144.args"
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./board/clock_config.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./board/clock_config.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./board/peripherals_edma_config_1.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./board/peripherals_edma_config_1.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./board/peripherals_lpi2c_config_1.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./board/peripherals_lpi2c_config_1.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./board/peripherals_lpuart_1.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./board/peripherals_lpuart_1.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./board/peripherals_osif_1.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./board/peripherals_osif_1.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./board/pin_mux.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./board/pin_mux.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./src/SFH5721.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./src/SFH5721.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./src/console.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./src/console.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: error: lpi2c_master_s32k144.elf uses VFP register arguments, ./src/main.o does not
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: failed to merge target specific data of file ./src/main.o
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: ./SDK/platform/drivers/src/interrupt/interrupt_manager.o: in function `INT_SYS_InstallHandler':
C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__VECTOR_RAM'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__VECTOR_TABLE'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__DATA_ROM'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_v10.2/gcc-10.2-arm32-eabi/bin/../lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__DATA_END'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:46: lpi2c_master_s32k144.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.

10:22:32 Build Failed. 5 errors, 0 warnings. (took 19s.142ms)

then i switch back to gcc 6.3, then still have these error(), 

Building target: lpi2c_master_s32k144.elf
Invoking: Standard S32DS C Linker
arm-none-eabi-gcc -o "lpi2c_master_s32k144.elf" "@lpi2c_master_s32k144.args"
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/build_tools/gcc_b1620/arm32_ewl2/lib/thumb/v7e-m/fpv4-sp/hard/__arm_start.o: in function `__thumb_startup':
arm32_ewl2/EWL_Runtime/src/arm/__arm_start.c:282: undefined reference to `__START_BSS'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: arm32_ewl2/EWL_Runtime/src/arm/__arm_start.c:282: undefined reference to `__END_BSS'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: ./SDK/platform/drivers/src/interrupt/interrupt_manager.o: in function `INT_SYS_InstallHandler':
C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__VECTOR_RAM'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__VECTOR_TABLE'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__DATA_ROM'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/software/S32SDK_S32K1XX_RTM_4.0.1/platform/drivers/src/interrupt/interrupt_manager.c:175: undefined reference to `__DATA_END'
c:/nxp/s32ds.3.5/s32ds/build_tools/gcc_b1620/gcc-6.3-arm32-eabi/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/real-ld.exe: C:/NXP/S32DS.3.5/S32DS/build_tools/gcc_b1620/arm32_ewl2/lib/thumb/v7e-m/fpv4-sp/hard\librt.a(__arm_eabi_init.o): in function `__init_registers':
arm32_ewl2/EWL_Runtime/src/arm/__arm_eabi_init.c:102: undefined reference to `__SP_INIT'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:43: lpi2c_master_s32k144.elf] Error 1
"make -j8 all" terminated with exit code 2. Build might be incomplete.

10:27:00 Build Failed. 8 errors, 0 warnings. (took 26s.737ms)

i use this example to test, lpi2c_master_s32k144

0 Kudos