U-boot移植
配置编译
官网下载 //http://www.denx.de/wiki/U-Boot/WebHome -> https://source.denx.de/u-boot/u-boot
//->选最新的稳定版本 如v2022.01 -> 下载得u-boot.v2022.01.tar.bz2
$ tar -xvf u-boot.v2022.01.tar.bz2 //注意,不能再共享目录解压
$ make p3450-0000_defconfig /*导入官方配置
见p3450由来,https://docs.nvidia.com/jetson/archives/l4t-archived/l4t-3261/index.html
的u-boot构建 里面的 命令中的占位符 里面可查到 jetson nano 板子的id号
p3450-0000 p3450-0000_defconfig配置在configs下可查到,这是英伟达官方已做好的
报错: /bin/sh: 1: bison: not found
解决:sudo apt-get install bison
报错: /bin/sh: 1: flex: not found
解决:sudo apt-get install flex
*/
$ make CROSS_COMPILE=aarch64-linux-gnu- /* 编译时 需指定 交叉编译工具链(不用ARCH=arm指定 cpu体系结构,因前面导入配置里已指定)
报错:include/image.h:1133:12: fatal error: openssl/evp.h: 没有那个文件或目录
解决:sudo apt-get install libssl-dev
*/
$ cp u-boot.bin /tftpboot
板子上运行 /*能看到下面信息表示成功
U-Boot 2022.01 (Feb 25 2022 - 09:59:57 +0800)
SoC: tegra210
Model: NVIDIA Jetson Nano Developer Kit
Board: NVIDIA P3450-0000
DRAM: 3.5 GiB
MMC: sdhci@700b0000: 1, sdhci@700b0600: 0
*/
USB网卡移植
识别设备型号
usb网卡连入虚拟机
$ lsusb /*查看usb设备信息(里面有品牌信息)
Bus 004 Device 003: ID 2357:0601 TP-Link USB 10/100/1000 LAN usb网卡的信息
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 006: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 005: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
*/
$ lsusb -t /*查看usb 设备的树壮信息,里面有驱动信息
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
|__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=r8152, 5000M usb网卡的驱动是 r8152
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/7p, 12M
|__ Port 1: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 12M
|__ Port 2: Dev 3, If 0, Class=Hub, Driver=hub/7p, 480M
|__ Port 3: Dev 5, If 0, Class=Hub, Driver=hub/7p, 12M
|__ Port 4: Dev 6, If 0, Class=Hub, Driver=hub/7p, 480M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|__ Port 2: Dev 2, If 0, Class=Hub, Driver=hub/7p, 12M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/6p, 480M
*/
$ lsmod /*查看驱动模块是否安装
Module Size Used by
cdc_ether 20480 0
usbnet 49152 1 cdc_ether
r8152 110592 0
mii 20480 2 usbnet,r8152 驱动模块
vsock_loopback 16384 0
*/
$ lspci /*查看pci设备信息(网卡一般走PCI总线)
<pre>00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: Broadcom / LSI 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
...D
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
02:00.0 USB controller: VMware USB1.1 UHCI Controller
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
02:02.0 Multimedia audio controller: Ensoniq ES1371/ES1373 / Creative Labs CT2518 (rev 02)
02:03.0 USB controller: VMware USB2 EHCI Controller
02:05.0 SATA controller: VMware SATA AHCI controller
02:06.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
03:00.0 USB controller: VMware USB3 xHCI 1.0 Controller
</pre>
*/
OK示例参考(有线网卡)
1.运行测试
# pci enum;pci /*激活 并扫描pci总线(网卡一般走PCI总线)
电路图 从网卡 GBE_MDI0_P GBE_MDI0_N 配对 对应的是PCI总线的差分信号,-> 有线网卡是接PCI的,需激活pci,网卡才生效
Scanning PCI devices on bus 0
BusDevFun VendorId DeviceId Device Class Sub-Class
_____________________________________________________________
00.01.00 0x10de 0x0fae Bridge device 0x04
00.02.00 0x10de 0x0faf Bridge device 0x04
*/
# ping 192.168.9.119 /*能正常ping通
Using eth_rtl8169 device
host 192.168.9.119 is alive
*/
2.配置
$ make menuconfig
//配置命令支持
Command line interface
Device access commands
[*] pci - Access PCI devices
Device Drivers
//配置驱动支持
[*] Network device support
[*] Realtek 8169 series Ethernet controller driver
//配置PCI总线支持
[*] PCI support
[*] Tegra PCI support
3.配置的补充取消pci命令
4.源码
{//cmd/pci.c 命令
#if defined(CONFIG_DM_PCI)
"pci enum\n"
" - Enumerate PCI buses\n"
#endif
U_BOOT_CMD(
pci, 5, 1, do_pci,
"list and access PCI Configuration Space", pci_help_text
);
}
{//cmd/Makefile
ifdef CONFIG_PCI
obj-$(CONFIG_CMD_PCI) += pci.o
endif
}
{//cmd/Kconfig
config CMD_PCI
bool "pci - Access PCI devices"
help
}
{//drivers/net/rtl8169.c 驱动
ifdef CONFIG_DM_ETH
static int rtl8169_eth_probe(struct udevice *dev)
{
struct pci_child_platdata *pplat = dev_get_parent_platdata(dev);
struct rtl8169_private *priv = dev_get_priv(dev);
struct eth_pdata *plat = dev_get_platdata(dev);
u32 iobase;
int region;
int ret;
debug("rtl8169: REALTEK RTL8169 @0x%x\n", iobase);
switch (pplat->device) {
case 0x8168:
region = 2;
break;
dm_pci_read_config32(dev, PCI_BASE_ADDRESS_0 + region * 4, &iobase); //PCI
iobase &= ~0xf;
priv->iobase = (int)dm_pci_mem_to_phys(dev, iobase);
ret = rtl_init(priv->iobase, dev->name, plat->enetaddr);
if (ret < 0) {
printf(pr_fmt("failed to initialize card: %d\n"), ret);
return ret;
}
}
}
static const struct udevice_id rtl8169_eth_ids[] = {
{ .compatible = "realtek,rtl8169" },
{ }
};
U_BOOT_DRIVER(eth_rtl8169) = {
.name = "eth_rtl8169",
.id = UCLASS_ETH,
.of_match = rtl8169_eth_ids,
.probe = rtl8169_eth_probe,
.ops = &rtl8169_eth_ops,
.priv_auto_alloc_size = sizeof(struct rtl8169_private),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
};
U_BOOT_PCI_DEVICE(eth_rtl8169, supported); //网卡是走PCI总线
}
{//drivers/net/Makefile
obj-$(CONFIG_RTL8169) += rtl8169.o
}
{//drivers/net/Kconfig
config RTL8169
bool "Realtek 8169 series Ethernet controler driver"
}
5.电路图芯片手册
//----2.3板子电路图Jetson_Nano_Carrier_Board_OrCAD_Schematics.pdf
Gigabit Ethernet with PoE -> GBE_MDI0_P
//----2.2板子芯片手册JetsonNano_DataSheet_DS09366001v1.0.pdf
4.2 PCI Express (PCIe)
PCIE_WAKE //唤醒
PCIE0_CLK_N PCIE0_CLK_P //差分信号的参考时钟
PCIE0_CLKREQ //时钟请求
PCIE0_RST //复位
//lane 0通道: 两对 收发 差分信号: 振幅相同,相位相反 -> 抗干扰
PCIE0_RX0_P //接收端 正极差分信号
PCIE0_RX0_N //接收端 负极差分信号
PCIE0_TX0_P //发送端 正极差分信号
PCIE0_TX0_N //发送端 负极差分信号
//lane 1通道:
//lane 2通道:
//lane 3通道:
//----3.1CPU芯片手册Tegra_X1_TRM_DP07225001_v1.3p.pdf
CHAPTER 34: PCI EXPRESS (PCIe) CONTROLLER
思考
老版本u-boot里没有8169,如何才能移植使它支持呢
当前u-boot里没有8169,最新的u-boot里才有,如何移植呢
移植USB命令
1.运行测试
//检测usb命令有没
板子上插入usb网卡
# usb /* usb命令使用说明
usb - USB sub-system
Usage:
usb start - start (scan) USB controller
usb reset - reset (rescan) USB controller
usb stop [f] - stop USB [f]=force stop
usb tree - show USB device tree
usb info [dev] - show available USB devices
usb test [dev] [port] [mode] - set USB 2.0 test mode
(specify port 0 to indicate the device's upstream port)
Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]
usb storage - show details of USB storage devices
usb dev [dev] - show or set current USB storage device
usb part [dev] - print partition table of one or all USB storage devices
usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'
to memory address `addr'
usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'
from memory address `addr'
*/
# usb start /* 启动(扫描)usb控制器
starting USB...
Bus usb@7d000000: tegrausb: Invalid dr_mode 2 for host mode
probe failed, error -1
Bus xusb@70090000:
Firmware size 126464
Firmware timestamp: 0x5f23e558, Version: 50.26 release
Register HCSParams1: 9000124 NbrPorts: 9
Starting the controller
USB XHCI 1.00
scanning bus xusb@70090000 for devices... 5 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
*/
# usb tree /* 查看usb的设备树
USB device tree:
1 Hub (5 Gb/s, 0mA)
| U-Boot XHCI Host Controller
|
+-2 Hub (480 Mb/s, 0mA)
| | Generic 4-Port USB 2.1 Hub
| |
| +-4 Hub (480 Mb/s, 100mA)
| | USB 2.0 Hub
| |
| +-5 Vendor specific (480 Mb/s, 100mA)
| Realtek USB 10/100 LAN 00E04C3603EA usb网卡 是Realtek的
|
+-3 (12 Mb/s, 100mA)
*/
# usb infor /*查看usb的设备 的信息
5: Vendor specific, USB Revision 2.10
- Realtek USB 10/100 LAN 00E04C3603EA
- Class: (from Interface) Vendor specific
- PacketSize: 64 Configurations: 2
- Vendor: 0x0bda Product 0x8152 Version 32.0 网卡芯片型号 8152
Configuration: 1
- Interfaces: 1 Bus Powered Remote Wakeup 100mA
Interface: 0
- Alternate Setting 0, Endpoints: 3
- Class Vendor specific
- Endpoint 1 In Bulk MaxPacket 512
- Endpoint 2 Out Bulk MaxPacket 512
- Endpoint 3 In Interrupt MaxPacket 2 Interval 8ms
*/
//注意:如果usb命令没有,或一些信息不对,需配置u-boot usb相关配置选项
2.配置
$ make menuconfig
//配置命令支持
Command line interface
Device access commands
[*] usb
3.源码
{//cmd/Kconfig
config CMD_USB
bool "usb"
select HAVE_BLOCK_DEVICE
help
USB support.
}
{//cmd/Makefile
obj-$(CONFIG_CMD_USB) += usb.o disk.o
}
{//cmd/usb.c usb命令(u-boot里大部分功能触发,通过命令)
U_BOOT_CMD(
usb, 5, 1, do_usb,
"USB sub-system",
"start - start (scan) USB controller\n"
"usb reset - reset (rescan) USB controller\n"
"usb stop [f] - stop USB [f]=force stop\n"
"usb tree - show USB device tree\n"
"usb info [dev] - show available USB devices\n"
"usb test [dev] [port] [mode] - set USB 2.0 test mode\n"
" (specify port 0 to indicate the device's upstream port)\n"
" Available modes: J, K, S[E0_NAK], P[acket], F[orce_Enable]\n"
#ifdef CONFIG_USB_STORAGE
"usb storage - show details of USB storage devices\n"
"usb dev [dev] - show or set current USB storage device\n"
"usb part [dev] - print partition table of one or all USB storage"
" devices\n"
"usb read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"
" to memory address `addr'\n"
"usb write addr blk# cnt - write `cnt' blocks starting at block `blk#'\n"
" from memory address `addr'"
#endif /* CONFIG_USB_STORAGE */
);
}
移植网卡驱动
$ make menuconfig
Device Drivers
USB support
//配置总线支持
[*] Enable driver model for USB
[*] xHCI HCD (USB 3.0) support
[*] Support for NVIDIA Tegra T210 on-chip XHCI USB controller
[*] EHCI HCD (USB 2.0) support
[*] Support for NVIDIA Tegra on-chip EHCI USB controller
//配置驱动支持
USB to Ethernet Controller Drivers
[*] Realtek RTL8152B/RTL8153 support
$ make
$ cp u-boo.bin /tftpboot
1.运行测试
# setenv bootcmd pci enum \; pci \; tftp u-boot.bin //内存中测试u-boot
# reset
# goraw 0x84000000
# usb start 启动(扫描)usb控制器
把网线从网口拔出,插入到usb网卡
# ping 192.168.9.119 //测试网络
Using r8152_eth device //发现该信息表示8152驱动有加载(用自带的网卡时打印信息是
host 192.168.9.119 is alive //表示网卡成功启动
# tftp u-boot.bin //发现用该网卡,能成功下载。移植成功
//注意切换回原网卡时,需切换pci总线
# usb stop //关闭usb网卡
# pci enum;pci
# ping 192.168.9.119 //发现失败,不能切换到原网卡,原因不明
2.源码
//drivers/usb/eth/r8152.c
3.电路图芯片手册
//----2.3板子电路图Jetson_Nano_Carrier_Board_OrCAD_Schematics.pdf
//----2.2板子芯片手册JetsonNano_DataSheet_DS09366001v1.0.pdf
//----3.1CPU芯片手册Tegra_X1_TRM_DP07225001_v1.3p.pdf
CHAPTER 22: USB COMPLEX
框图 //Figure 51: Tegra X1 USB Controllers and Interfaces
4.挑战:尝试
看能否两个网卡同时工作,或可切换工作
U盘启动
启动盘优先顺序
启动盘优先顺序 //SD卡 -> 内部eMMC ->USB 设备(或 NVMe 设备) -> 通过 DHCP/PXE 的 NFS 网络
# run distro_bootcmd //按启动盘优先顺序 选择启动
# setenv bootcmd run distro_bootcmd //设置自启动命令,为按启动盘优先顺序 选择启动
# saveenv
UBOOT环境变量
arch=arm
baudrate=115200
board=p3450-0000
board_name=p3450-0000
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_dcache_off=dcache off
boot_efi_binary=if fdt addr ${fdt_addr_r}; then bootefi bootmgr ${fdt_addr_r};else bootefi bootmgr ${fdtcontroladdr};fi;load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootaa64.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}${boot_syslinux_conf}
boot_net_usb_start=usb start
boot_pci_enum=pci enum //扫描激活pci总线
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_syslinux_conf=extlinux/extlinux.conf
boot_targets=mmc1 mmc0 usb0 nvme0 pxe dhcp //启动顺序:SD卡(mmc1) -> 内部eMMC(mmc0) -> USB 设备(usb0) -> 通过 DHCP的 NFS 网络
//NVMe 设备(仅限 Jetson TX2 系列才有)
bootcmd=run distro_bootcmd
bootcmd_dhcp=run boot_net_usb_start; run boot_pci_enum; if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi;setenv efi_fdtfile ${fdtfile}; setenv efi_old_vci ${bootp_vci};setenv efi_old_arch ${bootp_arch};setenv bootp_vci PXEClient:Arch:00011:UNDI:003000;setenv bootp_arch 0xb;if dhcp ${kernel_addr_r}; then tftpboot ${fdt_addr_r} dtb/${efi_fdtfile};if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r}; else bootefi ${kernel_addr_r} ${fdtcontroladdr};fi;fi;setenv bootp_vci ${efi_old_vci};setenv bootp_arch ${efi_old_arch};setenv efi_fdtfile;setenv efi_old_arch;setenv efi_old_vci;
bootcmd_mmc0=devnum=0; run mmc_boot
bootcmd_mmc1=devnum=1; run mmc_boot
bootcmd_nvme0=devnum=0; run nvme_boot
bootcmd_pxe=run boot_net_usb_start; run boot_pci_enum; dhcp; if pxe get; then pxe boot; fi
bootcmd_usb0=devnum=0; run usb_boot
bootdelay=2
cbootargs=tegraid=21.1.2.0.0 ddr_die=4096M@2048M section=512M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,4 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff780000 core_edp_mv=1075 core_edp_ma=4000 gpt earlycon=uart8250,mmio32,0x70006000 root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
cpu=armv8
distro_bootcmd=setenv nvme_need_init; for target in ${boot_targets}; do run bootcmd_${target}; done
//按boot_targets,顺序选择启动设备。
efi_dtb_prefixes=/ /dtb/ /dtb/current/
ethact=eth_rtl8169
ethaddr=48:b0:2d:51:f9:45
fdt_addr=83100000
fdt_addr_r=0x83000000
fdt_copy_node_paths=/chosen/plugin-manager:/chosen/reset:/chosen/display-board:/chosen/proc-board:/chosen/pmu-board:/external-memory-controller@7001b000:/memory@80000000
fdt_copy_prop_paths=/bpmp/carveout-start:/bpmp/carveout-size:/chosen/eks_info:/chosen/nvidia,bluetooth-mac:/chosen/nvidia,ethernet-mac:/chosen/nvidia,wifi-mac:/chosen/uuid:/chosen/linux,initrd-start:/chosen/linux,initrd-end:/serial-number:/psci/nvidia,system-lp0-disable
fdt_copy_src_addr=83100000
fdt_high=ffffffffffffffff
fdtcontroladdr=fc5fa380
fdtoverlay_addr_r=0x90200000
fileaddr=84000000
filesize=a6d84
initrd_high=ffffffffffffffff
ipaddr=192.168.9.9
kernel_addr_r=0x84000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x84000000
//从flash启动
mmc_boot=if mmc dev ${devnum}; then devtype=mmc; run scan_dev_for_boot_part; fi
nvme_boot=run boot_pci_enum; run boot_dcache_off; run nvme_init; if nvme dev ${devnum}; then devtype=nvme; run scan_dev_for_boot_part; fi
nvme_init=if ${nvme_need_init}; then setenv nvme_need_init false; nvme scan; fi
preboot=if test -e mmc 1:1 /u-boot-preboot.scr; then load mmc 1:1 ${scriptaddr} /u-boot-preboot.scr; source ${scriptaddr}; fi
pxefile_addr_r=0x90100000
ramdisk_addr_r=0x83200000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done; setenv devplist
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootaa64.efi; then echo Found EFI removable media binary efi/boot/bootaa64.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${boot_syslinux_conf}; then echo Found ${prefix}${boot_syslinux_conf}; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x90000000
serverip=192.168.9.119
soc=tegra210
stderr=serial
stdin=serial
stdout=serial
//从usb启动
usb_boot=run boot_pci_enum; usb start; if usb dev ${devnum}; then devtype=usb; run scan_dev_for_boot_part; fi
vendor=nvidia
xusb_fw_addr=92ca828c
Environment size: 5340/8188 bytes
加载内核启动
1.传统加载内核方式
2.从应用层加载内核
把内核放到文件系统中 /boot/Image //在应用层 ,可像普通文件一样更新内核
*3.实现原理
extlinux启动 //从文件系统中加载内核启动
//u-boot -> 从sd卡加载 初始小文件系统(ramdisk) -> 再从该文件系统里加载 kernel. 和挂载rootfs
extlinux.conf /*启动配置文件
注意:u-boot 通过 /boot/extlinux/extlinux.conf 里指定加载的内核,和挂载根文件系统的位置
LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image //指定启动的内核名
INITRD /boot/initrd //指定初始ramdisk(u-boot加载内核用)
APPEND ${cbootargs} rootfstype=ext4 root=/dev/mmcblk0p1 rw rootwait //指定文件系统
root=/dev/mmcblk0p1 指定要挂载的根文件系统的位置 是sd卡的第一个分区
mmcblk 指“ flash/sd块设备”,0 是设备的顺序编号,p1 就是第一个分区。
sda 是硬盘的命名规则,很多U盘 硬件 ext2格式的文件系统都是按这个去分区
sda表示第一块硬盘 sda1表示第一个分区, sdb表示第二块硬盘
*/
为何需要 extlinux /*目的是能把内核镜像,放在文件系统中,u-boot可以读取,
替换方便,可远程登录板子,可像普通文件一样替换内核即可
传统方式,是u-boot 是加载内核后,才能看到文件系统,
如要更改,要用脚本刷分区才行。
如 sudo ./flash.sh -k LNX jetson-nano-qspi-sd mmcblk0p1
*/
虚拟机里:更改U盘分区信息
把sd卡通过读卡器,接入虚拟机里。
$ cd /media/yhai/b1c100cd-cc74-4e7f-acb8-f0d34c931ee8/ //接入虚拟机后自动识别的目录
yhai@yhai:~$ sudo parted /dev/sdc /*查看分区表
编号 起始点 结束点 大小 文件系统 名称 标志
2 1049kB 1180kB 131kB TBC
3 2097kB 2556kB 459kB RP1
4 3146kB 3736kB 590kB EBT
5 4194kB 4260kB 65.5kB WB0
6 5243kB 5439kB 197kB BPF
7 6291kB 6685kB 393kB BPF-DTB
8 7340kB 7406kB 65.5kB FX
9 8389kB 8847kB 459kB TOS
10 9437kB 9896kB 459kB DTB //设备树
11 10.5MB 11.3MB 786kB LNX //u-boot
12 11.5MB 11.6MB 65.5kB EKS
13 12.6MB 12.8MB 197kB BMP
14 13.6MB 13.8MB 131kB RP4
1 14.7MB 128GB 128GB ext4 APP //存放 rootfs(app的存储场所)
*/
$ sudo boot/extlinux/extlinux.conf /*更改启动分区
把 root=/dev/mmcblk0p1
改为 root=/dev/sda1
mmcblk 指“ flash/sd块设备”,0 是设备的顺序编号,p1 就是第一个分区。
sda 是硬盘的命名规则,很多U盘 硬件 ext2格式的文件系统都是按这个去分区
sda表示第一块硬盘 sda1表示第一个分区, sdb表示第二块硬盘
*/
板子上:设置从U盘启动
插入到板子USB
# run usb_boot //从u盘启动
# setenv bootcmd run usb_boot //设置自动启动从u盘启动
# saveenv
# reset //复位后 发现能成功从U盘启动了