1. 制作nandflash镜像
1.1 编译开发板提供的内核
问题1:arm-linux-gnueabi-gcc: error: directory: No such file or directory
参考:
https://github.com/cubieboard/cubieboard.org/issues/5
内核和uboot编译成功以后执行build pack打包镜像文件,生成的镜像文件是基于flash的,只能烧写工具烧如flash后从flash启动。
2. 制作基于sun-xi社区的sd卡镜像
参考:https://linux-sunxi.org/Manual_build_howto
2.1 工具链
2.2 uboot
有2个方案可以选择,一个是从sunxi分支编译,一个是从主线编译。
从sunxi分支编译参考:https://linux-sunxi.org/U-Boot#Compile_U-Boot
可以通过boot.scr 文件来设置uboot环境变量,boot.scr 文件是从boot.cmd文件转换来的:
mkimage -C none -A arm -T script -d boot.cmd boot.scr
参数配置参考:https://linux-sunxi.org/U-Boot/Configuration
2.3 内核
同样可以选择从sunxi分支或者主线编译:
https://linux-sunxi.org/Linux_Kernel#Compilation
2.4 script.bin
参考:https://linux-sunxi.org/Script.bin#Build_script.bin
script.bin是sunxi替代设备树dtb用于描述系统设备的文件,是从script.fex文件转换来的。
这里只需要选取A20的某个板子的基础上进行调整即可。
2.5 sd卡启动盘
参考:https://linux-sunxi.org/Bootable_SD_card
2.5.1 清空sd卡
dd
if
=
/dev/zero
of=${card} bs=1M count=1
2.5.2 安装BootLoader
dd
if
=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8
2.5.3 创建及格式化分区
blockdev --rereadpt ${card}
cat
<<EOT | sfdisk ${card}
1M,16M,c
,,L
EOT
格式化:
mkfs.vfat ${card}${p}1
mkfs.ext4 ${card}${p}2
2.5.4 boot分区
mount
${card}${p}1
/mnt/
cp
linux-sunxi
/arch/arm/boot/uImage
/mnt/
cp
sunxi-boards
/sys_config/a10/script
.bin
/mnt/
umount
/mnt/
如果需要修改uboot环境变量还需要拷贝boot.scr文件
2.5.5 文件系统
这里选择debootstrap方案,创建基于debain的根文件系统
1)准备阶段
debootstrap --arch=armhf --foreign $distro /mnt/
这个操作会花费很长时间
完成之后需要chroot到/mnt继续进行第二阶段的操作
cp /usr/bin/qemu-arm-static /mnt/usr/bin/ chroot /mnt /usr/bin/qemu-arm-static /bin/sh -i /debootstrap/debootstrap --second-stage
2)更新目标系统apt源 及 fstab
cat <<EOT > etc/apt/sources.list deb http://http.debian.net/debian $distro main contrib non-free deb-src http://http.debian.net/debian $distro main contrib non-free deb http://http.debian.net/debian $distro-updates main contrib non-free deb-src http://http.debian.net/debian $distro-updates main contrib non-free deb http://security.debian.org/debian-security $distro/updates main contrib non-free deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free EOT
cat <<EOT >> etc/fstab none /tmp tmpfs defaults,noatime,mode=1777 0 0 # if you have a separate boot partition ${card}${p}1 /boot vfat defaults 0 0 EOT
后续
exit cp /etc/resolv.conf /mnt/etc chroot /mnt export LANG=C apt-get update # set up 'apt cat <<END > /etc/apt/apt.conf.d/71-no-recommends APT::Install-Recommends "0"; APT::Install-Suggests "0"; END # set up locales (Debian) - dpkg scripts tend to complain otherwise apt-get install locales dpkg-reconfigure locales # Choose en_US.UTF-8 for both prompts, or whatever you want. export LANG=en_US.UTF-8 # install your favourite packages here apt-get install nvi ; apt-get remove nano # set root password - otherwise you won't be able to log in passwd exit # cleanup rm /mnt/usr/bin/qemu-arm-static /mnt/etc/resolv.conf # ensure hostname has not carried over from your build host echo something > /mnt/etc/hostname # enable serial console (Debian/sysvinit way) echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> etc/inittab # enable serial console (Ubuntu/upstart way - TBD) umount /mnt
3. 创建armbian镜像
参考:https://forum.armbian.com/index.php/topic/6-how-to-build-my-own-image-or-kernel/