Skip to content

Commit

Permalink
add support for using Uart to start U-BOOT under Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
zwyzwm committed Nov 21, 2024
1 parent c5413b9 commit 9b13069
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 0 deletions.
61 changes: 61 additions & 0 deletions docs/mars/getting-started/bootloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,64 @@ 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
```

## Use Uart to start U-BOOT under Linux

### Download Bootloader Firmware

[Bootloader Firmware](https://github.com/milkv-mars/mars-buildroot-sdk/releases)

```
SPL: mars_u-boot-spl.bin.normal.out
U-Boot: mars_visionfive2_fw_payload.img
```

### Download tio

For reference: https://github.com/tio/tio

:::tip
Note that you need to download the latest version. The version downloaded by directly running the command `sudo apt-get install tio` does not meet the requirements.
:::

### Boot from UART

Press and hold the upgrade button on Mars, power the development board and upload `mars_u-boot-spl.bin.normal.out` via XMODEM.

Run the command `tio -b 115200 --databits 8 --flow none --stopbits 1 /dev/ttyUSB0`
```
$ tio -b 115200 --databits 8 --flow none --stopbits 1 /dev/ttyUSB0
[08:14:54.700] tio v2.7
[08:14:54.700] Press ctrl-t q to quit
[08:14:54.701] Connected
(C)StarFive
CCC
(C)StarFive
CCCCCCCC
```
Press ctrl-t x to start XMODEM-1K transmission and enter according to the prompts.

``` [15:37:49.827] Please enter which X modem protocol to use: [15:37:49.827] (0) XMODEM-1K send [15:37:49.827] (1) XMODEM-CRC send [15:37:49.827] (2) XMODEM-CRC receive CCCCCCCCCCCCCCCC [15:37:51.940] Send file with XMODEM-1K [15:38:15.230] Sending file '/tmp/mars_u-boot-spl.bin.normal.out' [15:38:15.230] Press any key to abort transfer .................................................................................................................................................................| [15:38:29.151] Done U-Boot SPL 2021.10 (Nov 24 2023 - 10:21:39 +0800)
LPDDR4: 1G version: g8ad50857.
Trying to boot from SPI
```

Note: `Sending file '/path/to/mars_u-boot-spl.bin.normal.out' `, after entering the file to be sent, wait for the | that appears after ...., which means the sending is complete.

### Flash the new version of U-Boot

Assuming your new U-Boot version is on partition 1 of the SD card, you can install it to the SPI flash using the following commands
```
sf probe
load mmc 0:1 $kernel_addr_r u-boot-spl.bin.normal.out
sf update $kernel_addr_r 0 $filesize
load mmc 0:1 $kernel_addr_r u-boot.itb
sf update $kernel_addr_r 0x100000 $filesize
```
After updating U-Boot, you may need to reboot and reset the environment to defaults.
```
env default -f -a
env save
```
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,77 @@ 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
```

## 在 Linux 下使用 Uart 启动 U-BOOT

### 下载 Bootloader 固件

[Bootloader 固件](https://github.com/milkv-mars/mars-buildroot-sdk/releases)

```
SPL: mars_u-boot-spl.bin.normal.out
U-Boot: mars_visionfive2_fw_payload.img
```

### 下载 tio

可参考:https://github.com/tio/tio

:::tip
注意要下载最新版本,直接运行命令 `sudo apt-get install tio` 下载的版本是不符合要求的。
:::

### 从 UART 启动

按住 Mars 上的升级键,为开发板供电并通过 XMODEM 上传 `mars_u-boot-spl.bin.normal.out`

运行命令 `tio -b 115200 --databits 8 --flow none --stopbits 1 /dev/ttyUSB0`
```
$ tio -b 115200 --databits 8 --flow none --stopbits 1 /dev/ttyUSB0
[08:14:54.700] tio v2.7
[08:14:54.700] Press ctrl-t q to quit
[08:14:54.701] Connected
(C)StarFive
CCC
(C)StarFive
CCCCCCCC
```
按ctrl-t x启动 XMODEM-1K 传输,根据提示输入即可。

```
[15:37:49.827] Please enter which X modem protocol to use:
[15:37:49.827] (0) XMODEM-1K send
[15:37:49.827] (1) XMODEM-CRC send
[15:37:49.827] (2) XMODEM-CRC receive
CCCCCCCCCCCCCCCC
[15:37:51.940] Send file with XMODEM-1K
[15:38:15.230] Sending file '/tmp/mars_u-boot-spl.bin.normal.out'
[15:38:15.230] Press any key to abort transfer
................................................................................................................................................|
[15:38:29.151] Done
U-Boot SPL 2021.10 (Nov 24 2023 - 10:21:39 +0800)
LPDDR4: 1G version: g8ad50857.
Trying to boot from SPI
```

注意:`Sending file '/path/to/mars_u-boot-spl.bin.normal.out' `,输入要发送的文件之后,等待....之后出现的 | ,便是发送完成。

### 刷新新版本的 U-Boot

假设您的新 U-Boot 版本位于 SD 卡的第 1 个分区上,您可以使用以下命令将其安装到 SPI 闪存中
```
sf probe
load mmc 0:1 $kernel_addr_r u-boot-spl.bin.normal.out
sf update $kernel_addr_r 0 $filesize
load mmc 0:1 $kernel_addr_r u-boot.itb
sf update $kernel_addr_r 0x100000 $filesize
```
更新 U-Boot 后,您可能需要重新启动并将环境重置为默认值。
```
env default -f -a
env save
```

0 comments on commit 9b13069

Please sign in to comment.