环境介绍

Win7 64 + Vmware 11 + ubuntu14.04 32

u-boot 版本:u-boot-2015-04

Linux kernel版本:linux-3.16.y

busybox版本:1_24_stable

交叉编译工具链:arm-linux-gnueabi-

qemu版本:stable-2.4

目的

本博文的目的是使用设备树来启动内核,这里有两种设备树传参方案,第一种是用u-boot,第二种是直接用Qemu启动kernel,然后在Qemu的命令行参数中利用-dtb将设备树文件传递过去。

关于设备树可以参考一下:http://www.cnblogs.com/pengdonglin137/p/4495056.html

步骤

1、配置u-boot

vexpress-a9的u-boot默认已经支持设备树了。

2、配置内核

vexpress-a9的kernel默认也已经支持了。

3、编译设备树

在内核源码根目录下执行如下命令:

make CROSS_COMPILE=arm-linux-gnueabi- ARCH=arm O=./out_vexpress_3_16 dtbs

然后会在out_vexpress_3_16/arch/arm/boot/dts/下生产如下几个文件

vexpress-v2p-ca15_a7.dtb  vexpress-v2p-ca15-tc1.dtb  vexpress-v2p-ca5s.dtb  vexpress-v2p-ca9.dtb

这里我们用vexpress-v2p-ca9.dtb,然后将其拷贝到/tftpboot下面

cp out_vexpress_3_16/arch/arm/boot/dts/vexpress-v2p-ca9.dtb /tftpboot/dtb

4、测试

执行如下命令

qemu-system-arm -M vexpress-a9 \
-kernel /root/tq2440_work/u-boot/u-boot/u-boot \
-nographic \
-m 512M \
-net nic,vlan= -net tap,vlan=,ifname=tap0 \
-sd /root/tq2440_work/busybox_study/a9rootfs.ext3

然后进入u-boot命令行模式,执行如下命令

setenv bootargs 'root=/dev/mmcblk0 console=ttyAMA0'
tftp 0x60003000 uImage
tftp 0x60500000 dtb
bootm 0x60003000 - 0x60500000

下面是启动信息:

U-Boot 2015.07-rc3--gf3edfd3-dirty (Dec   - :: -)

DRAM:   MiB
WARNING: Caches not enabled
Flash: MiB
MMC: MMC:
*** Warning - bad CRC, using default environment In: serial
Out: serial
Err: serial
Net: smc911x-
Warning: smc911x- using MAC address from net device Hit any key to stop autoboot:
VExpress# setenv bootargs 'root=/dev/mmcblk0 console=ttyAMA0'
VExpress# tftp 0x60003000 uImage
smc911x: MAC :::::
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC :::::
Using smc911x- device
TFTP from server 192.168.11.20; our IP address is 192.168.11.5
Filename 'uImage'.
Load address: 0x60003000
Loading: #################################################################
#################################################################
#################################################################
################################
698.2 KiB/s
done
Bytes transferred = (32cd30 hex)
smc911x: MAC :::::
VExpress# tftp 0x60500000 dtb
smc911x: MAC :::::
smc911x: detected LAN9118 controller
smc911x: phy initialized
smc911x: MAC :::::
Using smc911x- device
TFTP from server 192.168.11.20; our IP address is 192.168.11.5
Filename 'dtb'.
Load address: 0x60500000
Loading: #
971.7 KiB/s
done
Bytes transferred = (328d hex)
smc911x: MAC :::::
VExpress# bootm 0x60003000 - 0x60500000
## Booting kernel from Legacy Image at ...
Image Name: Linux-3.16.
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: Bytes = 3.2 MiB
Load Address:
Entry Point:
Verifying Checksum ... OK
## Flattened Device Tree blob at
Booting using the fdt blob at 0x60500000
Loading Kernel Image ... OK
Loading Device Tree to 7fee2000, end 7fee828c ... OK Starting kernel ... Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 3.16. (root@ubuntu) (gcc version 4.7. (Ubuntu/Linaro 4.7.-12ubuntu1) ) # SMP Sun Dec :: PST
CPU: ARMv7 Processor [410fc090] revision (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine model: V2P-CA9
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
PERCPU: Embedded pages/cpu @9ffcf000 s7552 r8192 d12928 u32768
Built zonelists in Zone order, mobility grouping on. Total pages:
Kernel command line: root=/dev/mmcblk0 console=ttyAMA0
PID hash table entries: (order: , bytes)
Dentry cache hash table entries: (order: , bytes)
Inode-cache hash table entries: (order: , bytes)
Memory: 513148K/524288K available (4567K kernel code, 191K rwdata, 1292K rodata, 239K init, 149K bss, 11140K reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( kB)
fixmap : 0xffc00000 - 0xffe00000 ( kB)
vmalloc : 0xa0800000 - 0xff000000 ( MB)
lowmem : 0x80000000 - 0xa0000000 ( MB)
modules : 0x7f000000 - 0x80000000 ( MB)
.text : 0x80008000 - 0x805c1238 ( kB)
.init : 0x805c2000 - 0x805fdd80 ( kB)
.data : 0x805fe000 - 0x8062dc20 ( kB)
.bss : 0x8062dc28 - 0x806533ec ( kB)
SLUB: HWalign=, Order=-, MinObjects=, CPUs=, Nodes=
Hierarchical RCU implementation.
RCU restricting CPUs from NR_CPUS= to nr_cpu_ids=.
RCU: Adjusting geometry for rcu_fanout_leaf=, nr_cpu_ids=
NR_IRQS: nr_irqs:
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
sched_clock: bits at 24MHz, resolution 41ns, wraps every 178956969942ns
Console: colour dummy device 80x30
Calibrating delay loop... 398.13 BogoMIPS (lpj=)
pid_max: default: minimum:
Mount-cache hash table entries: (order: , bytes)
Mountpoint-cache hash table entries: (order: , bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -, cpu , socket , mpidr
Setting up static identity map for 0x60455850 - 0x604558a8
CPU1: failed to boot: -
CPU2: failed to boot: -
CPU3: failed to boot: -
Brought up CPUs
SMP: Total of processors activated.
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.: implementor architecture part variant rev
regulator-dummy: no parameters
NET: Registered protocol family
DMA: preallocated KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
of_amba_device_create(): amba_device_add() failed (-) for /memory-controller@100e0000
of_amba_device_create(): amba_device_add() failed (-) for /memory-controller@100e1000
of_amba_device_create(): amba_device_add() failed (-) for /watchdog@100e5000
of_amba_device_create(): amba_device_add() failed (-) for /smb/motherboard/iofpga@,/sysctl@
of_amba_device_create(): amba_device_add() failed (-) for /smb/motherboard/iofpga@,/wdt@0f000
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
.uart: ttyAMA0 at MMIO 0x10009000 (irq = , base_baud = ) is a PL011 rev1
console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = , base_baud = ) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = , base_baud = ) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = , base_baud = ) is a PL011 rev1
3V3: mV
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource arm,sp804
NET: Registered protocol family
TCP established hash table entries: (order: , bytes)
TCP bind hash table entries: (order: , bytes)
TCP: Hash tables configured (established bind )
TCP: reno registered
UDP hash table entries: (order: , bytes)
UDP-Lite hash table entries: (order: , bytes)
NET: Registered protocol family
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4. backchannel transport module.
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, counters available
futex hash table entries: (order: , bytes)
squashfs: version 4.0 (//) Phillip Lougher
jffs2: version 2.2. (NAND) © - Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
msgmni has been set to
io scheduler noop registered (default)
clcd-pl11x: probe of .clcd failed with error -
clcd-pl11x: probe of 1001f000.clcd failed with error -
VD10: at mV
VD10_S2: at mV
VD10_S3: at mV
VCC1V8: at mV
DDR2VTT: at mV
VCC3V3: at mV
VIO: at mV
.flash: Found x16 devices at 0x0 in -bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
.flash: Found x16 devices at 0x0 in -bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(): "40000000.flash"
(): "40000000.flash"
into device "40000000.flash"
libphy: smsc911x-mdio: probed
smsc911x 4e000000.ethernet eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:, irq=-)
smsc911x 4e000000.ethernet eth0: MAC Address: :::::
nxp-isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
nxp-isp1760 4f000000.usb: new USB bus registered, assigned bus number
nxp-isp1760 4f000000.usb: Scratch test failed.
nxp-isp1760 4f000000.usb: can't setup: -19
nxp-isp1760 4f000000.usb: USB bus deregistered
usbcore: registered new interface driver usb-storage
mousedev: PS/ mouse device common for all mice
rtc-pl031 .rtc: rtc core: registered pl031 as rtc0
mmci-pl18x .mmci: Got CD GPIO #.
mmci-pl18x .mmci: Got WP GPIO #.
mmci-pl18x .mmci: No vqmmc regulator found
mmci-pl18x .mmci: mmc0: PL181 manf rev0 at 0x10005000 irq , (pio)
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
input: AT Raw Set keyboard as /devices/smb/smb:motherboard/smb:motherboard:iofpga@,/.kmi/serio0/input/input0
mmc0: new SD card at address
mmcblk0: mmc0: QEMU! 32.0 MiB
mmcblk0: unknown partition table
aaci-pl041 .aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
aaci-pl041 .aaci: FIFO entries
oprofile: using arm/armv7-ca9
TCP: cubic registered
NET: Registered protocol family
9pnet: Installing 9P2000 support
rtc-pl031 .rtc: setting system clock to -- :: UTC ()
ALSA device list:
#: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
input: ImExPS/ Generic Explorer Mouse as /devices/smb/smb:motherboard/smb:motherboard:iofpga@,/.kmi/serio1/input/input2
EXT3-fs (mmcblk0): recovery required on readonly filesystem
EXT3-fs (mmcblk0): write access will be enabled during recovery
kjournald starting. Commit interval seconds
EXT3-fs (mmcblk0): recovery complete
EXT3-fs (mmcblk0): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device :.
Freeing unused kernel memory: 236K (805c2000 - 805fd000)
random: nonblocking pool is initialized
smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0xa0900000, IRQ: Please press Enter to activate this console. [root@vexpress ]#
[root@vexpress ]#
[root@vexpress ]# ls /proc/device-tree/
#address-cells memory-controller@100e0000
#size-cells memory-controller@100e1000
aliases memory@
arm,hbi model
arm,vexpress,site name
cache-controller@1e00a000 pmu
chosen scu@1e000000
clcd@ smb
compatible timer@100e4000
cpus timer@1e000600
dcc watchdog@100e5000
interrupt-controller@1e001000 watchdog@1e000620

5、直接在Qemu的命令行中设置DT

执行如下命令

qemu-system-arm \
-M vexpress-a9 \
-m 512M \
-kernel /root/tq2440_work/kernel/linux-stable/out_vexpress_3_16/arch/arm/boot/zImage \
-nographic \
-append "root=/dev/mmcblk0 console=ttyAMA0" \
-sd /root/tq2440_work/busybox_study/a9rootfs.ext3 \
-dtb /tftpboot/dtb

启动信息:

Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Linux version 3.16. (root@ubuntu) (gcc version 4.7. (Ubuntu/Linaro 4.7.-12ubuntu1) ) # SMP Sun Dec :: PST
CPU: ARMv7 Processor [410fc090] revision (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine model: V2P-CA9
Memory policy: Data cache writeback
CPU: All CPU(s) started in SVC mode.
PERCPU: Embedded pages/cpu @9fbcf000 s7552 r8192 d12928 u32768
Built zonelists in Zone order, mobility grouping on. Total pages:
Kernel command line: root=/dev/mmcblk0 console=ttyAMA0
PID hash table entries: (order: , bytes)
Dentry cache hash table entries: (order: , bytes)
Inode-cache hash table entries: (order: , bytes)
Memory: 513116K/524288K available (4567K kernel code, 191K rwdata, 1292K rodata, 239K init, 149K bss, 11172K reserved)
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( kB)
fixmap : 0xffc00000 - 0xffe00000 ( kB)
vmalloc : 0xa0800000 - 0xff000000 ( MB)
lowmem : 0x80000000 - 0xa0000000 ( MB)
modules : 0x7f000000 - 0x80000000 ( MB)
.text : 0x80008000 - 0x805c1238 ( kB)
.init : 0x805c2000 - 0x805fdd80 ( kB)
.data : 0x805fe000 - 0x8062dc20 ( kB)
.bss : 0x8062dc28 - 0x806533ec ( kB)
SLUB: HWalign=, Order=-, MinObjects=, CPUs=, Nodes=
Hierarchical RCU implementation.
RCU restricting CPUs from NR_CPUS= to nr_cpu_ids=.
RCU: Adjusting geometry for rcu_fanout_leaf=, nr_cpu_ids=
NR_IRQS: nr_irqs:
GIC CPU mask not found - kernel will fail to boot.
GIC CPU mask not found - kernel will fail to boot.
sched_clock: bits at 24MHz, resolution 41ns, wraps every 178956969942ns
Console: colour dummy device 80x30
Calibrating delay loop... 286.10 BogoMIPS (lpj=)
pid_max: default: minimum:
Mount-cache hash table entries: (order: , bytes)
Mountpoint-cache hash table entries: (order: , bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -, cpu , socket , mpidr
Setting up static identity map for 0x60455850 - 0x604558a8
CPU1: failed to boot: -
CPU2: failed to boot: -
CPU3: failed to boot: -
Brought up CPUs
SMP: Total of processors activated.
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.: implementor architecture part variant rev
regulator-dummy: no parameters
NET: Registered protocol family
DMA: preallocated KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
of_amba_device_create(): amba_device_add() failed (-) for /memory-controller@100e0000
of_amba_device_create(): amba_device_add() failed (-) for /memory-controller@100e1000
of_amba_device_create(): amba_device_add() failed (-) for /watchdog@100e5000
of_amba_device_create(): amba_device_add() failed (-) for /smb/motherboard/iofpga@,/sysctl@
of_amba_device_create(): amba_device_add() failed (-) for /smb/motherboard/iofpga@,/wdt@0f000
hw-breakpoint: debug architecture 0x4 unsupported.
Serial: AMBA PL011 UART driver
.uart: ttyAMA0 at MMIO 0x10009000 (irq = , base_baud = ) is a PL011 rev1
console [ttyAMA0] enabled
1000a000.uart: ttyAMA1 at MMIO 0x1000a000 (irq = , base_baud = ) is a PL011 rev1
1000b000.uart: ttyAMA2 at MMIO 0x1000b000 (irq = , base_baud = ) is a PL011 rev1
1000c000.uart: ttyAMA3 at MMIO 0x1000c000 (irq = , base_baud = ) is a PL011 rev1
3V3: mV
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource arm,sp804
NET: Registered protocol family
TCP established hash table entries: (order: , bytes)
TCP bind hash table entries: (order: , bytes)
TCP: Hash tables configured (established bind )
TCP: reno registered
UDP hash table entries: (order: , bytes)
UDP-Lite hash table entries: (order: , bytes)
NET: Registered protocol family
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4. backchannel transport module.
hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, counters available
futex hash table entries: (order: , bytes)
squashfs: version 4.0 (//) Phillip Lougher
jffs2: version 2.2. (NAND) © - Red Hat, Inc.
9p: Installing v9fs 9p2000 file system support
msgmni has been set to
io scheduler noop registered (default)
clcd-pl11x: probe of .clcd failed with error -
clcd-pl11x: probe of 1001f000.clcd failed with error -
VD10: at mV
VD10_S2: at mV
VD10_S3: at mV
VCC1V8: at mV
DDR2VTT: at mV
VCC3V3: at mV
VIO: at mV
.flash: Found x16 devices at 0x0 in -bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
.flash: Found x16 devices at 0x0 in -bit bank. Manufacturer ID 0x000000 Chip ID 0x000000
Intel/Sharp Extended Query Table at 0x0031
Using buffer write method
Concatenating MTD devices:
(): "40000000.flash"
(): "40000000.flash"
into device "40000000.flash"
libphy: smsc911x-mdio: probed
smsc911x 4e000000.ethernet eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=4e000000.etherne:, irq=-)
smsc911x 4e000000.ethernet eth0: MAC Address: :::::
nxp-isp1760 4f000000.usb: NXP ISP1760 USB Host Controller
nxp-isp1760 4f000000.usb: new USB bus registered, assigned bus number
nxp-isp1760 4f000000.usb: Scratch test failed.
nxp-isp1760 4f000000.usb: can't setup: -19
nxp-isp1760 4f000000.usb: USB bus deregistered
usbcore: registered new interface driver usb-storage
mousedev: PS/ mouse device common for all mice
rtc-pl031 .rtc: rtc core: registered pl031 as rtc0
mmci-pl18x .mmci: Got CD GPIO #.
mmci-pl18x .mmci: Got WP GPIO #.
mmci-pl18x .mmci: No vqmmc regulator found
mmci-pl18x .mmci: mmc0: PL181 manf rev0 at 0x10005000 irq , (pio)
ledtrig-cpu: registered to indicate activity on CPUs
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
input: AT Raw Set keyboard as /devices/smb/smb:motherboard/smb:motherboard:iofpga@,/.kmi/serio0/input/input0
mmc0: new SD card at address
mmcblk0: mmc0: QEMU! 32.0 MiB
mmcblk0: unknown partition table
aaci-pl041 .aaci: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
aaci-pl041 .aaci: FIFO entries
oprofile: using arm/armv7-ca9
TCP: cubic registered
NET: Registered protocol family
9pnet: Installing 9P2000 support
rtc-pl031 .rtc: setting system clock to -- :: UTC ()
ALSA device list:
#: ARM AC'97 Interface PL041 rev0 at 0x10004000, irq 43
input: ImExPS/ Generic Explorer Mouse as /devices/smb/smb:motherboard/smb:motherboard:iofpga@,/.kmi/serio1/input/input2
kjournald starting. Commit interval seconds
EXT3-fs (mmcblk0): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device :.
Freeing unused kernel memory: 236K (805c2000 - 805fd000)
random: nonblocking pool is initialized
smsc911x 4e000000.ethernet eth0: SMSC911x/921x identified at 0xa0900000, IRQ: Please press Enter to activate this console. [root@vexpress ]#

未完待续。

最新文章

  1. MySQL之alter语句用法总结
  2. AOP 手动,半自动,全自动
  3. RBAC用户权限管理数据库设计
  4. OSPF协议详解
  5. winform之excel导入和导出
  6. QMap与QHash
  7. Linux 下查看文件字符编码和转换编码
  8. css禁止双击dom节点被选中user-select:none
  9. 对比iOS网络组件:AFNetworking VS ASIHTTPRequest(转载)
  10. spring security 11种过滤器介绍
  11. JS/CSS/IMG加载顺序关系之DOMContentLoaded事件
  12. 自定义带弹性效果的pageControl
  13. NSSortDescriptor(数组排序)
  14. bzoj1547 周末晚会
  15. [SQL] 从文本中提取数值
  16. Oracle 理论到实践之碎碎念
  17. Android中HttpURLConnection对象是怎么生成的
  18. https知识了解与javaweb中如何使用https
  19. python.pandas read and write CSV file
  20. dstat 性能测试工具常用选项

热门文章

  1. JAVA【一】
  2. RPC-Thrift(三)
  3. 【BZOJ2818】Gcd [莫比乌斯反演]
  4. bzoj1575 [Usaco2009 Jan]气象牛Baric
  5. [ CodeVS冲杯之路 ] P2492
  6. 【mysql优化1】表的优化与列类型选择
  7. Python学习笔记 - day6 - 函数
  8. vs附加到进程报MSVSMON.EXE未在远程计算机启动错误
  9. 【 Linux 网络虚拟化 】Netns
  10. 【LVS 】NAT方式实现过程