environment
Host: ubuntu14.04 64bit
Development board: qemu + vexpress-a9 (reference: http://www.cnblogs.com/pengdonglin137/p/6442583.html)
Toolchain: arm-none-linux-gnueabi-gcc (gcc version 4.8.3 20140320)
Python version: Python-2.7.13
Go to top
reference
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
text
1. Download and decompress the Python source code
Go to https://www.python.org/downloads/ to download the latest python2 series software. Here I use Python-2.7.13
1 # Unzip
2 tar -xf Python-2.7.13.tar.xz
3
4 #Create python2_7_13_for_x86_64
5 mkdir python2_7_13_for_x86_64
6
7 #Create python2_7_13_for_arm
8 mkdir python2_7_13_for_arm
2. Compile the x86_64 version of Python software
I wrote the compilation process into a script, enter the python2_7_13_for_x86_64/ directory, and then execute the following script:
Configure mk1_conf.sh
1 #!/bin/bash
2
3 ../Python-2.7.13/configure --prefix=`pwd`
Compile mk2_make.sh
1 #!/bin/bash
2
3 make -j4
Install mk3_install.sh
1 #!/bin/bash
2
3 make install
3. Cross-compilation
The first step of cross-compilation is to apply the cross-compilation patch to the Python source code: 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
I also put the compilation process into the script, which is also divided into three parts:
Configure 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"
Compile 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
Install 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. Recreate the ramdisk image
Reference blog post: Using Qemu to build aarch32 learning environment
Modify mk_ramdisk.sh as follows:
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 # Copy Python related files to the root file system
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 # Expand the size of ramdisk to 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
Things to note here:
1. Copy the files obtained by cross-compiling Python to rootfs/usr: bin, lib, include and share
2. Since Python's lib directory takes up a lot of space, about 70MB, we set the size of ramdisk to 100MB here.
3. In addition, when running qemu-system-arm, you can set a larger physical memory for -m. Here I set it to 1GB
5. Modify kernel configuration
Modify the size of the ramdisk. Here I set it to 100MB:
1 Device Drivers --->
2
3 [*] Block devices --->
4
5 (102400) Default RAM disk size (kbytes)
6. Testing
After making the ramdisk and compiling the new kernel, run the system:
1 sudo qemu-system-arm
2 -M vexpress-a9
3 -m 1024M
4 - junior high school 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
Here is the startup 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.
52 [ 0.000000] RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
53 [ 0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32, nr_cpu_ids=4
54 [ 0.000000] NR_IRQS:16 nr_irqs:16 16
55 [ 0.000000] L2C: platform modifies aux control register: 0x02020000 -> 0x02420000
56 [ 0.000000] L2C: DT/platform modifies aux control register: 0x02020000 -> 0x02420000
57 [ 0.000000] L2C-310 enabling early BRESP for Cortex-A9
58 [ 0.000000] L2C-310 full line of zeros enabled for Cortex-A9
59 [ 0.000000] L2C-310 dynamic clock gating disabled, standby mode disabled
60 [ 0.000000] L2C-310 cache controller enabled, 8 ways, 128 kB
61 [ 0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x46420001
62 [ 0.000000] smp_twd: clock not found -2
63 [ 0.000206] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
64 [ 0.002899] clocksource: arm,sp804: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
65 [ 0.003447] Failed to initialize '/smb@04000000/motherboard/iofpga@7,00000000/timer@12000': -22
66 [ 0.006792] Console: colour dummy device 80x30
67 [ 0.007168] Calibrating local timer... 94.56MHz.
Previous article:valgrind arm-linux cross-compilation
Next article:Run perf on TQ2440 to generate Flame Graph
Recommended ReadingLatest update time:2024-11-16 13:33
- Popular Resources
- Popular amplifiers
- Network Operating System (Edited by Li Zhixi)
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- MATLAB and FPGA implementation of wireless communication
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Please advise, where can I modify the USB device instance path generated by STM32?
- Msp430f149 microcontroller controls stepper motor C language program
- Spectrum Analyzer Principle
- TDA2030 audio amplifier circuit diagram
- dsp reports an error after importing a new project!
- Learn more about logic analyzers
- [NXP Rapid IoT Review] Adding Bluetooth Capabilities with NXP Rapid IoT
- On the saturation problem of operational amplifier circuit
- sdram_datasheet.pdf
- The book on switching power supplies states that because the capacitor is charged in each cycle, the current decline slope continues to increase. How do you understand this?