Device Management
The following document introduces how to achieve adaptive devices (board types) via EEPROM, including how to add support for new board types and implement adaptive booting.
In subsequent documentation, the terms "device" and "board type" are used interchangeably.
Adding a New Device
The following uses the addition of the k1-x_MUSE-Pi board type as an example.
Kernel Device Tree
If you refer to the design of the deb1 hardware, copy k1-x_deb1.dts to the following file and modify the relevant content:
target/linux/spacemit/dts/k1-x_MUSE-Pi.dts
For the newly added board type, the .dts files are stored in the above directory. They are packed into the bootfs partition during compilation and loaded by U-Boot before the kernel boots.
U-Boot Device Tree
To add a new board type, you need to modify the U-Boot source code repository as follows:
1.Add the U-Boot device tree u-boot-2022.10/arch/riscv/dts/k1-x_MUSE-Pi.dts.
2.Modify the Makefile to include k1-x_MUSE-Pi.dtb as follows: (Note that the suffix should be changed to .dtb).
11 dtb-$(CONFIG_TARGET_SPACEMIT_K1X) += k1-x_evb.dtb k1-x_deb2.dtb k1-x_deb1.dtb k1-x_hs450.dtb \
12 k1-x_kx312.dtb k1-x_MINI-PC.dtb k1-x_mingo.dtb k1-x_MUSE-N1.dtb \
13 k1-x_MUSE-Pi.dtb k1-x_spl.dtb k1-x_milkv-jupiter.dtb \
14 k1-x_MUSE-Book.dtb
15
3.modify uboot-2022.10/board/spacemit/k1-x/configs/uboot_fdt.its, add new node:
@@ -46,15 +46,6 @@
algo = "crc32";
};
};
+ fdt_4 {
+ description = "k1-x_MUSE-Pi";
+ type = "flat_dt";
+ compression = "none";
+ data = /incbin/("../dtb/1-x_MUSE-Pi.dtb");
+ hash-1 {
+ algo = "crc32";
+ };
+ };
};
configurations {
@@ -74,10 +65,5 @@
loadables = "uboot";
fdt = "fdt_3";
};
+ conf_4 {
+ description = "k1-x_MUSE-Pi";
+ loadables = "uboot";
+ fdt = "fdt_4";
+ };
};
};
4.Modify uboot-2022.10/include/configs/k1-x.h and update DEFAULT_PRODUCT_NAME. FSBL and U-Boot will, by default, load the dtb based on DEFAULT_PRODUCT_NAME. If the board has an EEPROM that records information such as product_name, then this takes precedence, and FSBL and U-Boot will use the information from the EEPROM to achieve adaptive booting.
@@ -25,7 +25,7 @@
#define CONFIG_GATEWAYIP 10.0.92.1
#define CONFIG_NETMASK 255.255.255.0
-#define DEFAULT_PRODUCT_NAME "k1_deb1"
+#define DEFAULT_PRODUCT_NAME "k1-x_MUSE-Pi"
#define K1X_SPL_BOOT_LOAD_ADDR (0x20200000)
#define DDR_TRAINING_DATA_BASE (0xc0829000)
Add Support for New Board
If it is a development board form factor, modify openwrt/target/linux/spacemit/image/k1-sbc.mk to add support for the k1-x_MUSE-Pi board type.
DEVICE_DTS := k1-x_deb1 k1-x_MUSE-Pi
If you need to add a new configuration, please refer tosolution management

