Busybox系统编译
电脑硬件配置
编译 Ubuntu 开发环境电脑硬件配置建议:
- 64 位 CPU
- Ubuntu22.04系统,不要使用 Windows 子系统 (WSL)
- 16GB 内存
- 80GB 空闲空间用来编译
- 普通用户编译,不要使用 root 用户编译
SDK下载
mkdir sdk-dir && cd sdk-dir
git clone http://git.neardi.com/repo-release/tools/repo.git
./repo/repo init --no-clone-bundle --repo-url=http://git.neardi.com/repo-release/tools/repo.git -u http://git.neardi.com/hisilicon/manifests.git -b hi3516-cv610 -m neardi_3516-cv610_linux5.10_next.xml
.repo/repo/repo sync
编译环境配置
可参考neardi_3516-cv610_linux5.10_next/readme_en.txt进行环境搭建。
安装环境包
## 1. Ubuntu 22.04 uses dash by default, which breaks SDK compile. Switch to bash:
~ $ sudo dpkg-reconfigure dash
Note: Select No when asked
## 2. Install System Dependencies
~ $ sudo apt update && sudo apt install -y make libc6-i386 lib32z1 lib32stdc++6 libncurses5-dev \
ncurses-term libncursesw5-dev g++ u-boot-tools texinfo gawk libssl-dev openssl \
bc p7zip-full gperf bison flex diffutils git unzip libffi-dev libtool libfreetype6 \
fakeroot autopoint po4a python3-pip wget libmpc-dev
~ $ sudo apt install -y zlib1g-dev liblzo2-dev uuid-dev pkg-config automake texlive
~ $ sudo pip3 install --upgrade pip wheel
~ $ sudo pip3 install pyelftools cryptography pycryptodome -i https://mirrors.aliyun.com/pypi/simple/
## 3. Configure Cross-Compiler
~ $ cd toolchain
~ $ sudo ./install_gcc_toolchain.sh
~ $ source /etc/profile
~ $ cd ../ && sudo chown -R $USER:$USER ./
(可选,若sudo make install无法安装,添加/opt/linux/x86-arm/arm-v01c02-linux-musleabi-gcc/bin至secure_path路径)
~ $ sudo visudo
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/opt/linux/x86-arm/arm-v01c02-linux-musleabi-gcc/bin"
## 4. Fix Missing Links
~ $ cd /opt/linux/x86-arm/arm-v01c02-linux-musleabi-gcc/bin
~ $ sudo ln -s ../tools/ tools
~ $ sudo ln -s ../target/ target
~ $ cd target
~ $ sudo ln -s usr/lib/ lib
## 5. Compile util-linux-2.38.1
~ $ cd neardi_3516-cv610_linux5.10_next/open_source/util-linux-2.38.1
~ $ ./configure --prefix=/opt/linux/x86-arm/arm-v01c02-linux-musleabi-gcc/arm-linux-musleabi \
--host=arm-v01c02-linux-musleabi \
--disable-all-programs \
--enable-libblkid \
--without-ncurses
~ $ make && sudo make install
## 6. Install gperf-3.1
~ $ cd neardi_3516-cv610_linux5.10_next/open_source/eudev/gperf-3.1
~ $ ./configure
~ $ make && sudo make install
编译 SDK
整体编译:
cd smp/a7_linux/source/bsp
make LIB_TYPE=musl CHIP=hi3516cv610 DEBUG=1 all
# 编译uboot
make LIB_TYPE=musl CHIP=hi3516cv610 DEBUG=1 gslboot_build
# 编译uboot_env
make LIB_TYPE=musl CHIP=hi3516cv610 DEBUG=1 uboot_env
# 编译kernel
make LIB_TYPE=musl CHIP=hi3516cv610 DEBUG=1 kernel
# 编译rootfs
make LIB_TYPE=musl CHIP=hi3516cv610 DEBUG=1 rootfs_build
单独编译kernel:
kernel defconfig: hi3516cv610_debug_defconfig
kernel dts: hi3516cv610-demb.dts
# 编辑配置
make ARCH=arm CROSS_COMPILE=arm-v01c02-linux-musleabi- hi3516cv610_debug_defconfig menuconfig
# 保存配置
make ARCH=arm CROSS_COMPILE=arm-v01c02-linux-musleabi- hi3516cv610_debug_defconfig savedefconfig
cp defconfig arch/arm/configs/hi3516cv610_debug_defconfig
# 编译kernel
make ARCH=arm CROSS_COMPILE=arm-v01c02-linux-musleabi- hi3516cv610_debug_defconfig uImage
# 编译kernel ko
make ARCH=arm CROSS_COMPILE=arm-v01c02-linux-musleabi- hi3516cv610_debug_defconfig modules