通过网络引导u-boot
AM335X 可以使用支持 BOOTP 网络协议的工具从 ROM Bootloader (RBL) 引导加载程序。此功能允许开发人员通过网络加载 u-boot,内核甚至文件系统。
本章节介绍了如何将基于 Ubuntu 22.04 的 Linux 主机设置为 BOOTP 服务器。该主机于 beaglebone black 配合使用可以实现通过网络加载 u-boot,内核以及文件系统。
配置 dhcp 服务器
-
安装软件 sudo apt-get install isc-dhcp-server -
配置BOOTP/DHCP 服务器
编辑文件 /etc/dhcp/dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0
{
range dynamic-bootp 192.168.2.3 192.168.2.100;
if substring (option vendor-class-identifier, 0, 10) = "AM335x ROM"
{
filename "u-boot-spl-restore.bin";
}
elsif substring (option vendor-class-identifier, 0, 10) = "DM814x ROM"
{
filename "u-boot-spl-restore.bin";
}
elsif substring (option vendor-class-identifier, 0, 10) = "AM43xx ROM"
{
filename "u-boot-restore.img";
}
elsif substring (option vendor-class-identifier, 0, 17) = "AM335x U-Boot SPL"
{
filename "u-boot-restore.img";
}
elsif substring (option vendor-class-identifier, 0, 10) = "AM43xx U-B"
{
filename "u-boot-restore.img";
}
else
{
filename "zImage";
}
range 192.168.2.101 192.168.2.199;
}
subnet 192.168.5.0 netmask 255.255.255.0
{
range dynamic-bootp 192.168.5.3 192.168.5.100;
if substring (option vendor-class-identifier, 0, 10) = "AM335x ROM"
{
filename "u-boot-spl-restore.bin";
}
elsif substring (option vendor-class-identifier, 0, 10) = "DM814x ROM"
{
filename "u-boot-spl-restore.bin";
}
elsif substring (option vendor-class-identifier, 0, 10) = "AM43xx ROM"
{
filename "u-boot-restore.img";
}
elsif substring (option vendor-class-identifier, 0, 17) = "AM335x U-Boot SPL"
{
filename "u-boot-restore.img";
}
elsif substring (option vendor-class-identifier, 0, 10) = "AM43xx U-B"
{
filename "u-boot-restore.img";
}
else
{
filename "zImage";
}
range 192.168.5.101 192.168.5.199;
}
笔记
此配置创建了两个子网,其中 bootp 的 ip 地址范围分别是是 3-100。isc-dhcp-server 将使用此地址池响应客户端的获取 IP 地址请求。服务器(Ubuntu 22.04)需要配置两个 IP 地址(192.168.2.1 192.168.5.1),否则 dhcp 服务器将无法启动。
编辑文件/etc/default/isc-dhcp-server 并将适当的端口(例如 usb0 或 eth1)添加到 INTERFACES 选项,示例: NTERFACESv4="usb0 enx00e04c7407f1 enx00e04c7a5b96"
-
设置 TFTP 服务器,创建 TFTP 存储路径 参考上一章节内容 -
重启服务器以使配置生效 sudo service isc-dhcp-server restart
为主机配置静态 IP
DHCP 服务器设置好以后,我们需要为主机设置相应网段的静态 IP 地址,以保证 DHCP 服务器能够正常工作,设置静态 IP 的网卡要与 isc-dhcp-serve 文件中定义的接口一致
usb 模拟网卡配置
如果使用了 beaglebone black 的 usb 模拟网卡(usb0),由于 usb0 网卡在 beaglebone black 的不同启动阶段会上下波动,因此需要在 usb0 网卡启动后,重启 isc-dhcp-server,因此我们需要创建以下文件
路径:/etc/network/if-up.d/usb-interfaces
内容:
#!/bin/sh
if [ "$IFACE" = usb0 ]; then
sudo service isc-dhcp-server restart
fi
功能验证
从 SDK 的 prebuilt-images 文件夹拷贝 u-boot-spl.bin-am335x-evm u-boot-am335x-evm.img 到 TFTP 存储目录,分别重命名为 u-boot-spl-restore.bin u-boot-restore.img ,连接开发板的 usb 以及串口到主机,串口信息如下:
Welcome to minicom 2.8
OPTIONS: I18n
Port /dev/ttyUSB0, 16:01:25
Press CTRL-A Z for help on special keys
CCCCCCCC
U-Boot SPL 2021.01-g44a87e3ab8 (May 14 2022 - 22:32:40 +0000)
Trying to boot from USB eth
eth0: eth_cpsw, eth1: usb_ether
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
musb-hdrc: peripheral reset irq lost!
high speed config #2: 2 mA, Ethernet Gadget, using RNDIS
USB RNDIS network up!
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
DHCP client bound to address 192.168.2.4 (2001 ms)
Using usb_ether device
TFTP from server 192.168.2.1; our IP address is 192.168.2.4
Filename 'u-boot-restore.img'.
Load address: 0x82000000
Loading: #T ################################################################
#################################################################
##############################################
145.5 KiB/s
done
Bytes transferred = 897764 (db2e4 hex)
U-Boot 2021.01-g44a87e3ab8 (May 14 2022 - 22:32:40 +0000)
CPU : AM335X-GP rev 2.1
Model: TI AM335x BeagleBone Black
DRAM: 512 MiB
WDT: Started with servicing (60s timeout)
NAND: 0 MiB
MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1
Loading Environment from FAT... <ethaddr> not set. Validating first E-fuse MAC
Net: eth2: ethernet@4a100000, eth3: usb_ether
Hit any key to stop autoboot: 0
=>
=>
=> version
U-Boot 2021.01-g44a87e3ab8 (May 14 2022 - 22:32:40 +0000)
arm-none-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 9.2.1 20191025
GNU ld (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) 2.33.1.20191209
=>
|