ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.9k stars 286 forks source link

Error: Symbol libusb_dev_mem_alloc not found when running X64 Openocd #1802

Closed zh522130 closed 2 months ago

zh522130 commented 2 months ago

The log is as follows:

./box64 ./openocd -f ./test.cfg -s scripts
sh: lscpu: not found
sh: lscpu: not found
 PageSize:4096 Running on Unknown CPU with 4 Cores
Will use time-based emulation for rdtsc, even if hardware counter are available
Will use Software counter measured at 1.0 GHz emulating 2.0 GHz
Params database has 14 entries
Box64 v0.3.1 16f156be built on Sep  6 2024 09:53:27
BOX64: Didn't detect 48bits of address space, considering it's 39bits
Counted 19 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/bin/:/sbin/:/usr/bin/:/usr/sbin/:/userdata/:/userdata/bin/:/data/bin/:/data/bin/pcba_test/
Looking for ./openocd
argv[1]="-f"
argv[2]="./test.cfg"
argv[3]="-s"
argv[4]="scripts"
Rename process to "openocd"
Using native(wrapped) libusb-1.0.so.0
Using emulated libhidapi-hidraw.so.0
Using native(wrapped) libm.so.6
Using native(wrapped) libutil.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) librt.so.1
Using native(wrapped) libbsd.so.0
Using native(wrapped) libudev.so.1
Error: Symbol libusb_dev_mem_alloc not found, cannot apply R_X86_64_JUMP_SLOT @0x1006828d0 (0x69156) in /userdata/x64-openocd/bin/openocd
Error: Symbol libusb_dev_mem_free not found, cannot apply R_X86_64_JUMP_SLOT @0x100682ac8 (0x69546) in /userdata/x64-openocd/bin/openocd
Open On-Chip Debugger 0.12.0+dev-00597-ga5a30519f (2024-08-03-11:02)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : Using CMSIS-DAPv2 interface with VID:PID=0x0d28:0x0204, serial=012345ABCDEF
3470|SIGSEGV @0x34dff070 (???(./openocd+0x5ff070)) (x64pc=0x69156/"???", rsp=0x7f8cfe2278), for accessing 0x69156 (code=1)
RAX:0x000000004c9c21f0 RCX:0x000000004c9b1600 RDX:0x0000000000000200 RBX:0x000000004c9b1600
RSP:0x0000007f8cfe2278 RBP:0x0000007f8cfe22a0 RSI:0x0000000000000200 RDI:0x000000004c9c21f0
 R8:0x000000004c9b15a0  R9:0x0000007f8cfe21f0 R10:0x0000000000000001 R11:0x0000007f8cfe1d10
R12:0x0000007f8cfe2a00 R13:0x000000004c93edc0 R14:0x0000000000000000 R15:0x0000000000000001
ES:0x002b CS:0x0033 SS:0x002b DS:0x002b FS:0x0043 GS:0x0053
Segmentation fault

I run nm /usr/lib/libusb-1.0* | grep libusb_dev_mem_alloc and it displayed:

0000000000004870 T libusb_dev_mem_alloc
0000000000004870 T libusb_dev_mem_alloc
0000000000004870 T libusb_dev_mem_alloc

This indicates that the symbol libusb_dev_mem_alloc does exist.

ptitSeb commented 2 months ago

Ok, the functions have been added, it should go farther now.

zh522130 commented 2 months ago

Ok, the functions have been added, it should go farther now.

Thank you very much for the amazingly quick resolution. I tested it, and the error no longer occurs.

I have another issue that's outside the scope of this issue. When I use the same OpenOCD on native x64, there are no problems, but on ARM64, it reports an error:Error: CMSIS-DAP: SWD not supported.

sh: lscpu: not found
sh: lscpu: not found
 PageSize:4096 Running on Unknown CPU with 4 Cores
Will use time-based emulation for rdtsc, even if hardware counter are available
Will use Software counter measured at 1.0 GHz emulating 2.0 GHz
Params database has 14 entries
Box64 v0.3.1 17fa9303 built on Sep  7 2024 13:52:55
BOX64: Didn't detect 48bits of address space, considering it's 39bits
Counted 19 Env var
BOX64 LIB PATH: BOX64 BIN PATH: ./:bin/:/bin/:/sbin/:/usr/bin/:/usr/sbin/:/userdata/:/userdata/bin/:/data/bin/:/data/bin/pcba_test/
Looking for ./openocd
argv[1]="-f"
argv[2]="./test.cfg"
argv[3]="-s"
argv[4]="scripts"
Rename process to "openocd"
Using native(wrapped) libusb-1.0.so.0
Using emulated libhidapi-hidraw.so.0
Using native(wrapped) libm.so.6
Using native(wrapped) libutil.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) librt.so.1
Using native(wrapped) libbsd.so.0
Using native(wrapped) libudev.so.1
Open On-Chip Debugger 0.12.0+dev-00597-ga5a30519f (2024-08-03-11:02)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : Using CMSIS-DAPv2 interface with VID:PID=0x0d28:0x0204, serial=012345ABCDEF
Error: CMSIS-DAP: SWD not supported

Do you have any troubleshooting suggestions for this?

ptitSeb commented 2 months ago

Not sure of what is happening no. As a strater, to debug, use BOX64_LOG=2 to see every wrapped function call,It will be very chatty, but you should have all the detail you need (assuming the issue is something on a function call).

To rule out box64 dynarec issue, you can also try to run with BOX64_DYNAREC=0 to have it slowly run on interpreter.

zh522130 commented 2 months ago

Thank you for your suggestion.