最近花点时间,将手头上的基于OMAP-L138处理器的Linux内核平台进行了升级,移植了linux-3.4.5版本的内核。移植过程中遇到了不少问题,后续将会贴出所遇到问题对应的解决过程,首先贴出移植后的Linux-3.4.5内核启动信息吧!
Booting with TI UBL
xxx(保密屏蔽) UBL version: V5.x.y_z (201x-yy-zz)
Device OPP (450MHz, 1.3V)
U-Boot 2009.11 (Jul 4 2012 - 16:23:52)
xxx(保密屏蔽 boot version: V5.x.y_z
I2C: ready
DRAM: 128 MB
Flash: 128 MB
Using default environment
In: serial
Out: serial
Err: serial
ARM Clock : 450000000 Hz
DDR Clock : 150000000 Hz
DSP: wake up
Net: Ethernet PHY: GENERIC @ 0x07
autoboot in 2 seconds (stop with 'c')...
## Booting kernel from Legacy Image at 60080000 ...
Image Name: Linux-3.4.5
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1362048 Bytes = 1.3 MB
Load Address: c0008000
Entry Point: c0008000
Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 60300000 ...
Image Name: Ram disk (xxx(保密屏蔽): Vx.y.z-m)
Image Type: ARM Linux RAMDisk Image (gzip compressed)
Data Size: 6459406 Bytes = 6.2 MB
Load Address: c4f00000
Entry Point: c4f00000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Booting Linux on physical CPU 0
Linux version 3.4.5 (root@xxxxx) (gcc version 4.2.2) #62 Sun Apr 28 09:05:51 CST 2013
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: DaVinci DA850/OMAP-L138/AM18x EVM
Memory policy: ECC disabled, Data cache writethrough
BUG: mapping for 0xffff0000 at 0xfffe0000 out of vmalloc space
DaVinci da850/omap-l138/am18x variant 0x1
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 28448
Kernel command line: console=ttyS2,115200n8 initrd=0xc4f00000,32M rw root=/dev/ram0 rootfstype=ext2 mem=112M mtdparts=physmap-flash.0:512k(bootloader)ro,2560k(kernal0)ro,8M(ramdisk0)ro,2560k(kernal1)ro,8M(ramdisk1)ro,10752k(log),68M(jffs2),20M(golden) mac=00:30:bf:01:02:d2
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 112MB = 112MB total
Memory: 77840k/77840k available, 36848k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
vmalloc : 0xc7800000 - 0xff000000 ( 888 MB)
lowmem : 0xc0000000 - 0xc7000000 ( 112 MB)
pkmap : 0xbfe00000 - 0xc0000000 ( 2 MB)
modules : 0xbf000000 - 0xbfe00000 ( 14 MB)
.text : 0xc0008000 - 0xc027f000 (2524 kB)
.init : 0xc027f000 - 0xc029c000 ( 116 kB)
.data : 0xc029c000 - 0xc02be9c0 ( 139 kB)
.bss : 0xc02be9e4 - 0xc02f6384 ( 223 kB)
NR_IRQS:245
sched_clock: 32 bits at 25MHz, resolution 40ns, wraps every 171798ms
Calibrating delay loop... 223.64 BogoMIPS (lpj=1118208)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
Setting up static identity map for 0xc0232b98 - 0xc0232bd4
devtmpfs: initialized
gpiochip_add: registered GPIOs 0 to 31 on device: DaVinci
gpiochip_add: registered GPIOs 32 to 63 on device: DaVinci
gpiochip_add: registered GPIOs 64 to 95 on device: DaVinci
gpiochip_add: registered GPIOs 96 to 127 on device: DaVinci
gpiochip_add: registered GPIOs 128 to 143 on device: DaVinci
DaVinci: 144 gpio irqs
NET: Registered protocol family 16
bio: create slab <bio-0> at 0
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Switching to clocksource timer0_1
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
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.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (no cpio magic); looks like an initrd
Freeing initrd memory: 32768K
EMAC: MII PHY configured, RMII PHY will not be functional
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
msgmni has been set to 216
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
HDLC line discipline maxframe=4096
N_HDLC line discipline registered.
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
serial8250.0: ttyS0 at MMIO 0x1c42000 (irq = 25) is a 16550A
serial8250.0: ttyS1 at MMIO 0x1d0c000 (irq = 53) is a 16550A
serial8250.0: ttyS2 at MMIO 0x1d0d000 (irq = 61) is a 16550A
console [ttyS2] enabled
brd: module loaded
loop: module loaded
physmap platform flash device: 07800000 at 60000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x002801
NOR chip too large to fit in mapping. Attempting to cope...
Amd/Fujitsu Extended Query Table at 0x0040
Amd/Fujitsu Extended Query version 1.3.
number of CFI chips: 1
Reducing visibility of 131072KiB chip to 122880KiB
8 cmdlinepart partitions found on MTD device physmap-flash.0
Creating 8 MTD partitions on "physmap-flash.0":
0x000000000000-0x000000080000 : "bootloader"
0x000000080000-0x000000300000 : "kernal0"
0x000000300000-0x000000b00000 : "ramdisk0"
0x000000b00000-0x000000d80000 : "kernal1"
0x000000d80000-0x000001580000 : "ramdisk1"
0x000001580000-0x000002000000 : "log"
0x000002000000-0x000006400000 : "jffs2"
0x000006400000-0x000007800000 : "golden"
Generic platform RAM MTD, (c) 2004 Simtec Electronics
Fixed MDIO Bus: probed
tun: Universal TUN/TAP device driver, 1.6
tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
davinci_mdio davinci_mdio.0: davinci mdio revision 1.5
davinci_mdio davinci_mdio.0: detected phy mask ffffff7f
davinci_mdio.0: probed
davinci_mdio davinci_mdio.0: phy[7]: device davinci_mdio-0:07, driver Micrel KS8001 or KS8721
PPP generic driver version 2.4.2
omap_rtc omap_rtc: rtc core: registered omap_rtc as rtc0
omap_rtc: RTC power up reset detected
watchdog watchdog: heartbeat 600 sec
cpuidle: using governor ladder
TCP: cubic registered
NET: Registered protocol family 17
omap_rtc omap_rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
RAMDISK: gzip image found at block 0
VFS: Mounted root (ext2 filesystem) on device 1:0.
Freeing init memory: 116K
System initialization...
Hostname : xxx(保密屏蔽)
Filesystem : xxx(保密屏蔽) initrd version: Vx.y.z-m (2012-03-06 13:56:35)
Kernel release : Linux 3.4.5
Kernel version : #62 Sun Apr 28 09:05:51 CST 2013
Mounting default filesystems ...
Enabling hot-plug ...
Create modules.dep ...
Starting syslogd ...
Starting inetd ...
Starting telnetd ...
Starting sshd ...
Mounting /mnt/flash ...
问题一:无法识别NorFlash中的分区信息
NorFlash的分区信息是uboot传递给内核,但是启动后一直无法看到以下信息:
physmap platform flash device: 07800000 at 60000000
physmap-flash.0: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x002801
NOR chip too large to fit in mapping. Attempting to cope...
Amd/Fujitsu Extended Query Table at 0x0040
Amd/Fujitsu Extended Query version 1.3.
number of CFI chips: 1
Reducing visibility of 131072KiB chip to 122880KiB
8 cmdlinepart partitions found on MTD device physmap-flash.0
Creating 8 MTD partitions on "physmap-flash.0":
0x000000000000-0x000000080000 : "bootloader"
0x000000080000-0x000000300000 : "kernal0"
0x000000300000-0x000000b00000 : "ramdisk0"
0x000000b00000-0x000000d80000 : "kernal1"
0x000000d80000-0x000001580000 : "ramdisk1"
0x000001580000-0x000002000000 : "log"
0x000002000000-0x000006400000 : "jffs2"
0x000006400000-0x000007800000 : "golden"
看到这个关键打印信息“physmap platform flash device: 07800000 at 60000000”就知道问题所在了,需要修改内核的配置,相关详细配置如下(需要与实际硬件板上设定保持一致):
/* important notice--mtd driver configuration
* Device Drivers --->
* <*> Memory Technology Device (MTD) support --->
* <*> Mapping drivers for chip acccess --->
* <*> Flash device in physical memory map
* [*] Physmap compat support
* (0x60000000) Physical start address of flash mapping
* (0x07800000) Physical length of flash mapping
* (2) Bank width in octets
*/
其实只要对linux内核相关配置选项有一定了解的人来说,该配置不难解决。
问题二:无法识别以太网卡
造成这个问题的主要原因还是内核的配置有问题,需要选定Davinci的EMAC驱动,相关详细配置如下:
/* important notice--net driver configuration
* Device Drivers --->
* [*] Network device support --->
* --- Network device support
* [*] Ethernet deriver support --->
* --- Network device support
* [*] Micrel devices
* [*] Texas Instruments (TI) devices
* <*> TI DaVinci EMAC Support
*/
设定相关配置后,在启动后使用ifconfig -a命令可以正常看到eth0
问题3:使用ifconfig eth0命令时打印mdio驱动无法找到对应的phy设备(具体的打印信息忘了截取)
解决思路是在arch\arm\mach-davinci\board-da850-evm.c文件中,修改PHY_ID,保持与硬件网卡的PHY_ADDR置一致
//#define DA850_EVM_PHY_ID "davinci_mdio-0:00"//原内核配置
#define DA850_EVM_PHY_ID"davinci_mdio-0:07" //Added by xxxxx--keep the same with your schematics
问题4:使用ifconfig eth0命令时打印eth0的irq中断处理注册失败(具体的打印信息忘了截取)
查找打印信息,可以定位到源码以下位置:drivers\net\ethernet\ti\davinci_emac.c中的static int emac_dev_open(struct net_device *ndev)函数
在该函数中当eth设备激活时会进行中断的注册,代码是:
if (request_irq(i, emac_irq, IRQF_DISABLED,
ndev->name, ndev))
goto rollback;
该部分代码有点小问题,由于OMAP_L138芯片的eth的数据收发很多都是采用共享中断进行处理,因此注册中断处理函数时记得添加IRQF_SHARED标志,表明该中断线上的中断处理支持共享。修改后的代码如下:
if (request_irq(i, emac_irq, (IRQF_DISABLED | IRQF_SHARED), //Added by Kevin Liu should added IRQF_SHARED
ndev->name, ndev))
goto rollback;