Milk-V Mars Bootloader Update Guide
Whether Mars starts the system through the SD card or the eMMC module, it must be started through the Bootloader boot program. This boot program is stored in an SPI Flash on the board and contains two parts: SPL and U-Boot.
The Bootloader in Mars can be understood as the BIOS in PC
When Mars is shipped, it already comes with a pre-installed initial Bootloader program. There is no need to upgrade this program during normal usage. Bootloader upgrade is only necessary in the following situations:
- When the bootloader program in SPI Flash is accidentally damaged, causing the system to fail to start normally.
- When upgrading the official system image (such as Debian), it must be matched with the new bootloader, otherwise it cannot be started.
- U-Boot has fixed some bugs or added new functions. When you need to use these new functions.
There are several ways to update the Bootloader in SPI Flash on Mars, such as Windows burning tools, TFTP, flashcp commands, etc. Here are the methods of using the flashcp command and using the UsbFlashTool burning tool in Windows systems.
Update Bootloader using flashcp command
If the current bootloader of your Mars can boot the Debian system normally, you can use the flashcp command in the Debian system to update the bootloader.
-
Install flashcp command
The
flashcpcommand in the Debian system is included in themtd-utilspackage. Execute the following command to install:sudo apt install mtd-utils -
Download Bootloader Firmware
The firmware contains two files,
SPLandU-Boot:SPL: mars_u-boot-spl.bin.normal.out
U-Boot: mars_visionfive2_fw_payload.imgYou can download it directly on Mars, or download it on PC and then transfer it to Mars through scp command or USB flash drive.
-
View SPI Flash partition information
cat /proc/mtdThe output is as follows:
user@milkv:~$ cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00001000 "spl"
mtd1: 00300000 00001000 "uboot"
mtd2: 00100000 00001000 "data"We need to update
SPLto themtd0partition andU-Bootto themtd1partition. -
Update Bootloader
Update SPL:
sudo flashcp -v mars_u-boot-spl.bin.normal.out /dev/mtd0Update U-Boot:
sudo flashcp -v mars_visionfive2_fw_payload.img /dev/mtd1The output of successful execution is as follows:
user@milkv:~$ sudo flashcp -v mars_u-boot-spl.bin.normal.out /dev/mtd0
Erasing blocks: 36/36 (100%)
Writing data: 143k/143k (100%)
Verifying data: 143k/143k (100%)
user@milkv:~$
user@milkv:~$ sudo flashcp -v mars_visionfive2_fw_payload.img /dev/mtd1
Erasing blocks: 723/723 (100%)
Writing data: 2890k/2890k (100%)
Verifying data: 2890k/2890k (100%)