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
flashcp
command in the Debian system is included in themtd-utils
package. Execute the following command to install:sudo apt install mtd-utils
-
Download Bootloader Firmware
The firmware contains two files,
SPL
andU-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/mtd
The 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
SPL
to themtd0
partition andU-Boot
to themtd1
partition. -
Update Bootloader
Update SPL:
sudo flashcp -v mars_u-boot-spl.bin.normal.out /dev/mtd0
Update U-Boot:
sudo flashcp -v mars_visionfive2_fw_payload.img /dev/mtd1
The 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%)
After powering on again, you can determine whether the bootloader has been updated based on the timestamp in the UART serial port log:
U-Boot SPL 2021.10 (Nov 24 2023 - 10:21:39 +0800)
U-Boot 2021.10 (Nov 24 2023 - 10:21:39 +0800)
Use UsbFlashTool to upgrade bootloader under Windows
Download UsbFlashTool burning tool and Bootloader firmware
SPL: mars_u-boot-spl.bin.normal.out
U-Boot: mars_visionfive2_fw_payload.img
Install driver for the burning tool
Driver installation is only required for the first use.
Extract the downloaded Mars-UsbFlashTool-*-Windows.zip
into the Windows system.
-
Connect the USB to TTL serial port cable to the 40 pin header on Mars, connect the USB to the PC and note down the serial port number
How to connect USB to serial cable: Use Serial Console
Note: If any other serial port program is open and using the serial port, please exit the program to release the port and avoid occupying it.
-
Connect the PC and Mars using a USB 2.0 interface with a type A Male to Male USB data cable
-
Press and hold the
upgrade button
on Mars, and then power on Mars through the Type C interface. At this time, Mars will enter the upgrade mode. You can release theupgrade button
to continue the operation. -
Run the
UsbFlashTool-*-Windows.exe
flashing program in the flashing tool directory -
Set the serial port number in the
Serial Setting
on the right side to the serial port number noted in step 1 -
Select
Firmware
inFile Type
, then clickFile Select
to select theusbprog-mars-230510.out
in theupdate
directory, then clickLoad
, and wait for the messageLoaded
to appear after loading -
At this time, the JH7110 device has been identified in the Windows Device Manager and the driver needs to be installed
-
Run the
zadig-2.5
program in the flashing tool directory, selectList All Devices
in the menuOptions
, selectStarFive JH7110 Device
in the drop-down list, and then clickInstall Driver
to complete the driver installationAfter the driver is successfully installed, check whether the status in the device manager has become a normal USB device
-
After the driver is successfully installed, close the UsbFlashTool window and power off Mars.
Upgrade Bootloader
The first 5 steps of burning the bootloader are the same as the first 5 steps of installing the driver above.
-
Connect the USB to TTL serial port cable to the 40 pin header on Mars, connect the USB to the PC and note down the serial port number
How to connect USB to serial cable: Use Serial Console
Note: If any other serial port program is open and using the serial port, please exit the program to release the port and avoid occupying it.
-
Connect the PC and Mars using a USB 2.0 interface with a type A Male to Male USB data cable
-
Press and hold the upgrade button on Mars, and then power on Mars through the Type C interface. At this time, Mars will enter the upgrade mode. You can release the upgrade button to continue the operation.
-
Run the
UsbFlashTool-*-Windows.exe
flashing program in the flashing tool directory -
Set the serial port number in the
Serial Setting
on the right side to the serial port number noted in step 1 -
Select
Firmware
inFile Type
, then clickFile Select
to select theusbprog-mars-230510.out
in theupdate
directory, then clickLoad
, and wait for the messageComplete
to appear after loading -
Flash the
SPL
Click
File Select
, select theSPL
firmwareu-boot-spl.bin.normal.out
to be burned, selectSPL
inFile Type
, selectFLASH
inMemory Type
, ClickLoad
to start burning firmware.After successful burning,
SUCCEED
andComplete
will be displayed. -
Flash the
U-BOOT
Click
File Select
, select theU-BOOT
firmwarevisionfive2_fw_payload.img
to be burned, selectU-Boot
inFile Type
, selectFLASH
inMemory Type
, and then clickLoad
to start burning firmware.After successful burning,
SUCCEED
andComplete
will be displayed. -
After burning is completed, close the UsbFlashTool window and power off Mars.
After powering on again, you can determine whether the bootloader has been updated based on the time information in the serial port log.
U-Boot SPL 2021.10 (Aug 31 2023 - 12:55:45 +0800)
U-Boot 2021.10 (Aug 31 2023 - 12:55:45 +0800), Build: jenkins-github_visionfive2-17