移植Python3到TQ2440(二)

接着前一篇博文。
在上一篇博文中我们用NFS挂载根文件系统的方式启动了系统,接下来我们把移植了Python3的根文件系统固化到NandFlash中,但是由于linux-4.9目前不支持Yaffs2文件系统,所以我们用Jiffs2文件系统。
下面我们分为几部分:
1、移植mtd-utils工具
2、固化根文件系统到NandFlash中
3、支持Telnet
 

平台

硬件:TQ2440  64MB内存 256MB NandFlash
bootloader:U-Boot 2015.04
kernel:linux-4.9
Python: Python-3.6.0
工具链:arm-none-linux-gnueabi-gcc  4.8.3
 

正文

一、移植mtd-utils工具

mtd-utils提供了大量的用于操作Flash的工具,这里需要首先下载编译一些依赖包。
下面是编译脚本:
1 #!/bin/bash
2 
3 export CC=arm-linux-gcc
4 
5 ../configure --prefix=`pwd` \
6         --shared

然后编译make && make install

  • lzo-2.10
编译脚本:
1 #!/bin/bash
2 
3 ../configure --host=arm-linux \
4         CC="arm-linux-gcc" \
5         --prefix=`pwd`

然后编译make && make install

  • e2fsprogs-1.43.4
编译:
1 #!/bin/bash
2 
3 ../configure --host=arm-linux \
4         CC="arm-linux-gcc" \
5         --prefix=`pwd`

 编译 make && make install

  • mtd-utils
编译:
1 ( pengdl@ubuntu | ~/Study/tq2440/MTD_UTILS/mtd-utils-v2 | Remote:True )
2 $./autogen.sh
3 
4 ( pengdl@ubuntu | ~/Study/tq2440/MTD_UTILS/mtd-utils-v2 | Remote:True Ret: 130 @ 22:31:03 )
5 $cd build_tq2440/
6 
7 ( pengdl@ubuntu | ~/Study/tq2440/MTD_UTILS/mtd-utils-v2/build_tq2440 | Remote:True )
8 $./mk.sh 

编译脚本:

 1 #!/bin/bash
 2 
 3 export CC=arm-linux-gcc
 4 export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/pengdl/Study/tq2440/MTD_UTILS/e2fsprogs-1.43.4/build_tq2440/lib/uuid
 5 
 6 ../configure --host=arm-linux \
 7         --prefix=`pwd` \
 8         LDFLAGS="-L/home/pengdl/Study/tq2440/MTD_UTILS/zlib-1.2.11/build_tq2440/lib \
 9         -L/home/pengdl/Study/tq2440/MTD_UTILS/lzo-2.10/build_tq2440/lib \
10         -L/home/pengdl/Study/tq2440/MTD_UTILS/e2fsprogs-1.43.4/build_tq2440/lib" \
11         CPPFLAGS="-I/home/pengdl/Study/tq2440/MTD_UTILS/zlib-1.2.11/build_tq2440/include \
12         -I/home/pengdl/Study/tq2440/MTD_UTILS/lzo-2.10/build_tq2440/include \
13         -I/home/pengdl/Study/tq2440/MTD_UTILS/e2fsprogs-1.43.4/build_tq2440/include"
14 
15 make -j4
16 make install

在sbin下面会生成我们需要的工具, 这里我们只要flash_eraseall和flash_erase两个工具, 将这两个工具拷贝到根文件系统的/bin下面。

二、固化根文件系统到NandFlash

先把前一篇博文中生成的rootfs目录进行压缩:
sudo tar -czf rootfs.tar.gz rootfs

然后将rootfs.tar.gz拷贝到根文件系统下面,然后启动系统,烧写系统:

1 flash_eraseall  /dev/mtd5
2 mount -t jffs2 /dev/mtdblock5 /mnt
3 tar -xf rootfs.tar.gz /mnt
4 cd /mnt
5 mv rootfs/* .
6 rm -r rootfs

然后修改uboot的bootargs参数:

noinitrd root=/dev/mtdblock5 rw rootfstype=jffs2 console=ttySAC0,115200n init=/linuxrc

三、支持telnet

四、开机log

  1 U-Boot 2015.04-g5095150 (Dec 21 2015 - 06:17:05)
  2 
  3 CPUID: 32440001
  4 FCLK:      400 MHz
  5 HCLK:      100 MHz
  6 PCLK:       50 MHz
  7 I2C:   ready
  8 DRAM:  64 MiB
  9 WARNING: Caches not enabled
 10 Flash: 0 Bytes
 11 NAND:  256 MiB
 12 In:    serial
 13 Out:   serial
 14 Err:   serial
 15 Net:   dm9000
 16 Hit any key to stop autoboot:  0 
 17 
 18 NAND read: device 0 offset 0x300000, size 0x500000
 19  5242880 bytes read: OK
 20 
 21 NAND read: device 0 offset 0x800000, size 0x100000
 22  1048576 bytes read: OK
 23 ## Booting kernel from Legacy Image at 30008000 ...
 24    Image Name:   Linux-4.9.0+
 25    Created:      2017-04-19  10:07:00 UTC
 26    Image Type:   ARM Linux Kernel Image (uncompressed)
 27    Data Size:    3503832 Bytes = 3.3 MiB
 28    Load Address: 30008000
 29    Entry Point:  30008000
 30    Verifying Checksum ... OK
 31 ## Flattened Device Tree blob at 32000000
 32    Booting using the fdt blob at 0x32000000
 33    Loading Kernel Image ... OK
 34    Loading Device Tree to 33aa6000, end 33aaa62c ... OK
 35 
 36 Starting kernel ...
 37 
 38 Uncompressing Linux... done, booting the kernel.
 39 [    0.000000] Booting Linux on physical CPU 0x0
 40 [    0.000000] Linux version 4.9.0+ (pengdl@ubuntu) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #2 Wed Apr 19 03:06:50 PDT 2017
 41 [    0.000000] CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c000717f
 42 [    0.000000] CPU: VIVT data cache, VIVT instruction cache
 43 [    0.000000] OF: fdt:Machine model: TQ2440
 44 [    0.000000] Memory policy: Data cache writeback
 45 [    0.000000] DT missing boot CPU MPIDR[23:0], fall back to default cpu_logical_map
 46 [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
 47 [    0.000000] Kernel command line: noinitrd root=/dev/mtdblock5 rw rootfstype=jffs2  console=ttySAC0,115200n init=/linuxrc
 48 [    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
 49 [    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
 50 [    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
 51 [    0.000000] Memory: 57900K/65536K available (4729K kernel code, 234K rwdata, 1376K rodata, 204K init, 262K bss, 7636K reserved, 0K cma-reserved)
 52 [    0.000000] Virtual kernel memory layout:
 53 [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
 54 [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
 55 [    0.000000]     vmalloc : 0xc4800000 - 0xff800000   ( 944 MB)
 56 [    0.000000]     lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
 57 [    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
 58 [    0.000000]       .text : 0xc0008000 - 0xc04a67f0   (4730 kB)
 59 [    0.000000]       .init : 0xc0627000 - 0xc065a000   ( 204 kB)
 60 [    0.000000]       .data : 0xc065a000 - 0xc0694840   ( 235 kB)
 61 [    0.000000]        .bss : 0xc0694840 - 0xc06d60a8   ( 263 kB)
 62 [    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
 63 [    0.000000] NR_IRQS:103
 64 [    0.000000] irq: clearing pending status 00000002
 65 [    0.000000] _get_rate: could not find clock xti
 66 [    0.000128] sched_clock: 16 bits at 1000kHz, resolution 1000ns, wraps every 32767500ns
 67 [    0.000262] clocksource: samsung_clocksource_timer: mask: 0xffff max_cycles: 0xffff, max_idle_ns: 29163075 ns
 68 [    0.001283] Console: colour dummy device 80x30
 69 [    0.001485] Calibrating delay loop... 199.47 BogoMIPS (lpj=498688)
 70 [    0.035125] pid_max: default: 32768 minimum: 301
 71 [    0.035715] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
 72 [    0.035803] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
 73 [    0.039125] CPU: Testing write buffer coherency: ok
 74 [    0.041713] Setting up static identity map for 0x30008200 - 0x30008258
 75 [    0.067192] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302231375000 ns
 76 [    0.067812] pinctrl core: initialized pinctrl subsystem
 77 [    0.071047] NET: Registered protocol family 16
 78 [    0.074165] DMA: preallocated 256 KiB pool for atomic coherent allocations
 79 [    0.096405] cpuidle: using governor ladder
 80 [    0.097029] No ATAGs?
 81 [    0.355694] SCSI subsystem initialized
 82 [    0.357161] usbcore: registered new interface driver usbfs
 83 [    0.357830] usbcore: registered new interface driver hub
 84 [    0.358518] usbcore: registered new device driver usb
 85 [    0.362268] Advanced Linux Sound Architecture Driver Initialized.
 86 [    0.393373] clocksource: Switched to clocksource samsung_clocksource_timer
 87 [    0.460629] NET: Registered protocol family 2
 88 [    0.464553] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
 89 [    0.464669] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
 90 [    0.464723] TCP: Hash tables configured (established 1024 bind 1024)
 91 [    0.465667] UDP hash table entries: 256 (order: 0, 4096 bytes)
 92 [    0.465778] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
 93 [    0.466911] NET: Registered protocol family 1
 94 [    0.545633] RPC: Registered named UNIX socket transport module.
 95 [    0.545741] RPC: Registered udp transport module.
 96 [    0.545757] RPC: Registered tcp transport module.
 97 [    0.545773] RPC: Registered tcp NFSv4.1 backchannel transport module.
 98 [    0.553953] futex hash table entries: 256 (order: -1, 3072 bytes)
 99 [    0.562980] workingset: timestamp_bits=30 max_order=14 bucket_order=0
100 [    0.697643] NFS: Registering the id_resolver key type
101 [    0.697875] Key type id_resolver registered
102 [    0.697912] Key type id_legacy registered
103 [    0.697998] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
104 [    0.698281] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
105 [    0.707965] romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
106 [    0.728928] io scheduler noop registered
107 [    0.729037] io scheduler deadline registered
108 [    0.731029] io scheduler cfq registered (default)
109 [    0.945571] 50000000.serial: ttySAC0 at MMIO 0x50000000 (irq = 32, base_baud = 0) is a S3C2440
110 [    1.303277] random: fast init done
111 [    1.537741] console [ttySAC0] enabled
112 [    1.693858] brd: module loaded
113 [    1.698712] s3c24xx-nand 4e000000.nand: Tacls=1, 10ns Twrph0=3 30ns, Twrph1=1 10ns
114 [    1.701109] s3c24xx-nand 4e000000.nand: NAND ECC disabled
115 [    1.706441] nand: device found, Manufacturer ID: 0xec, Chip ID: 0xda
116 [    1.712658] nand: Samsung NAND 256MiB 3,3V 8-bit
117 [    1.717150] nand: 256 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
118 [    1.724707] nand: NAND_ECC_NONE selected by board driver. This is not recommended!
119 [    1.732301] Scanning device for bad blocks
120 [    1.761552] Bad eraseblock 364 at 0x000002d80000
121 [    1.761944] Bad eraseblock 369 at 0x000002e20000
122 [    1.774618] Bad eraseblock 558 at 0x0000045c0000
123 [    1.810576] Bad eraseblock 1291 at 0x00000a160000
124 [    1.835265] Bad eraseblock 1792 at 0x00000e000000
125 [    1.835424] Bad eraseblock 1793 at 0x00000e020000
126 [    1.851744] Creating 6 MTD partitions on "tq2440-0":
127 [    1.851909] 0x000000000000-0x000000100000 : "SPL"
128 [    1.860632] ftl_cs: FTL header not found.
129 [    1.867840] 0x000000100000-0x000000200000 : "U-BOOT"
130 [    1.876060] ftl_cs: FTL header not found.
131 [    1.881673] 0x000000200000-0x000000300000 : "PARAMS"
132 [    1.887146] ftl_cs: FTL header not found.
133 [    1.895758] 0x000000300000-0x000000800000 : "KERNEL"
134 [    1.904875] ftl_cs: FTL header not found.
135 [    1.910723] 0x000000800000-0x000000900000 : "DTB"
136 [    1.916009] ftl_cs: FTL header not found.
137 [    1.925445] 0x000000900000-0x000010000000 : "ROOTFS"
138 [    1.937184] ftl_cs: FTL header not found.
139 [    1.949791] eth0: dm9000e at c4932000,c4934004 IRQ 7 MAC: 00:00:de:ad:be:ef (platform data)
140 [    1.953206] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
141 [    1.959146] ohci-s3c2410: OHCI S3C2410 driver
142 [    1.966554] s3c2410-ohci 49000000.usb_ohci: OHCI Host Controller
143 [    1.969213] s3c2410-ohci 49000000.usb_ohci: new USB bus registered, assigned bus number 1
144 [    1.978389] s3c2410-ohci 49000000.usb_ohci: irq 26, io mem 0x49000000
145 [    2.049314] hub 1-0:1.0: USB hub found
146 [    2.051489] hub 1-0:1.0: 2 ports detected
147 [    2.057806] usbcore: registered new interface driver usb-storage
148 [    2.060801] mousedev: PS/2 mouse device common for all mice
149 [    2.066162] s3c-rtc 57000000.rtc: rtc disabled, re-enabling
150 [    2.070382] rtc rtc0: alarm rollover not handled
151 [    2.073906] rtc rtc0: invalid alarm value: 1900-2-1 0:0:0
152 [    2.080535] s3c-rtc 57000000.rtc: rtc core: registered s3c as rtc0
153 [    2.086568] i2c /dev entries driver
154 [    2.093037] s3c2410-wdt 53000000.watchdog: watchdog inactive, reset disabled, irq disabled
155 [    2.099750] sdhci: Secure Digital Host Controller Interface driver
156 [    2.103179] sdhci: Copyright(c) Pierre Ossman
157 [    2.110337] hidraw: raw HID events driver (C) Jiri Kosina
158 [    2.122224] usbcore: registered new interface driver usbhid
159 [    2.122350] usbhid: USB HID core driver
160 [    2.131286] NET: Registered protocol family 17
161 [    2.132068] Key type dns_resolver registered
162 [    2.197106] s3c-rtc 57000000.rtc: setting system clock to 2000-04-12 01:57:40 UTC (955504660)
163 [    2.201017] ALSA device list:
164 [    2.203000]   No soundcards found.
165 [    8.385039] VFS: Mounted root (jffs2 filesystem) on device 31:5.
166 [    8.386953] Freeing unused kernel memory: 204K (c0627000 - c065a000)
167 [    8.392017] This architecture does not have kernel memory protection.
168 [   11.614549] dm9000 20000000.ethernet eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1
169 
170 Please press Enter to activate this console. 
171 [root@tq2440 ]# 
172 [root@tq2440 ]# mount
173 /dev/root on / type jffs2 (rw,relatime)
174 proc on /proc type proc (rw,relatime)
175 tmpfs on /tmp type tmpfs (rw,relatime)
176 sysfs on /sys type sysfs (rw,relatime)
177 tmpfs on /dev type tmpfs (rw,relatime)
178 debugfs on /sys/kernel/debug type debugfs (rw,relatime)
179 devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
180 [root@tq2440 ]# cat /proc/mtd 
181 dev:    size   erasesize  name
182 mtd0: 00100000 00020000 "SPL"
183 mtd1: 00100000 00020000 "U-BOOT"
184 mtd2: 00100000 00020000 "PARAMS"
185 mtd3: 00500000 00020000 "KERNEL"
186 mtd4: 00100000 00020000 "DTB"
187 mtd5: 0f700000 00020000 "ROOTFS"
188 [root@tq2440 ]# 

 

完。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值