【嵌入式Linux】U-boot移植

本文详细介绍了如何进行U-boot的移植和配置,包括下载最新稳定版源码、解决编译问题,以及针对JetsonNano的配置步骤。此外,还讲述了USB网卡的识别、驱动安装和测试过程,包括如何查看和启用USB设备,以及通过USB网卡进行网络通信的配置和测试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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)
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值