Files
BPI-CM9-Linux/build/patch/u-boot/legacy/u-boot-spacemit-k1/004-Add-syslinux-script-and-uefi-support.patch
T

393 lines
16 KiB
Diff

From 767d386dcc7422266d6afc0585b7b742f631bf28 Mon Sep 17 00:00:00 2001
From: Patrick Yavitz <[email protected]>
Date: Sat, 21 Feb 2026 15:56:32 -0500
Subject: [PATCH] Add syslinux script and uefi support
Signed-off-by: Patrick Yavitz <[email protected]>
---
board/spacemit/k1-x/k1-x.env | 374 ++++-------------------------------
1 file changed, 38 insertions(+), 336 deletions(-)
diff --git a/board/spacemit/k1-x/k1-x.env b/board/spacemit/k1-x/k1-x.env
index 3499aec7..463cbd07 100644
--- a/board/spacemit/k1-x/k1-x.env
+++ b/board/spacemit/k1-x/k1-x.env
@@ -1,336 +1,38 @@
-// Common parameter
-earlycon=sbi
-init=/init
-bootdelay=0
-baudrate=115200
-stderr=serial
-stdin=serial,usbkbd,usbkbd1
-stdout=serial
-workqueue.default_affinity_scope=system
-
-//partitions/mtdparts/mtdids would set while flashing env.bin
-
-// Nor flash rootfs device
-nor_root=/dev/mtdblock6
-nor_rootfstype=squashfs
-
-// eMMC/SDCard rootfs device
-mmc_rootfstype=ext4
-
-// NAND UBI rootfs device
-nand_rootfstype=ubifs
-nand_ubi_mtd=6
-nand_ubi_dev=0
-nand_ubi_bootfs_vol=bootfs
-nand_ubi_rootfs_vol=rootfs
-nand_mtd_name=user
-
-// rootfs part number must less than 99
-rootfs_part_to_ul=echo "set rootfs_part to ul"; setexpr temp_num_0 ${rootfs_part} / a; \
- setexpr temp_num_1 ${rootfs_part} % a; \
- setenv rootfs_part ${temp_num_0}${temp_num_1};
-
-// Get "rootfs" partition number in decimal, and set var "blk_root"
-// Variable "boot_devnum" is set during board_lat_init()
-set_rootfs_env=if test "${bootfs_devname}" = mmc; then \
- setenv blk_root "/dev/mmcblk${boot_devnum}p${rootfs_part}"; \
- elif test "${bootfs_devname}" = nvme; then \
- setenv blk_root "/dev/nvme${boot_devnum}n1p${rootfs_part}"; \
- else \
- echo "not define rootfs part at this blk device, add to env"; \
- fi;
-
-get_rootfs_env=part number ${bootfs_devname} ${boot_devnum} rootfs rootfs_part; \
- setexpr rootfs_part ${rootfs_part} + 0; \
- if test ${rootfs_part} > 9; then run rootfs_part_to_ul; fi; \
- echo "get rootfs_part index:${rootfs_part}";
-
-// get "rootfs" partition uuid, and set var "rootfs_uuid"
-get_rootfs_uuid=part number ${bootfs_devname} ${boot_devnum} rootfs rootfs_part; \
- fsuuid ${bootfs_devname} ${boot_devnum}:${rootfs_part} rootfs_uuid;
-
-set_root_arg=run get_rootfs_uuid; \
- setenv bootargs "${bootargs}" root=UUID=${rootfs_uuid};
-
-//override here, otherwise gen random addr and save to eeprom by uboot
-//ethaddr=fe:fe:fe:22:22:01
-//eth1addr=fe:fe:fe:22:22:02
-
-ipaddr=
-netmask=255.255.255.0
-serverip=10.0.92.148
-gatewayip=10.0.92.1
-net_data_path=net_flash_file/net_flash_file/
-mac_mapping_file=/home/it/nfs/bianbu/mac_mapping.txt
-
-//net_flash_protocol=spacemit_tftp
-
-preboot=
-ramdisk_size=-
-ramdisk_combo=-
-knl_name=Image.itb
-ramdisk_name=initramfs-generic.img
-dtb_dir=
-dtb_name=k1-x_evb.dtb
-splashfile=bianbu.bmp
-grub_file=EFI/BOOT/BOOTRISCV64.EFI
-mdio_intf=
-phyaddr0=1
-phy_link_time=10000
-netdev=eth0
-
-uboot_status=IN_UBOOT
-
-// EFI system partition
-esp_name=ESP
-esp_index=5
-usb_start=true
-
-get_esp_index=env set esp_index ${bootfs_part}; \
- part number ${bootfs_devname} ${boot_devnum} ${esp_name} esp_index;
-
-// Common boot args
-commonargs=setenv bootargs earlyprintk quiet splash plymouth.ignore-serial-consoles \
- plymouth.prefer-fbcon clk_ignore_unused swiotlb=65536 \
- workqueue.default_affinity_scope=${workqueue.default_affinity_scope}
-set_loglevel=if test "${loglevel}" != "";then \
- setenv bootargs "${bootargs}" loglevel=${loglevel};
- fi
-
-set_console=if test "${console}" != "";then \
- setenv bootargs "${bootargs}" console=${console};
- fi
-
-add_bootarg=run set_console; \
- run set_loglevel;
-
-set_bootargs_unified=run commonargs; \
- run add_bootarg; \
- if test "${boot_device}" = nand; then \
- run set_nand_args; \
- elif test "${boot_device}" = nor; then \
- run set_nor_args; \
- run set_root_arg; \
- elif test "${boot_device}" = mmc; then \
- run set_mmc_args; \
- run set_root_arg; \
- elif test "${boot_device}" = nfs; then \
- setenv bootargs "${bootargs}" root=/dev/nfs net.ifnames=0 nfsroot=${serverip}:${rootfs_path} bootfs=${serverip}:${bootfs_path} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}::${netdev}:off noipath; \
- else \
- echo "Unknown boot_device: ${boot_device}"; \
- fi;
-
-//detect product_name from env and select dtb file to load
-dtb_env=if test -n "${product_name}"; then \
- if test "${product_name}" = k1_evb; then \
- setenv dtb_name ${dtb_dir}/k1-x_evb.dtb; \
- elif test "${product_name}" = k1_deb1; then \
- setenv dtb_name ${dtb_dir}/k1-x_deb1.dtb; \
- elif test "${product_name}" = k1_deb2; then \
- setenv dtb_name ${dtb_dir}/k1-x_deb2.dtb; \
- elif test "${product_name}" = k1_hs450; then \
- setenv dtb_name ${dtb_dir}/k1-x_hs450.dtb; \
- elif test "${product_name}" = k1_kx312; then \
- setenv dtb_name ${dtb_dir}/k1-x_kx312.dtb; \
- elif test "${product_name}" = k1_mingo; then \
- setenv dtb_name ${dtb_dir}/k1-x_mingo.dtb; \
- elif test "${product_name}" = k1_MINI-PC; then \
- setenv dtb_name ${dtb_dir}/k1-x_MINI-PC.dtb; \
- else \
- echo "match dtb by product_name: ${dtb_dir}/${product_name}.dtb"; \
- setenv dtb_name ${dtb_dir}/${product_name}.dtb; \
- fi; \
- fi;
-
-detect_dtb=echo "product_name: ${product_name}"; run dtb_env; echo "select ${dtb_name} to load";
-
-loadknl=echo "Loading kernel..."; \
- load ${bootfs_devname} ${boot_devnum}:${bootfs_part} ${kernel_addr_r} ${knl_name};
-
-loadramdisk=echo "Loading ramdisk ..."; \
- if load ${bootfs_devname} ${boot_devnum}:${bootfs_part} ${ramdisk_addr} ${ramdisk_name}; then \
- size ${bootfs_devname} ${boot_devnum}:${bootfs_part} ${ramdisk_name}; \
- setenv ramdisk_size ${filesize}; \
- setenv ramdisk_combo ${ramdisk_addr}:${ramdisk_size}; \
- else \
- echo "load ramdisk from bootfs fail, use built-in ramdisk"; \
- setenv ramdisk_addr -; \
- fi;
-
-loaddtb=echo "Loading dtb..."; \
- if load ${bootfs_devname} ${boot_devnum}:${bootfs_part} ${dtb_addr} ${dtb_name}; then \
- else \
- echo "load dtb from bootfs fail, use built-in dtb"; \
- setenv dtb_addr ""; \
- fi;
-
-load_grub=echo "Loading grub..."; \
- load ${bootfs_devname} ${boot_devnum}:${esp_index} ${kernel_addr_r} ${grub_file};
-
-# bootm command for fit image, booti command for PE or compress PE image
-start_kernel=fdt addr ${kernel_addr_r}; \
- if fdt list /; then \
- bootm ${kernel_addr_r} ${ramdisk_combo} ${dtb_addr}; \
- else \
- booti ${kernel_addr_r} ${ramdisk_combo} ${dtb_addr}; \
- fi;
-
-boot_kernel=run set_root_arg; \
- run detect_dtb; \
- run loadknl; \
- run loaddtb; \
- run loadramdisk; \
- run start_kernel;
-
-boot_grub=env set -e -bs product_name "${product_name}"; \
- env set -e -bs bootargs "${bootargs}"; \
- run usb_start;
- run load_grub; \
- bootefi ${kernel_addr_r};
-
-// Nor+ssd boot combo
-set_nor_args=setenv bootargs "${bootargs}" mtdparts=${mtdparts} rootfstype=ext4
-nor_boot=echo "Try to boot from ${bootfs_devname}${boot_devnum} ..."; \
- run commonargs; \
- run add_bootarg; \
- run set_nor_args; \
- run get_esp_index; \
- if test -e ${bootfs_devname} ${boot_devnum}:${esp_index} ${grub_file}; then \
- run boot_grub; \
- else \
- run boot_kernel; \
- fi; \
- echo "########### boot failed by default config, check your boot config #############"
-
-//##############################################################################
-# spinand_ubifs boot
-fastboot_ubi_size=16
-ubifs_list= mtd list; \
- ubifsls;
-ubifs_loadimg=echo "Loading kernel image..."; \
- if ubifsload ${kernel_addr_r} Image.itb; then \
- echo "Loaded Image.itb successfully"; \
- setenv boot_cmd "bootm"; \
- elif ubifsload ${kernel_addr_r} Image; then \
- echo "Loaded Image successfully"; \
- setenv boot_cmd "booti"; \
- else \
- echo "Failed to load kernel image"; \
- setenv boot_cmd ""; \
- fi;
-
-ubifs_boot=echo "Trying to boot from UBIFS..."; \
- run ubifs_loadimg; \
- if test -n "${boot_cmd}"; then \
- ${boot_cmd} ${kernel_addr_r}; \
- else \
- echo "No valid kernel image found"; \
- fi;
-
-# Nand boot
-set_nand_args=setenv bootargs "${bootargs}" mtdparts=${mtdparts} root=ubi${nand_ubi_dev}:${nand_ubi_rootfs_vol} rootfstype=${nand_rootfstype} ubi.mtd=${nand_ubi_mtd};
-
-nand_boot=echo "Try to boot from nand flash..."; \
- run commonargs; \
- run add_bootarg; \
- run set_nand_args; \
- echo "bootargs: ${bootargs}"; \
- run detect_dtb; \
- run ubifs_list; \
- run ubifs_loadimg; \
- if test -n "${boot_cmd}"; then \
- if test "${boot_cmd}" = "bootm"; then \
- echo "Booting FIT image with embedded DTB and ramdisk..."; \
- ${boot_cmd} ${kernel_addr_r}; \
- else \
- echo "Loading separate DTB and ramdisk for raw kernel..."; \
- if test -e ${dtb_name}; then \
- echo "Loading dtb from UBIFS..."; \
- ubifsload ${dtb_addr} ${dtb_name}; \
- fi; \
- if test -e ${ramdisk_name}; then \
- echo "Loading ramdisk from UBIFS..."; \
- ubifsload ${ramdisk_addr} ${ramdisk_name}; \
- setenv ramdisk_size ${filesize}; \
- setenv ramdisk_combo ${ramdisk_addr}:${ramdisk_size}; \
- else \
- setenv ramdisk_combo -; \
- fi; \
- echo "Booting with ${boot_cmd} command..."; \
- ${boot_cmd} ${kernel_addr_r} ${ramdisk_combo} ${dtb_addr}; \
- fi; \
- else \
- echo "No valid kernel image found"; \
- fi;
-
-// eMMC/SDCard boot
-//##############################################################################
-set_mmc_args=setenv bootargs "${bootargs}" rootwait rootfstype=${mmc_rootfstype};
-
-mmc_boot=echo "Try to boot from ${bootfs_devname}${boot_devnum} ..."; \
- run commonargs; \
- run add_bootarg; \
- run set_mmc_args; \
- run get_esp_index; \
- if test -e ${bootfs_devname} ${boot_devnum}:${esp_index} ${grub_file}; then \
- run boot_grub; \
- else \
- run boot_kernel; \
- fi; \
- echo "########### boot failed by default config, check your boot config #############"
-
-nfs_boot=echo "Try to boot from NFS ..."; \
- run commonargs; \
- run add_bootarg; \
- setenv bootargs "${bootargs}" root=/dev/nfs net.ifnames=0 nfsroot=${serverip}:${rootfs_path} bootfs=${serverip}:${bootfs_path} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}::${netdev}:off noipath; \
- echo "bootargs: ${bootargs}"; \
- run detect_dtb; \
- echo "Loading kernel from NFS..."; \
- nfs ${kernel_addr_r} ${serverip}:${bootfs_path}/${knl_name}; \
- echo "Loading dtb from NFS..."; \
- nfs ${dtb_addr} ${serverip}:${bootfs_path}/${dtb_name}; \
- if test -n "${ramdisk_name}"; then \
- echo "Loading ramdisk from NFS..."; \
- nfs ${ramdisk_addr} ${serverip}:${bootfs_path}/${ramdisk_name}; \
- setenv ramdisk_size ${filesize}; \
- setenv ramdisk_combo ${ramdisk_addr}:${ramdisk_size}; \
- else \
- setenv ramdisk_combo -; \
- fi; \
- run start_kernel; \
- echo "########### boot kernel failed from NFS, check your boot config #############"
-
-// Variable "boot_device" is set during board_late_init()
-autoboot=if test ${boot_device} = nand; then \
- run nand_boot; \
- elif test ${boot_device} = nor; then \
- run nor_boot; \
- elif test ${boot_device} = mmc; then \
- run mmc_boot; \
- elif test ${boot_device} = nfs; then \
- run nfs_boot; \
- fi;
-
-bootcmd=run autoboot; echo "run autoboot"
-
-// Boot menu definitions
-boot_default=echo "Current Boot Device: ${boot_device}"
-flash_default=echo "Returning to Boot Menu..."
-flash_from_usb=echo "recovery from usb...... "; \
- flash_image usb;
-flash_from_mmc=echo "recovery from mmc...... " \
- flash_image mmc;
-flash_from_net=echo "recovery from net...... " \
- flash_image net;
-
-bootmenu_delay=5
-bootmenu_0="-------- Boot Options --------"=run boot_default
-bootmenu_1="Boot from Nor"=run nor_boot
-bootmenu_2="Boot from Nand"=run nand_boot
-bootmenu_3="Boot from MMC"=run mmc_boot
-bootmenu_4="Autoboot"=run autoboot
-bootmenu_5="Show current Boot Device"=run boot_default
-bootmenu_6="-------- Flash Options --------"=run flash_default
-bootmenu_7="recovery from usb"=run flash_from_usb
-bootmenu_8="recovery from mmc"=run flash_from_mmc
-bootmenu_9="recovery from net"=run flash_from_net
+// SYSLINUX, SCRIPT and UEFI Support
+
+nvme_devtype=nvme
+nvme_devnum=0
+nvme_bootpart=1
+
+autoboot=if test -e ${devtype} ${devnum}:${distro_bootpart} /extlinux/extlinux.conf; then \
+ sysboot ${devtype} ${devnum}:${distro_bootpart} any 0x2000000 /extlinux/extlinux.conf; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} /boot/extlinux/extlinux.conf; then \
+ sysboot ${devtype} ${devnum}:${distro_bootpart} any 0x2000000 /boot/extlinux/extlinux.conf; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} /boot.scr; then \
+ load ${devtype} ${devnum}:${distro_bootpart} 0x2000000 /boot.scr; source 0x2000000; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} /boot/boot.scr; then \
+ load ${devtype} ${devnum}:${distro_bootpart} 0x2000000 /boot/boot.scr; source 0x2000000; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} EFI/BOOT/BOOTRISCV64.EFI; then \
+ load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} EFI/BOOT/BOOTRISCV64.EFI; bootefi ${kernel_addr_r}; \
+ fi;
+ nvme part; \
+ setenv devtype $nvme_devtype; \
+ setenv devnum $nvme_devnum; \
+ setenv distro_bootpart $nvme_bootpart; \
+ if test -e ${devtype} ${devnum}:${distro_bootpart} /extlinux/extlinux.conf; then \
+ sysboot ${devtype} ${devnum}:${distro_bootpart} any 0x2000000 /extlinux/extlinux.conf; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} /boot/extlinux/extlinux.conf; then \
+ sysboot ${devtype} ${devnum}:${distro_bootpart} any 0x2000000 /boot/extlinux/extlinux.conf; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} /boot.scr; then \
+ load ${devtype} ${devnum}:${distro_bootpart} 0x2000000 /boot.scr; source 0x2000000; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} /boot/boot.scr; then \
+ load ${devtype} ${devnum}:${distro_bootpart} 0x2000000 /boot/boot.scr; source 0x2000000; \
+ elif test -e ${devtype} ${devnum}:${distro_bootpart} EFI/BOOT/BOOTRISCV64.EFI; then \
+ load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} EFI/BOOT/BOOTRISCV64.EFI; bootefi ${kernel_addr_r}; \
+ fi;
+
+bootcmd=echo "Loading K1-X Environment ..."; \
+ echo ""; \
+ echo "Running NVMe Scan ..."; \
+ nvme scan; \
+ run autoboot
--
2.51.0