本文主要探讨基于orangeP内核移植的相关知识。
环境
orangePi_zero_2(h616):已经移植uboot
ubuntu(22.04):安装好交叉编译环境
安装依赖
apt install build-essential lzop libncurses5-dev libssl-dev flex bison -y
编译生成镜像,设备树,驱动模块
tar -zxvf linux-6.0.tar.gz
vim /root/linux-6.0/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dts
#添加3.3v 的节点(reg_vcc5前)
reg_vcc3v3: vcc3v3 {
compatible = "regulator-fixed";
regulator-name = "vcc-3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
#修改pio节点
&pio {
vcc-pc-supply = <®_vcc3v3>;
vcc-pf-supply = <®_vcc3v3>;
vcc-pg-supply = <®_vcc3v3>;
vcc-ph-supply = <®_vcc3v3>;
vcc-pi-supply = <®_vcc3v3>;
};
# 修改mmc0(启动 sunxi-mmc 驱动)
&mmc0 {
vmmc-supply = <®_vcc3v3>;
cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
bus-width = <4>;
status = "okay";
};
cd /root/linux-6.0/
make defconfig && make Image && make dtbs && make modules
编译生成根文件系统
tar -zxvf buildroot-2023.05.tar.gz
cd buildroot-2023.05
make menuconfig
# 配置 Target options
> Target options
Target Architecture (AArch64 (little endian)) --->
Target Binary Format (ELF) --->
Target Architecture Variant (cortex-A53) --->
Floating point strategy (VFPv4) --->
# 配置 Toolchain
> Toolchain
Toolchain type (External toolchain) --->
Toolchain (Custom toolchain) --->
Toolchain origin (Pre-installed toolchain) --->
(/root/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu) Toolchain path
(aarch64-linux-gnu) Toolchain prefix
External toolchain gcc version (7.x) --->
External toolchain kernel headers series (4.10.x) --->
[*] Toolchain has SSP support? (NEW)
[*] Toolchain has RPC support? (NEW)
[*] Toolchain has C++ support?
# 配置 Filesystem images
-> Filesystem images
-> [*] ext2/3/4 root filesystem
-> ext2/3/4 variant = ext4
-> exact size =128M
-> [*] ubi image containing an ubifs root filesystem
make
写入SD卡(image,dtbs,module)
sd卡划分区
mkdir /root/boot
mkdir /root/rootfs
fdisk /dev/sdc
d(删除分区)
n(新建分区)
w(保存分区)
新建
起始位置40960
/dev/sdc1 128M
/dev/sdc2 1G
mkfs.fat /dev/sdc1
mkfs.ext4 /dev/sdc2
mount /dev/sdc1 /root/boot
mount /dev/sdc2 /root/rootfs
cp /root/linux-6.4/arch/arm64/boot/dts/allwinner/sun50i-h616-orangepi-zero2.dtb /root/boot/
cp /root/linux-6.4/arch/arm64/boot/Image /root/boot/
tar -xvf /root/buildroot-2023.05/output/images/rootfs.tar -C /root/rootfs
cd /root/linux-6.4/
make INSTALL_MOD_PATH=/work/rootfs modules modules_install
make INSTALL_HDR_PATH=/work/rootfs/usr headers_install
umount /root/boot
umount /root/rootfs
串口启动并修改配置
uboot配置
设置延时
setenv bootdelay 8
检查文件
ext4ls mmc 0:2
设置启动命令
setenv bootcmd 'fatload mmc 0:1 0x40200000 Image;fatload mmc 0:1 0x4fa00000 sun50i-h616-orangepi-zero2.dtb;booti 0x40200000 - 0x4fa00000'
设置bootargs参数
setenv bootargs 'console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rw init=/sbin/init debug panic=30'
保存配置
saveenv
启动
boot
linux配置
ssh配置
vi /etc/ssh/sshd_config
PermitRootLogin yes
AllowUsers root
/etc/init.d/S50sshd restart
设置root密码
passwd root
配置终端
vi /etc/profile.d/terminal.sh
#!/bin/sh
PS1='[\u@\h]:\w$ '
export PS1
chmod +x /etc/profile.d/terminal.sh
source /etc/profile.d/terminal.sh