UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
993 Views
Registered: ‎06-11-2018

undefined reference building u-boot

Jump to solution

I'm trying to minimize the size of my U-boot image. I want to remove USB and ethernet support. When I do this with "petalinux-config -c u-boot-xlnx" (see detailed steps below) and then try to build, I get undefined references to various network functions. I've seen some other threads with similar issues, but the things that worked there don't seem to be working for me.

Steps to reproduce:

Run:

petalinux-create -t project --template zynqMP --name zcu104_tiny
cd zcu104_tiny
petalinux-config --get-hw-description ../../hw/zcu104_minimal

where "../../hw/zcu104_minimal" contains a DSA file for a project I generated based on the devkit sample project. (If you're trying to reproduce these steps, you should be able to use "zcu104_rv_ss.dsa" from the ZCU104 dev kit sample project.)

In the menu, change "u-boot Configuration" -> "u-boot config target" to "xilinx_zynqmp_zcu104_revC_defconfig", and disable "Image Packaging Configuration" -> "Copy final images to tftpboot". Save and exit.

Now run

petalinux-config -c u-boot-xlnx

Disable everything related to USB, ethernet, SATA, or EFI (none of which I currently want for u-boot). Save and exit. The resulting config fragment is:

# CONFIG_AHCI is not set
# CONFIG_DISTRO_DEFAULTS is not set
# CONFIG_CMD_BOOTEFI is not set
# CONFIG_CMD_NET is not set
# CONFIG_CMD_TFTPPUT is not set
# CONFIG_CMD_DHCP is not set
# CONFIG_CMD_PXE is not set
# CONFIG_CMD_NFS is not set
# CONFIG_CMD_MII is not set
# CONFIG_CMD_PING is not set
# CONFIG_NET is not set
# CONFIG_SCSI_AHCI is not set
# CONFIG_DM_ETH is not set
# CONFIG_SCSI is not set
# CONFIG_DM_SCSI is not set

Build u-boot:

petalinux-build -c u-boot-xlnx

The do_compile step fails during linking:

  aarch64-xilinx-linux-ld.bfd   -g -Ttext 0xc100000 -o examples/standalone/hello_world -e hello_world examples/standalone/hello_world.o examples/standalone/libstubs.o -L /home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/recipe-sysroot/usr/lib/aarch64-xilinx-linux/7.2.0 -lgcc
  aarch64-xilinx-linux-objcopy -O srec  examples/standalone/hello_world examples/standalone/hello_world.srec
  aarch64-xilinx-linux-objcopy -O binary  examples/standalone/hello_world examples/standalone/hello_world.bin
  aarch64-xilinx-linux-ld.bfd   -pie  --gc-sections -Bstatic  --no-dynamic-linker -Ttext 0x8000000 -o u-boot -T u-boot.lds arch/arm/cpu/armv8/start.o --start-group  arch/arm/cpu/built-in.o  arch/arm/cpu/armv8/built-in.o  arch/arm/lib/built-in.o  board/xilinx/zynqmp/built-in.o  cmd/built-in.o  common/built-in.o  disk/built-in.o  drivers/built-in.o  drivers/dma/built-in.o  drivers/gpio/built-in.o  drivers/i2c/built-in.o  drivers/mtd/built-in.o  drivers/mtd/onenand/built-in.o  drivers/mtd/spi/built-in.o  drivers/mtd/ubi/built-in.o  drivers/net/built-in.o  drivers/net/phy/built-in.o  drivers/pci/built-in.o  drivers/power/built-in.o  drivers/power/battery/built-in.o  drivers/power/domain/built-in.o  drivers/power/fuel_gauge/built-in.o  drivers/power/mfd/built-in.o  drivers/power/pmic/built-in.o  drivers/power/regulator/built-in.o  drivers/serial/built-in.o  drivers/spi/built-in.o  drivers/usb/common/built-in.o  drivers/usb/dwc3/built-in.o  drivers/usb/emul/built-in.o  drivers/usb/eth/built-in.o  drivers/usb/gadget/built-in.o  drivers/usb/gadget/udc/built-in.o  drivers/usb/host/built-in.o  drivers/usb/musb-new/built-in.o  drivers/usb/musb/built-in.o  drivers/usb/phy/built-in.o  drivers/usb/ulpi/built-in.o  dts/built-in.o  env/built-in.o  fs/built-in.o  lib/built-in.o  net/built-in.o  test/built-in.o  test/dm/built-in.o --end-group -L /home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/recipe-sysroot/usr/lib/aarch64-xilinx-linux/7.2.0 -lgcc -Map u-boot.map;  true
cmd/built-in.o: In function `do_load_wrapper':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/cmd/fs.c:30: undefined reference to `efi_set_bootdev'
cmd/built-in.o: In function `do_scsi':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/cmd/scsi.c:36: undefined reference to `scsi_bus_reset'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/cmd/scsi.c:44: undefined reference to `scsi_scan'
common/built-in.o: In function `bootm_disable_interrupts':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/common/bootm.c:497: undefined reference to `eth_halt'
common/built-in.o: In function `eth_get_dev':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/include/net.h:193: undefined reference to `eth_current'
aarch64-xilinx-linux-ld.bfd: common/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `eth_current' which may bind externally can not be used when making a shared object; recompile with -fPIC
common/built-in.o: In function `bootm_disable_interrupts':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/common/bootm.c:499: undefined reference to `eth_current'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/common/bootm.c:499: undefined reference to `eth_unregister'
drivers/net/built-in.o: In function `nc_stdio_getc':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:284: undefined reference to `net_loop'
drivers/net/built-in.o: In function `eth_get_dev':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/include/net.h:193: undefined reference to `eth_current'
aarch64-xilinx-linux-ld.bfd: drivers/net/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `eth_current' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/include/net.h:193: undefined reference to `eth_current'
drivers/net/built-in.o: In function `nc_send_packet':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:189: undefined reference to `net_null_ethaddr'
aarch64-xilinx-linux-ld.bfd: drivers/net/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `net_null_ethaddr' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:189: undefined reference to `net_null_ethaddr'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:190: undefined reference to `eth_is_active'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:195: undefined reference to `net_loop'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:201: undefined reference to `eth_is_active'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:203: undefined reference to `eth_init'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:212: undefined reference to `net_tx_packet'
aarch64-xilinx-linux-ld.bfd: drivers/net/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `net_tx_packet' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:212: undefined reference to `net_tx_packet'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:212: undefined reference to `net_eth_hdr_size'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:216: undefined reference to `net_send_udp_packet'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:220: undefined reference to `eth_halt'
drivers/net/built-in.o: In function `eth_init_state_only':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/include/net.h:211: undefined reference to `eth_current'
drivers/net/built-in.o: In function `eth_halt_state_only':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/include/net.h:218: undefined reference to `eth_current'
drivers/net/built-in.o: In function `nc_stdio_start':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:241: undefined reference to `net_init'
drivers/net/built-in.o: In function `eth_get_dev':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/include/net.h:193: undefined reference to `eth_current'
aarch64-xilinx-linux-ld.bfd: drivers/net/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `eth_current' which may bind externally can not be used when making a shared object; recompile with -fPIC
drivers/net/built-in.o: In function `nc_stdio_tstc':
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:312: undefined reference to `eth_current'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:312: undefined reference to `eth_is_active'
/home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/git/drivers/net/netconsole.c:318: undefined reference to `net_loop'
/bin/sh: line 1:  8995 Segmentation fault      (core dumped) aarch64-xilinx-linux-ld.bfd -pie --gc-sections -Bstatic --no-dynamic-linker -Ttext 0x8000000 -o u-boot -T u-boot.lds arch/arm/cpu/armv8/start.o --start-group arch/arm/cpu/built-in.o arch/arm/cpu/armv8/built-in.o arch/arm/lib/built-in.o board/xilinx/zynqmp/built-in.o cmd/built-in.o common/built-in.o disk/built-in.o drivers/built-in.o drivers/dma/built-in.o drivers/gpio/built-in.o drivers/i2c/built-in.o drivers/mtd/built-in.o drivers/mtd/onenand/built-in.o drivers/mtd/spi/built-in.o drivers/mtd/ubi/built-in.o drivers/net/built-in.o drivers/net/phy/built-in.o drivers/pci/built-in.o drivers/power/built-in.o drivers/power/battery/built-in.o drivers/power/domain/built-in.o drivers/power/fuel_gauge/built-in.o drivers/power/mfd/built-in.o drivers/power/pmic/built-in.o drivers/power/regulator/built-in.o drivers/serial/built-in.o drivers/spi/built-in.o drivers/usb/common/built-in.o drivers/usb/dwc3/built-in.o drivers/usb/emul/built-in.o drivers/usb/eth/built-in.o drivers/usb/gadget/built-in.o drivers/usb/gadget/udc/built-in.o drivers/usb/host/built-in.o drivers/usb/musb-new/built-in.o drivers/usb/musb/built-in.o drivers/usb/phy/built-in.o drivers/usb/ulpi/built-in.o dts/built-in.o env/built-in.o fs/built-in.o lib/built-in.o net/built-in.o test/built-in.o test/dm/built-in.o --end-group -L /home/peta/sw/zcu104_tiny/build/tmp/work/plnx_zynqmp-xilinx-linux/u-boot-xlnx/v2018.01-xilinx-v2018.2+gitAUTOINC+21812b5fd3-r0/recipe-sysroot/usr/lib/aarch64-xilinx-linux/7.2.0 -lgcc -Map u-boot.map

All the "undefined references" are to things that I thought I disabled, so why are they still being included? "petalinux-build -x mrproper" did not help.

 

Another thing to note, in case it is relevant: although I want these devices removed from U-boot, I do want some of them available from Linux, so I need to keep them in the device tree.

Does anyone know how to get this to build?

0 Kudos
1 Solution

Accepted Solutions
895 Views
Registered: ‎06-11-2018

Re: undefined reference building u-boot

Jump to solution

I'm afraid your steps didn't help - I had already disabled those options. However, I was able to figure out what was going on.

Following your steps in detail:

1. petalinux-config -c u-boot
Device Drivers --->[] USB support ---> un select

This was already un-selected.

2. Command line interface --> Device access commands --> [ ] usb -- Un select

                                                                                           ---> [ ] dfu --- > un select

---> Device access commands --> Boot commands ---> [ ] thor - TIZEN 'thor' download -- Unselect 

These were also already un-selected.


3. Device Drivers --->[ ] Ethernet PHY (physical media interface) support
[ ] Network device support 

These options were not present in the menu. These are CONFIG_PHYLIB and CONFIG_NETDEVICES, respectively, which both depends on CONFIG_NET, which was already disabled.


[ ] Enable Driver Model for Ethernet drivers -- unselect &save and exit

This was already disabeld.

4. petalinux-build

Since no options changed, the build result is the same. (I did re-run petalinux-build.)

 

I've dug into this a bit further. Some of the errors I was getting are during the compile of netconsole.c, for example, which seemed strange, since CONFIG_NETCONSOLE (Networking Support -> NetConsole support) was also disabled. I figured out that, despite what is shown by the u-boot menuconfig, CONFIG_NETCONSOLE is in fact being defined in the auto-generated file project-spec/meta-plnx-generated/recipes-bsp/u-boot/configs/platform-auto.h. Here is a portion of that file:

 

/* ethernet - psu_ethernet_3 */
#define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
#define PHY_ANEG_TIMEOUT 20000
#define CONFIG_MII
#define CONFIG_NET_MULTI
#define CONFIG_NETCONSOLE       1
#define CONFIG_SERVERIP 172.17.0.7
#define CONFIG_IPADDR

 

 

It seems that petalinux-config's auto-generated output is generating #defines for features present in the Zynq Vivado project (DSA or HDF file). Disabling an option in menuconfig just removes an #ifdef, which is easy for platform-auto.h to add back in. So, my solution is to re-#undef them in platform-top. In particular, I appended the following to the end of project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h:

/* Disable auto-generated config options from platform-auto.h */
#undef CONFIG_MII #undef CONFIG_NET_MULTI #undef CONFIG_NETCONSOLE

This got rid of my "net"-related errors. My remaining errors were in fs.c and scsi.c. I found I needed to disable the following additional u-boot options:

  • CONFIG_EFI_LOADER (Library routines -> Support running EFI applications in U-Boot)
  • CONFIG_CMD_SCSI (Command line interface -> Filesystem commands -> scsi - Access to SCSI devices)

I was then able to run petalinux-build successfully.

For anyone else running into similar problems: you might need to read through the generated platform-auto.h to see if it is re-enabling any options that you want disabled. If it is, add #undef entries to platform-top.h to re-disable them.

2 Replies
Xilinx Employee
Xilinx Employee
943 Views
Registered: ‎02-07-2018

Re: undefined reference building u-boot

Jump to solution

Hi asmith@kepler

Please follow below steps. I just verified it should work.

1. petalinux-config -c u-boot
Device Drivers --->[] USB support ---> un select

2. Command line interface --> Device access commands --> [ ] usb -- Un select

                                                                                           ---> [ ] dfu --- > un select

---> Device access commands --> Boot commands ---> [ ] thor - TIZEN 'thor' download -- Unselect 


3. Device Drivers --->[ ] Ethernet PHY (physical media interface) support
[ ] Enable Driver Model for Ethernet drivers
[ ] Network device support  -- unselect &save and exit

4. petalinux-build

 

Thanks & regards

Aravind

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

0 Kudos
896 Views
Registered: ‎06-11-2018

Re: undefined reference building u-boot

Jump to solution

I'm afraid your steps didn't help - I had already disabled those options. However, I was able to figure out what was going on.

Following your steps in detail:

1. petalinux-config -c u-boot
Device Drivers --->[] USB support ---> un select

This was already un-selected.

2. Command line interface --> Device access commands --> [ ] usb -- Un select

                                                                                           ---> [ ] dfu --- > un select

---> Device access commands --> Boot commands ---> [ ] thor - TIZEN 'thor' download -- Unselect 

These were also already un-selected.


3. Device Drivers --->[ ] Ethernet PHY (physical media interface) support
[ ] Network device support 

These options were not present in the menu. These are CONFIG_PHYLIB and CONFIG_NETDEVICES, respectively, which both depends on CONFIG_NET, which was already disabled.


[ ] Enable Driver Model for Ethernet drivers -- unselect &save and exit

This was already disabeld.

4. petalinux-build

Since no options changed, the build result is the same. (I did re-run petalinux-build.)

 

I've dug into this a bit further. Some of the errors I was getting are during the compile of netconsole.c, for example, which seemed strange, since CONFIG_NETCONSOLE (Networking Support -> NetConsole support) was also disabled. I figured out that, despite what is shown by the u-boot menuconfig, CONFIG_NETCONSOLE is in fact being defined in the auto-generated file project-spec/meta-plnx-generated/recipes-bsp/u-boot/configs/platform-auto.h. Here is a portion of that file:

 

/* ethernet - psu_ethernet_3 */
#define CONFIG_SYS_FAULT_ECHO_LINK_DOWN
#define PHY_ANEG_TIMEOUT 20000
#define CONFIG_MII
#define CONFIG_NET_MULTI
#define CONFIG_NETCONSOLE       1
#define CONFIG_SERVERIP 172.17.0.7
#define CONFIG_IPADDR

 

 

It seems that petalinux-config's auto-generated output is generating #defines for features present in the Zynq Vivado project (DSA or HDF file). Disabling an option in menuconfig just removes an #ifdef, which is easy for platform-auto.h to add back in. So, my solution is to re-#undef them in platform-top. In particular, I appended the following to the end of project-spec/meta-user/recipes-bsp/u-boot/files/platform-top.h:

/* Disable auto-generated config options from platform-auto.h */
#undef CONFIG_MII #undef CONFIG_NET_MULTI #undef CONFIG_NETCONSOLE

This got rid of my "net"-related errors. My remaining errors were in fs.c and scsi.c. I found I needed to disable the following additional u-boot options:

  • CONFIG_EFI_LOADER (Library routines -> Support running EFI applications in U-Boot)
  • CONFIG_CMD_SCSI (Command line interface -> Filesystem commands -> scsi - Access to SCSI devices)

I was then able to run petalinux-build successfully.

For anyone else running into similar problems: you might need to read through the generated platform-auto.h to see if it is re-enabling any options that you want disabled. If it is, add #undef entries to platform-top.h to re-disable them.