pcDuino的linux移植三
pcduino的linux移植二内核是启动了,但是还存在问题,先分析启动信息,再移植根文件系统问题一:** Unable to read "uEnv.txt" from mmc 0:1 **部分启动信息:reading uEnv.txt** Unable to read "uEnv.txt" from mmc 0:1 **Loading file "uEnv.txt" from mmc device 0:1很明显找不到uEnv.txt,uEnv.txt是设置启动参数的,生成过程boot.cmd——>boot.src——>uEnv.txt1.创建boot.cmd设置启动参数。boot.cmd:setenv bootargs console=ttyS0,115200 noinitrd root=/dev/mmcblk0p2 init=/sbin/init rootwait panic=10 ${extra}
fatload mmc 0 0x43000000 boot/script.bin
fatload mmc 0 0x48000000 boot/uImage
bootm 0x480000002.根据boot.cmd生成u-boot能够读取的boot.src文件mkimage -C none -A arm -T script -d boot.cmd boot.scr3.据说老版本的u-boot能读取boot.scr,新版本的不能直接读取。为了验证这个,我先只用boot.scr,不行再通过uEnv.txt读取boot.scr:bootenv=boot.scr
loaduimage=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
mmcboot=echo Running boot.scr script from mmc ...; source ${loadaddr}4.烧写实验直接用boot.scr:change@change:~/Si/A10/pcduino$ vim boot.cmdsetenv bootargs console=ttyS0,115200 noinitrd root=/dev/mmcblk0p2 init=/sbin/init rootwait panic=10 ${extra}
fatload mmc 0 0x43000000 boot/script.bin
fatload mmc 0 0x48000000 boot/uImage
bootm 0x48000000保存退出change@change:~/Si/A10/pcduino$ mkimage -C none -A arm -T script -d boot.cmd boot.scr
Image Name:
Created: Sat Apr 20 21:41:43 2013
Image Type: ARM Linux Script (uncompressed)
Data Size: 225 Bytes = 0.22 kB = 0.00 MB
Load Address: 00000000
Entry Point:00000000
Contents:
Image 0: 217 Bytes = 0.21 kB = 0.00 MB若干这里mkimage报错或移植二中make uImage报错,需要将编译u-boot是生成的tools目录下的mkimage拷贝到/usr/local/bin,即可解决问题change@change:~/Si/A10/pcduino$ sudo mount /dev/sdb1 /mnt/
password for change:
change@change:~/Si/A10/pcduino$ cp boot.scr /mnt/放到pcduino tf卡槽,设置串口 115200 8 n 1启动信息还是U-Boot SPL 2012.10 (Apr 19 2013 - 18:46:44)
DRAM: 1024MB
SUNXI SD/MMC: 0
U-Boot 2012.10 (Apr 19 2013 - 18:46:44) Allwinner TechnologyCPU: SUNXI Family
Board: pcDuino
I2C: ready
DRAM:1 GiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environmentIn: serial
Out: serial
Err: serial
Hit any key to stop autoboot:0
reading uEnv.txt** Unable to read "uEnv.txt" from mmc 0:1 **
Loading file "uEnv.txt" from mmc device 0:1
Failed to mount ext2 filesystem...
** Bad ext2 partition or disk - mmc 0:1 **
ext2load - load binary file from a Ext2 filesystem看来还是得用uEnv.txt读取boot.scrchange@change:~/Si/A10/pcduino$ vim uEnv.txtbootenv=boot.scr
loaduimage=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
mmcboot=echo Running boot.scr script from mmc ...; source ${loadaddr}保存,退出,tf卡插到UBUNTU变/dev/sdcchange@change:~/Si/A10/pcduino$ sudo mount /dev/sdc1 /mnt/
change@change:~/Si/A10/pcduino$ cp uEnv.txt /mnt/
change@change:~/Si/A10/pcduino$ sudo umount /dev/sdc1 /mnt/
umount: /mnt: not mountedtf卡插到pcduino卡槽,连接串口设置115200 8 n 1,启动信息如下:U-Boot 2012.10 (Apr 19 2013 - 18:46:44) Allwinner TechnologyCPU: SUNXI Family
Board: pcDuino
I2C: ready
DRAM:1 GiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environmentIn: serial
Out: serial
Err: serial
Hit any key to stop autoboot:0
reading uEnv.txt144 bytes read
Loaded environment from uEnv.txt
reading boot.scr289 bytes read
Jumping to boot.scr
## Executing script at 44000000
Wrong image format for "source" command
reading script.bin44900 bytes read
reading uImage4693132 bytes read
## Booting kernel from Legacy Image at 48000000 ...
Image Name: Linux-3.0.62
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4693068 Bytes = 4.5 MiB
Load Address: 40008000
Entry Point:40008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OKStarting kernel ...<6>Initializing cgroup subsys cpuset
<5>Linux version 3.0.62 (change@change) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #1 PREEMPT Sat Apr 20 18:32:39 CST 2013
CPU: ARMv7 Processor revision 2 (ARMv7), cr=10c5387d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: sun4i
<6>Memory cut off:
<6> MALI : 0x5c000000 - 0x5fffffff(64 MB)
<4>Ignoring unrecognised tag 0x00000000
<6>Memory Reserved:
<6> SYS: 0x43000000 - 0x4300ffff(64 kB)
<6> VE : 0x44000000 - 0x48ffffff(80 MB)
<6> G2D: 0x49000000 - 0x49ffffff(16 MB)
<6> LCD: 0x5a000000 - 0x5bffffff(32 MB)
Memory policy: ECC disabled, Data cache writeback
<6>chip-id: A10 (AW1623 revision C)
<7>On node 0 totalpages: 245760
<7>free_area_init_node: node 0, pgdat c0887ea0, node_mem_map c094e000
<7>Normal zone: 1280 pages used for memmap
<7>Normal zone: 0 pages reserved
<7>Normal zone: 146176 pages, LIFO batch:31
<7>HighMem zone: 768 pages used for memmap
<7>HighMem zone: 97536 pages, LIFO batch:31
<7>pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
<7>pcpu-alloc: 0
Built 1 zonelists in Zone order, mobility grouping on.Total pages: 243712
<5>Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait loglevel=8 panic=10
<6>PID hash table entries: 4096 (order: 2, 16384 bytes)
<6>Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
<6>Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
<6>Memory: 448MB 512MB = 960MB total
<5>Memory: 833852k/833852k available, 149188k reserved, 393216K highmem
<5>Virtual kernel memory layout:
vector: 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap: 0xfff00000 - 0xfffe0000 ( 896 kB).........太长了此处省略若干,通过上面的启动信息发现uEnv.txt读取正常<0>Kernel panic - not syncing: Attempted to kill init!
[ 2.650000] Kernel panic - not syncing: Attempted to kill init!
[<c003e92c>] (unwind_backtrace+0x0/0x13c) from [<c05fa2ac>] (panic+0x74/0x188)
[ 2.660000] [<c003e92c>] (unwind_backtrace+0x0/0x13c) from [<c05fa2ac>] (panic+0x74/0x188)
[<c05fa2ac>] (panic+0x74/0x188) from [<c006bfd0>] (do_exit+0x6c4/0x788)
[ 2.670000] [<c05fa2ac>] (panic+0x74/0x188) from [<c006bfd0>] (do_exit+0x6c4/0x788)
[<c006bfd0>] (do_exit+0x6c4/0x788) from [<c003c87c>] (die+0x288/0x300)
[ 2.690000] [<c006bfd0>] (do_exit+0x6c4/0x788) from [<c003c87c>] (die+0x288/0x300)
[<c003c87c>] (die+0x288/0x300) from [<c0042cb0>] (__do_kernel_fault+0x74/0x84)
[ 2.700000] [<c003c87c>] (die+0x288/0x300) from [<c0042cb0>] (__do_kernel_fault+0x74/0x84)
[<c0042cb0>] (__do_kernel_fault+0x74/0x84) from [<c0042e40>] (do_page_fault+0x180/0x2e4)
[ 2.720000] [<c0042cb0>] (__do_kernel_fault+0x74/0x84) from [<c0042e40>] (do_page_fault+0x180/0x2e4)
[<c0042e40>] (do_page_fault+0x180/0x2e4) from [<c00312b4>] (do_DataAbort+0x34/0x98)
[ 2.730000] [<c0042e40>] (do_page_fault+0x180/0x2e4) from [<c00312b4>] (do_DataAbort+0x34/0x98)
[<c00312b4>] (do_DataAbort+0x34/0x98) from [<c0037dd0>] (__dabt_svc+0x70/0xa0)
[ 2.750000] [<c00312b4>] (do_DataAbort+0x34/0x98) from [<c0037dd0>] (__dabt_svc+0x70/0xa0)
Exception stack(0xe783bee8 to 0xe783bf30)
[ 2.770000] Exception stack(0xe783bee8 to 0xe783bf30)
bee0: 29c5c734 00000000 1137666c f1c20800 00000001 55866a9a
[ 2.780000] bee0: 29c5c734 00000000 1137666c f1c20800 00000001 55866a9a
bf00: c0039358 00000000 00000001 6239831b c0944588 11376664 1137665c e783bf30
[ 2.790000] bf00: c0039358 00000000 00000001 6239831b c0944588 11376664 1137665c e783bf30
bf20: f8a905a8 c0059aac 20000013 ffffffff
[ 2.810000] bf20: f8a905a8 c0059aac 20000013 ffffffff
[<c0037dd0>] (__dabt_svc+0x70/0xa0) from [<c0059aac>] (sunxi_gpio_request_array+0x160/0x540)
[ 2.810000] [<c0037dd0>] (__dabt_svc+0x70/0xa0) from [<c0059aac>] (sunxi_gpio_request_array+0x160/0x540)
[<c0059aac>] (sunxi_gpio_request_array+0x160/0x540) from [<c040b868>] (alloc_pin+0xc/0x60)
[ 2.830000] [<c0059aac>] (sunxi_gpio_request_array+0x160/0x540) from [<c040b868>] (alloc_pin+0xc/0x60)
[<c040b868>] (alloc_pin+0xc/0x60) from [<c00209cc>] (sw_hci_sunxi_init+0x3c/0x144)
[ 2.850000] [<c040b868>] (alloc_pin+0xc/0x60) from [<c00209cc>] (sw_hci_sunxi_init+0x3c/0x144)
[<c00209cc>] (sw_hci_sunxi_init+0x3c/0x144) from [<c0031378>] (do_one_initcall+0x34/0x180)
[ 2.860000] [<c00209cc>] (sw_hci_sunxi_init+0x3c/0x144) from [<c0031378>] (do_one_initcall+0x34/0x180)
[<c0031378>] (do_one_initcall+0x34/0x180) from [<c00084d4>] (kernel_init+0x108/0x194)
[ 2.880000] [<c0031378>] (do_one_initcall+0x34/0x180) from [<c00084d4>] (kernel_init+0x108/0x194)
[<c00084d4>] (kernel_init+0x108/0x194) from [<c0039358>] (kernel_thread_exit+0x0/0x8)
[ 2.900000] [<c00084d4>] (kernel_init+0x108/0x194) from [<c0039358>] (kernel_thread_exit+0x0/0x8)
<0>Rebooting in 10 seconds..[ 2.920000] Rebooting in 10 seconds..这下内核启动算成功了,由于还没有文件系统,找不到进程init,故kill init
问题二:<0>Kernel panic - not syncing: Attempted to kill init!上面分析了,其实就是找不到init进程,而文件系统提供这些进程。先写到这,明天开始移植文件系统下面开始移植根文件系统:change@change:~/Si/A10/pcduino$ mkdir rootfs1.编译、安装busybox获取busybox源码http://www.busybox.net/点击BusyBox 1.21.0下载源码,解压到工作目录并进入该目录change@change:~/Si/A10/pcduino/busybox-1.21.0$ make menuconfig先采用默认配置,不行回来再改。回来把builid option 把 Build BusyBox as a static binary (no shared libs) 把这个选上change@change:~/Si/A10/pcduino/busybox-1.21.0$ vim Makefile修改:164:CROSS_COMPILE ?= arm-none-linux-gnueabi-190:ARCH ?= arm保存退出,开始编译change@change:~/Si/A10/pcduino/busybox-1.21.0$ make........//过程有点长,省略若干AR util-linux/volume_id/lib.a
LINK busybox_unstripped
Trying libraries: crypt m
Library crypt is not needed, excluding it
Library m is needed, can't exclude it (yet)
Final link with: m
DOC busybox.pod
DOC BusyBox.txt
DOC busybox.1
DOC BusyBox.html编译结束,开始安装到指定目录change@change:~/Si/A10/pcduino/busybox-1.21.0$ make CONFIG_PREFIX=../rootfs install--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
--------------------------------------------------
安装过程完成,安装在上面新建的rootfs目录change@change:~/Si/A10/pcduino/busybox-1.21.0$ cd ../rootfs/
change@change:~/Si/A10/pcduino/rootfs$ ls -l
total 12
drwxr-xr-x 2 change change 4096 2013-04-21 16:05 bin
lrwxrwxrwx 1 change change 11 2013-04-21 16:05 linuxrc -> bin/busybox
drwxr-xr-x 2 change change 4096 2013-04-21 16:05 sbin
drwxr-xr-x 4 change change 4096 2013-04-21 16:05 usr
change@change:~/Si/A10/pcduino/rootfs$2.创建设备文件(可以省,后来忘记也能启动呵呵)change@change:~/Si/A10/pcduino/rootfs$ mkdir dev
change@change:~/Si/A10/pcduino/rootfs$ cd dev/
change@change:~/Si/A10/pcduino/rootfs/dev$ sudo mknod console c 5 1
change@change:~/Si/A10/pcduino/rootfs/dev$ sudo mknod null c 1 3
change@change:~/Si/A10/pcduino/rootfs/dev$ ls -l
total 0
crw-r--r-- 1 root root 5, 1 2013-04-21 17:00 console
crw-r--r-- 1 root root 1, 3 2013-04-21 17:00 null
3.构建配置文件直接拷贝busybox的,偷点懒change@change:~/Si/A10/pcduino$ cp busybox-1.21.0/examples/bootfloppy/etc/ rootfs/change@change:~/Si/A10/pcduino/rootfs$ vim etc/inittab
# /etc/inittab
::sysinit:/etc/init.d/rcS::askfirst:~/bin/sh
保存退出change@change:~/Si/A10/pcduino/rootfs$ vim etc/fstab
proc /proc proc nosuid,noexec,nodev 0 0
sysfs /sys sysfs nosuid,noexec,nodev 0 0
devpts /dev/pts devpts gid=4,mode=620 0 0
tmpfs /tmp tmpfs defaults 0 0
devtmpfs /dev devtmpfs mode=0755,nosuid 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
保存退出4.安装glibc库change@change:~/Si/A10/pcduino/rootfs$ mkdir -p lib
change@change:~/Si/A10/pcduino/rootfs$ ls
bindevetcinittabliblinuxrcsbinusr
change@change:~/Si/A10/pcduino/rootfs$ cd /home/change/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib/
change@change:~/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib$ cp *.so* /home/change/Si/A10/pcduino/rootfs/lib/ -d
change@change:~/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/lib$ cd ../usr/lib
change@change:~/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/usr/lib$ cp *.so* /home/change/Si/A10/pcduino/rootfs/lib/ -d5.烧写、测试change@change:~/tools/arm-2009q3/arm-none-linux-gnueabi/libc/armv4t/usr/lib$ cd /home/change/Si/A10/pcduino/
change@change:~/Si/A10/pcduino$ sudo mount /dev/sdc2 /mnt/
password for change:
change@change:~/Si/A10/pcduino$ sudo cp -pR rootfs/*/mnt/change@change:~/Si/A10/pcduino$ sudo umount /dev/sdc2插tf到pcduino,系统启动U-Boot 2012.10 (Apr 19 2013 - 18:46:44) Allwinner TechnologyCPU: SUNXI Family
Board: pcDuino
I2C: ready
DRAM:1 GiB
MMC: SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environmentIn: serial
Out: serial
Err: serial
Hit any key to stop autoboot:0
reading uEnv.txt144 bytes read
Loaded environment from uEnv.txt
reading boot.scr289 bytes read
Jumping to boot.scr
## Executing script at 44000000
Wrong image format for "source" command
reading script.bin44900 bytes read
reading uImage4693132 bytes read
## Booting kernel from Legacy Image at 48000000 ...
Image Name: Linux-3.0.62
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 4693068 Bytes = 4.5 MiB
Load Address: 40008000
Entry Point:40008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OKStarting kernel ...<6>Initializing cgroup subsys cpuset
<5>Linux version 3.0.62 (change@change) (gcc version 4.4.1 (Sourcery G++ Lite 2009q3-67) ) #1 PREEMPT Sat Apr 20 18:32:39 CST 2013
CPU: ARMv7 Processor revision 2 (ARMv7), cr=10c5387d
CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine: sun4i
<6>Memory cut off:
<6> MALI : 0x5c000000 - 0x5fffffff(64 MB)
<4>Ignoring unrecognised tag 0x00000000
<6>Memory Reserved:
<6> SYS: 0x43000000 - 0x4300ffff(64 kB)
<6> VE : 0x44000000 - 0x48ffffff(80 MB)
<6> G2D: 0x49000000 - 0x49ffffff(16 MB)
<6> LCD: 0x5a000000 - 0x5bffffff(32 MB)
Memory policy: ECC disabled, Data cache writeback
<6>chip-id: A10 (AW1623 revision C)
<7>On node 0 totalpages: 245760
<7>free_area_init_node: node 0, pgdat c0887ea0, node_mem_map c094e000
<7>Normal zone: 1280 pages used for memmap
<7>Normal zone: 0 pages reserved
<7>Normal zone: 146176 pages, LIFO batch:31
<7>HighMem zone: 768 pages used for memmap
<7>HighMem zone: 97536 pages, LIFO batch:31
<7>pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
<7>pcpu-alloc: 0
Built 1 zonelists in Zone order, mobility grouping on.Total pages: 243712
<5>Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait loglevel=8 panic=10
<6>PID hash table entries: 4096 (order: 2, 16384 bytes)
<6>Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
<6>Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
<6>Memory: 448MB 512MB = 960MB total
<5>Memory: 833852k/833852k available, 149188k reserved, 393216K highmem
<5>Virtual kernel memory layout:
vector: 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap: 0xfff00000 - 0xfffe0000 ( 896 kB)........//太长了,省略若干<6>mmc0: new high speed SD card at address 1234
[ 4.140000] mmc0: new high speed SD card at address 1234
<6>mmcblk0: mmc0:1234 SA01G 942 MiB
[ 4.160000] mmcblk0: mmc0:1234 SA01G 942 MiB
<6> mmcblk0: p1 p2
[ 4.170000]mmcblk0: p1 p2
<6>Console: switching to colour frame buffer device 160x45
[ 4.290000] Console: switching to colour frame buffer device 160x45
<4>regulator_init_complete: axp20_buck3: incomplete constraints, leaving on
[ 4.330000] regulator_init_complete: axp20_buck3: incomplete constraints, leaving on
<4>regulator_init_complete: axp20_buck2: incomplete constraints, leaving on
[ 4.350000] regulator_init_complete: axp20_buck2: incomplete constraints, leaving on
<4>regulator_init_complete: axp20_ldo4: incomplete constraints, leaving on
[ 4.360000] regulator_init_complete: axp20_ldo4: incomplete constraints, leaving on
<4>regulator_init_complete: axp20_ldo3: incomplete constraints, leaving on
[ 4.380000] regulator_init_complete: axp20_ldo3: incomplete constraints, leaving on
<4>regulator_init_complete: axp20_ldo2: incomplete constraints, leaving on
[ 4.390000] regulator_init_complete: axp20_ldo2: incomplete constraints, leaving on
<4>regulator_init_complete: axp20_ldo1: incomplete constraints, leaving on
[ 4.410000] regulator_init_complete: axp20_ldo1: incomplete constraints, leaving on
<6>sunxi-rtc sunxi-rtc: sunxi_rtc_gettime
[ 4.420000] sunxi-rtc sunxi-rtc: sunxi_rtc_gettime
<6>sunxi-rtc sunxi-rtc: read time 2010-1-1 0:0:10
[ 4.430000] sunxi-rtc sunxi-rtc: read time 2010-1-1 0:0:10
<6>sunxi-rtc sunxi-rtc: setting system clock to 2010-01-01 00:00:10 UTC (1262304010)
[ 4.440000] sunxi-rtc sunxi-rtc: setting system clock to 2010-01-01 00:00:10 UTC (1262304010)
<3>EXT3-fs (mmcblk0p2): error: couldn't mount because of unsupported optional features (240)
[ 4.460000] EXT3-fs (mmcblk0p2): error: couldn't mount because of unsupported optional features (240)
<3>EXT2-fs (mmcblk0p2): error: couldn't mount because of unsupported optional features (244)
[ 4.480000] EXT2-fs (mmcblk0p2): error: couldn't mount because of unsupported optional features (244)
<6>EXT4-fs (mmcblk0p2): recovery complete
[ 5.840000] EXT4-fs (mmcblk0p2): recovery complete
<6>EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[ 6.060000] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
<6>VFS: Mounted root (ext4 filesystem) on device 179:2.
[ 6.080000] VFS: Mounted root (ext4 filesystem) on device 179:2.
<6>devtmpfs: mounted
[ 6.090000] devtmpfs: mounted
<6>Freeing init memory: 164K
[ 6.090000] Freeing init memory: 164K
mount: mounting devpts on /dev/pts failed: No such file or directory
mount: mounting /dev/mmcblk0p1 on /boot failed: No such file or directory
Please press Enter to activate this console.
Processing /etc/profile... Done
/ # ls
bin home lost+foundrun tmp
dev lib mnt sbin usr
etc linuxrc proc sys var
/ #
挂载文件系统部分花了不少时间,经过多种尝试,系统·终于启动了。下一步可着手驱动开发了。
页:
[1]