目標板:dma2440
編譯工具:crosstool-0.43 ( gcc-4.1.1-glibc-2.3.6)
編輯 ~/.bashrc 在檔案最底下加入Cross-Toolchain 路徑 與 自己的指令(yc_make),這樣可以省去一些修改Makefile的瑣事
PATH=$PATH:$HOME/bin:/opt/crosstool/gcc-4.1.1-glibc-2.3.6/arm-linux-gnu/bin
alias yc_make='make CROSS_COMPILE=arm-linux-gnu- V=1 ARCH=arm'
改好之後關閉終端機,重新開啟套用新設定。
接下來,開始進行移植的工作
1. 下載需要的 source code
kernel:
由台灣的 mirrow site: http://www.tw.kernel.org/linux/kernel/v2.6/
下載 linux-2.6.27.4.tar.bz2
yaffs2:
由 http://www.yaffs.net/
下載 yaffs2.tar.gz
2. 將 yaffs2 加入到 kernel 編譯選項
在個人目錄底下解壓縮 linux-2.6.27.4.tar.bz2與 yaffs2.tar.gz
yctsai@yc-ubuntu:~$ cd yaffs2/
yctsai@yc-ubuntu:~/yaffs2$ ./patch-ker.sh c ~/linux-2.6.27.4/
3.修改 kernel source 與 編譯
yctsai@yc-ubuntu:~$ cd linux-2.6.27.4/
(1)編輯 arch/arm/plat-s3c24xx/common-smdk.c
修改 mtd分區:(盡量先避開NANDFlash 的Bad Block)
static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "Bootloader",
.size = 0x40000,
.offset = 0,
},
[1] = {
.name = "Kernel",
.offset = 0x2b0000,
.size = 0x5c0000,
},
[2] = {
.name = "Filesystem",
.offset = 0xc00000,
.size = 0x1b00000,
}
/*
[3] = {
.name = "S3C2410 flash partition 3",
.offset = SZ_8M,
.size = SZ_2M,
},
[4] = {
.name = "S3C2410 flash partition 4",
.offset = SZ_1M * 10,
.size = SZ_4M,
},
[5] = {
.name = "S3C2410 flash partition 5",
.offset = SZ_1M * 14,
.size = SZ_1M * 10,
},
[6] = {
.name = "S3C2410 flash partition 6",
.offset = SZ_1M * 24,
.size = SZ_1M * 24,
},
[7] = {
.name = "S3C2410 flash partition 7",
.offset = SZ_1M * 48,
.size = SZ_16M,
}
*/
};
(2)編輯 arch/arm/mach-s3c2440/mach-smdk2440.c
修改時脈:
//s3c24xx_init_clocks(16934400);
s3c24xx_init_clocks(12000000);
修改Lcd:(根據開發板)
/* LCD driver info */
static struct s3c2410fb_display smdk2440_lcd_cfg __initdata = {
.lcdcon5 = S3C2410_LCDCON5_FRM565
S3C2410_LCDCON5_INVVLINE
S3C2410_LCDCON5_INVVFRAME
S3C2410_LCDCON5_PWREN
S3C2410_LCDCON5_HWSWP,
.type = S3C2410_LCDCON1_TFT,
.width = 480,//240,
.height = 272,//320,
.pixclock = 166667, /* HCLK 60 MHz, divisor 10 */
.xres = 480,//240,
.yres = 272,//320,
.bpp = 16,
.left_margin = 8,//20,
.right_margin = 4,//8,
.hsync_len = 4,
.upper_margin = 6,//8,
.lower_margin = 8,//7,
.vsync_len = 2,//4,
};
static struct s3c2410fb_mach_info smdk2440_fb_info __initdata = {
.displays = &smdk2440_lcd_cfg,
.num_displays = 1,
.default_display = 0,
#if 0
/* currently setup by downloader */
.gpccon = 0xaa940659,
.gpccon_mask = 0xffffffff,
.gpcup = 0x0000ffff,
.gpcup_mask = 0xffffffff,
.gpdcon = 0xaa84aaa0,
.gpdcon_mask = 0xffffffff,
.gpdup = 0x0000faff,
.gpdup_mask = 0xffffffff,
#endif
// .lpcsel = ((0xCE6) & ~7) 1<<4, gpccon =" 0xaa8096a9," gpccon_mask =" 0xffc0ffff," gpcup =" (0x1f<<11)" gpcup_mask =" 0x00000000," gpdcon =" 0xaa80aaa0," gpdcon_mask =" 0xffc0fff0," gpdup =" (0x1f<<11)" gpdup_mask =" 0x00000000," lpcsel =" 0xc0c,">
(3)設定kernel與編譯
初始化kernel設定選項:
yctsai@yc-ubuntu:~/linux-2.6.27.4$ yc_make s3c2410_defconfig
開始設定kernel:
yctsai@yc-ubuntu:~/linux-2.6.27.4$ yc_make xconfig
取消一些不必要的裝置設定 ... ... (記得勾選 yaffs2支援)
存檔設定,也另存設定檔到 arch/arm/configs/s3c2440_defconfig
編譯 kernel 成 uImage:
yctsai@yc-ubuntu:~/linux-2.6.27.4$ yc_make uImage
開始等待編譯結果 ... ...
在 arch/arm/boot/ 底下可以找到kernel的映象檔 uImage
(4) 燒寫到 nand flash並嘗試啟動
透過 u-boot 燒寫,並且啟動 ... ...
首次啟動時,發現了一些裝置錯誤,經過重新調整 kernel參數
重新編譯、重新燒寫啟動之後 ...
終於... ...
U-Boot 1.3.1 (Oct 2 2008 - 18:10:13)
DRAM: 64 MB
Flash: 1 MB
NAND: NAND flash probing at 0x4E000000
64 MB
*** Warning - bad CRC or NAND, using default environment
In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
NAND read: device 0 offset 262144, size 1835008 ...
1605632 bytes read: ERROR
## Booting image at 32000000 ...
Image Name: Linux-2.6.27.4
Created: 2008-11-02 3:59:20 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 1970732 Bytes = 1.9 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
OK
Starting kernel ...
Uncompressing Linux................................................................................. ........................................... done, booting the kernel.
Linux version 2.6.27.4 (yctsai@yc-ubuntu) (gcc version 4.1.1) #2 Sun Nov 2 11:59:02 CST 2008
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
Machine: SMDK2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C244X: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
S3C24XX Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
Kernel command line: root=/dev/mtdblock2 rootfstype=cramfs init=/linuxrc console=ttySAC1,115200 mem= 65536K
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000010
PID hash table entries: 256 (order: 8, 1024 bytes)
timer tcon=00500000, tcnt a4ca, tcfg 00000200,00000000, usec 00001e57
Console: colour dummy device 80x30
console [ttySAC1] enabled
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 64MB = 64MB total
Memory: 60804KB available (3592K code, 303K data, 144K init)
Calibrating delay loop... 201.93 BogoMIPS (lpj=504832)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
net_namespace: 440 bytes
NET: Registered protocol family 16
S3C2410 Power Management, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics
DMA channel 0 at c4800000, irq 33
DMA channel 1 at c4800040, irq 34
DMA channel 2 at c4800080, irq 35
DMA channel 3 at c48000c0, irq 36
S3C244X: Clock Support, DVS off
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 2048 (order: 2, 16384 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
NET: Registered protocol family 1
NetWinder Floating Point Emulator V0.97 (extended precision)
JFFS2 version 2.2. (NAND) (SUMMARY) ? 2001-2006 Red Hat, Inc.
yaffs Nov 2 2008 11:10:08 Installing.
msgmni has been set to 118
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler deadline registered
io scheduler cfq registered
Console: switching to colour frame buffer device 60x34
fb0: s3c2410fb frame buffer device
Serial: 8250/16550 driver4 ports, IRQ sharing enabled
s3c2440-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2440-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2440-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
brd: module loaded
loop: module loaded
dm9000 Ethernet Driver, V1.31
Driver 'sd' needs updating - please use bus_type methods
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand s3c2440-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 114 at 0x001c8000
Bad eraseblock 170 at 0x002a8000
Bad eraseblock 542 at 0x00878000
Bad eraseblock 739 at 0x00b8c000
Bad eraseblock 2515 at 0x0274c000
Bad eraseblock 3088 at 0x03040000
Bad eraseblock 4079 at 0x03fbc000
Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00040000 : "Bootloader"
0x00040000-0x00300000 : "Linux Kernel"
0x00300000-0x04000000 : "Root Filesystem"
usbmon: debugfs is not available
s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000
usb usb1: configuration #1 chosen from 1 choice
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
usbcore: registered new interface driver libusual
usbcore: registered new interface driver usbserial
usbserial: USB Serial support registered for generic
usbcore: registered new interface driver usbserial_generic
usbserial: USB Serial Driver core
usbserial: USB Serial support registered for FTDI USB Serial Device
usbcore: registered new interface driver ftdi_sio
ftdi_sio: v1.4.3:USB FTDI Serial Converters Driver
usbserial: USB Serial support registered for pl2303
usbcore: registered new interface driver pl2303
pl2303: Prolific PL2303 USB to serial adaptor driver
mice: PS/2 mouse device common for all mice
s3c2440-i2c s3c2440-i2c: slave address 0x10
s3c2440-i2c s3c2440-i2c: bus frequency set to 98 KHz
s3c2440-i2c s3c2440-i2c: i2c-0: S3C I2C adapter
S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics
s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled
TCP cubic registered
NET: Registered protocol family 17
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
List of all partitions:
1f00 256 mtdblock0 (driver?)
1f01 2816 mtdblock1 (driver?)
1f02 62464 mtdblock2 (driver?)
No filesystem could mount root, tried: cramfs
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
接下來,就準備來掛上 root file system
0 意見:
張貼意見