【Hi3516A开发板】初步调试分析--uboot

安装USB转串口驱动: CP2102 USB to UART Bridge Controller

链接:https://pan.baidu.com/s/1IPtQt08wfTuTFSPosYY5oQ 
提取码:y6rj

开发板上的的的uboot,kernel,rootfs

U-BOOT 2010.6   //u-boot版本
Linux version 3.4.35  //内核版本
jffs2  //文件系统
//机器平台:hi3516a

开发板连接电脑,启动后在SecureCRT中打印出如下信息:

U-Boot 2010.06 (Apr 10 2019 - 09:16:36)

Check spi flash controller v350... Found
Spi(cs1) ID: 0xC2 0x20 0x19 0xC2 0x20 0x19
Spi(cs1): Block:64KB Chip:32MB Name:"MX25L(256/257)35(E/F)"
Check Nand Flash Controller v610 ... found
Special NAND id table Version 1.36
Nand ID: 0x1B 0x1B 0x1B 0x1B 0x1B 0x1B 0x1B 0x1B
No NAND device found!!!
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0 
32768 KiB hi_sfc at 0:0 is now current device

## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-3.4.35
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2903568 Bytes = 2.8 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Loading Kernel Image ... OK
OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.4.35 (root@ubuntu) (gcc version 4.8.3 20131202 (prerelease) (Hisilicon_v300) ) #23 Sun Mar 18 22:28:34 PDT 2018
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: hi3516a
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),3M(kernel),12M(rootfs)
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 59224k/59224k available, 6312k reserved, 0K highmem
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc0522000   (5224 kB)
      .init : 0xc0522000 - 0xc05450b4   ( 141 kB)
      .data : 0xc0546000 - 0xc0572a20   ( 179 kB)
       .bss : 0xc0572a44 - 0xc05911d8   ( 122 kB)
SLUB: Genslabs=11, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:128
sched_clock: 32 bits at 49MHz, resolution 20ns, wraps every 86767ms
Console: colour dummy device 80x30
Calibrating delay loop... 1191.93 BogoMIPS (lpj=1191936)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
Initializing cgroup subsys freezer
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x803f90f0 - 0x803f9148
dummy: 
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
uart:0: ttyAMA0 at MMIO 0x20080000 (irq = 40) is a PL011 rev2
console [ttyAMA0] enabled
uart:1: ttyAMA1 at MMIO 0x20090000 (irq = 41) is a PL011 rev2
uart:2: ttyAMA2 at MMIO 0x200a0000 (irq = 42) is a PL011 rev2
uart:3: ttyAMA3 at MMIO 0x20230000 (irq = 43) is a PL011 rev2
bio: create slab <bio-0> at 0
SCSI subsystem initialized
hi-spi-master hi-spi-master.0: with 1 chip select slaves attached
hi-spi-master hi-spi-master.1: with 3 chip select slaves attached
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
cfg80211: Calling CRDA to update world regulatory domain
Switching to clocksource timer0
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
squashfs: version 4.0 (2009/01/31) Phillip Lougher
NFS: Registering the id_resolver key type
jffs2: version 2.2. (NAND)2001-2006 Red Hat, Inc.
fuse init (API version 7.18)
msgmni has been set to 115
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered (default)
io scheduler cfq registered
brd: module loaded
Spi id table Version 1.22
Spi(cs1) ID: 0xC2 0x20 0x19 0xC2 0x20 0x19
SPI nor flash boot mode is 3 Bytes
Spi(cs1): 
Block:64KB
Chip:32MB 
Name:"MX25L 256/257 35 E/F"
spi size: 32MB
chip num: 1
3 cmdlinepart partitions found on MTD device hi_sfc
3 cmdlinepart partitions found on MTD device hi_sfc
Creating 3 MTD partitions on "hi_sfc":
0x000000000000-0x000000100000 : "boot"
0x000000100000-0x000000400000 : "kernel"
0x000000400000-0x000001000000 : "rootfs"
Higmac dma_sg_phy: 0x83a00000
higmac_mdio_bus: probed
ETH0: rgmii, phy_addr=1, mii_name=mdio0
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
hiusb-ehci hiusb-ehci.0: HIUSB EHCI
hiusb-ehci hiusb-ehci.0: new USB bus registered, assigned bus number 1
hiusb-ehci hiusb-ehci.0: irq 53, io mem 0x100b0000
hiusb-ehci hiusb-ehci.0: USB 0.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
hiusb-ohci hiusb-ohci.0: HIUSB OHCI
hiusb-ohci hiusb-ohci.0: new USB bus registered, assigned bus number 2
hiusb-ohci hiusb-ohci.0: irq 54, io mem 0x100a0000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
Initializing USB Mass Storage driver...
usbcore: registered new interface driver usb-storage
USB Mass Storage support registered.
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
hisi_i2c hisi_i2c.0: Hisilicon [i2c-0] probed!
hisi_i2c hisi_i2c.1: Hisilicon [i2c-1] probed!
hisi_i2c hisi_i2c.2: Hisilicon [i2c-2] probed!
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
Initializing XFRM netlink socket
NET: Registered protocol family 17
NET: Registered protocol family 15
lib80211: common routines for IEEE802.11 drivers
Registering the dns_resolver key type
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
VFS: Mounted root (jffs2 filesystem) on device 31:2.
Freeing init memory: 140K
Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

错误1: 找不到NAND设备

No NAND device found!!!
*** Warning - bad CRC, using default environment

问题可能存在的原因:

  • nand flash中没有保存环境变量值,可使用saveenv保存环境变量试下;
  • 环境变量保存位置不正确,导致nand读取环境变量出错;
  • nand flash驱动存在问题,导致nand flash读写错误……

关于海思uboot的环境变量问题讨论

烧写NAND Flash时出现错误:*** Warning - bad CRC or NAND, using default environment

对于Kernel panic - not syncing: No init found出错的解决办法
错误2: 找不到init

Kernel panic - not syncing: No init found.   //找不到init
Try passing init= option to kernel.  //尝试通过init配置内核
See Linux Documentation/init.txt for guidance. //查看init.txt文档获取指导

提示去查阅init.tx文档
在这里插入图片描述
init指定的是内核启起来后,进入系统中运行的第一个脚本(二进制文件),一般init=linuxrc,运行init程序后,挂载文件系统等等操作

在init.txt文档中列出了几个找不到init的原因:

Some uhigh-level reasons for failure (listed roghly in order of execution)to load the init binary are:
//加载init初始化二进制文件失败的一些高级原因(按执行顺序列出):
A) Unable to mount root FS   //无法挂载根文件系统
B) init binary doesn't exist on rootfs  //rootfs根文件系统上不存在init初始化二进制文件
C) broken console device  //控制台设备损害
D) binary exists but dependencies not available  //二进制文件存在但依赖项不可用
E) binary cannot be loaded  //无法加载二进制文件

对应的几个解决方法说明:

Detailed explanations:
//详细说明
0) Set "debug" kernel parameter (in bootloader config file or CONFIG_CMDLINE)
   to get more detailed kernel messages.
//设置"调试"内核参数以获得更详细的内核消息(在引导加载程序配置文件或者CONFIG_CMDLINE中设置)

A) make sure you have the correct root FS type
   (and root= kernel parameter points to the correct partition),
   required drivers such as storage hardware (such as SCSI or USB!)
   and filesystem (ext3, jffs2 etc.) are builtin (alternatively as modules,
   to be pre-loaded by an initrd)
//确保具有正确的根文件系统类型,并且root=内核参数指向正确的分区
//需要的驱动程序例如存储硬件(SCSI或USB)以及根文件系统(ext3,jffs2等)时内置的(或者作为模块),由iinitrd预先加载

C) Possibly a conflict in console= setup --> initial console unavailable.
   E.g. some serial consoles are unreliable due to serial IRQ issues (e.g.
   missing interrupt-based configuration).
   Try using a different console= device or e.g. netconsole= .
//也许时控制台=设置-->初始控制台不可用,例如由于串行IRQ问题,某些串行控制台不可靠(例如缺少基于中断的配置)
//尝试使用其他控制台=设备,例如netconsole

D) e.g. required library dependencies of the init binary such as
   /lib/ld-linux.so.2 missing or broken. Use readelf -d <INIT>|grep NEEDED
   to find out which libraries are required.
//init初始化二进制的必需库依赖项(例如/lib/ld-linux.so.2)丢失或损坏
//可使用readelf -d <INIT>|grep NEEDED  来找出需要哪些库

E) make sure the binary's architecture matches your hardware.
   E.g. i386 vs. x86_64 mismatch, or trying to load x86 on ARM hardware.
//确保二进制文件的体系结构与硬件匹配,例如i386与x86_64就不匹配,或者是想ARM硬件上加载x86也是不行的

   In case you tried loading a non-binary file here (shell script?),
   you should make sure that the script specifies an interpreter in its shebang
   header line (#!/...) that is fully working (including its library
   dependencies). And before tackling scripts, better first test a simple
   non-script binary such as /bin/sh and confirm its successful execution.
//如果尝试在脚本上加载非二进制二年级,确保脚本在shebang中指定了解释器

   To find out more, add code to init/main.c to display kernel_execve()s
   return values.
//想要了解更多信息,可在init/main.c中添加代码来显示kernel_execve()的返回值

虽然出现了错误信息,但是还能进入u-boot界面
在这里插入图片描述

进入U-boot界面下分析

1,常用u-boot命令

base    - print or set address offset //查看基地址
go      - start application at address 'addr'  //执行裸机程序时用
nand    - NAND sub-system
nboot   - boot from NAND device
ping    - send ICMP ECHO_REQUEST to network host    //ping命令
printenv- print environment variables //打印环境变量
reset   - Perform RESET of the CPU //重启
saveenv - save environment variables to persistent storage  //保存环境变量
setenv  - set environment variables  //设置环境变量
tftp    - tftp  - download or upload image via network using TFTP protocol //下载或上传文件用

在这里插入图片描述

2,查看环境变量

hisilicon # printenv  //打印环境变量值
bootargs=mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:1M(boot),3M(kernel),12M(rootfs)
//bootargs这个参数非常重要,见后面详解
bootcmd=sf probe 0;sf read 0x82000000 0x100000 0x300000;bootm 0x82000000
//bootcmd是启动时默认执行的一些命令
bootdelay=1  //u-boot启动延时时间
baudrate=115200  //波特率
ethaddr=00:00:23:34:45:66  //以太网的MAC地址
ipaddr=192.168.12.32   //开发板上的IP地址
serverip=192.168.12.30 //服务器上的IP地址
netmask=255.255.255.0  //子网掩码
bootfile="uImage"
stdin=serial   //标准输入
stdout=serial  //标准输出
stderr=serial  //标准出错
verify=n
ver=U-Boot 2010.06 (Apr 10 2019 - 09:16:36) //u-boot版本

Environment size: 430/262140 bytes

在这里插入图片描述
参考:
uboot sf 命令用法

bootm跳转到kernel的流程

uboot分析之启动函数bootm命令

U_boot 的 bootcmd 和bootargs参数详解

u-boot 中 tftp、sf命令使用详解

发布了37 篇原创文章 · 获赞 13 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Chen_qi_hai/article/details/104604948