Both VIMs can boot from different boot media like eMMC, SD Card and USB Disk, but different with VIM1, as VIM2 specs with a 2MB SPI Flash, so VIM2 can also boot from SPI Flash. And here is an instructions how to boot VIM2 from the SPI Flash.
Preperations
Build SPI Flash supported U-Boot
As the boot media are different, to support SPI Flash, we have to enable following first, which is located on uboot/board/khadas/configs/kvim2.h
:
diff --git a/board/khadas/configs/kvim2.h b/board/khadas/configs/kvim2.h
index c7a8fd6..d1556ba 100644
--- a/board/khadas/configs/kvim2.h
+++ b/board/khadas/configs/kvim2.h
@@ -386,7 +386,7 @@
#define CONFIG_SYS_NO_FLASH 1
/*SPI*/
-//#define CONFIG_SPI_BOOT 1
+#define CONFIG_SPI_BOOT 1
#define CONFIG_AMLOGIC_SPI_FLASH 1
#ifdef CONFIG_AMLOGIC_SPI_FLASH
#undef CONFIG_ENV_IS_NOWHERE
After modification, build again:
$ cd uboot
$ make distclean
$ make CROSS_COMPILE=aarch64-linux-gnu- kvim2_defconfig
$ make CROSS_COMPILE=aarch64-linux-gnu-
Gerneration file for SPI Flash:
uboot/fip/u-boot.bin
Download U-Boot into SPI Flash
To continue the guidance, you have to follow up Load Images with U-Boot via TFTP Instructions do the setup first.
1) Load u-boot.bin into memory via tftp
kvim2# tftp 12000000 u-boot.bin
2) Initiate the SPI Flash
kvim2# sf probe
3) Erase SPI Flash
kvim2# sf erase 0 200000
Above command will earse all the whole SPI Flash, the offset is 0 and the size is 200000.
4) Download U-Boot into SPI Flash
kvim2# sf write 12000000 0 200000
5) Set the default boot meidia as SPI Flash
kvim2# kbi bootmode w spi
The default boot media is eMMC, and here we use kbi to change it to SPI Flash. kbi means Khadas Bootloader Instrucionts, you can refer more KBI instrucions at TBD.
If you wanna check the boot media, you can run:
kvim2# kbi bootmode r
bootmode: spi
6) Check it
To check it, you have to power off the VIM2 first, and power on again:
...
AddrBus test pass!
Load fip header from SPI, src: 0x0000c000, des: 0x01400000, size: 0x00004000
New fip structure!
Load bl30 from SPI, src: 0x00010000, des: 0x01100000, size: 0x0000d600
Load bl31 from SPI, src: 0x00020000, des: 0x05100000, size: 0x00018400
...
The Load fip header from SPI printing it says that VIM2 is boot from the SPI Flash.
Enjoy!