Link Issue

gary-newman wrote on Thursday, February 04, 2016:

Hi,

I have ported the Cyclone V SOC Demo onto the Arria V Soc which is all up and working fine.

I’ve got to benchmark some code, so I thought I’d just check I could get some debug out of the serial.
I updated printf-stdarg.c to uart0 & added + a printf to LEDs.c.
All worked fine.

The problem came when adding a printf to main_blinky.c
Now the linker is failing with the following errors:

‘Building target: ALGDemo.elf’
‘Invoking: Cross GCC Linker’
arm-altera-eabi-gcc -Xlinker -TTEST.ld -Xlinker --defsym=__cs3_isr_irq=FreeRTOS_IRQ_Handler -Xlinker --defsym=__cs3_isr_swi=FreeRTOS_SWI_Handler -Xlinker -Map=RTOSDemo.map -Xlinker --gc-sections -Xlinker --allow-multiple-definition -o “ALGDemo.elf” ./Standard_Demo_Tasks/Minimal/BlockQ.o ./Standard_Demo_Tasks/Minimal/EventGroupsDemo.o ./Standard_Demo_Tasks/Minimal/GenQTest.o ./Standard_Demo_Tasks/Minimal/IntSemTest.o ./Standard_Demo_Tasks/Minimal/PollQ.o ./Standard_Demo_Tasks/Minimal/QPeek.o ./Standard_Demo_Tasks/Minimal/QueueOverwrite.o ./Standard_Demo_Tasks/Minimal/QueueSet.o ./Standard_Demo_Tasks/Minimal/QueueSetPolling.o ./Standard_Demo_Tasks/Minimal/TaskNotify.o ./Standard_Demo_Tasks/Minimal/TimerDemo.o ./Standard_Demo_Tasks/Minimal/blocktim.o ./Standard_Demo_Tasks/Minimal/countsem.o ./Standard_Demo_Tasks/Minimal/death.o ./Standard_Demo_Tasks/Minimal/dynamic.o ./Standard_Demo_Tasks/Minimal/flop.o ./Standard_Demo_Tasks/Minimal/integer.o ./Standard_Demo_Tasks/Minimal/recmutex.o ./Standard_Demo_Tasks/Minimal/semtest.o ./FreeRTOS_Source/portable/MemMang/heap_4.o ./FreeRTOS_Source/portable/GCC/ARM_CA9/port.o ./FreeRTOS_Source/portable/GCC/ARM_CA9/portASM.o ./FreeRTOS_Source/croutine.o ./FreeRTOS_Source/event_groups.o ./FreeRTOS_Source/list.o ./FreeRTOS_Source/queue.o ./FreeRTOS_Source/tasks.o ./FreeRTOS_Source/timers.o ./FreeRTOS+CLI/CLI_Examples/Sample-CLI-commands.o ./FreeRTOS+CLI/CLI_Examples/UARTCommandConsole.o ./FreeRTOS+CLI/FreeRTOS_CLI.o ./Altera_Code/SoCSupport/cache_support.o ./Altera_Code/SoCSupport/fpga_support.o ./Altera_Code/SoCSupport/mmu_support.o ./Altera_Code/SoCSupport/uart0_support.o ./Altera_Code/HardwareLibrary/alt_16550_uart.o ./Altera_Code/HardwareLibrary/alt_address_space.o ./Altera_Code/HardwareLibrary/alt_bridge_manager.o ./Altera_Code/HardwareLibrary/alt_cache.o ./Altera_Code/HardwareLibrary/alt_can.o ./Altera_Code/HardwareLibrary/alt_clock_manager.o ./Altera_Code/HardwareLibrary/alt_dma.o ./Altera_Code/HardwareLibrary/alt_dma_program.o ./Altera_Code/HardwareLibrary/alt_ecc.o ./Altera_Code/HardwareLibrary/alt_fpga_manager.o ./Altera_Code/HardwareLibrary/alt_generalpurpose_io.o ./Altera_Code/HardwareLibrary/alt_globaltmr.o ./Altera_Code/HardwareLibrary/alt_i2c.o ./Altera_Code/HardwareLibrary/alt_interrupt.o ./Altera_Code/HardwareLibrary/alt_mmu.o ./Altera_Code/HardwareLibrary/alt_nand.o ./Altera_Code/HardwareLibrary/alt_qspi.o ./Altera_Code/HardwareLibrary/alt_reset_manager.o ./Altera_Code/HardwareLibrary/alt_sdmmc.o ./Altera_Code/HardwareLibrary/alt_spi.o ./Altera_Code/HardwareLibrary/alt_system_manager.o ./Altera_Code/HardwareLibrary/alt_timers.o ./Altera_Code/HardwareLibrary/alt_watchdog.o ./LEDs.o ./main.o ./main_blinky.o ./main_full.o ./printf-stdarg.o ./reg_test.o ./serial.o
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-sbrkr.o): In function _sbrk_r': sbrkr.c:(.text+0x18): undefined reference to _sbrk’
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-writer.o): In function _write_r': writer.c:(.text+0x20): undefined reference to _write’
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-closer.o): In function _close_r': closer.c:(.text+0x18): undefined reference to _close’
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-fstatr.o): In function _fstat_r': fstatr.c:(.text+0x1c): undefined reference to _fstat’
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-isattyr.o): In function _isatty_r': isattyr.c:(.text+0x18): undefined reference to _isatty’
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-lseekr.o): In function _lseek_r': lseekr.c:(.text+0x20): undefined reference to _lseek’
c:/altera/15.1/embedded/host_tools/mentor/gnu/arm/baremetal/bin/…/lib/gcc/arm-altera-eabi/4.9.2/…/…/…/…/arm-altera-eabi/lib\libc.a(lib_a-readr.o): In function _read_r': readr.c:(.text+0x20): undefined reference to _read’
collect2.exe: error: ld returned 1 exit status
make: *** [ALGDemo.elf] Error 1

Im at a bit of a loss as to why the linker would be satisfied by printf-stdarg.o for one C file but not with another. Any ideas would be gratefully received.

Regards

Gary

rtel wrote on Thursday, February 04, 2016:

These are coming from the library, which is expecting the host to provide implementations of the functions that are missing. The functions should not actually be called, not by FreeRTOS or printf-stdarg.c in any case, so can be stubbed out. Just provide an implementation of the function (you can get the prototypes from the header files or a Google search) and just an infinite loop or an assert() in the functions implementations - that way if it actually does get called you will know because it will stop your code executing.

Regards.

gary-newman wrote on Thursday, February 04, 2016:

Thanks