您的位置:首页 > 编程语言 > Python开发

交叉编译Python-2.7.13到ARM(aarch64)平台

2017-03-20 14:12 986 查看
方法跟交叉编译Python-2.7.13到ARM(aarch32)平台基本一样, 不同的地方只是把工具链换成编译aarch64的工具链,这里可以参考用qemu搭建aarch64学习环境.

创建目录:

mkdir python2_7_13_for_aarch64


下面是配置、编译和安装的脚本:

1、配置: mk1_conf.sh

#!/bin/bash

export PATH=/home/pengdonglin/src/qemu/aarch64/gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin:$PATH

../Python-2.7.13/configure --prefix=`pwd` \
--host=aarch64-linux-gnu \
--build=x86_64-linux-gnu \
--enable-ipv6 \
--enable-shared \
ac_cv_file__dev_ptmx="yes" \
ac_cv_file__dev_ptc="no"


2、编译: mk2_make.sh

#!/bin/bash

export PATH=/home/pengdonglin/src/qemu/aarch64/gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin:$PATH

make HOSTPYTHON=../python2_7_13_for_x86_64/python \
HOSTPGEN=../python2_7_13_for_x86_64/Parser/pgen \
BLDSHARED="aarch64-linux-gnu-gcc -shared" \
CROSS_COMPILE=aarch64-linux-gnu- \
CROSS_COMPILE_TARGET=yes \
HOSTARCH=aarch64-linux-gnu \
BUILDARCH=x86_64-linux-gnu \
-j4


3、安装: mk3_install.sh

#!/bin/bash

export PATH=/home/pengdonglin/src/qemu/aarch64/gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin:$PATH

make install HOSTPYTHON=../python2_7_13_for_x86_64/python \
BLDSHARED="aarch64-linux-gnu-gcc -shared" \
CROSS_COMPILE=arm-none-linux-gnueabi- \
CROSS_COMPILE_TARGET=yes \
prefix=`pwd`


此外别忘了修改制作ramdisk的脚本以及修改内核配置。

运行Qemu:

sudo qemu-system-aarch64 \
-M  virt \
-cpu cortex-a53 \
-smp 2 \
-m 4096M \
-kernel ./linux-4.10/out_aarch64/arch/arm64/boot/Image \
-nographic \
-append "root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel" \
-initrd ./rootfs/ramdisk.img \
-net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
-fsdev local,security_model=passthrough,id=fsdev0,path=/nfsroot \
-device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare


启动log:

$./run_all.sh
sudo tunctl -u root -t tap0
TUNSETIFF: Device or resource busy
sudo ifconfig tap0 0.0.0.0 promisc up
sudo brctl addif br0 tap0
brctl show
bridge name    bridge id        STP enabled    interfaces
br0        8000.36de5b2e5a93    no        eth0
tap0
docker0        8000.024280392ab1    no
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.10.0+ (pengdonglin@pengdonglin-HP) (gcc version 4.9.1 20140529 (prerelease) (crosstool-NG linaro-1.13.1-4.9-2014.07 - Linaro GCC 4.9-2014.06) ) #6 SMP PREEMPT Mon Mar 20 13:59:55 CST 2017
[    0.000000] Boot CPU: AArch64 Processor [410fd034]
[    0.000000] debug: ignoring loglevel setting.
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Reserved 16 MiB at 0x00000000ff000000
[    0.000000] NUMA: No NUMA configuration found
[    0.000000] NUMA: Faking a node at [mem 0x0000000000000000-0x000000013fffffff]
[    0.000000] NUMA: Adding memblock [0x40000000 - 0x13fffffff] on node 0
[    0.000000] NUMA: Initmem setup node 0 [mem 0x40000000-0x13fffffff]
[    0.000000] NUMA: NODE_DATA [mem 0x13ffea600-0x13ffec57f]
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x00000000ffffffff]
[    0.000000]   Normal   [mem 0x0000000100000000-0x000000013fffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x000000013fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000013fffffff]
[    0.000000] On node 0 totalpages: 1048576
[    0.000000]   DMA zone: 12288 pages used for memmap
[    0.000000]   DMA zone: 0 pages reserved
[    0.000000]   DMA zone: 786432 pages, LIFO batch:31
[    0.000000]   Normal zone: 4096 pages used for memmap
[    0.000000]   Normal zone: 262144 pages, LIFO batch:31
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv0.2 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: Trusted OS migration not required
[    0.000000] percpu: Embedded 21 pages/cpu @ffff8000fffbd000 s48128 r8192 d29696 u86016
[    0.000000] pcpu-alloc: s48128 r8192 d29696 u86016 alloc=21*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: enabling workaround for ARM erratum 845719
[    0.000000] Built 1 zonelists in Node order, mobility grouping on.  Total pages: 1032192
[    0.000000] Policy zone: Normal
[    0.000000] Kernel command line: root=/dev/ram0 rw rootfstype=ext4 console=ttyAMA0 init=/linuxrc ignore_loglevel
[    0.000000] PID hash table entries: 4096 (order: 3, 32768 bytes)
[    0.000000] software IO TLB [mem 0xfafff000-0xfefff000] (64MB) mapped at [ffff8000bafff000-ffff8000beffefff]
[    0.000000] Memory: 4008696K/4194304K available (8572K kernel code, 946K rwdata, 3864K rodata, 1024K init, 398K bss, 169224K reserved, 16384K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     modules : 0xffff000000000000 - 0xffff000008000000   (   128 MB)
[    0.000000]     vmalloc : 0xffff000008000000 - 0xffff7dffbfff0000   (129022 GB)
[    0.000000]       .text : 0xffff000008080000 - 0xffff0000088e0000   (  8576 KB)
[    0.000000]     .rodata : 0xffff0000088e0000 - 0xffff000008cb0000   (  3904 KB)
[    0.000000]       .init : 0xffff000008cb0000 - 0xffff000008db0000   (  1024 KB)
[    0.000000]       .data : 0xffff000008db0000 - 0xffff000008e9ca00   (   947 KB)
[    0.000000]        .bss : 0xffff000008e9ca00 - 0xffff000008f003d0   (   399 KB)
[    0.000000]     fixed   : 0xffff7dfffe7fd000 - 0xffff7dfffec00000   (  4108 KB)
[    0.000000]     PCI I/O : 0xffff7dfffee00000 - 0xffff7dffffe00000   (    16 MB)
[    0.000000]     vmemmap : 0xffff7e0000000000 - 0xffff800000000000   (  2048 GB maximum)
[    0.000000]               0xffff7e0000000000 - 0xffff7e0004000000   (    64 MB actual)
[    0.000000]     memory  : 0xffff800000000000 - 0xffff800100000000   (  4096 MB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]     Build-time adjustment of leaf fanout to 64.
[    0.000000]     RCU restricting CPUs from NR_CPUS=64 to nr_cpu_ids=2.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=64, nr_cpu_ids=2
[    0.000000] NR_IRQS:64 nr_irqs:64 0
[    0.000000] GICv2m: range[mem 0x08020000-0x08020fff], SPI[80:143]
[    0.000000] arm_arch_timer: WARNING: Invalid trigger for IRQ3, assuming level low
[    0.000000] arm_arch_timer: WARNING: Please fix your firmware
[    0.000000] arm_arch_timer: Architected cp15 timer(s) running at 62.50MHz (virt).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x1cd42e208c, max_idle_ns: 881590405314 ns
[    0.000102] sched_clock: 56 bits at 62MHz, resolution 16ns, wraps every 4398046511096ns
[    0.002442] Console: colour dummy device 80x25
[    0.005189] Calibrating delay loop (skipped), value calculated using timer frequency.. 125.00 BogoMIPS (lpj=250000)
[    0.005287] pid_max: default: 32768 minimum: 301
[    0.006012] Security Framework initialized
[    0.008915] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes)
[    0.013062] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes)
[    0.014733] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes)
[    0.014797] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes)
[    0.042484] ASID allocator initialised with 65536 entries
[    0.065159] EFI services will not be available.
[    0.079440] smp: Bringing up secondary CPUs ...
[    0.114887] Detected VIPT I-cache on CPU1
[    0.116592] CPU1: Booted secondary processor [410fd034]
[    0.124003] smp: Brought up 1 node, 2 CPUs
[    0.124142] SMP: Total of 2 processors activated.
[    0.124377] CPU features: detected feature: 32-bit EL0 Support
[    0.128079] CPU: All CPU(s) started at EL1
[    0.129967] alternatives: patching kernel code
[    0.158339] devtmpfs: initialized
[    0.168735] DMI not present or invalid.
[    0.169788] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.169924] futex hash table entries: 512 (order: 4, 65536 bytes)
[    0.172991] pinctrl core: initialized pinctrl subsystem
[    0.189367] NET: Registered protocol family 16
[    0.219905] cpuidle: using governor menu
[    0.221064] vdso: 2 pages (1 code @ ffff0000088e7000, 1 data @ ffff000008db5000)
[    0.221247] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[    0.225392] DMA: preallocated 256 KiB pool for atomic allocations
[    0.226642] Serial: AMBA PL011 UART driver
[    0.264136] 9000000.pl011: ttyAMA0 at MMIO 0x9000000 (irq = 39, base_baud = 0) is a PL011 rev1
[    0.275026] console [ttyAMA0] enabled
[    0.279829] irq: type mismatch, failed to map hwirq-27 for /intc!
[    0.374165] HugeTLB registered 2 MB page size, pre-allocated 0 pages
[    0.388778] ACPI: Interpreter disabled.
[    0.392241] vgaarb: loaded
[    0.393255] SCSI subsystem initialized
[    0.396197] libata version 3.00 loaded.
[    0.397290] usbcore: registered new interface driver usbfs
[    0.397613] usbcore: registered new interface driver hub
[    0.399000] usbcore: registered new device driver usb
[    0.400821] pps_core: LinuxPPS API ver. 1 registered
[    0.400936] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.401138] PTP clock support registered
[    0.401718] dmi: Firmware registration failed.
[    0.403488] Advanced Linux Sound Architecture Driver Initialized.
[    0.417340] clocksource: Switched to clocksource arch_sys_counter
[    0.418126] VFS: Disk quotas dquot_6.6.0
[    0.418355] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.419846] pnp: PnP ACPI: disabled
[    0.463782] NET: Registered protocol family 2
[    0.469532] TCP established hash table entries: 32768 (order: 6, 262144 bytes)
[    0.470282] TCP bind hash table entries: 32768 (order: 7, 524288 bytes)
[    0.470875] TCP: Hash tables configured (established 32768 bind 32768)
[    0.471545] UDP hash table entries: 2048 (order: 4, 65536 bytes)
[    0.471858] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes)
[    0.473026] NET: Registered protocol family 1
[    0.476084] RPC: Registered named UNIX socket transport module.
[    0.476229] RPC: Registered udp transport module.
[    0.476324] RPC: Registered tcp transport module.
[    0.476411] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.476581] PCI: CLS 0 bytes, default 128
[    0.479495] Trying to unpack rootfs image as initramfs...
[    0.484128] rootfs image is not initramfs (no cpio magic); looks like an initrd
[    0.578919] Freeing initrd memory: 22496K
[    0.580290] kvm [1]: HYP mode not available
[    0.590173] audit: initializing netlink subsys (disabled)
[    0.593443] audit: type=2000 audit(0.572:1): initialized
[    0.595692] workingset: timestamp_bits=42 max_order=20 bucket_order=0
[    0.641038] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.645703] NFS: Registering the id_resolver key type
[    0.646365] Key type id_resolver registered
[    0.646447] Key type id_legacy registered
[    0.646640] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[    0.647720] 9p: Installing v9fs 9p2000 file system support
[    0.657828] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 247)
[    0.658058] io scheduler noop registered
[    0.658796] io scheduler cfq registered (default)
[    0.677416] pl061_gpio 9030000.pl061: PL061 GPIO chip @0x0000000009030000 registered
[    0.680850] OF: PCI: host bridge /pcie@10000000 ranges:
[    0.681385] OF: PCI:    IO 0x3eff0000..0x3effffff -> 0x00000000
[    0.681674] OF: PCI:   MEM 0x10000000..0x3efeffff -> 0x10000000
[    0.681806] OF: PCI:   MEM 0x8000000000..0xffffffffff -> 0x8000000000
[    0.683330] pci-host-generic 3f000000.pcie: ECAM at [mem 0x3f000000-0x3fffffff] for [bus 00-0f]
[    0.684406] pci-host-generic 3f000000.pcie: PCI host bridge to bus 0000:00
[    0.684729] pci_bus 0000:00: root bus resource [bus 00-0f]
[    0.684894] pci_bus 0000:00: root bus resource [io  0x0000-0xffff]
[    0.685023] pci_bus 0000:00: root bus resource [mem 0x10000000-0x3efeffff]
[    0.685453] pci_bus 0000:00: root bus resource [mem 0x8000000000-0xffffffffff]
[    0.686138] pci 0000:00:00.0: [1b36:0008] type 00 class 0x060000
[    0.689896] pci 0000:00:01.0: [1af4:1000] type 00 class 0x020000
[    0.690272] pci 0000:00:01.0: reg 0x10: [io  0x0000-0x001f]
[    0.690467] pci 0000:00:01.0: reg 0x14: [mem 0x00000000-0x00000fff]
[    0.690685] pci 0000:00:01.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[    0.690800] pci 0000:00:01.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
[    0.691547] pci 0000:00:02.0: [1af4:1009] type 00 class 0x000200
[    0.691687] pci 0000:00:02.0: reg 0x10: [io  0x0000-0x003f]
[    0.691798] pci 0000:00:02.0: reg 0x14: [mem 0x00000000-0x00000fff]
[    0.691931] pci 0000:00:02.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[    0.694663] pci 0000:00:01.0: BAR 6: assigned [mem 0x10000000-0x1003ffff pref]
[    0.694980] pci 0000:00:01.0: BAR 4: assigned [mem 0x8000000000-0x8000003fff 64bit pref]
[    0.695232] pci 0000:00:02.0: BAR 4: assigned [mem 0x8000004000-0x8000007fff 64bit pref]
[    0.695398] pci 0000:00:01.0: BAR 1: assigned [mem 0x10040000-0x10040fff]
[    0.695560] pci 0000:00:02.0: BAR 1: assigned [mem 0x10041000-0x10041fff]
[    0.695699] pci 0000:00:02.0: BAR 0: assigned [io  0x1000-0x103f]
[    0.695827] pci 0000:00:01.0: BAR 0: assigned [io  0x1040-0x105f]
[    0.723487] virtio-pci 0000:00:01.0: enabling device (0000 -> 0003)
[    0.727062] virtio-pci 0000:00:02.0: enabling device (0000 -> 0003)
[    0.729663] xenfs: not registering filesystem on non-xen platform
[    0.751880] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[    0.760418] SuperH (H)SCI(F) driver initialized
[    0.762917] msm_serial: driver initialized
[    0.766553] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.811840] brd: module loaded
[    0.852090] loop: module loaded
[    0.853734] hisi_sas: driver version v1.6
[    0.871287] libphy: Fixed MDIO Bus: probed
[    0.874215] tun: Universal TUN/TAP device driver, 1.6
[    0.874294] tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
[    0.889533] e1000e: Intel(R) PRO/1000 Network Driver - 3.2.6-k
[    0.889636] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[    0.889982] igb: Intel(R) Gigabit Ethernet Network Driver - version 5.4.0-k
[    0.890088] igb: Copyright (c) 2007-2014 Intel Corporation.
[    0.890498] igbvf: Intel(R) Gigabit Virtual Function Network Driver - version 2.4.0-k
[    0.890637] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[    0.891022] sky2: driver version 1.30
[    0.894966] VFIO - User Level meta-driver version: 0.3
[    0.901735] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.901887] ehci-pci: EHCI PCI platform driver
[    0.902339] ehci-platform: EHCI generic platform driver
[    0.902941] ehci-exynos: EHCI EXYNOS driver
[    0.903417] ehci-msm: Qualcomm On-Chip EHCI Host Controller
[    0.903889] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.904064] ohci-pci: OHCI PCI platform driver
[    0.904525] ohci-platform: OHCI generic platform driver
[    0.905262] ohci-exynos: OHCI EXYNOS driver
[    0.908295] usbcore: registered new interface driver usb-storage
[    0.913536] mousedev: PS/2 mouse device common for all mice
[    0.918212] rtc-pl031 9010000.pl031: rtc core: registered pl031 as rtc0
[    0.920729] i2c /dev entries driver
[    0.935350] sdhci: Secure Digital Host Controller Interface driver
[    0.935469] sdhci: Copyright(c) Pierre Ossman
[    0.936463] Synopsys Designware Multimedia Card Interface Driver
[    0.938773] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.943455] ledtrig-cpu: registered to indicate activity on CPUs
[    0.950714] usbcore: registered new interface driver usbhid
[    0.950840] usbhid: USB HID core driver
[    0.962833] NET: Registered protocol family 17
[    0.964201] 9pnet: Installing 9P2000 support
[    0.966240] Key type dns_resolver registered
[    0.968614] registered taskstats version 1
[    0.975184] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    0.978068] rtc-pl031 9010000.pl031: setting system clock to 2017-03-20 06:00:31 UTC (1489989631)
[    0.978949] ALSA device list:
[    0.979032]   No soundcards found.
[    0.981541] uart-pl011 9000000.pl011: no DMA platform data
[    0.983448] RAMDISK: gzip image found at block 0
[    3.599083] EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null)
[    3.599404] VFS: Mounted root (ext4 filesystem) on device 1:0.
[    3.601412] devtmpfs: mounted
[    3.651244] Freeing unused kernel memory: 1024K

Please press Enter to activate this console.
[root@aarch64 ]#
[root@aarch64 ]#
[root@aarch64 ]#
[root@aarch64 ]# python
Python 2.7.13 (default, Mar 20 2017, 13:55:26)
[GCC 4.9.1 20140529 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> for i in rang[   34.888834] random: fast init done
e(10): print "Hello World", i
...
Hello World 0
Hello World 1
Hello World 2
Hello World 3
Hello World 4
Hello World 5
Hello World 6
Hello World 7
Hello World 8
Hello World 9


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: