How can I boot from usb and mount rootfiles on usb?

Information:
Version 21.02
Model - HLK7628n

I have two difficulties.

The first would be in relation to booting via usb. I tried using the method “setenv bootargs root = / dev / sda1 rw rootfstype = ext4” ... but I didn't get success, I think my uboot is too outdated version 1.0

The second would be to mount or rootfiles on usb, this would be the most important.

I'm trying my best to solve this problem, but without success.

I'm guessing that some kernel boot driver for usb reading might be missing. What are all the necessary drivers?

Affectionate Information:
The usb is reading normally.

Thanks for the help.

You might want to force uboot to scan the USB ports for storage, before you attempt a boot.

There might be some usable info in https://forum.doozan.com/read.php?3,12
Doozans' usually a great source of info about uboot booting, although the versions
described there, might be newer than the one you're using.

2 Likes

can you set up an extroot? https://openwrt.org/docs/guide-user/additional-software/extroot_configuration

2 Likes

Can you post the uboot env with printenv command ?
It is more the bootcmd that you need to tweak for changing the boot device...

U-Boot 1.1.3 (May 23 2020 - 14:42:28)

"printenv" result:
bootdelay=10
baudrate=57600
ethaddr="03:17:73:AB:CD:EF"
ethact=Eth0 (10/100-M)
bootcmd=????
boot_args=setenv bootargs root=/dev/sda1 rw rootfstype=ext4
ramargs=setenv bootargs root=/dev/ram sda1 1 rw
ipaddr=10.10.10.123
serverip=10.10.10.3
bootfile=openwrt-ramips-mt76x8-hilink_hlk-7628n-initramfs-kernel.bin
bootargs=root = / dev / sda1 rw rootfstype = ext4
stdin=serial
stdout=serial
stderr=serial

"bootcmd" result:
Unknown command 'bootcmd' - try 'help'

"help" result:
? - alias for 'help'
bootm - boot application image from memory
cp - memory copy
crc32 - checksum calculation
erase - erase SPI FLASH memory
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls - list files in a directory (default /)
flash_always_3byte always switch to 3byte
flash_always_4byte always switch to 4byte
flash_exit_4byte exit to 4byte
flash_to_4byte switch to 4byte
go - start application at address 'addr'
help - print online help
loadb - load binary file over serial line (kermit mode)
md - memory display
mdio - Ralink PHY register R/W command !!
mm - memory modify (auto-incrementing)
nm - memory modify (constant address)
ping - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
reset - Perform RESET of the CPU
rf - read/write rf register
saveenv - save environment variables to persistent storage
setenv - set environment variables
spi - spi command
spi_read_sr read Status Register
switch - rt3052 embedded switch command
tftpboot- boot image via network using TFTP protocol
usb - USB sub-system
usbboot - boot from USB device
version - print monitor version

I tried to update uboot to hilink's hlk7628n stage, but with no success.

bootcmd is missing, the value is empty ?
bootargs is incorrect, there is space characters which must be removed
You normally have a command to reset to default values.
You must find somewhere these defaults and missing values, or find the command to reset them.

bootcmd normally filled with commands executed when you boot, or with the boot command.

already changed the boot cmd value several times to try to see if it works.

I've already removed the bootargs spaces as well, but I don't know what I can do.

I'm missing something stupid, but so far I've managed to resolve it.

can you tell if 'setenv bootcmd 'echo test21-ok' works?

http://h.hlktech.com/download/HLK-7628N/1/openwrt版本文档.zip

https://www.hlktech.com/en/Product/Details/23#datum

Reset the firmware with factory binaries...
and try again to upgrade to OpenWrt !
https://firmware-selector.openwrt.org/?version=21.02.0&target=ramips%2Fmt76x8&id=hilink_hlk-7628n

The devices look like to be the same, or close to, Xiami routeurs ?

ex: setenv bootcmd 'usb restart; fatload usb 0:1'

I tried several ways, but without success, I'm wrong something very stupid.

is this device even from the hilink "HLK-7628N"
are similar, but a lot changes from mt7628 to mt 7621

look usb commands with usb or help usb

do it manually for testing... step by step...
usb reset
some times work only one time and may need a reset of uboot before !

then fatls usb 0:1

then fatload usb 0:1 0x_the_memory_address the_file_path

You missing values like memory address where to load binaries and jump (go) to execute

3: System Boot system code via Flash.

Booting image at bc050000 ...

Image Name: MIPS OpenWrt Linux-5.4.143
Image Type: MIPS Linux Kernel Image (lzma compressed)
Data Size: 7604136 Bytes = 7.3 MB
Load Address: 80000000
Entry Point: 80000000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
No initrd

Transferring control to Linux (at address 80000000) ...

Giving linux memsize in MB, 128

when using (go) the system crashes

manually I can read the usb, read the usb image with fatls, but I don't understand how I can set the rootfiles through usb and load the image through usb

kind of over the top, for your use case, but still usable as reference https://forum.doozan.com/read.php?2,22241,22345#msg-22345
Obviously most (if not all) 0x????? values shouldn't be used, they might be hw specific.

From here : Mounting a microsd on hi-link board hlk7628n
You were booting...
What were your env settings ?

MT7628 # setenv bootargs 'console=ttyS0,115200 rootfstype=squashfs,jffs2

?

EDIT (UPDATE)...

Try to use 0x80000000 for loading address...
Then use bootm 0x80000000

Here another topics with (may be) some interesting values :

Xiaomi Mi 4C use the same CPU/SOC !?

https://deviwiki.com/wiki/Xiaomi_Mi_Router_4C_(R4CM)

@vcarvalho12 Can you share a complete booting log ?

EDIT (UPDATE) :

I think I may have found some possible values :

loadaddr = 0x80c00000
bootcmd = bootm 0xbc050000

or : https://github.com/kysonlok/u-boot-mt7628/blob/d258fdace2b742bfbbfb9b8c9de4cbf3e631989d/common/main.c

@vcarvalho12, Maybe this will help you - https://github.com/ValCher1961/McDebian_WRT3200ACM/wiki/%23-Using-external-drives-in-U-Boot

1 Like

I broke the uboot of the boards, I would like to know if there is any way to solve this

U-Boot 1.1.3 (Oct  7 2021 - 19:58:55)

Board: MediaTek APSoC DRAM: RAM size (0x00004000) too small !!! do_reset

[B0000000BC0226D001204D4152][BC0214F90000657A6973][A3650000][18188888][00000036]
DU Setting Cal Done


U-Boot 1.1.3 (Oct  7 2021 - 19:58:55)

Board: MediaTek APSoC DRAM: RAM size (0x00004000) too small !!! do_reset

[B0000000BC0226D001204D4152][BC0214F90000657A6973][A3650000][18188888][00000036]
DU Setting Cal Done


U-Boot 1.1.3 (Oct  7 2021 - 19:58:55)

Board: MediaTek APSoC DRAM: RAM size (0x00004000) too small !!! do_reset