Official uboot is very different from the mediatek uboot, not that easy to use but very flexible.
For example, if my firmware stored in USB disk and I want to update firmware from uboot, I will need to load from usb disk to memory first, then erase flash and write to it all by command.
- usb start this will enable usb
- fatload usb 0:0 0x81000000 root_uImage my firmware name is root_uImage, and I load it to 0x81000000 (DDR memory address)
- sf start this will enable spi flash
- sf erase 0x50000 0xfb0000 erase the firmware partition, from 0x50000 and size is 0xfb0000
- sf write 0x81000000 0x50000 0x600325 read from 0x81000000 and write to SPI flash 0x50000, size is 0x600325(6292261), this size we can find at fatload.
Here is the log:
U-Boot 2022.01 (Oct 29 2022 - 14:39:20 +0000)
resetctl_reboot resetctl-reboot: set_state_simple op missing
mtmips-reset rstctrl@0x34: set_state_simple op missing
CPU: MediaTek MT7628A ver:1 eco:2
Boot: DDR2, SPI-NOR 3-Byte Addr, CPU clock from XTAL
Clock: CPU: 580MHz, Bus: 193MHz, XTAL: 40MHz
DRAM: 128 MiB
pinconfig pin_state: set_state_simple op missing
simple_bus palmbus@10000000: set_state_simple op missing
mt7628-clk clkctrl@0x2c: set_state_simple op missing
mt762x_wdt watchdog@100: set_state_simple op missingg
WDT: Started watchdog@100 with servicing (60s timeout)
MMC: fixed_clock clk48m@0: set_state_simple op missing
pinconfig sd_iot_mode: set_state_simple op missing
mmc@10130000: 0
Loading Environment from SPIFlash... mt7621_spi spi@b00: set_state_simple op mig
mt7621_spi spi@b00: spi_find_chip_select: plat=86fa0258, cs=0
jedec_spi_nor spi-flash@0: set_state_simple op missing
SF: Detected w25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
jedec_spi_nor spi-flash@0: from 0x00030000, len 4096
OK
In: uart2@e00
Out: uart2@e00
Err: uart2@e00
Net: pinconfig ephy_iot_mode: set_state_simple op missing
mtmips-reset rstctrl@0x34: set_state_simple op missing
Warning: eth@10110000 (eth0) using random MAC address - ce:78:14:4e:a5:ac
eth0: eth@10110000
Hit any key to stop autoboot: 0
=>
=> usb start
starting USB...
Bus ehci@101c0000: ehci_generic ehci@101c0000: set_state_simple op missing
mt76x8_usb_phy usb-phy@10120000: set_state_simple op missing
USB EHCI 1.00
scanning bus ehci@101c0000 for devices... usb_hub usb_hub: set_state_simple op g
2 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
=> fatload usb 0:0 0x81000000 root_uImage
6292261 bytes read in 245 ms (24.5 MiB/s)
=> sf start
No SPI flash selected. Please run `sf probe'
=> sf probe
mt7621_spi spi@b00: spi_find_chip_select: plat=86fa0258, cs=0
mt7621_spi spi@b00: spi_find_chip_select: plat=86fa0258, cs=0
=> sf erase 0x50000 0xfb0000
jedec_spi_nor spi-flash@0: at 0x50000, len 16449536
SF: 16449536 bytes @ 0x50000 Erased: OK
=> sf write 0x81000000 0x50000 0x600325
device 0 offset 0x50000, size 0x600325
jedec_spi_nor spi-flash@0: to 0x00050000, len 6292261
SF: 6292261 bytes @ 0x50000 Written: OK
Please make a guide about building mainline u-boot with sd-card boot support. Thanks!