mini2440移植linux3.14.72内核笔记(1)

来源:互联网 发布:算法导论 中文版 pdf 编辑:程序博客网 时间:2024/05/01 18:05
转载自 http://www.256h.com/news/show/?402e24f70102w7tu.html

最有参考意义的是lingd大牛的http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=23089249&id=4293986文章,在此表示万分崇敬!

我下载的是3.14.72版本,而lingd是在3.14.6基础上移植。昨天花了一天时间按lingd的方法做了,确实成功了,但要注意:为了防止停留在加载kernel界面,直接使用mini2440的机器码1999!改了机器码,你需要重新移植bootloader,工作量加大很多。机器码重复没什么大不了的。
还有一个严重问题:64M内存只识别了16M!采取了很多方法都解决不了。最后的解决方法是:直接在干净的3.14.72内核基础上进行简单配置,而不用改bootloader就一切OK!原因就是3.14.72内核直接完美支持mini2440。有时间试一下4.3内核,但觉得应该使用最后的成熟版本,可能工作量小很多。如3.14.6移植需要很多修改,而3.14.72是3.14的最后版本,支持的硬件很丰富,移植就容易得多。
具体做法:

1、修改Makefile以便在make时候少输参数
[root@Fedora9i386 linux-3.14.72]# vi Makefile 
将198、199行修改为以下内容:
ARCH   ?= arm
CROSS_COMPILE ?= arm-linux-

2、生成.config文件
[root@Fedora9i386 linux-3.14.72]# cp arch/arm/configs/mini2440_config .config

3、配置内核
[root@Fedora9i386 linux-3.14.72]# make menuconfig

3.1 设置内核启动参数
Boot options  --->
() Default kernel command string  --->
填入以下内核启动参数:
noinitrd root=/dev/mtdblock3 rw mem=64M init=/linuxrc console=ttySAC0,115200

3.2 ftl_cs: FTL header not found.问题解决方法:取消以下内核配置选项
Device Drivers  ---> 
<*> Memory Technology Device (MTD) support  --->
< >   FTL (Flash Translation Layer) support  
< >   NFTL (NAND Flash Translation Layer) support
< >   INFTL (Inverse NAND Flash Translation Layer) support

3.3 添加RTC支持
Device Drivers  --->
[*] Real Time Clock  --->
<*> Samsung S3C series SoC RTC

4、添加yaffs2支持
需先打补丁,配置中才有yaff2支持。
4.1 获取yaffs源码
[root@Fedora9i386 linux-3.14.72]# git clone git://www.aleph1.co.uk/yaffs2 

4.2 为内核打yaffs2补丁
[root@Fedora9i386 linux-3.14.72]# cd yaffs2/
[root@Fedora9i386 linux-3.14.72/yaffs2]# ./patch-ker.sh l m ..
Updating 。。。linux-3.14.72/fs/Kconfig
Updating 。。。linux-3.14.72/fs/Makefile
特别注意:内核目录不要再改名或挪动位置,否则make将报错找不到这个yaffs2的补丁!

4.3 内核配置选项
File systems  --->
[*] Miscellaneous filesystems  --->
<*>   yaffs2 file system support // 这里缺省是M,一定要改为* 
-*-     512 byte / page devices
[ ]       Use older-style on-NAND data format with pageStatus byte
[ ]         Lets yaffs do its own ECC
-*-     2048 byte (or larger) / page devices
[*]       Autoselect yaffs2 format
[ ]       Disable yaffs from doing ECC on tags by default
[ ]     Force chunk erase check
[ ]     Empty lost and found on boot
[ ]     Disable yaffs2 block refreshing
[ ]     Disable yaffs2 background processing
[ ]     Disable yaffs2 bad block marking
[ ]     Enable yaffs2 xattr support

然后,make!成功后烧写内核测试。成功画面如下:

Superboot-2440 V1.3a(20131213) by FriendlyARM

Booting from NAND
Load Kernel...
Booting Linux on physical CPU 0x0
Linux version 3.14.72 (root@Fedora9i386) (gcc version 4.4.3 (ctng-1.6.1) ) #1 Mon Jan 1 21:11:32 CST 2018
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
Warning: Neither atags nor dtb found 
// bootloader不配套,内核参数没有传进来!故需要在内核配置中配置!
Memory policy: Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C24XX Clocks, Copyright 2004 Simtec Electronics
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
Kernel command line: noinitrd root=/dev/mtdblock3 rw init=/linuxrc mem=64M console=ttySAC0,115200
PID hash table entries: 256 (order: -2, 1024 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 59720K/65536K available (3637K kernel code, 187K rwdata, 964K rodata, 143K init, 243K bss, 5816K reserved)
// 终于认到64M内存了,lingd的试验中只认16M内存
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
    vmalloc : 0xc4800000 - 0xff000000   ( 936 MB)
    lowmem  : 0xc0000000 - 0xc4000000   (  64 MB)
    modules : 0xbf000000 - 0xc0000000   (  16 MB)
      .text : 0xc0008000 - 0xc048679c   (4602 kB)
      .init : 0xc0487000 - 0xc04aaf24   ( 144 kB)
      .data : 0xc04ac000 - 0xc04dad00   ( 188 kB)
       .bss : 0xc04dad00 - 0xc0517b50   ( 244 kB)
SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
NR_IRQS:103
S3C2440: IRQ Support
irq: clearing pending status 00000002
sched_clock: 16 bits at 1012kHz, resolution 987ns, wraps every 64725925ns
Console: colour dummy device 80x30
Calibrating delay loop... 201.52 BogoMIPS (lpj=503808)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0x3037a0b0 - 0x3037a108
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
MINI2440: Option string mini2440=0tb
MINI2440: 't' ignored, touchscreen not compiled in
MINI2440: LCD [0:240x320] 1:800x480 2:1024x768 3:320x240 // LCD配置有问题,待解决
S3C2440: Initialising architecture
S3C244X: Clock Support, DVS off
bio: create slab at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
s3c-i2c s3c2440-i2c.0: slave address 0x10
s3c-i2c s3c2440-i2c.0: bus frequency set to 98 KHz
s3c-i2c s3c2440-i2c.0: i2c-0: S3C I2C adapter
Switched to clocksource samsung_clocksource_timer
NET: Registered protocol family 2
TCP established hash table entries: 1024 (order: 0, 4096 bytes)
TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
TCP: Hash tables configured (established 1024 bind 1024)
TCP: reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
futex hash table entries: 256 (order: -1, 3072 bytes)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) 漏 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 116
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
Console: switching to colour frame buffer device 60x53
s3c2410-lcd s3c2410-lcd: fb0: s3c2410fb frame buffer device
s3c2440-uart.0: ttySAC0 at MMIO 0x50000000 (irq = 74, base_baud = 0) is a S3C2440
console [ttySAC0] enabled
s3c2440-uart.1: ttySAC1 at MMIO 0x50004000 (irq = 77, base_baud = 0) is a S3C2440
s3c2440-uart.2: ttySAC2 at MMIO 0x50008000 (irq = 80, base_baud = 0) is a S3C2440
brd: module loaded
at24 0-0050: 1024 byte 24c08 EEPROM, writable, 16 bytes/write
s3c24xx-nand s3c2440-nand: Tacls=1, 9ns Twrph0=3 29ns, Twrph1=2 19ns
s3c24xx-nand s3c2440-nand: NAND soft ECC
nand: device found, Manufacturer ID: 0xec, Chip ID: 0xda
nand: Samsung NAND 256MiB 3,3V 8-bit
nand: 256MiB, SLC, page size: 2048, OOB size: 64 // NAND信息
Creating 4 MTD partitions on "nand": // 4个分区
0x000000000000-0x000000040000 : "u-boot"
0x000000040000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000560000 : "kernel"
0x000000560000-0x000010000000 : "root"
dm9000 dm9000: read wrong id 0x01010101 // 网卡
dm9000 dm9000: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000e at c48ca300,c48cc304 IRQ 55 MAC: 92:9f:e9:e6:70:a2 (random)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci-s3c2410: OHCI S3C2410 driver
s3c2410-ohci s3c2410-ohci: OHCI Host Controller
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
mousedev: PS/2 mouse device common for all mice
s3c-rtc s3c2410-rtc: rtc disabled, re-enabling // 时钟
s3c-rtc s3c2410-rtc: rtc core: registered s3c as rtc0
i2c /dev entries driver
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq disabled
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
s3c-sdi s3c2440-sdi: running at 0kHz (requested: 0kHz).
s3c-sdi s3c2440-sdi: running at 398kHz (requested: 400kHz).
s3c-sdi s3c2440-sdi: mmc0 - using pio, sw SDIO IRQ
s3c-sdi s3c2440-sdi: powered down.
hidraw: raw HID events driver (C) Jiri Kosina
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
TCP: cubic registered
NET: Registered protocol family 17
Key type dns_resolver registered
input: gpio-keys as /devices/platform/gpio-keys/input/input0
s3c-rtc s3c2410-rtc: setting system clock to 2000-01-01 03:50:01 UTC (946698601)
yaffs: dev is 32505859 name is "mtdblock3" rw
yaffs: passed flags ""
VFS: Mounted root (yaffs filesystem) on device 31:3.
Freeing unused kernel memory: 140K (c0487000 - c04aa000)
mount: mounting none on /proc/bus/usb failed: No such file or directory
random: sshd urandom read with 9 bits of entropy available
[31/Dec/1999:19:50:15 +0000] boa: server version Boa/0.94.13
[31/Dec/1999:19:50:15 +0000] boa: server built Jul 26 2010 at 15:58:29.
[31/Dec/1999:19:50:15 +0000] boa: starting server pid=802, port 80
                        
open device leds: No such file or directory
Try to bring eth0 interface up......dm9000 dm9000 eth0: link down
Done

Please press Enter to activate this console. dm9000 dm9000 eth0: link up, 100Mbps, full-duplex, lpa 0xCDE1

[root@FriendlyARM /]# free
              total         used         free       shared      buffers
  Mem:        59860        21320        38540            0            0
 Swap:            0            0            0
Total:        59860        21320        38540
[root@FriendlyARM /]# uname -a
Linux FriendlyARM 3.14.72 #1 Mon Jan 1 21:11:32 CST 2018 armv4tl unknown
[root@FriendlyARM /]# free
              total         used         free       shared      buffers
  Mem:        59860        21308        38552            0            0
 Swap:            0            0            0
Total:        59860        21308        38552
[root@FriendlyARM /]# 

附注:如果修改网卡驱动dm9000.c,在读取ID的函数之前加上延时udelay(150)即可,添加位置位于 iow(db, DM9000_NCR, NCR_MAC_LBK | NCR_RST)之后,这是因为复位后要延时一小段时间才能正常读ID。其实意义不大,看改后的结果:
Creating 4 MTD partitions on "nand":
0x000000000000-0x000000040000 : "u-boot"
0x000000040000-0x000000060000 : "u-boot-env"
0x000000060000-0x000000560000 : "kernel"
0x000000560000-0x000010000000 : "root"
dm9000 dm9000: eth%d: Invalid ethernet MAC address. Please set using ifconfig
eth0: dm9000e at c48ca300,c48cc304 IRQ 55 MAC: ae:10:44:d0:09:41 (random)
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
ohci-s3c2410: OHCI S3C2410 driver
s3c2410-ohci s3c2410-ohci: OHCI Host Controller

[root@FriendlyARM /]# ifconfig
eth0      Link encap:Ethernet  HWaddr 08:90:90:90:90:90  
          inet addr:192.168.1.230  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:384 (384.0 B)  TX bytes:0 (0.0 B)
          Interrupt:55 Base address:0xa300 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

[root@FriendlyARM /]# 




嵌入式开发

linux3.14.72

内核移植

mini2440

0 0