Update U-Boot (from U-Boot)

NOTE: Incorrect procedure or power loss during this process can render your board unusable - please be careful.

NOTE: If you are able to boot into Linux, then please follow the guide for updating U-Boot from within Linux.


If you are unable to boot into Linux, then it is possible to update U-Boot from within U-Boot itself, following the steps below.

To perform this operation, you will require:

  • Access to the serial console using a 3.3v TTL UART, connecting to the Console port as outlined in the Quick Start.
  • A TFTP server on the same network as the 4Kopen, hosting the new binary file.

MAC Address

Before starting, make sure that you have a valid MAC address loaded into your environment. Without this, you will be unable to load the image via TFTP.

Run printenv ethaddr at the command prompt.

If U-Boot responds with your current MAC address, then you're all set to go.

4KOpen> printenv ethaddr
ethaddr=2a:72:0d:83:7f:9c

If you see the Error: "ethaddr" not defined, then you must setup your MAC address by reading the label attached to your 4Kopen board, for example:

4KOpen> printenv ethaddr
## Error: "ethaddr" not defined
4KOpen> setenv ethaddr ${YOUR_MAC_ADDRESS}

Download the Update

This example shows loading 4KOpen-flash-v0.1.1.bin (MD5: a4d265d79ef0bba3a0fbed011c102fda), via TFTP - it occupies the full 32 MB of flash.

4KOpen> setenv autoload no
4KOpen> dhcp
Using MAC Address 2a:72:0d:83:7f:9c
STM-GMAC: REALTEK RTL8211E(G) found
STM-GMAC: 100Mbs full duplex link detected
STM-GMAC: Allocating coherent descriptors
Successfully allocated coherent descriptors
[...]
DHCP client bound to address 10.0.1.113 (6665 ms)
4KOpen> tftp 0x98000000 ${SERVER_IP}:4KOpen-flash-v0.1.1.bin
Using MAC Address 2a:72:0d:83:7f:9c
STM-GMAC: REALTEK RTL8211E(G) found
STM-GMAC: 100Mbs full duplex link detected
STM-GMAC: Using already allocated descriptors.
Using stmac-1 device
TFTP from server 10.0.1.190; our IP address is 10.0.1.113
Filename '4KOpen-flash-v0.1.1.bin'.
Load address: 0x98000000
Loading: #################################################################
         #################################################################
[...]
         ###########
           1.2 MiB/s
done
Bytes transferred = 33554432 (2000000 hex)
4KOpen> setenv imgsize ${filesize}

Insert the MAC Address

Patch the downloaded image with your MAC address.

4KOpen> env export -t 0x980d0000 ethaddr

Disable Write Protection and Probe Flash

Ensure that the previous command completed successfully, it should download 32MB of data. Doing the next steps without the correct download happening will force you to need to boot a version over JTAG.

4KOpen> mw 0x09230028 0x10
4KOpen> mw 0x09230038 0x10
4KOpen> mw 0x09230044 0x10
4KOpen> mw 0x09230004 0x10
4KOpen> sf probe
SPI is boot device.
FSM SF: Detected ST N25Q256 with sector size 64 KiB, total 32 MiB

Erase the Flash

Erase and confirm (output should be all ones / 0xFF):

4KOpen> sf erase 0 +${imgsize}
SF: 33554432 bytes @ 0x0 Erased: OK
4KOpen> sf read 0x97000000 0 40

SF: 64 bytes @ 0x0 Read: OK
4KOpen> md.b 0x97000000 40
97000000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
97000010: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
97000020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................
97000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................

Write the Update to Flash

Write and confirm (should hold valid data, not necessarily exactly as below):

4KOpen> sf write 0x98000000 0 ${imgsize}
SF: 33554432 bytes @ 0x0 Written: OK
4KOpen> sf read 0x97000000 0 40
SF: 64 bytes @ 0x0 Read: OK
4KOpen> md.b 0x97000000 40
97000000: 15 0f 07 ee 10 1f 11 ee 06 1b 81 e3 4f f0 7f f5 ............O...
97000010: 10 1f 01 ee 6f f0 7f f5 00 00 00 ea 00 00 00 00 ....o...........
97000020: 04 f0 1f e5 41 00 00 00 ff ff ff ff ff ff ff ff ....A...........
97000030: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ................

Verify Update

Verify. If any issues present, re-run from "Erase and Confirm".

4KOpen> sf read 0x9A000000 0 ${imgsize}
SF: 33554432 bytes @ 0x0 Read: OK
4KOpen> cmp.b 0x98000000 0x9A000000 ${imgsize}
Total of 33554432 byte(s) were the same