How to link libc.a in S32 Design Studio?

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

How to link libc.a in S32 Design Studio?

4,734 Views
yyin
Contributor II


I'm trying to call functions in C standard library, e.g. printf(...). I created a new S32DS project with Newlib setting, but got some error when linking:

/home/rb501c/build_gcc_dir/build_gnu/opt/freescale/ELvle/obj_newlib/powerpc-eabivle/fp/e200z4/libgloss/libnosys/../../../../../../src_newlib/libgloss/libnosys/sbrk.c:21: undefined reference to `end'

/home/rb501c/build_gcc_dir/build_gnu/opt/freescale/ELvle/obj_newlib/powerpc-eabivle/fp/e200z4/libgloss/libnosys/../../../../../../src_newlib/libgloss/libnosys/sbrk.c:21: undefined reference to `end'

collect2.exe: error: ld returned 1 exit status

make: *** [HwTest2.elf] Error 1

 

I also tried to call another function sleep(1) but indicated that it's undefined. I included <sys/unitstd.h>.

 

If anybody have any idea about newlib configuration for libc.a?

Labels (1)
16 Replies

2,704 Views
sandeepvl
Contributor III

Thanks Martin. 

I had linking issues when assert() was used. It used printf() internally. This discussion thread really helped me. I used your uart_console_io.c and modified my UART functions as needed.

0 Kudos

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I have also written simple document about EWL and printf function. You can check:

https://community.nxp.com/docs/DOC-332018 

Regards,

Martin

2,704 Views
yalamandadosaky
Contributor V

Hi Martin I am not printf output on UART.

I am running micrium rtos on mpc 574xg MB board with mpc5748-176ds and I am calling printf from my application with all changes made according to u r suggestions.

I got one doubt how printf func will call read_console, write_console functions in UART_console_io.c

0 Kudos

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

please let's solve this issue in single thread. I suggest the following thread which also alexvinchev​ helps us in.

MPC5748G error when building

Regards,

Martin

2,704 Views
yalamandadosaky
Contributor V

Hi Martin,

The Application was crashed while running .I dont know how to configure SIUL and LINFLEX modules correct in uart.c file(MPC5748G).Can you please help me out.

what about the pformatterfp, where it is defined.

0 Kudos

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

look at the following thread. https://community.freescale.com/message/651904?et=watches.email.thread#comment-651904

alexvinchev​ post there answer you are looking for.

Regards,

Martin

2,704 Views
yalamandadosaky
Contributor V

Hi Martin I am  not getting printf output on UART.

I am running micrium rtos on mpc 574xg MB board with mpc5748-176ds and I am calling printf from my application with all changes made according to u r suggestions.

I got one doubt how printf func will call read_console, write_console functions in UART_console_io.c

0 Kudos

2,704 Views
yalamandadosaky
Contributor V

b55689

Thank you very much Mr.  Martin ,

I used your link MPC5748G error when building for solving above query. I added the files(uart.c,uart.h and uart_console_io.c for mpc5748) to my project.I am able to compile successfully.

Regards,

0 Kudos

2,704 Views
yalamandadosaky
Contributor V

Thank you Martin,One more thing I want bring to u r notice that you may help.We are working with MPC5748G Microcontroller.

So I included that header file which i have already,I couldn't find Configuration of SICL &LINFLEX in uart.c file.b55689

It is compiling but one more error is getting ,Can you please help me how to sort out the following error

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(printf.o): In function `printf':

S32DS/e200_ewl/EWL_C/src/stdio/printf.c:44: undefined reference to `__pformatter'

collect2.exe: error: ld returned 1 exit status

scons: *** [DEBUG\BG_Z4_1.elf] Error 1

scons: building terminated because of errors.

0 Kudos

2,704 Views
yalamandadosaky
Contributor V

@Hi Martin ,

Thank you for early reply,I added the file but I got the below errors after compiling

app\uart_console_io.o: In function `__read_console':

C:\Users\yalamanda\Downloads\bg\BCG_OS3_Z4_1\ecu/app/uart_console_io.c:93: undefined reference to `ReadUARTN'

app\uart_console_io.o: In function `__write_console':

C:\Users\yalamanda\Downloads\bg\BCG_OS3_Z4_1\ecu/app/uart_console_io.c:151: undefined reference to `WriteUARTN'

app\uart_console_io.o: In function `__init_uart_console':

C:\Users\yalamanda\Downloads\bg\BCG_OS3_Z4_1\ecu/app/uart_console_io.c:200: undefined reference to `InitializeUART'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(printf.o): In function `printf':

S32DS/e200_ewl/EWL_C/src/stdio/printf.c:44: undefined reference to `__pformatter'

collect2.exe: error: ld returned 1 exit status

scons: *** [DEBUG\BG_Z4_1.elf] Error 1

scons: building terminated because of errors.

0 Kudos

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

I forgot uart.c and uart.h files (in attachment), which are also important. Please add them to your project. Do not forget configure SIUL and LINFLEX modules correct in uart.c file (files in attachment are configured for MPC5744P).

Regards,

Martin

2,704 Views
yalamandadosaky
Contributor V

Hi All,

I am also facing similar problem .Plz look at the below ,Plz help me how to overcome this as early as possible.b55689

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(printf.o): In function `printf':

S32DS/e200_ewl/EWL_C/src/stdio/printf.c:44: undefined reference to `__pformatter'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0x38): undefined reference

to `__read_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0x3c): undefined reference

to `__write_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0x40): undefined reference

to `__close_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0x7c): undefined reference

to `__read_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0x80): undefined reference

to `__write_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0x84): undefined reference

to `__close_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0xc0): undefined reference

to `__read_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0xc4): undefined reference

to `__write_console'

C:/Freescale/S32_Power_v1.0/S32DS/e200_ewl2/lib/fp/e200z4\libc.a(ansi_files.o):(.data.__files+0xc8): undefined reference

to `__close_console'

collect2.exe: error: ld returned 1 exit status

scons: *** [DEBUG\BG_Z4_1.elf] Error 1

scons: building terminated because of errors.

0 Kudos

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

add the file in the attachment to your project. There are defined some callback functions, which are used during the printf is called.

Regards,

Martin

2,704 Views
yyin
Contributor II

It's PowerPC architecture, Panther MPC5744p from NXP.

I also found memcpy in string.h can be called. There is no any linking error. So I guess function sleep() is not implemented in Newlib C library? If yes, which function should we call to let task go to sleep in Newlib?

0 Kudos

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

look at the following example and add files uart.c, uart.h and uart_console_io.c. Then edit section.ld file. Stack section should looks as follows:

.stack (NOLOAD) : ALIGN(16)

    {

      __HEAP = . ;

      _end = . ;

      end = . ;

      . += __HEAP_SIZE ;

      __HEAP_END = . ;

      _stack_end = . ;

      . +=  __STACK_SIZE ;

      _stack_addr = . ;

      __SP_INIT = . ;

      . += 4;

    } > m_data

Do not forget #include <stdio.h>

Example MPC5744P PinToggleStationery S32DS

About sleep function, it is not implemented. I do not think there is function, which allows you to sleep task. If you do not use operating system, there is nothing like task. But you can use for example FOR loop instead of this function or look at the Mode Entry module. This module is able to switch micro to STOP mode or HALT mode.

Regards,

Martin

2,704 Views
martin_kovar
NXP Employee
NXP Employee

Hi,

could you please clarify, if you use S32 Design Studio for ARM of for Power Architecture? And which processor you use?

Regards,

Martin