Guide: Upgrading firmware with only a serial/uart connection via u-boot

Please use a terminal that supports YMODEM file transfers. For Windows there is Tera Term. On Linux I recommend minicom, but ensure lrzsz is also installed, as the file transfer feature uses it.

Set up connection at 115200 bps, 8N1.

First, prepare the files you want to flash, such as from the latest release:

https://github.com/starfive-tech/VisionFive2/releases

  • u-boot-spl.bin.normal.out
  • visionfive2_fw_payload.img

Boot in flash mode, without a sdcard inserted, or otherwise interrupt u-boot’s autoboot:

Hit any key to stop autoboot:  0
StarFive #

After sending loady command, start the YMODEM upload through your terminal’s interface.

Like:

StarFive # loady
## Ready for binary (ymodem) download to 0xA0000000 at 115200 bps...
CCxyzModem - CRC mode, 1(SOH)/128(STX)/0(CAN) packets, 7 retries
## Total Size      = 0x0001fe80 = 130688 Bytes
StarFive #

There is strong assurance that the transfer went well, as YMODEM uses a CRC16 checksum on every block sent (1KB blocks), so if $filesize matches, it should be good. Regardless, it’s possible to CRC32 the whole file and manually compare.

StarFive # crc32 $loadaddr $filesize
crc32 for a0000000 ... a001fe7f ==> ca14da8e

OK. It’s the same file. Let’s flash it next. First, detect the SPI Flash:

StarFive # sf probe
SF: Detected gd25lq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB

Then, time to flash the file we transferred.

For u-boot-spl.bin.normal.out the offset at the flash is zero:

#WARNING: This is for u-boot-spl.bin.normal.out. Ensure that is the file we loaded!
StarFive # sf update $loadaddr 0x0 $filesize
device 0 offset 0x0, size 0x1fe80
130688 bytes written, 0 bytes skipped in 0.600s, speed 221563 B/s

Whereas for visionfive2_fw_payload.img the right offset is 0x100000:

#WARNING: This is for visionfive2_fw_payload.img.  Ensure that is the file we loaded!
StarFive # sf update $loadaddr 0x100000 $filesize
device 0 offset 0x100000, size 0x2aae85
867973 bytes written, 1929216 bytes skipped in 5.750s, speed 497796 B/s

Once done, reboot by either using the reset command or physically pressing the reset button.

9 Likes

Painfully, editing is no longer possible.

On Linux, the recommended terminal is minicom. Shows a nice menu on C-a s for sending files.

It is possible to do YMODEM with GNU screen, but it’s relatively painful as it doesn’t have an UI for that. In long command mode, exec !! sx --ymodem <filepath> .

edit: It is possible again, so I just fixed it. Either reputation based, or perhaps too any edits in a row do temporarily lock editing.

3 Likes

On Windows I would recommend TeraTerm Pro. I just flash my board using your method with it.

4 Likes

Thank you for this straight forward set of instructions. I was having some trouble getting TFTP on my PC talking to the board properly.

I’d like to echo what @cwt said about TeraTerm as well, has YMODEM support and worked perfectly.

1 Like

The open source Tera Term is what I have used on Windows, too.

Which I installed via chocolatey.

Note that Tera Term does also support Kermit, which is a better protocol overall. (use loadb instead of loady)

1 Like

I got my adafruit serial adapter just today, this worked wonderfully and I’m running image69 perfectly now! Thank you so much for making this guide!

4 Likes

@rvalles how did you transfer the file?

Thanks to @rvalles , nice work.
While you’re transferring firmwre, though, you can go get a cup of coffee. since it needs almost 5minutes

3 Likes

Screen has always worked better for me and I have used X, Y, and Z modem transfers, but I agree it’s not super intuitive.

1 Like

Ironically, Konsole (the KDE/Plasma terminal) has file transfers, but for some reason it’s only ZMODEM. Somebody must really like ZMODEM :sweat_smile:

Implementing X/YMODEM for them is one item in my “maybe TODO” list, for a day of boredom.

Yep, perfect if you do, like me, love your coffee.

But if you hate coffee, it is possible to change the baudrate to something faster on both ends. 115200 is only the default.

I have not tested other speeds, but loady is like loady [addr [baud]].

Current usb-ttl adapters typically do 1mbit/s, sometimes more. I have successfully done 10mbit/s before, with different boards/setups.

I know Z implements a sliding window so it’s more efficient, especially at higher speeds (no pauses inserted, waiting for acknowledgements). I’m not sure how X and Y compare to each other, but presumably complexity goes up X → Y → Z.

1 Like

After XMODEM appeared, there were a bunch of extensions to it, most notably XMODEM-CRC (crc16-xmodem instead of a crude 8bit sum, easily identified by the use of ‘C’ as handshake in the receiver) and XMODEM-1K (1K blocks instead of 128 byte, implies CRC).

YMODEM requires both of these extensions, and adds a zero packet that contains metadata like filename and size (thus there isn’t trailing garbage as padding as with XMODEM), as well as the ability to send/receive multiple files in one batch.

If I have to get more complex than YMODEM, I’d go to Kermit, much older protocol yet highly reliable and also capable of high speeds with sliding windows.

ZMODEM is a totally different protocol vs X/YMODEM, relatively complex.

X/YMODEM and Kermit still work over TCP, whereas ZMODEM in my experience has a lot of trouble in that situation, thus my distrust of ZMODEM.

3 Likes

Thanks @rvalles. I didn’t have access to ethernet so couldn’t load the new firmware. I did have a serial connector and was able to make it work and finally installed image-69.

1 Like

Successfully flashed v2.10.4 with this method. All good.

And v3.0.4 today, without issue.

This version of u-boot sees my SSD. :slight_smile:

starfive_pcie pcie@2C000000: Starfive PCIe bus probed.
PCI: Failed autoconfig bar 10
pci enum ...

IDE device 0: Vendor: 0x1e4b Rev: H220902a Prod: P300ADBB221125357
            Type: Hard Disk
            Capacity: 1953514.3 MB = 1907.7 GB (4000797360 x 512)
bootmode flash device 1/0
1 Like

Processing: teraterm starfive console output serial settings.png…

I’m having some issues connecting to my StarFive’s console. I just purchased this TTL adapter (DSD TECH SH-U09C USB to TTL Serial Adapter with FTDI FT232RL Chip) and this is the first time to use it. I’m getting garbled characters with both Tera Term and Putty with the serial port set to 115200 8N1 OFF. I think my settings are correct, so looking for advice/thoughts. Could my TTL be bad? Is there a way to test? Could my board be bad? Could its firmware be corrupt in some way?

The board is booting into Debian currently off an SD card. My main reason for ordering the TTL was to get the version of my firmware to see if it even needed updating to boot off NVME.

2 Likes

Did you not connect the adapter’s GND to VF2’s GND?

Your settings are correct; this is all I can come up with.

3 Likes

Thank you. I did not. That fixed it. Working beautifully now. I’ve never used one of these USB to TTL converters before and didn’t even think about it. I only connected TX and RX to the board.

3 Likes

@rvalles Thank you for pointing me to this guide from the other thread.

But I’m missing something in your guide, when exactly am I selecting the files from the file dialog?

Edit: I figured it out myself, directly after “loady” you send the file via the dialog.

First the .out and after a second “loady” the .img file.

Tera_Term_filetransfer

Tera_Term_flash

At last “reset”.

1 Like