代码拉取完成,页面将自动刷新
#!/bin/sh
SD_CARD=NezhaSTU-Sdcard.img
sudo dd if=/dev/zero of=${SD_CARD} bs=1M count=4000
echo "Create new GPT parititon table and partitions"
sudo parted -s -a optimal -- ${SD_CARD} mklabel gpt
sudo parted -s -a optimal -- ${SD_CARD} mkpart primary ext2 40MiB 100MiB
sudo parted -s -a optimal -- ${SD_CARD} mkpart primary ext4 100MiB -2GiB
sudo parted -s -a optimal -- ${SD_CARD} mkpart primary linux-swap -1GiB 100%
loopdevice=`sudo losetup -f --show ${SD_CARD}`
device=`sudo kpartx -va $loopdevice | sed -E 's/.*(loop[0-9])p.*/\1/g' | head -1`
device="/dev/mapper/${device}"
partBoot="${device}p1"
partRoot="${device}p2"
swapPart="${device}p3"
echo "Write SPL"
sudo dd if=sun20i_d1_spl/nboot/boot0_sdcard_sun20iw1p1.bin of=${SD_CARD} bs=8192 seek=16
echo "Write u-boot table of contents"
sudo dd if=u-boot.toc1 of=${SD_CARD} bs=512 seek=32800
#Creat mount dir.
sudo mkdir -p /mnt/sdcard_boot
sudo mkdir -p /mnt/sdcard_rootfs
#Copy kernel and dtb.
sudo mkfs.ext4 $partBoot
echo "Copy files to /boot partition"
sudo mount -t ext4 $partBoot /mnt/sdcard_boot
sudo cp -rfv linux/arch/riscv/boot/Image.gz /mnt/sdcard_boot
sudo cp -rfv boot.scr /mnt/sdcard_boot
sudo cp -rfv linux/arch/riscv/boot/dts/allwinner/sun20i-d1-nezha.dtb /mnt/sdcard_boot
sudo sync
sudo umount /mnt/sdcard_boot
#Copy filesystem.
echo "Copy files to root filesystem"
sudo mkfs.ext4 $partRoot
sudo mount -t ext4 $partRoot /mnt/sdcard_rootfs
sudo cp -av rootfs/* /mnt/sdcard_rootfs/
sudo sync
sudo umount /mnt/sdcard_rootfs
sudo rmdir /mnt/sdcard_boot
sudo rmdir /mnt/sdcard_rootfs
sudo mkswap $swapPart
sudo kpartx -d $loopdevice
sudo losetup -d $loopdevice
echo "Successfully finished output RV64 image to ${SD_CARD}"
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。