环境
主机: ubuntu14.04 64bit
开发板: qemu + vexpress-a9 (参考: http://www.cnblogs.com/pengdonglin137/p/6442583.html)
工具链: arm-none-linux-gnueabi-gcc (gcc version 4.8.3 20140320)
Python版本: Python-2.7.13
回到顶部(go to top)
参考
http://www.41443.com/HTML/Python/20151105/414154.html
http://www.cnblogs.com/tolimit/p/4519838.html?utm_source=tuicool&utm_medium=referral
回到顶部(go to top)
正文
1、下载解压python源码
到https://www.python.org/downloads/下载最新的python2系列的软件,这里我用的是Python-2.7.13
1 #解压
2 tar -xf Python-2.7.13.tar.xz
3
4 #创建python2_7_13_for_x86_64
5 mkdir python2_7_13_for_x86_64
6
7 #创建python2_7_13_for_arm
8 mkdir python2_7_13_for_arm
2、编译x86_64版本的python软件
我把编译过程写成了脚本, 进入python2_7_13_for_x86_64/目录,然后执行如下脚本:
配置 mk1_conf.sh
1 #!/bin/bash
2
3 ../Python-2.7.13/configure --prefix=`pwd`
编译mk2_make.sh
1 #!/bin/bash
2
3 make -j4
安装 mk3_install.sh
1 #!/bin/bash
2
3 make install
3、交叉编译
交叉编译的第一步是为python源码打上交叉编译用的patch:Python-2.7.13-compile.patch.tar.gz
1 cd Python-2.7.13/
2 patch -p1 < ../python2_7_13_for_arm/Python-2.7.13-xcompile.patch
我也把编译过程放到脚本,也分为三个:
配置 mk1_conf.sh
1 #!/bin/bash
2 export PATH=/home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin:$PATH
3 ../Python-2.7.13/configure --prefix=`pwd`
4 --host=arm-none-linux-gnueabi
5 --build=x86_64-linux-gnu
6 --enable-ipv6
7 --enable-shared
8 ac_cv_file__dev_ptmx="yes"
9 ac_cv_file__dev_ptc="no"
编译 mk2_make.sh
1 #!/bin/bash
2 export PATH=/home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin:$PATH
3 make HOSTPYTHON=../python2_7_13_for_x86_64/python
4 HOSTPGEN=../python2_7_13_for_x86_64/Parser/pgen
5 BLDSHARED="arm-none-linux-gnueabi-gcc -shared"
6 CROSS_COMPILE=arm-none-linux-gnueabi-
7 CROSS_COMPILE_TARGET=yes
8 HOSTARCH=arm-none-linux-gnueabi
9 BUILDARCH=x86_64-linux-gnu
10 -j4
安装 mk3_install.sh
1 #!/bin/bash
2 export PATH=/home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin:$PATH
3 make install HOSTPYTHON=../python2_7_13_for_x86_64/python
4 BLDSHARED="arm-none-linux-gnueabi-gcc -shared"
5 CROSS_COMPILE=arm-none-linux-gnueabi-
6 CROSS_COMPILE_TARGET=yes
7 prefix=`pwd`
4、重新制作ramdisk镜像
参考博文:用Qemu搭建aarch32学习环境
修改mk_ramdisk.sh如下:
1 #!/bin/bash
2 sudo rm -rf rootfs
3 sudo rm -rf tmpfs
4 sudo rm -rf ramdisk*
5 sudo mkdir rootfs
6 sudo cp ../busybox-1.24.2/_install/* rootfs/ -raf
7 sudo mkdir -p rootfs/proc/
8 sudo mkdir -p rootfs/sys/
9 sudo mkdir -p rootfs/tmp/
10 sudo mkdir -p rootfs/root/
11 sudo mkdir -p rootfs/var/
12 sudo mkdir -p rootfs/mnt/
13 sudo cp etc rootfs/ -arf
14 sudo cp -arf ../arm-2014.05/arm-none-linux-gnueabi/libc/lib rootfs/
15 sudo rm -rf rootfs/lib/*.a
16 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip rootfs/lib/*
17 # 拷贝python相关的文件到根文件系统中
18 sudo mkdir -p rootfs/usr
19 pushd rootfs/usr
20 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/python2_7_13_for_arm/lib .
21 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/python2_7_13_for_arm/include .
22 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/python2_7_13_for_arm/bin .
23 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/python2_7_13_for_arm/share .
24 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip lib/python*
25 popd
26 sudo mkdir -p rootfs/dev/
27 sudo mknod rootfs/dev/tty1 c 4 1
28 sudo mknod rootfs/dev/tty2 c 4 2
29 sudo mknod rootfs/dev/tty3 c 4 3
30 sudo mknod rootfs/dev/tty4 c 4 4
31 sudo mknod rootfs/dev/console c 5 1
32 sudo mknod rootfs/dev/null c 1 3
33 sudo mkdir -p rootfs/lib/modules/4.10.0+
34 sudo mkdir -p rootfs/tools
35 sudo cp ./other_tools/* rootfs/tools
36 # 将ramdisk的大小扩展为100MB
37 sudo dd if=/dev/zero of=ramdisk bs=1M count=100
38 sudo mkfs.ext4 -F ramdisk
39 sudo mkdir -p tmpfs
40 sudo mount -t ext4 ramdisk ./tmpfs/ -o loop
41 sudo cp -raf rootfs/* tmpfs/
42 sudo umount tmpfs
43 sudo gzip --best -c ramdisk > ramdisk.gz
44 sudo mkimage -n "ramdisk" -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img
这里需要注意:
1、将刚才交叉编译python所得的文件拷贝到rootfs/usr下面: bin、lib、include和share
2、由于Python的lib目录占用了很大空间,有70MB左右,所以这里我们把ramdisk的大小设置为100MB
3、此外,qemu-system-arm运行的,可以给-m设置较大的物理内存,这里我设置的是1GB
5、修改kernel配置
修改ramdisk的大小设置, 这里我设置的是100MB:
1 Device Drivers --->
2
3 [*] Block devices --->
4
5 (102400) Default RAM disk size (kbytes)
6、测试
制作好ramdisk以及编译出新的kernel后,运行系统:
1 sudo qemu-system-arm
2 -M vexpress-a9
3 -m 1024M
4 -smp 2
5 -kernel ./linux-4.10/out_aarch32/arch/arm/boot/zImage
6 -nographic
7 -append "root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel"
8 -initrd ./rootfs/ramdisk.img
9 -net nic,vlan=0 -net tap,vlan=0,ifname=tap0
10 -dtb ./linux-4.10/out_aarch32/arch/arm/boot/dts/vexpress-v2p-ca9.dtb
下面是启动log:
1 $./run.sh
2 sudo tunctl -u root -t tap0
3 TUNSETIFF: Device or resource busy
4 sudo ifconfig tap0 0.0.0.0 promisc up
5 sudo brctl addif br0 tap0
6 brctl show
7 bridge name bridge id STP enabled interfaces
8 br0 8000.480fcf3ace87 no eth0
9 tap0
10 docker0 8000.02423772cc85 no
11 [ 0.000000] Booting Linux on physical CPU 0x0
12 [ 0.000000] Linux version 4.10.0+ (pengdonglin@pengdonglin-HP) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #10 SMP Mon Mar 20 11:31:00 CST 2017
13 [ 0.000000] CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
14 [ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
15 [ 0.000000] OF: fdt:Machine model: V2P-CA9
16 [ 0.000000] debug: ignoring loglevel setting.
17 [ 0.000000] Memory policy: Data cache writealloc
18 [ 0.000000] On node 0 totalpages: 262144
19 [ 0.000000] free_area_init_node: node 0, pgdat c0a637c0, node_mem_map ef7fa000
20 [ 0.000000] Normal zone: 1536 pages used for memmap
21 [ 0.000000] Normal zone: 0 pages reserved
22 [ 0.000000] Normal zone: 196608 pages, LIFO batch:31
23 [ 0.000000] HighMem zone: 65536 pages, LIFO batch:15
24 [ 0.000000] percpu: Embedded 14 pages/cpu @ef7b5000 s27648 r8192 d21504 u57344
25 [ 0.000000] pcpu-alloc: s27648 r8192 d21504 u57344 alloc=14*4096
26 [ 0.000000] pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3
27 [ 0.000000] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260608
28 [ 0.000000] Kernel command line: root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel
29 [ 0.000000] log_buf_len individual max cpu contribution: 4096 bytes
30 [ 0.000000] log_buf_len total cpu_extra contributions: 12288 bytes
31 [ 0.000000] log_buf_len min size: 16384 bytes
32 [ 0.000000] log_buf_len: 32768 bytes
33 [ 0.000000] early log buf free: 14860(90%)
34 [ 0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
35 [ 0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
36 [ 0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
37 [ 0.000000] Memory: 1007212K/1048576K available (6144K kernel code, 453K rwdata, 1440K rodata, 1024K init, 191K bss, 41364K reserved, 0K cma-reserved, 262144K highmem)
38 [ 0.000000] Virtual kernel memory layout:
39 [ 0.000000] vector : 0xffff0000 - 0xffff1000 ( 4 kB)
40 [ 0.000000] fixmap : 0xffc00000 - 0xfff00000 (3072 kB)
41 [ 0.000000] vmalloc : 0xf0800000 - 0xff800000 ( 240 MB)
42 [ 0.000000] lowmem : 0xc0000000 - 0xf0000000 ( 768 MB)
43 [ 0.000000] pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
44 [ 0.000000] modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
45 [ 0.000000] .text : 0xc0008000 - 0xc0700000 (7136 kB)
46 [ 0.000000] .init : 0xc0900000 - 0xc0a00000 (1024 kB)
47 [ 0.000000] .data : 0xc0a00000 - 0xc0a71784 ( 454 kB)
48 [ 0.000000] .bss : 0xc0a73000 - 0xc0aa2c4c ( 192 kB)
49 [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
50 [ 0.000000] Hierarchical RCU implementation.
51 [ 0.000000] Build-time adjustment of leaf fanout to 32.
上一篇:valgrind arm-linux 交叉编译
下一篇:在TQ2440上运行perf,生成Flame Graph
推荐阅读最新更新时间:2024-11-07 14:47
设计资源 培训 开发板 精华推荐
- #第六届立创电赛#迷你单电源模拟小功放
- 1.5V~30V 3A可调式开关电源电路原理图+PCB资料
- 使用 ROHM Semiconductor 的 BU4915 的参考设计
- AM30EW-2415DZ ¦15V 单路输出 DC/DC 转换器的典型应用
- AD9709-EB,使用 AD9709 的评估板,8 位,125 MSPS,双 TxDAC+ 数模转换器
- 使用 ROHM Semiconductor 的 BD4724 的参考设计
- AD9508/PCBZ,AD9508 评估板,1.65 GHz,带输出分频器和延迟的时钟扇出缓冲器
- EVAL-ADM3054EBZ,ADM3054 5kV rms 信号隔离高速CAN收发器评估板,具有总线保护
- 基于用于STM32 Nucleo的BLUENRG-M2SP模块的蓝牙低功耗扩展板
- L7806C 带温度补偿的可调输出电压的典型应用