This will delete the page "How-to-create-Linux.iso"
. Please be certain.
Setup environment
export ARCH=riscv
export CROSS_COMPILE= <RISCV_tool_chain>
- version 12.0.2
Git clone VisionFive2 Linux repository
> git clone https://github.com/starfive-tech/linux
> cd linux
> git checkout VF2_v2.11.5
Compile Linux code
> make starfive_visionfive2_defconfig
> make -j$(nproc)
Copy and rename Linux image file
> cp arch/riscv/boot/Image ../linux-riscv64.efi
> cd ..
Download Busybox
> wget https://busybox.net/downloads/busybox-1.26.2.tar.bz2
> tar -xvf busybox-1.26.2.tar.bz2
Config Busybox
> cd busybox-1.26.2
> make defconfig
> make menuconfig
In the Busybox Settings menu, select Build Options, and check the box next to Build BusyBox as a static binary (no shared libs).
Build Busybox
> make
> make CONFIG_PREFIX=./../busybox_rootfs install
Create a directory hierarchy for initramfs
> mkdir -p initramfs/{bin,dev,etc,home,mnt,proc,sys,usr}
> cd initramfs/dev
> sudo mknod sda b 8 0
> sudo mknod console c 5 1
Copy everything from the busybox_rootfs folder to the initramfs folder.
Create an «init» file in the initramfs folder, and write the following into it:
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
exec /bin/sh
Make it executable
> chmod +x init
Create and gzip initramfs
> cd initramfs
> find . -print0 | cpio --null -ov --format=newc > initramfs.cpio
> gzip ./initramfs.cpio
Copy the following and save the file
initrd initramfs.cpio.gz
linux-riscv64.efi console=tty1 console=ttyS0,115200 earlycon=sbi rootwait
This script is used for UEFI Shell to auto-load initramfs and linux image during device boot up
Query the loop device
> sudo losetup -f
Create a mount device
> mkfs.msdos -C linux.iso 64000
> sudo losetup /dev/loop* linux.iso
> sudo mount /dev/loop* /mnt
Replace loop* with the number shown in previous command
Copy the kernel and initramfs that built previously
> sudo cp linux-riscv64.efi /mnt
> sudo cp initramfs.cpio.gz /mnt
> sudo mkdir /mnt/efi
> sudo mkdir /mnt/efi/boot
> sudo cp startup.nsh /mnt/efi/boot
> sudo umount /mnt
> sudo losetup -d /dev/$loop
Copy startup.nsh is optional, ignore if not using it
This will delete the page "How-to-create-Linux.iso"
. Please be certain.