配置环境 ubuntu 18.04
1. SD 分区
Ubuntu 打开 GParted 分区工具![f7e3a4a8-e395-4a50-85b8-e30182ac3b69.jpg][1],分成三区如下:
2. 写入 U-boot
编译 u-boot-2019.10
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
生成 u-boot-sunxi-with-spl.bin,写入 SD 分区表空白处,注意设置正确的SD卡设备路径, 例如 /dev/sdb
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/<sdx> bs=1024 seek=8
3. 解压 alpine-uboot-3.10.3-armv7.tar.gz 至 boot 分区
sudo tar xvzf alpine-uboot-3.10.3-armv7.tar.gz -C /media/<user>/<mount path>
4. 解压 alpine-minirootfs-3.10.3-armv7.tar.gz 至 ‘Alpine Linux’ 分区
sudo tar xvzf alpine-minirootfs-3.10.3-armv7.tar.gz -C /media/<user>/<mount path>
修改 "Alpine Linux" 分区目录下 /etc/inittab,使能 getty tty0, 并添加自动登录脚本
cd /media/<user>/<mount path>
sudo vi inittab
# /etc/inittab
::sysinit:/sbin/openrc sysinit
::sysinit:/sbin/openrc boot
::wait:/sbin/openrc default
# Set up a couple of getty's
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
tty3::respawn:/sbin/getty 38400 tty3
tty4::respawn:/sbin/getty 38400 tty4
tty5::respawn:/sbin/getty 38400 tty5
tty6::respawn:/sbin/getty 38400 tty6
# Put a getty on the serial port
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 -n -l /etc/autologin -I "console auto login as root..."
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/sbin/openrc shutdown
添加 /etc/autologin:
#!/bin/sh
exec /bin/login -f root
cd /media/<user>/<mount path>
sudo vi autologin
sudo chmod +x autologin
5. 写入 buildroot 编译的 rootfs, 输出目录 output\images,rootfs.tar。
sudo tar xvf buildroot_rootfs.tar -C /media/<user>/<mount path>
6. 拷贝编译好的 zImage 到 boot 目录下
7. 移除 extlinux
8. 修改 boot/grup/grub.cfg, 添加启动项菜单:
set timeout=3
menuentry "Linux vanilla" {
linux /boot/vmlinuz-vanilla modules=loop,squashfs,sd-mod,usb-storage quiet
initrd /boot/initramfs-vanilla
}
menuentry "Busybox" {
linux /boot/zImage console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p2 earlyprintk rw
}
menuentry "Alpine Linux" {
linux /boot/zImage console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p3 earlyprintk rw
}
最近编辑记录 Iron (2019-12-19 17:25:01)
离线
wow,感谢分享!
这是通过串口选择要进入的系统吧?
是的,在 boot 按键进入 grub 菜单。。
U-Boot SPL 2019.10-ge71ae959-dirty (Dec 10 2019 - 19:15:16 +0000)
DRAM: 64 MiB
Trying to boot from MMC1
U-Boot 2019.10-ge71ae959-dirty (Dec 10 2019 - 19:15:16 +0000) Allwinner Technology
CPU: Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM: 64 MiB
MMC: mmc@01c0f000: 0
Loading Environment from FAT... *** Warning - bad CRC, using default environment
In: serial@01c28000
Out: serial@01c28000
Err: serial@01c28000
Net: No ethernet found.
starting USB...
No working controllers found
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found EFI removable media binary efi/boot/bootarm.efi
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Scanning disk mmc@01c0f000.blk...
Found 4 disks
BootOrder not defined
EFI boot manager: Cannot load any image
311296 bytes read in 31 ms (9.6 MiB/s)
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Welcome to GRUB!
error: no such device: alpine-uboot 3.10.3 armv7.
GNU GRUB version 2.02
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Linux vanilla │
│ busybox │
│*Alpine Linux │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
│ │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Use the ▲ and ▼ keys to select which entry is highlighted.
Press enter to boot the selected OS, `e' to edit the commands before booting or `c' for a command-line.
离线