uboot: HTTP netboot support

If we receive an option 67 (bootfile) matching http://IP/rootfs.itb,
use U-Boot's wget implementation to download the file. The web server
must listen on port 80. tftp:// is also supported.

Without a protocol prefix, assume that the bootfile should be fetched
using TFTP from ${serverip}.
This commit is contained in:
Tobias Waldekranz
2024-06-17 14:59:27 +02:00
parent ccb17b1c91
commit ba73f3e832
2 changed files with 27 additions and 11 deletions
+4
View File
@@ -26,6 +26,10 @@ CONFIG_CMD_MMC=y
CONFIG_FS_SQUASHFS=y
CONFIG_CMD_SQUASHFS=y
CONFIG_PROT_TCP=y
CONFIG_PROT_TCP_SACK=y
CONFIG_CMD_WGET=y
CONFIG_USE_PREBOOT=y
CONFIG_CMD_BOOTMENU=y
CONFIG_CMD_PAUSE=y
+23 -11
View File
@@ -1,16 +1,28 @@
if dhcp ${ramdisk_addr_r}; then
setenv autoload no
setenv old_fdt_addr ${fdt_addr}
if fdt addr ${ramdisk_addr_r}; then
fdt get value sqoffs /images/rootfs data-position
fdt get value sqsize /images/rootfs data-size
fdt addr ${old_fdt_addr}
if dhcp; then
setenv proto tftp
setenv dltool tftpboot
setexpr sqaddr ${ramdisk_addr_r} + ${sqoffs}
setexpr sqblkcnt ${sqsize} / 0x200
setexpr sqkbsize ${sqsize} / 0x400
if setexpr proto sub "^(http|tftp)://.*" "\\1" "${bootfile}" && setexpr bootfile sub "^(http|tftp)://([^/]+?)/(.*)" "\2:\3"; then
if test "${proto}" = "http"; then
setenv dltool wget
fi
fi
setenv bootargs_root "root=/dev/ram0 ramdisk_size=0x${sqkbsize} initrd=0x${sqaddr},${sqsize}"
setenv prepared ok
if ${dltool} ${ramdisk_addr_r} "${bootfile}"; then
setenv old_fdt_addr ${fdt_addr}
if fdt addr ${ramdisk_addr_r}; then
fdt get value sqoffs /images/rootfs data-position
fdt get value sqsize /images/rootfs data-size
fdt addr ${old_fdt_addr}
setexpr sqaddr ${ramdisk_addr_r} + ${sqoffs}
setexpr sqblkcnt ${sqsize} / 0x200
setexpr sqkbsize ${sqsize} / 0x400
setenv bootargs_root "root=/dev/ram0 ramdisk_size=0x${sqkbsize} initrd=0x${sqaddr},${sqsize}"
setenv prepared ok
fi
fi
fi