Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker Error During BusyBox Compilation #21

Open
Kingxukai opened this issue Jul 28, 2024 · 0 comments
Open

Linker Error During BusyBox Compilation #21

Kingxukai opened this issue Jul 28, 2024 · 0 comments

Comments

@Kingxukai
Copy link

Kingxukai commented Jul 28, 2024

Hi there,
I'm currently encountering a linking error while trying to compile BusyBox on my Ubuntu 20.04 system. I have tried checking for missing libraries, but the issue persists.Here are the details of the error:

First Step

I tried to boot linux with u-boot ,but it failed as the lack of init process.
Here is the output info below:

[    0.179696] platform 502b0000.pinmux: Fixed dependency cycle(s) with /soc/bus@50200000/pinmux@502b0000/jtag-pinmux
[    0.195124] platform 50440000.syscon: Fixed dependency cycle(s) with /soc/bus@50400000/syscon@50440000/clock-controller
[    0.210875] k210-sysctl 50440000.syscon: K210 system controller
[    0.222554] k210-rst 50440000.syscon:reset-controller: K210 reset controller
[    0.230191] 38000000.serial: ttySIF0 at MMIO 0x38000000 (irq = 1, base_baud = 24375000) is a SiFive UART v0
[    0.239278] printk: console [ttySIF0] enabled
[    0.239278] printk: console [ttySIF0] enabled
[    0.247891] printk: bootconsole [sifive0] disabled
[    0.247891] printk: bootconsole [sifive0] disabled
[    0.259842] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.268511] spi spi1.0: setup: ignoring unsupported mode bits a00
[    0.274610] i2c_dev: i2c /dev entries driver
[    0.290696] k210-fpioa 502b0000.pinmux: K210 FPIOA pin controller
[    0.332473] mmc_spi spi3.0: SD/MMC host mmc0, no WP, no poweroff, cd polling
[    0.343051] Waiting for root device /dev/mmcblk0p2...
[    0.364506] mmc0: host does not support reading read-only switch, assuming write-enable
[    0.371805] mmc0: new SDHC card on SPI
[    0.377328] mmcblk0: mmc0:0000 SA16G 14.4 GiB 
[    0.416484]  mmcblk0: p1 p2
[    0.434923] VFS: Mounted root (ext2 filesystem) readonly on device 179:2.
[    0.446836] devtmpfs: mounted
[    0.449442] Freeing unused kernel image (initmem) memory: 116K
[    0.454893] This architecture does not have kernel memory protection.
[    0.461327] Run /sbin/init as init process
[    0.465600] Run /etc/init as init process
[    0.475219] Run /bin/init as init process
[    0.478709] Run /bin/sh as init process
[    0.482493] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance.
[    0.496442] SMP: stopping secondary CPUs
[    0.500363] ---[ end Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/admin-guide/init.rst for guidance. ]---

Second

So, I guess may be it is the result of lack of BusyBox which built failed that I skipped before:

$ make SKIP_STRIP=y               
  CC      applets/applets.o                                                
In file included from include/libbb.h:13,                                  
                 from include/busybox.h:8,                                 
                 from applets/applets.c:9:                                 
include/platform.h:164:11: fatal error: byteswap.h: No such file or directory
  164 | # include <byteswap.h>                                             
      |           ^~~~~~~~~~~~                                             
compilation terminated.                                                    
make[1]: *** [scripts/Makefile.build:198: applets/applets.o] Error 1       
make: *** [Makefile:372: applets_dir] Error 2

I find the files it needs

opt/riscv64-uclibc/host/riscv64-buildroot-linux-uclibc/sysroot/usr/lib$ ls
crt1.o  libcrypt.a  libintl.a  libnsl.a     librt.a
libc.a  libdl.a     libm.a     libresolv.a
/opt/riscv64-uclibc/host/riscv64-buildroot-linux-uclibc/sysroot/usr/lib$ sudo find /opt -name byteswap.h                                    
/opt/riscv64-uclibc/host/riscv64-buildroot-linux-uclibc/sysroot/usr/include/byteswap.h

and then check the PATH is set

k210-linux-nommu/busybox$ echo $PATH | grep "/opt/riscv64-uclibc/bin"                                                               
/opt/riscv64-uclibc/bin ...

Third

after that I tried with
k210-linux-nommu/busybox$ make SKIP_STRIP=y CFLAGS="-I/opt/riscv64-uclibc/host/riscv64-buildroot-linux-uclibc/sysroot/usr/include"
but it return with

/opt/riscv64-uclibc/riscv64-buildroot-linux-uclibc/bin/ld.real: cannot find crt1.o: No such file or directory
collect2: error: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [Makefile:718: busybox_unstripped] Error 1 

And it not works with
k210-linux-nommu/busybox$ make SKIP_STRIP=y CFLAGS="-I/opt/riscv64-uclibc/host/riscv64-buildroot-linux-uclibc/sysroot/usr/include" CONFIG_EXTRA_LDLIBS="/opt/riscv64-uclibc/host/riscv64-buildroot-linux-uclibc/sysroot/usr/lib/crt1.o"

still return the error:

/opt/riscv64-uclibc/riscv64-buildroot-linux-uclibc/bin/ld.real: cannot find crt1.o: No such file or directory
collect2: error: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [Makefile:718: busybox_unstripped] Error 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant