在上一篇博文中我们用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的工具,这里需要首先下载编译一些依赖包。
zlib-1.2.11
下载: http://files.cnblogs.com/files/pengdonglin137/zlib-1.2.11.tar.gz 或者 mtd-utils-2.0.0.tar.bz2
下面是编译脚本:
1 #!/bin/bash
2
3 export CC=arm-linux-gcc
4
5 ../configure --prefix=`pwd`
6 --shared
然后编译make && make install
lzo-2.10
下载 http://files.cnblogs.com/files/pengdonglin137/lzo-2.10.tar.gz 或者 http://www.oberhumer.com/opensource/lzo/download/
编译脚本:
1 #!/bin/bash
2
3 ../configure --host=arm-linux
4 CC="arm-linux-gcc"
5 --prefix=`pwd`
然后编译make && make install
e2fsprogs-1.43.4
下载 http://files.cnblogs.com/files/pengdonglin137/e2fsprogs-1.43.4.tar.gz 或者 https://sourceforge.net/projects/e2fsprogs/files/latest/download?source=files
编译:
1 #!/bin/bash
2
3 ../configure --host=arm-linux
4 CC="arm-linux-gcc"
5 --prefix=`pwd`
编译 make && make install
mtd-utils
下载:http://git.infradead.org/mtd-utils.git 或者 http://files.cnblogs.com/files/pengdonglin137/mtd-utils-v2.tar.gz
编译:
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
参考博文 http://www.cnblogs.com/pengdonglin137/p/5028802.html
四、开机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.
设计资源 培训 开发板 精华推荐
- LTC3873IDDB-5、1W 隔离式家政电信转换器的典型应用电路
- LT3580,这款 350V 电源具有一个纤巧的 5.8mm-5.8mm 3mm 变压器,开关频率为 200kHz
- 使用 Analog Devices 的 AD8147ACPZ 的参考设计
- MPC86XADS、MPC8xx 参考板,基于 MPC860DP MPU PowerQUICC MPC8xx 处理器
- 使用 Analog Devices 的 LT1086CM 的参考设计
- LTC3633AIUFD-3 1.2V/1.8V 降压稳压器的典型应用电路,具有一致跟踪和 6V 输入 UVLO
- LTC1069-1 低功率、8 阶渐进椭圆、低通滤波器的典型应用
- FAN53600 3 MHz 600mA /1A 同步降压稳压器典型应用电路
- 使用用于白光 LED 的 TB62736FUG 升压 DC-DC 转换器的典型应用
- 使用 ROHM Semiconductor 的 BD46321 的参考设计
- 诺基亚6300 4G/8000 4G详细信息解密:搭载KaiOS
- Razer推出适用于新款Xbox的两款游戏耳机:Kaira与Kaira Pro
- 比赛怎可没欢呼声 MLB利用iPad模拟现场观众声音
- 苹果AirPods Studio或将亮相?
- 今晚iPhone 12 mini/Pro Max开始预订
- 视频渲染看细节:这样的小米11你喜欢吗?
- 消息称索尼已砍掉Xperia 10 Ⅱ Plus新机 或全力布局5G
- 苹果不忘iPhone 6等老机型:推出iOS 12.4.9正式版
- 小屏手机市场并不存在 iPhone 12 mini即使来了也没用
- 三星或将推256GB存储空间的Galaxy S20 FE