树老大 发表于 2013-5-18 23:42:58

pcDuino的linux移植二

大清早就被摇醒了,床摇的厉害,赶紧往外跑,原来地震了,太吓人啦。言归正传,继pcduino的linux移植一,实现目标二移植内核1.获取linux源码https://github.com/pcduino/kernel 点击linux-sunxi,跳转到https://github.com/linux-sunxi/linux-sunxi下载linux-sunxi源码2.配置、编译解压上面下载的linux-sunxi-sunxi-3.0.zip,并解压到ubuntu工作目录change@change:~$ cd Si/A10/pcduino/linux-sunxi-sunxi-3.0/
change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ ls
Android.mkbuild.shcrypto         firmwareinit    KconfigMAINTAINERSmodulesREPORTING-BUGSscripts   tools
arch      COPYING   Documentationfs      ipc   kernel   Makefile   net      rootfs          securityusr
block       CREDITS   drivers      include   Kbuildlib      mm         README   samples         sound   virt2.1配置单板change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ find -name "*defconfig"./arch/arm/configs/sun4i_defconfig
./arch/arm/configs/netx_defconfig
./arch/arm/configs/vexpress_defconfig
./arch/arm/configs/g3evm_defconfig
./arch/arm/configs/at91rm9200_defconfig
./arch/arm/configs/pxa168_defconfig
./arch/arm/configs/at91sam9g20ek_defconfig
./arch/arm/configs/stamp9g20_defconfig
./arch/arm/configs/integrator_defconfig
./arch/arm/configs/sun3i_defconfig
./arch/arm/configs/pxa910_defconfig
./arch/arm/configs/h5000_defconfig
./arch/arm/configs/mini2440_defconfig
./arch/arm/configs/a13_defconfig
./arch/arm/configs/versatile_defconfig
./arch/arm/configs/mx1_defconfig
./arch/arm/configs/colibri_pxa270_defconfig
./arch/arm/configs/ixp2000_defconfig
./arch/arm/configs/sam9_l9260_defconfig
./arch/arm/configs/a12_nuclear_defconfig
./arch/arm/configs/s3c6400_defconfig
./arch/arm/configs/sun4i_crane_defconfig找到全志A10默认单板配置./arch/arm/configs/sun4i_defconfig,下面使用默认单板配置
change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ make ARCH=arm sun4i_defconfig
#
# configuration written to .config
#
change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ make ARCH=arm menuconfig
HOSTCCscripts/kconfig/lxdialog/checklist.o
HOSTCCscripts/kconfig/lxdialog/inputbox.o
HOSTCCscripts/kconfig/lxdialog/menubox.o
HOSTCCscripts/kconfig/lxdialog/textbox.o
HOSTCCscripts/kconfig/lxdialog/util.o
HOSTCCscripts/kconfig/lxdialog/yesno.o
HOSTCCscripts/kconfig/mconf.o
HOSTLDscripts/kconfig/mconf
scripts/kconfig/mconf Kconfig保存退出即可,若执行make menuconfig报错,需要安装屏幕绘制动态库,安装过程如下:change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ sudo apt-get install libncurses52.2编译编译器可以选用自己的,这里继续用pcduino的linux移植一配置的交叉编译链change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage出现如下错误:In file included from include/linux/memory_hotplug.h:6,
               from include/linux/mmzone.h:671,
               from include/linux/topology.h:32,
               from include/linux/sched.h:78,
               from arch/arm/kernel/asm-offsets.c:13:
include/linux/notifier.h:15: fatal error: linux/srcu.h: No such file or directory
compilation terminated.
make: *** Error 1
make: *** Error 22.3解决问题根据include/linux/notifier.h:15: fatal error: linux/srcu.h: No such file or directory解决错误,解决过程如下:change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ vim include/linux/notifier.h15:#include <linux/srcu.h>接着发现include/linux/目录下的确没有srcu.h,很是纳闷以前编译都没有这个错误,于是到linux-3.0.62下相应目录拷贝include/linux/srcu.h文件,继续编译change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage上面的错误没了,编译过程有点长,吃完饭继续LD      vmlinux
SYSMAPSystem.map
SYSMAP.tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
AS      arch/arm/boot/compressed/head.o
CC      arch/arm/boot/compressed/misc.o
GZIP    arch/arm/boot/compressed/piggy.gzip
CC      arch/arm/boot/compressed/decompress.o
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS      arch/arm/boot/compressed/lib1funcs.o
AS      arch/arm/boot/compressed/piggy.gzip.o
LD      arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
UIMAGEarch/arm/boot/uImage
Image Name:   Linux-3.0.62
Created:      Sat Apr 20 18:33:26 2013
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    4693068 Bytes = 4583.07 kB = 4.48 MB
Load Address: 40008000
Entry Point:40008000
Image arch/arm/boot/uImage is ready
终于编译完了,已生成arch/arm/boot/uImage,说明编译成功。 3.烧写、测试插上tf卡,查看设备change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ ls /dev/sdb
sdb   sdb1
3.1烧写u-boot过程参考pcduino的linux移植一:change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ cd ../u-boot-sunxi-sunxi/
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1
password for change:
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0103637 s, 101 MB/s
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo sfdisk -R /dev/sdb
BLKRRPART: Device or resource busy
This disk is currently in use.出现这种BLKRRPART: Device or resource busy,tf卡已被挂载,重插拔一次即可
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo sfdisk -R /dev/sdb
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo cat <<EOT | sudo sfdisk --in-order -uM /dev/sdb
> 1,16,c
> ,,L
> EOT
Checking that no-one is using this disk right now ...
OK


Disk /dev/sdb: 1020 cylinders, 31 heads, 61 sectors/track


sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/sdb: unrecognized partition table type
Old situation:
No partitions found
New situation:
Units = mebibytes of 1048576 bytes, blocks of 1024 bytes, counting from 0


   Device Boot Start   End    MiB    #blocks   IdSystem
/dev/sdb1         0+    17-    17-   17019    cW95 FAT32 (LBA)
/dev/sdb2      17+   941-   925-    946445+83Linux
/dev/sdb3         0      -      0          0    0Empty
/dev/sdb4         0      -      0          0    0Empty
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table


Re-reading the partition table ...


If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo sfdisk -l /dev/sdb


Disk /dev/sdb: 1020 cylinders, 31 heads, 61 sectors/track
Units = cylinders of 968192 bytes, blocks of 1024 bytes, counting from 0


   Device Boot Start   End   #cyls    #blocks   IdSystem
/dev/sdb1          1      18      18      17019    cW95 FAT32 (LBA)
/dev/sdb2         19    1019    1001   946445+83Linux
/dev/sdb3          0       -       0          0    0Empty
/dev/sdb4          0       -       0          0    0Empty
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo mkfs.vfat /dev/sdb1
mkfs.vfat 3.0.7 (24 Dec 2009)
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo mkfs.ext4 /dev/sdb2
mke2fs 1.41.11 (14-Mar-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
59264 inodes, 236611 blocks
11830 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=243269632
8 block groups
32768 blocks per group, 32768 fragments per group
7408 inodes per group
Superblock backups stored on blocks:
      32768, 98304, 163840, 229376


正在写入inode表:完成                        
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成


This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.Use tune2fs -c or -i to override.
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=spl/sunxi-spl.bin of=/dev/sdb bs=1024 seek=8
20+0 records in
20+0 records out
20480 bytes (20 kB) copied, 0.0256702 s, 798 kB/s
change@change:~/Si/A10/pcduino/u-boot-sunxi-sunxi$ sudo dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32
171+1 records in
171+1 records out
175272 bytes (175 kB) copied, 0.105589 s, 1.7 MB/s
取下tf卡,插入pcduino,接上串口线设置115200 8 n 1,默认从tf卡启动,启动界面如下: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 Technology

CPU:   SUNXI Family
Board: pcDuino
I2C:   ready
DRAM:1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:0
sun4i#
3.2烧写linux内核准备工作:制作对对A10芯片进行配置的二进制文件script.bin获取源码:https://github.com/pcduino/kernel 选择sunxi-tools,并下载 change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ cd ../sunxi-tools-master/change@change:~/Si/A10/pcduino/sunxi-tools-master$ make
make 出现如下错误:Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
Package libusb-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libusb-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libusb-1.0' found
但还是在sunxi-tools-master目录下生成了fex2bin。这个错误还没解决,打算先用生成的fex2bin试试(fex2bin 文件,能把 *.fex 文件生成 *.bin文件)解决方法:pkg-config 是一个提供从源代码中编译软件时查询已安装的库时使用的统一接口的计算机软件。可以解决明明在自己机器上编译好好的,在别人电脑上编译就不行问题。当安装一个库时(从RPM,deb或其他二进制包管理系统),会包括一个后缀名为pc的文件,它会同其他.pc文件一起放入一个文件夹(依赖与你的系统设置)。在这个文件里包含有数个条目。这些条目通常包含用于其他使用这个库的程序编译时需要的库设置,以及头文件的位置,版本信息和一个简介。change@change:/$ sudo apt-get install libusb-1.0-0-dev
正在读取软件包列表... 完成
正在分析软件包的依赖关系树      
正在读取状态信息... 完成      
下列【新】软件包将被安装:
libusb-1.0-0-dev
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 207 个软件包未被升级。
需要下载 149kB 的软件包。
解压缩后会消耗掉 975kB 的额外空间。
获取:1 http://free.nchc.org.tw/ubuntu/ lucid/main libusb-1.0-0-dev 2:1.0.6-1
下载 149kB,耗时 3秒 (47.9kB/s)         
选中了曾被取消选择的软件包 libusb-1.0-0-dev。
(正在读取数据库 ... 系统当前总共安装有 142909 个文件和目录。)
正在解压缩 libusb-1.0-0-dev (从 .../libusb-1.0-0-dev_2%3a1.0.6-1_i386.deb) ...
正在处理用于 doc-base 的触发器...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
正在设置 libusb-1.0-0-dev (2:1.0.6-1) ...
change@change:/$ ls /usr/lib/pkgconfig/libusb-1.0.pc
/usr/lib/pkgconfig/libusb-1.0.pcchange@change:/$ export PKG_CONFIG_PATH=/usr/lib/pkgconfig:$PKG_CONFIG_PATH
change@change:/$ set | grep PKG_CONFIG
PKG_CONFIG_PATH=/usr/lib/pkgconfig:
change@change:/$ pkg-config libusb-1.0 --cflags --libs
-I/usr/include/libusb-1.0-lusb-1.0
接着make就OK了。获取源码https://github.com/pcduino/kernel 选择sunxi-boards,利用上面生成的工具fex2bin,将sunxi-boards/sys_config/a10/pcduino.fex文件生成对A10芯片进行配置的二进制文件script.binchange@change:~/Si/A10/pcduino/sunxi-tools-master$ ./fex2bin ../sunxi-boards/sys_config/a10/pcduino.fex script.bin
下面开始烧写tf卡,插入tf卡到ubuntuchange@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ sudo mount /dev/sdb1 /mnt/
password for change:
change@change:~/Si/A10/pcduino/linux-sunxi-sunxi-3.0$ cp arch/arm/boot/uImage /mnt/
change@change:~/Si/A10/pcduino/sunxi-tools-master$ cp script.bin /mnt/
change@change:~/Si/A10/pcduino/sunxi-tools-master$ sudo umount /mnt/
取下tf卡,插到pcduino,接好串口线设置115200 8 n1,启动信息如下: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 Technology

CPU:   SUNXI Family
Board: pcDuino
I2C:   ready
DRAM:1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    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

Usage:
ext2load <interface> <dev[:part]>
    - load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from ext2 filesystem
Loading file "boot/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

Usage:
ext2load <interface> <dev[:part]>
    - load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from ext2 filesystem
reading boot.scr


** Unable to read "boot.scr" from mmc 0:1 **
Loading file "boot.scr" 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

Usage:
ext2load <interface> <dev[:part]>
    - load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from ext2 filesystem
Loading file "boot/boot.scr" 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

Usage:
ext2load <interface> <dev[:part]>
    - load binary file 'filename' from 'dev' on 'interface'
      to address 'addr' from ext2 filesystem
reading script.bin

44900 bytes read
reading uImage

4693132 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
OK

Starting 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
............//太长了此处省略·若干<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.870000] [<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..
linux内核终于启动了,看到启动信息就知道出现不少问题。pcduino的linux移植二写的太长了,根文件系统移植以及未解决的问题留在pcduino的linux移植三。

有些问题还未解决,知道的直接留言,我们一起解决。sd卡烧写参考http://linux-sunxi.org/Bootable_SD_card
转自:http://blog.csdn.net/u010216127/article/details/8828418
页: [1]
查看完整版本: pcDuino的linux移植二