其他分享
首页 > 其他分享> > Hi3518ev200:内核启动分析

Hi3518ev200:内核启动分析

作者:互联网

1)从DDR地址0x82000000加载内核镜像

hisilicon # bootm 82000000
## Booting kernel from Legacy Image at 82000000 ...
   Image Name:   Linux-4.9.37
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2206715 Bytes = 2.1 MiB
   Load Address: 80008000
   Entry Point:  80008000
   Loading Kernel Image ... OK
OK

Starting kernel ...

信息:内核为Linux-4.9.37,内核入口为DDR地址0x80008000。

镜像移动记录

刷机:SD卡 → DDR 0x82000000 → Flash 80000~280000

启动内核:Flash 80000~280000 → DDR 0x82000000 → 解压镜像文件到DDR 80008000

发现一个问题:uImage_kernel > 2MB,而Flash 80000~280000只分配了2MB。按道理应该会加载失败,或镜像文件不完整。但实际启动过程中又没有出现问题。

内核文件是vmlinux;zImage = 压缩的vmlinux + 一段解压启动代码;

uImage = zImage + 64字节头部信息(内核版本+加载位置+生成时间、大小等信息)


2)CPU信息

Booting Linux on physical CPU 0x0
Linux version 4.9.37 (root@virtual) (gcc version 6.2.1 20161016 (Hisilicon_v510_20180120) ) #5 Mon Sep 7 14:09:21 CST 2020
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=0005317f

① 启动CPU0,内核版本和编译信息

②CPU信息ARM926EJ-S,ARM-v5TEJ,


3)缓冲方式和设备树

CPU: VIVT data cache, VIVT instruction cache
OF: fdt:Machine model: Hisilicon HI3518EV20X DEMO Board

CPU缓存方式为VIVT,使用虚拟地址索引域和虚拟地址的标记域。More:https://blog.csdn.net/Q_AN1314/article/details/78980191

FDT:Flattened Device Tree即扁平设备树,方便管理内核其他子系统、设备。

设备树是一种描述硬件的数据结构,它起源于OpenFirmware(OF)。它的出现可以实现驱动代码和设备的硬件信息相互的隔离,减小了代码的耦合性。

驱动代码只要负责处理逻辑,而关于一些板级信息则放到设备树文件中,这样即使硬件接口信息变化,也不需要修改驱动逻辑,提高了驱动代码的复用性

More:https://blog.csdn.net/kunkliu/article/details/82846713

Memory policy: Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 8128
Kernel command line: mem=32M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtdparts=hi_sfc:512K(boot),2560K(kernel),13M(rootfs)

内存策略:数据缓存写回,即空闲时数据从cache中写回磁盘或主存。


4)

创建进程pid、文件inode、dentry cache(简称dcache,目录项高速缓存)的哈希表

PID hash table entries: 128 (order: -3, 512 bytes)
Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)

内核将所有进程存储在任务列表中,任务列表是一个循环双向链表。

我们要想通过pid找到要杀死的进程,一般来说需要遍历链表,然后删除节点;但如果将进程号和进程节点的映射关系添加到一个哈希表中,那么通过pid,我们可以用O(1)的时间找到对应进程节点,将其从链表中删除。(类似LRU,链表+哈希表映射)


5)内存区布局和内存管理
Memory: 26432K/32768K available (4317K kernel code, 143K rwdata, 944K rodata, 160K init, 228K bss, 6336K reserved, 0K cma-reserved)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xc2800000 - 0xff800000   ( 976 MB)
    lowmem  : 0xc0000000 - 0xc2000000   (  32 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc043fa20   (4319 kB)
      .init : 0xc054c000 - 0xc0574000   ( 160 kB)
      .data : 0xc0574000 - 0xc0597ea0   ( 144 kB)
       .bss : 0xc0597ea0 - 0xc05d0ff8   ( 229 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1

内核管理页面使用了2个算法:伙伴算法和SLUB算法,伙伴算法以页为单位管理内存,但在大多数情况下,程序需要的并不是完整的一页,而几个、几十个字节的小内存。

于是需要另一套系统来完成对小内存的管理,这就是slub系统。slub把一个4K内存页进行分组管理,每个组分别包含2^3、2^4、 …2^11个字节,和96B、192B,共有11个组。

Slub就相当于零售商,它向伙伴系统“批发”内存,然后再零售给出去。

SLUB算法原文:https://blog.csdn.net/lukuen/article/details/6935068


6)部分子系统和组件的初始化、外设和网络协议初始化
NR_IRQS:16 nr_irqs:16 16
VIC @fe0d0000: id 0x00641190, vendor 0x41
clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
Console: colour dummy device 80x30
Calibrating delay loop... 269.10 BogoMIPS (lpj=1345536)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x80008400 - 0x80008458
devtmpfs: initialized
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 256 (order: -1, 3072 bytes)


pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
Serial: AMBA PL011 UART driver
20080000.uart: ttyAMA0 at MMIO 0x20080000 (irq = 21, base_baud = 0) is a PL011 rev2
console [ttyAMA0] enabled
SCSI subsystem initialized
ssp-pl022 200c0000.spi: ARM PL022 driver, device ID: 0x00800022
ssp-pl022 200c0000.spi: mapped registers from 0x200c0000 to fe1c0000
ssp-pl022 200e0000.spi: ARM PL022 driver, device ID: 0x00800022
ssp-pl022 200e0000.spi: mapped registers from 0x200e0000 to fe1e0000
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
clocksource: Switched to clocksource arm,sp804

NET: Registered protocol family 2
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
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.
workingset: timestamp_bits=30 max_order=13 bucket_order=0
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
NET: Registered protocol family 38

Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
io scheduler noop registered
io scheduler deadline registered (default)
io scheduler cfq registered
pinctrl-single 200f0000.pinmux: 66 pins at pa fe1f0000 size 264
pinctrl-single 200f0800.pinconf: 76 pins at pa fe1f0800 size 304
pl061_gpio 20140000.gpio_chip: PL061 GPIO chip @0x20140000 registered
.......
pl061_gpio 201c0000.gpio_chip: PL061 GPIO chip @0x201c0000 registered

futext(fast userspace mutext),是Linux的一个基础组件,可以用来构建各种更高级的同步机制,比如锁、信号量等,POSIX信号量就是基于futex构建。


7)加载板级驱动:加载Flash驱动,创建分区、加载RTL8188FTV部分驱动;挂载文件系统

brd: module loaded
hisi-sfc hisi_spi_nor.0: SPI Nor ID Table Version 1.0
hisi-sfc hisi_spi_nor.0: all blocks is unlocked.
hisi-sfc hisi_spi_nor.0: w25q128 (Chipsize 16 Mbytes, Blocksize 64KiB)
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-0x000000080000 : "boot"
0x000000080000-0x000000300000 : "kernel"
0x000000300000-0x000001000000 : "rootfs"

ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-platform: EHCI generic platform driver
ehci-platform 100b0000.ehci: EHCI Host Controller
ehci-platform 100b0000.ehci: new USB bus registered, assigned bus number 1
ehci-platform 100b0000.ehci: irq 31, io mem 0x100b0000
ehci-platform 100b0000.ehci: USB 2.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
ohci-platform: OHCI generic platform driver
ohci-platform 100a0000.ohci: Generic Platform OHCI controller
ohci-platform 100a0000.ohci: new USB bus registered, assigned bus number 2
ohci-platform 100a0000.ohci: irq 32, io mem 0x100a0000
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
mousedev: PS/2 mouse device common for all mice
i2c /dev entries driver
hisi-i2c-hisilicon 200d0000.i2c: Hisilicon [i2c-0] probed!
hisi-i2c-hisilicon 20240000.i2c: Hisilicon [i2c-1] probed!
hisi-i2c-hisilicon 20250000.i2c: Hisilicon [i2c-2] probed!
himci: mmc host probe
himci: mmc host probe
usb 1-1: new high-speed USB device number 2 using ehci-platform
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
hisi-dmac 10060000.hidma-controller: hidmac probe!
NET: Registered protocol family 10
sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
NET: Registered protocol family 17
lib80211: common routines for IEEE802.11 drivers


mmc0: cannot verify signal voltage switch
himci: tuning mmc0: valid phase shift [0, 6] Final Phase 3
mmc0: new ultra high speed SDR104 SDHC card at address aaaa
mmcblk0: mmc0:aaaa SC16G 14.8 GiB 
 mmcblk0:
VFS: Mounted root (jffs2 filesystem) readonly on device 31:2.
devtmpfs: mounted
Freeing unused kernel memory: 160K (c054c000 - c0574000)
This architecture does not have kernel memory protection.
random: init: uninitialized urandom read (4 bytes read)

RTL8188FTV是一款 802.11b/g/n 2.4G 单芯片,集成了无线局域网 (WLAN) 和网络 USB 接口(兼容 USB 1.0/1.1/2.0)控制器。它在单个芯片中结合了 WLAN MAC、支持 1T1R 的 WLAN 基带和 WLAN RF。 为高吞吐量性能和低功耗的集成无线 LAN 设备提供了完整的解决方案。


8)加载WIFI模块驱动,启动udhcpc服务,挂载SD卡
Wed Jan  1 00:00:00 CST 2020

            _ _ _ _ _ _ _ _ _ _ _ _
            \  _  _   _  _ _ ___
            / /__/ \ |_/
           / __   /  -  _ ___
          / /  / /  / /
  _ _ _ _/ /  /  \_/  \_ ______
___________\___\__________________

[RCS]: /etc/init.d/S00devs
mknod: /dev/console: File exists
mknod: /dev/ttyAMA0: File exists
mknod: /dev/null: File exists
[RCS]: /etc/init.d/S01udev
udev[89]: starting version 167
[RCS]: /etc/init.d/S05dropbear
Not recognise ACTION:change
[RCS]: /etc/init.d/S80network
[RCS]: /etc/init.d/S90wifi
8188eu: loading out-of-tree module taints kernel.
random: fast init done
bFWReady == _FALSE call reset 8051...
usbcore: registered new interface driver rtl8188eu
==> rtl8188e_iol_efuse_patch
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Successfully initialized wpa_supplicant
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
udhcpc: started, v1.26.2
Setting IP address 0.0.0.0 on wlan0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
udhcpc: no lease, forking to background

FAT-fs (mmcblk0): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
mount: mounting /dev/mmcblk0p1 on /mnt/mmcblk0 failed: No such file or directory
mmz_start: 0x82000000, mmz_size: 32M

9)加载流媒体相关模块(海思SDK中提供的,与以后的开发有关)

The sensor_type 'ov9732' !!!
sys config init ok!
Hisilicon Media Memory Zone Manager
Module himedia: init ok
hi3518e_base: module license 'Proprietary' taints kernel.
Disabling lock debugging due to kernel taint
load sys.ko for Hi3518EV200...OK!
load tde.ko ...OK!
load region.ko ....OK!
load vgs.ko for Hi3518EV200...OK!
ISP Mod init!
load viu.ko for Hi3518EV200...OK!
load vpss.ko ....OK!
load vou.ko ....OK!
load hifb.ko OK!
load rc.ko ...OK!
load venc.ko ...OK!
load chnl.ko for Hi3518EV200...OK!
load h264e.ko ...OK!
load jpege.ko ...OK!
load ive.ko for Hi3518EV200...OK!
load sensor_i2c.ko ...OK!
==== Your input Sensor type is ov9732 ====
load pwm.ko ...OK!
load piris.ko ...OK!
acodec inited!
load hi3518e_aio.ko ...OK!
load ai.ko ...OK!
load ao.ko ...OK!
load aenc.ko ...OK!
load adec.ko ...OK!
insert audio
mipi_init
init phy power successful!
load hi_mipi.ko ...OK!

10)用户登陆

Auto login as root ...
Jan  1 00:00:23 login[190]: root login on 'ttyS000'
Welcome to HiLinux.
None of nfsroot found in cmdline.
~ # 

标签:load,...,OK,启动,driver,ko,init,内核,Hi3518ev200
来源: https://blog.csdn.net/weixin_43796767/article/details/117630532