Use libc within

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LuTa_4642501
Level 3
Level 3
Welcome!

Hi,

I need to use spritf with the demo cyfxusbdebug, but it doest compile::

tanureal@archtower $ make
make[1]: Entering directory '/media/workspace/usb_lessons/src'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): in function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0x18): undefined reference to `_sbrk'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-abort.o): in function `abort':
abort.c:(.text.abort+0x10): undefined reference to `_exit'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-signalr.o): in function `_kill_r':
signalr.c:(.text._kill_r+0x20): undefined reference to `_kill'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-signalr.o): in function `_getpid_r':
signalr.c:(.text._getpid_r+0x4): undefined reference to `_getpid'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-writer.o): in function `_write_r':
writer.c:(.text._write_r+0x28): undefined reference to `_write'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-closer.o): in function `_close_r':
closer.c:(.text._close_r+0x18): undefined reference to `_close'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-fstatr.o): in function `_fstat_r':
fstatr.c:(.text._fstat_r+0x20): undefined reference to `_fstat'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-isattyr.o): in function `_isatty_r':
isattyr.c:(.text._isatty_r+0x18): undefined reference to `_isatty'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-lseekr.o): in function `_lseek_r':
lseekr.c:(.text._lseek_r+0x28): undefined reference to `_lseek'
arm-none-eabi-ld: /opt/gcc-arm-none-eabi-9-2020-q2-update/arm-none-eabi/lib/libc.a(lib_a-readr.o): in function `_read_r':
readr.c:(.text._read_r+0x28): undefined reference to `_read'
make[1]: *** [makefile:48: main.elf] Error 1
make[1]: Leaving directory '/media/workspace/usb_lessons/src'
make: *** [makefile:2: all] Error 2

I can see the answer Using sprint() Function in EZ-USB® FX3™ - KBA90264 , but it only works for CPP applications, not plain C.

Only the GNU Linker for C++ applications has __heap_start and __heap_end definitions.

How Can I enable the use of libc functions into my plain C firmware?

0 Likes
1 Solution

Hello,

Please refer to the example project, the linker script file, and the RTOS port helper file attached with this KBA Printing Floating Values using FX3 SDK – KBA231244 and follow the steps mentioned in the Q2 .

Please let me know if it helps

Regards,

Rashi

Regards,
Rashi

View solution in original post

0 Likes
4 Replies
LuTa_4642501
Level 3
Level 3
Welcome!

I did the changes explained by Using sprint() Function in EZ-USB® FX3™ - KBA90264, but it had no effect.

Do I need to include cyfxcppsyscall.cpp into my make, or the sdk already includes it?

0 Likes

Hello LuTa_4642501​,

Can you please confirm if you have followed the steps mentioned in the KBA while building the project from the command prompt: Using Command Prompt for Building FX3 Projects - KBA229628 ?

"Do I need to include cyfxcppsyscall.cpp into my make, or the sdk already includes it?"
=> Can you please try including the cyfxcppsyscall.cpp file in your make command and try building the project?


As mentioned in the KBA90264, "A reference implementation is provided in the cyfxcppsyscall.cpp file with the cyfxbulkloopauto_cpp example project (available at FX3_INSTALL_PATH\firmware\basic_examples \cyfxbulklpauto_cpp)."

The KBA only mentions that the cyfxcppsyscall.cpp is a reference file only included into the cyfxbulkloopauto_cpp example and so, you may need to include the file into your project to make use of the commands being referenced to that cpp file.

Regards,

Yashwant

0 Likes
lock attach
Attachments are accessible only for community members.

Yes, I did the same steps as Using Command Prompt for Building FX3 Projects - KBA229628 for linux.

The project builds fine, but doesn't build if I use sprintf in my code.

I attached the fx3.ld and cyfxtx.c with my changes following the article about libc.

Doesn't work.

0 Likes

Hello,

Please refer to the example project, the linker script file, and the RTOS port helper file attached with this KBA Printing Floating Values using FX3 SDK – KBA231244 and follow the steps mentioned in the Q2 .

Please let me know if it helps

Regards,

Rashi

Regards,
Rashi
0 Likes