arm: ./busybox: line 1: syntax error: unexpected word (expecting ")") - build

I am setting up a virtual machine specifically for crosscompiling for armv7l. As a test I decided to compile busybox, and while the crosscompilation itself works fine, upon uploading the resulting binary to a router with the correct architecture, the binary complains about ./busybox: line 1: syntax error: unexpected word (expecting ")")
I did not have this issue when compiling for x86, and as such I believe the problem is with my build environment.
It's based on ubuntu18 server, and I've installed these packages:
gcc-arm-linux-gnueabi
binutils-arm-linux-gnueabi
libncurses5-dev
gawk
build-essentials
make
my buildscript:
export ac_cv_linux_vers=2
export CC=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-gcc
export GCC=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-gcc
export CXX=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-g++
export CPP=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-cpp
export LD=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-ld
export AR=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-ar
export AS=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-as
export NM=/usr/local/arm-2011.09/bin/arm-none-linux-gnueabi-nm
export RANLIB=/usr/local/arm-2011.09/arm-none-linux-gnueabi/bin/ranlib
export CC1=/usr/local/arm-2011.09/libexec/gcc/arm-none-linux-gnueabi/4.6.1/cc1
export PATH=/usr/local/arm-2011.09/bin:/usr/local/arm-2011.09/:/usr/local/arm-2011.09/lib:/usr/local/arm-2011.09/libexec/gcc/arm-none-linux-gnueabi/4.6.1:$PATH
export ac_cv_func_getpgrp_void=yes
export ac_cv_func_setpgrp_void=yes
export LDFLAGS="-static"
export CFLAGS="-Os -s"
# I already did make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
make install
Any obvious flaws with my build process?
The platform on which I am trying to run busybox:
# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 1594.16
Features : swp half thumb fastmult edsp thumbee tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x4
CPU part : 0xc09
CPU revision : 1
CPU physical :0
processor : 1
model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 1594.16
Features : swp half thumb fastmult edsp thumbee tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x4
CPU part : 0xc09
CPU revision : 1
CPU physical :1
Hardware : Hisilicon A9
Revision : 0000
Serial : 0000000000000000
# uname -m
armv7l

Solved it. It turned out that my make menuconfig was incomplete.
Busybox Settings -> Build Options -> Build Busybox as a static binary (no shared libs)
Busybox Settings -> Build Options -> Cross compiler prefix -> Set this option equal to "arm-linux-gnueabi-"
Busybox Settings -> Installation Options -> Don't use /usr -> Enable
Linux Module Utilities -> () Default directory containing modules -> blank
after that, the binary produced by the build script worked as intended

Related

Can't program daisy device from VSCode - openocd can't find libusb

I am trying to debug my daisy program but I can't get VSCode to program the device, even though it works from the command line.
When I do task program from the command palette I get
openocd -s /usr/local/share/openocd/scripts -f interface/stlink.cfg -f target/stm32h7x.cfg
-c "program ./build/PickupMachine.elf verify reset exit"
dyld[62640]: Library not loaded: /usr/local/opt/libusb-compat/lib/libusb-0.1.4.dylib
Referenced from: <2AF14ADF-FE69-3018-B458-47925DB060E7> /Library/DaisyToolchain/0.1.3-ARM/openocd/bin/openocd
Reason: tried: '/usr/local/opt/libusb-compat/lib/libusb-0.1.4.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/libusb-compat/lib/libusb-0.1.4.dylib' (no such file), '/usr/local/opt/libusb-compat/lib/libusb-0.1.4.dylib' (no such file), '/usr/local/lib/libusb-0.1.4.dylib' (no such file), '/usr/lib/libusb-0.1.4.dylib' (no such file, not in dyld cache)
make: *** [program] Abort trap: 6
I tried brew reinstall libusb
The same command works from the command line:
➜ PickupMachine git:(main) ✗ openocd -s /usr/local/share/openocd/scripts -f interface/stlink.cfg -f target/stm32h7x.cfg
-c "program ./build/PickupMachine.elf verify reset exit"
Open On-Chip Debugger 0.11.0
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select '.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1800 kHz
Info : STLINK V3J7M2 (API v3) VID:PID 0483:374E
Info : Target voltage: 3.297018
Info : stm32h7x.cpu0: hardware has 8 breakpoints, 4 watchpoints
Info : starting gdb server for stm32h7x.cpu0 on 3333
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080005e0 msp: 0x20020000
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
Info : Unable to match requested speed 4000 kHz, using 3300 kHz
** Programming Started **
Info : Device: STM32H74x/75x
Info : flash size probed value 128
Info : STM32H7 flash has a single bank
Info : Bank (0) size is 128 kb, base address is 0x08000000
Info : Padding image section 1 at 0x08011c50 with 16 bytes (bank write end alignment)
Warn : Adding extra erase range, 0x08011c60 .. 0x0801ffff
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
The issue had to do with VSCode still using the old brew locations. If I install VSCode via brew (ironically) it looks for openocd, arm-none-eabi-gcc in the old /usr/bin folder. If I download VSCode using the Apple Silicon link at the visual studio site then it correctly uses the /opt/homebrew folder.

openocd fails to load board/ti_cc26x0_launchpad.cfg

Has anyone got openocd to work with the TI cc2640r2 launchpad? I built the latest openocd source but it fails to initialise.
OS is Ubuntu 18.04.1 LTS and openocd was built with
configure --enable-xds110 --enable-cmsis-dap
make
make install
Running
openocd -f board/ti_cc26x0_launchpad.cfg
gets the output
Open On-Chip Debugger 0.10.0+dev-00676-g346ce2f1 (2019-02-05-00:53)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 2500 kHz
Error: The 'jtag configure' command must be used after 'init'.
placing 'debug level 3' statements inside the script files show that it is failing within target/ti_cc26x0.cfg at line 25, which is
jtag configure $_CHIPNAME.cpu -event tap-enable "icepick_c_tapenable $_CHIPNAME.jrc 0"
The scripts must have worked (at least once) as they are part of the source distribution.
I use the zephyr folk of open-ocd:
git clone https://github.com/zephyrproject-rtos/openocd.git
cd open-ocd
configure
make
make install
I also needed to reduce the JTAG clock speed:
diff --git a/tcl/board/ti_cc26x0_launchpad.cfg b/tcl/board/ti_cc26x0_launchpad.cfg
index 3613a47f7..2580faa52 100644
--- a/tcl/board/ti_cc26x0_launchpad.cfg
+++ b/tcl/board/ti_cc26x0_launchpad.cfg
## -2,6 +2,6 ##
# TI CC26x0 LaunchPad Evaluation Kit
#
source [find interface/xds110.cfg]
-adapter_khz 2500
+adapter_khz 1500
transport select jtag
source [find target/ti_cc26x0.cfg]

Fix crash due to SIGILL in OpenSSL

I've read several Q&As here regarding the fact that OpenSSL tries different instructions to test if cpu supports them, which causes SIGILL. But those answers usually state that OP was running the app under gdb, but I'm not. So my app on OpenWrt MIPS router actually crashes when using OpenSSL, whenever I make a call to OpenSSL library. The crash is illegal instruction. I actually don't have a backtrace, though my app is a debug build. It works fine on Ubuntu and MacOS.
I made sure that both my executable and ssl libs are of the same cpu architecture.
Result of cat /proc/cpuinfo:
system type : Atheros AR9330 rev 1
machine : 8devices Carambola2 board
processor : 0
cpu model : MIPS 24Kc V7.4
BogoMIPS : 265.42
wait instruction : yes
microsecond timers : yes
tlb_entries : 16
extra interrupt vector : yes
hardware watchpoint : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16
shadow register sets : 1
kscratch registers : 0
package : 0
core : 0
VCED exceptions : not available
VCEI exceptions : not available
What worries me is that toolchain toolchain-mips_34kc_gcc-5.2.0_musl-1.1.11 mentions 34kc in its name. I wonder if it's ok to build with this toolchain for 24 Kc cpu. Though everything else except for openssl works fine.
So could you please answer what are my options to fix it?
I don't know what the problem was, but the app didn't work with the openssl library provided in the toolchain and copied to target board. When libopenssl was installed via opkg from official carambola2 repos, the problem is gone. So it must have been some incompatibility.

Compile OpenCV with TBB on Raspberry Pi 2

I've tried to build OpenCV on Raspberry Pi 2 with TBB,I've installed TBB from source on the Pi,I've specified the path to to TBB libs to cmake config but I'm getting the error:
/home/mihai/tbb43_20150316oss/include/tbb/machine/gcc_armv7.h:31:2: error: #error compilation requires an ARMv7-a architecture.
I think the error is because in the OpenCV makefile i have to include the flag for ARMv7
-DTBB_USE_GCC_BUILTINS=1 -D__TBB_64BIT_ATOMICS=0
The problem is that I don't know where to include it.Has anyone had this problem abd want to share a solution?
I have resolved it :D .For those having this problem follow these steps:
1.Go to file gcc_armv7.h line 31 and comment lines
30 #if !(__ARM_ARCH_7A__)
31 #error compilation requires an ARMv7-a architecture.
32 #endif
2.Next in the same file gcc_armv7.h go to line 56 and replace it with
56 #define __TBB_full_memory_fence() 0xffff0fa0 // __asm__ __volatile__("dmb ish": : :"memo ry")
For those who want an explanation how I did it, after the first step I get the following errors :
/tmp/ccnkbkfd.s:313: Error: selected processor does not support ARM mode `dmb ish'
/tmp/ccnkbkfd.s:386: Error: selected processor does not support ARM mode `dmb ish'
/tmp/ccnkbkfd.s:533: Error: selected processor does not support ARM mode `dmb ish'
/tmp/ccnkbkfd.s:562: Error: selected processor does not support ARM mode `dmb ish'
After I have searched on google and found this :
The alternative for using dmb is to call the Linux kernel __kuser_memory_barrier
the __kuser_memory_barrier helper operation is found in all ARM kernels 2.6.15 and later
and provide a way to issue a memory barrier that will work across all ARM arch.__kuser_memory_barrier
helper function found at address 0xffff0fa0
or you can run
sudo make CXXFLAGS="-DTBB_USE_GCC_BUILTINS=1 -D__TBB_64BIT_ATOMICS=0"
instead of just running
sudo make

Compiling on Vortex86: "Illegal instruction"

I'm using an embedded PC which has a Vortex86-SG CPU, Ubuntu 10.04 w/ kernel 2.6.34.10-vortex86-sg. Unfortunately we can't compile a new kernel, cause we don't have any source code, not even drivers or patches.
I have to run a small project written in C++ with OpenFrameworks. The framework compiles right each script in of_v0071_linux_release/scripts/linux/ubuntu/install_*.sh.
I noticed that in order to compile against Vortex86/Ubuntu 10.04, the following options must be added in every config.make file:
USER_CFLAGS = -march=i486
USER_LDFLAGS = -lGLEW
In effects, it compiles without errors, but the generated binary doesn't start at all:
root#jb:~/openframeworks/of_v0071_linux_release/apps/myApps/emptyExample/bin# ./emptyExample
Illegal instruction
root#jb:~/openframeworks/of_v0071_linux_release/apps/myApps/emptyExample/bin# echo $?
132
Strace last lines:
munmap(0xb77c3000, 4096) = 0
rt_sigprocmask(SIG_BLOCK, [PIPE], NULL, 8) = 0
--- SIGILL (Illegal instruction) # 0 (0) ---
+++ killed by SIGILL +++
Illegal instruction
root#jb:~/openframeworks/of_v0071_linux_release/apps/myApps/emptyExample/bin#
Any idea to solve this problem?
I know I am a bit late on this but I recently had my own issues trying to compile the kernel for the vortex86dx. I finally was able to build the kernel as well. Use these steps at your own risk as I am not a Linux guru and some settings you may have to change to your own preference/hardware:
Download and use a Linux distribution that runs on a similar kernel version that you plan on compiling. Since I will be compiling Linux 2.6.34.14, I downloaded and installed Debian 6 on virtual box with adequate ram and processor allocations. You could potentially compile on the Vortex86DX itself, but that would likely take forever.
Made sure I hade decencies: #apt-get install ncurses-dev kernel-package
Download kernel from kernel.org (I grabbed Linux-2.6.34.14.tar.xz). Extract files from package.
Grab Config file from dmp ftp site: ftp://vxmx:gc301#ftp.dmp.com.tw/Linux/Source/config-2.6.34-vortex86-sg-r1.zip. Please note vxmx user name. Copy the config file to freshly extracted Linux source folder.
Grab Patch and at ftp://vxdx:gc301#ftp.dmp.com.tw/Driver/Linux/config%26patch/patch-2.6.34-hda.zip. Please note vxdx user name. Copy to kernel source folder.
Patch Kernel: #patch -p1 < patchfilename
configure kernel with #make menuconfig
Load Alternate Configuration File
Enable generic x86 support
Enable Math Emulation
I disabled generic IDE support because I will using legacy mode(selectable in bios)
Under Device Drivers -> Ethernet (10 or 100Mbit) -> Make sure RDC R6040 Fast Ethernet Adapter Support is selected
USB support -> Select Support for Host-side USB, EHCI HCD (USB 2.0) support, OHCI HCD support
safe config as .config
check serial ports: edit .config manually make sure CONFIG_SERIAL_8250_NR_UARTS = 4 (or more if you have additional), CONFIG_SERIAL_8250_RUNTIME_UARTS = 4(or more if you have additional). If you are to use more that 4 serial ports make use config_serail_8250_MANY_PORTs is set.
compile kernel headers and source: #make-kpkg --initrd kernel_image kernel_source kernel_headers modules_image