[Merge] ~alexghiti/livecd-rootfs:int/alex/riscv_no_beaglev into livecd-rootfs:ubuntu/master

Heinrich Schuchardt mp+424678 at code.launchpad.net
Fri Jul 1 13:17:31 UTC 2022


See detail comments in the code.

Diff comments:

> diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary
> index e802848..0062266 100755
> --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary
> +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image-uefi.binary
> @@ -183,39 +220,114 @@ install_grub() {
>              ;;
>          riscv64)
>              # TODO grub-efi-riscv64 does not exist yet on riscv64
> -            chroot mountpoint apt-get install -qqy u-boot-menu #grub-efi-riscv64
> -            efi_target=riscv64-efi
> +            if [ -n "${SUBARCH:-}" ]; then
> +                case "${SUBARCH}" in
> +                    "nezha")
> +                        echo "Installing U-Boot for Nezha board" &1>2
> +                        chroot mountpoint mkdir -p /etc/flash-kernel/
> +                        chroot mountpoint bash -c "echo 'Allwinner D1 Nezha' > /etc/flash-kernel/machine"

Flash-kernel discovers the dtb to install by looking up the value of /proc/device-tree/model in its database. When preparing the image this file in not available. /etc/flash-kernel/machine can be used as a substitute.

> +                        chroot mountpoint apt-get install -qqy grub-efi-riscv64 flash-kernel

We need to make sure that flash-kernel is installed after creating /etc/flash-kernel/machine.

> +                        efi_target=riscv64-efi
>  
> -            chroot mountpoint u-boot-update
> +                        chroot mountpoint apt-get install -qqy nezha-boot0
> +                        # FSBL, which gets U-Boot SPL
> +                        loader1="/dev/mapper${loop_device///dev/}p13"
> +                        dd if=mountpoint/usr/lib/u-boot/nezha/boot0_sdcard_sun20iw1p1.bin of=$loader1
> +                        # The real U-Boot
> +                        chroot mountpoint apt-get install -qqy u-boot-nezha
> +                        loader2="/dev/mapper${loop_device///dev/}p14"
> +                        dd if=mountpoint/usr/lib/u-boot/nezha/u-boot.toc1 of=$loader2
> +                        # Provide end-user modifyable CIDATA
> +                        cidata_dev="/dev/mapper${loop_device///dev/}p12"
> +                        setup_cidata "${cidata_dev}"
> +                        # Provide stock nocloud datasource
> +                        # Allow interactive login on baremetal SiFive board,
> +                        # without a cloud datasource.
> +                        setup_cinocloud mountpoint
>  
> -            if [ -n "${SUBARCH:-}" ]; then
> -                u_boot_arch="${SUBARCH}"
> -                if [ "${u_boot_arch}" = "hifive" ]; then
> -                    u_boot_arch=sifive_fu540
> -                fi
> -                chroot mountpoint apt-get install -qqy u-boot-sifive
> -                # FSBL, which gets U-Boot SPL
> -                loader1="/dev/mapper${loop_device///dev/}p13"
> -                # The real U-Boot
> -                loader2="/dev/mapper${loop_device///dev/}p14"
> -                dd if=mountpoint/usr/lib/u-boot/${u_boot_arch}/u-boot-spl.bin of=$loader1
> -                dd if=mountpoint/usr/lib/u-boot/${u_boot_arch}/u-boot.itb of=$loader2
> -                # Provide end-user modifyable CIDATA
> -                cidata_dev="/dev/mapper${loop_device///dev/}p12"
> -                setup_cidata "${cidata_dev}"
> -                # Provide stock nocloud datasource
> -                # Allow interactive login on baremetal SiFive board,
> -                # without a cloud datasource.
> -                setup_cinocloud mountpoint
> +                        # u-boot-nezha will boot using UEFI if it does not find
> +                        # any extlinux.conf or boot.scr: but flash-kernel will
> +                        # install a boot.scr if it believes it did not boot in
> +                        # EFI mode, so make sure we don't leave a boot.scr
> +                        # behind.
> +                        chroot mountpoint rm -f /boot/boot.scr
> +                        ;;
> +                    "visionfive")
> +                        echo "Installing GRUB for VisionFive board" &1>2
> +                        chroot mountpoint mkdir -p /etc/flash-kernel/
> +                        chroot mountpoint bash -c "echo 'StarFive VisionFive V1' > /etc/flash-kernel/machine"
> +                        chroot mountpoint apt-get install -qqy grub-efi-riscv64 flash-kernel
> +                        efi_target=riscv64-efi
> +
> +                        # factory u-boot requires a p3 partition with /boot/uEnv.txt file
> +                        uenv_dev="/dev/mapper${loop_device///dev/}p3"
> +                        mkfs.ext4 "${uenv_dev}"
> +                        uenv_mnt_dir=`mktemp -d uenvXXX`
> +                        mount "${uenv_dev}" "${uenv_mnt_dir}"
> +                        mkdir -p "${uenv_mnt_dir}"/boot
> +
> +                        cat <<'EOF' >${uenv_mnt_dir}/boot/uEnv.txt

flash-kernel never creates uEnv.txt files. It will create a boot.scr file if ever called after booting without EFI. With the uEnv.txt file we boot via GRUB. Flash-kernel is just responsible to provide the dtb in the location where update-grub expects it. Update-grub will add a device-tree command to /boot/grub/grub.dfg.

> +scriptaddr=0x88100000
> +script_offset_f=0x1fff000
> +script_size_f=0x1000
> +
> +kernel_addr_r=0x84000000
> +kernel_comp_addr_r=0x90000000
> +kernel_comp_size=0x10000000
> +
> +fdt_addr_r=0x88000000
> +ramdisk_addr_r=0x88300000
> +
> +bootcmd=load mmc 0:f ${kernel_addr_r} /EFI/ubuntu/grubriscv64.efi; bootefi ${kernel_addr_r}
> +bootcmd_mmc0=devnum=0; run mmc_boot
> +
> +ipaddr=192.168.120.200
> +netmask=255.255.255.0
> +EOF
> +
> +                        umount "${uenv_mnt_dir}"
> +                        rmdir "${uenv_mnt_dir}"
> +                        # Provide end-user modifyable CIDATA
> +                        cidata_dev="/dev/mapper${loop_device///dev/}p12"
> +                        setup_cidata "${cidata_dev}"
> +                        # Provide stock nocloud datasource
> +                        # Allow interactive login on baremetal SiFive board,
> +                        # without a cloud datasource.
> +                        setup_cinocloud mountpoint
> +                        ;;
> +                    *)
> +                        u_boot_arch="${SUBARCH}"
> +                        if [ "${u_boot_arch}" = "hifive" ]; then
> +                            u_boot_arch=sifive_fu540
> +                        fi
> +                        chroot mountpoint apt-get install -qqy u-boot-sifive
> +                        # FSBL, which gets U-Boot SPL
> +                        loader1="/dev/mapper${loop_device///dev/}p13"
> +                        # The real U-Boot
> +                        loader2="/dev/mapper${loop_device///dev/}p14"
> +                        dd if=mountpoint/usr/lib/u-boot/${u_boot_arch}/u-boot-spl.bin of=$loader1
> +                        dd if=mountpoint/usr/lib/u-boot/${u_boot_arch}/u-boot.itb of=$loader2
> +                        # Provide end-user modifyable CIDATA
> +                        cidata_dev="/dev/mapper${loop_device///dev/}p12"
> +                        setup_cidata "${cidata_dev}"
> +                        # Provide stock nocloud datasource
> +                        # Allow interactive login on baremetal SiFive board,
> +                        # without a cloud datasource.
> +                        setup_cinocloud mountpoint
> +                        ;;
> +                esac
> +            fi
> +
> +            if [ "${SUBARCH}" != "visionfive" && "${SUBARCH}" != "nezha" ]; then
> +                ## TODO remove below once we have grub-efi-riscv64
> +                rm mountpoint/tmp/device.map
> +                umount mountpoint/boot/efi
> +                mount
> +                umount_partition mountpoint
> +                rmdir mountpoint
> +                return
> +                ##
>              fi
> -            ## TODO remove below once we have grub-efi-riscv64
> -            rm mountpoint/tmp/device.map
> -            umount mountpoint/boot/efi
> -            mount
> -            umount_partition mountpoint
> -            rmdir mountpoint
> -            return
> -            ##
>              ;;
>      esac
>  


-- 
https://code.launchpad.net/~alexghiti/livecd-rootfs/+git/livecd-rootfs/+merge/424678
Your team Ubuntu Core Development Team is subscribed to branch livecd-rootfs:ubuntu/master.




More information about the Ubuntu-reviews mailing list