mirror of
https://github.com/armbian/build.git
synced 2025-08-14 07:06:58 +02:00
416 lines
15 KiB
Diff
416 lines
15 KiB
Diff
From 913408ef316997f97828cf050ade9f9d3f0e4733 Mon Sep 17 00:00:00 2001
|
|
From: Patrick Yavitz <pyavitz@gmail.com>
|
|
Date: Sat, 15 Feb 2025 11:13:36 -0500
|
|
Subject: [PATCH] Add syslinux and script support
|
|
|
|
Signed-off-by: Patrick Yavitz <pyavitz@gmail.com>
|
|
---
|
|
board/spacemit/k1-x/k1-x.env | 280 ++++-------------------------------
|
|
board/spacemit/k1-x/k1x.c | 20 +--
|
|
configs/k1_defconfig | 1 +
|
|
include/configs/k1-x.h | 23 ++-
|
|
4 files changed, 48 insertions(+), 276 deletions(-)
|
|
|
|
diff --git a/board/spacemit/k1-x/k1-x.env b/board/spacemit/k1-x/k1-x.env
|
|
index f4dadc9a..8eb9c525 100644
|
|
--- a/board/spacemit/k1-x/k1-x.env
|
|
+++ b/board/spacemit/k1-x/k1-x.env
|
|
@@ -1,253 +1,27 @@
|
|
-// 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
|
|
-
|
|
-// 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;
|
|
-
|
|
-//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 #############"
|
|
-
|
|
-//##############################################################################
|
|
-// 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 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 and SCRIPT Support
|
|
+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; \
|
|
+ fi;
|
|
+ nvme part; \
|
|
+ if test -e nvme 0:1 /extlinux/extlinux.conf; then \
|
|
+ sysboot nvme 0:1 any 0x2000000 /extlinux/extlinux.conf; \
|
|
+ elif test -e nvme 0:1 /boot/extlinux/extlinux.conf; then \
|
|
+ sysboot nvme 0:1 any 0x2000000 /boot/extlinux/extlinux.conf; \
|
|
+ elif test -e nvme 0:1 /boot.scr; then \
|
|
+ load nvme 0:1 0x2000000 /boot.scr; source 0x2000000; \
|
|
+ elif test -e nvme 0:1 /boot/boot.scr; then \
|
|
+ load nvme 0:1 0x2000000 /boot/boot.scr; source 0x2000000; \
|
|
+ fi;
|
|
+
|
|
+bootcmd=echo "Loading K1-X Environment ..."; \
|
|
+ usb start; \
|
|
+ echo ""; \
|
|
+ echo "Running NVMe Scan ..."; \
|
|
+ nvme scan; \
|
|
+ run autoboot
|
|
diff --git a/board/spacemit/k1-x/k1x.c b/board/spacemit/k1-x/k1x.c
|
|
index 9210e121..f6c9a5c7 100644
|
|
--- a/board/spacemit/k1-x/k1x.c
|
|
+++ b/board/spacemit/k1-x/k1x.c
|
|
@@ -458,8 +458,8 @@ void _load_env_from_blk(struct blk_desc *dev_desc, const char *dev_name, int dev
|
|
#endif
|
|
}
|
|
|
|
- env_set("bootfs_part", simple_itoa(part));
|
|
- env_set("bootfs_devname", dev_name);
|
|
+ env_set("distro_bootpart", simple_itoa(part));
|
|
+ env_set("devnum", dev_name);
|
|
|
|
/*load env.txt and import to uboot*/
|
|
memset((void *)CONFIG_SPL_LOAD_FIT_ADDRESS, 0, CONFIG_ENV_SIZE);
|
|
@@ -662,7 +662,7 @@ void setenv_boot_mode(void)
|
|
u32 boot_mode = get_boot_mode();
|
|
switch (boot_mode) {
|
|
case BOOT_MODE_NAND:
|
|
- env_set("boot_device", "nand");
|
|
+ env_set("devtype", "nand");
|
|
break;
|
|
case BOOT_MODE_NOR:
|
|
char *blk_name;
|
|
@@ -673,23 +673,23 @@ void setenv_boot_mode(void)
|
|
return;
|
|
}
|
|
|
|
- env_set("boot_device", "nor");
|
|
- env_set("boot_devnum", simple_itoa(blk_index));
|
|
+ env_set("devtype", "nor");
|
|
+ env_set("devnum", simple_itoa(blk_index));
|
|
break;
|
|
case BOOT_MODE_EMMC:
|
|
- env_set("boot_device", "mmc");
|
|
- env_set("boot_devnum", simple_itoa(MMC_DEV_EMMC));
|
|
+ env_set("devtype", "mmc");
|
|
+ env_set("devnum", simple_itoa(MMC_DEV_EMMC));
|
|
break;
|
|
case BOOT_MODE_SD:
|
|
- env_set("boot_device", "mmc");
|
|
- env_set("boot_devnum", simple_itoa(MMC_DEV_SD));
|
|
+ env_set("devtype", "mmc");
|
|
+ env_set("devnum", simple_itoa(MMC_DEV_SD));
|
|
break;
|
|
case BOOT_MODE_USB:
|
|
// for fastboot image download and run test
|
|
env_set("bootcmd", CONFIG_BOOTCOMMAND);
|
|
break;
|
|
default:
|
|
- env_set("boot_device", "");
|
|
+ env_set("devtype", "");
|
|
break;
|
|
}
|
|
}
|
|
diff --git a/configs/k1_defconfig b/configs/k1_defconfig
|
|
index 18ac1e3a..fd33afde 100644
|
|
--- a/configs/k1_defconfig
|
|
+++ b/configs/k1_defconfig
|
|
@@ -294,3 +294,4 @@ CONFIG_PRINT_TIMESTAMP=y
|
|
# CONFIG_SPL_SHA256 is not set
|
|
CONFIG_ZSTD=y
|
|
# CONFIG_HEXDUMP is not set
|
|
+CONFIG_OF_LIBFDT_OVERLAY=y
|
|
diff --git a/include/configs/k1-x.h b/include/configs/k1-x.h
|
|
index 3e83e032..3cd5f491 100644
|
|
--- a/include/configs/k1-x.h
|
|
+++ b/include/configs/k1-x.h
|
|
@@ -106,11 +106,6 @@
|
|
#define TLV_CODE_EEPROM_I2C_INDEX 0x81
|
|
#define TLV_CODE_EEPROM_PIN_GROUP 0x82
|
|
|
|
-// #define RAMDISK_LOAD_ADDR (CONFIG_FASTBOOT_BUF_ADDR + CONFIG_FASTBOOT_BUF_SIZE)
|
|
-// #define DTB_LOAD_ADDR (CONFIG_FASTBOOT_BUF_ADDR + CONFIG_FASTBOOT_BUF_SIZE * 2)
|
|
-#define RAMDISK_LOAD_ADDR 0x21000000
|
|
-#define DTB_LOAD_ADDR 0x31000000
|
|
-
|
|
// for those has NOT been through test procedure(ATE)
|
|
#define SVT_DRO_DEFAULT_VALUE (120)
|
|
|
|
@@ -164,6 +159,11 @@ struct boot_storage_op
|
|
#define BOOT_TARGET_DEVICES(func) \
|
|
func(QEMU, qemu, na)
|
|
|
|
+#define KERNEL_ADDR_R __stringify(0x10000000)
|
|
+#define RAMDISK_ADDR_R __stringify(0x21000000)
|
|
+#define FDT_ADDR_R __stringify(0x31000000)
|
|
+#define FDTOVERLAY_ADDR_R __stringify(0x01000000)
|
|
+
|
|
#include <config_distro_bootcmd.h>
|
|
|
|
#define BOOTENV_DEV_QEMU(devtypeu, devtypel, instance) \
|
|
@@ -189,16 +189,13 @@ struct boot_storage_op
|
|
/*if env not use for spl, please define to board/spacemit/k1-x/k1-x.env */
|
|
#define CONFIG_EXTRA_ENV_SETTINGS \
|
|
"stdout_flash=serial,vidconsole\0" \
|
|
- "kernel_comp_addr_r=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
|
|
- "kernel_comp_size=" __stringify(CONFIG_FASTBOOT_BUF_SIZE) "\0" \
|
|
- "kernel_addr_r=" __stringify(CONFIG_FASTBOOT_BUF_ADDR) "\0" \
|
|
- "ramdisk_addr=" __stringify(RAMDISK_LOAD_ADDR) "\0" \
|
|
- "dtb_addr=" __stringify(DTB_LOAD_ADDR) "\0" \
|
|
"scriptaddr=0x2c100000\0" \
|
|
"pxefile_addr_r=0x0c200000\0" \
|
|
- "splashimage=" __stringify(CONFIG_FASTBOOT_BUF_ADDR) "\0" \
|
|
- "splashpos=m,m\0" \
|
|
- "splashfile=bianbu.bmp\0" \
|
|
+ "fdt_addr_r=" FDT_ADDR_R "\0" \
|
|
+ "kernel_addr_r=" KERNEL_ADDR_R "\0" \
|
|
+ "ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
|
|
+ "fdtoverlay_addr_r=" FDTOVERLAY_ADDR_R "\0" \
|
|
+ "fdtfile=spacemit/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
|
|
BOOTENV_DEVICE_CONFIG
|
|
|
|
|
|
--
|
|
2.39.5
|
|
|