Chinaunix首页 | 论坛 | 博客
  • 博客访问: 246477
  • 博文数量: 35
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 334
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-10 21:31
文章分类

全部博文(35)

文章存档

2010年(22)

2009年(13)

我的朋友

分类: 嵌入式

2009-11-10 21:53:08

 第一步 修改Makefile文件如下

1、添加

 CROSS_COMPILE =  /usr/local/arm/3.3.2/bin/arm-linux-

 # set default to nothing for native builds
 ifeq ($(HOSTARCH),$(ARCH))
 CROSS_COMPILE ?=

2__LIBS := $(subst $(obj),,$(LIBS)) $(subst $(obj),,$(LIBBOARD))

修改为
__LIBS := $(subst $(obj),,$(LIBBOARD)) $(subst $(obj),,$(LIBS))

3、添加

utu2440_config : unconfig
 @$(MKCONFIG) $(@:_config=) arm arm920t utu2440 samsung s3c24x0

 

第二步 添加utu2440开发板目录

1cp -rf board/samsung/smdk2410 board/samsung/utu2440

2mv board/samsung/utu2440/smdk2410.c /board/samsung/utu2440/utu2440.c

3、修改board/samsung/utu2440/Makefile

COBJS := smdk2410.o flash.o

修改为:

COBJS := utu2440.o flash.o

4、创建开发板配置文件

cp include/configs/smdk2410.h include/configs/utu2440.h

 

第三步 编译测试

1make utu2440_config

2make(由于编译器不同,可能出现硬浮点问题)

3、硬浮点问题解决

修改cpu/arm920t/config.mk

PLATFORM_RELFLAGS += -fno-strict-aliasing  -fno-common -ffixed-r8 \
 -msoft-float

删除-msoft-float选项后变为

PLATFORM_RELFLAGS += -fno-strict-aliasing  -fno-common -ffixed-r8

然后首先需要clean一下,再编译

make clean;make

第四步 内存配置

1、内存配置文件主要在board/samsung/utu2440/lowlevel_init.s文件中,需要配置的参数可参考

http://blog.csdn.net/Apollo5520/archive/2009/11/09/4792003.aspx

2、修改#define REFCNT   1113 /* period=15.6us, HCLK=60Mhz, (2048+1-15.6*60) */

#define REFCNT   1268 /* period=64/8192 us, HCLK=100Mhz, (2048+1-64/8192*100) 

(8192 Refresh cycles 64ms) */

第五步 利用网络资源

    今晚在网上闲逛,突然发现网上已经有uboot-2009.08 for mini2440patch了(下载地址:http://blog.chinaunix.net/u1/34474/showart.php?id=2085154

,可以省点事了,参照这个patch,很快移植到utu2440开发板上了,注意以下两点:

1、我的板子上没有nor flash,去掉配置文件中nor flash的相关配置

2、我的板子还是CS8900的网络芯片,将配置文件中的网络芯片配置改为CS8900

   编译通过后,烧到板子上,串口输出正常,可以ping通主机,但是有个问题,使用linux系统下的tftp服务器下载文件时提示错误: 

TFTP error: 'Unsupported option(s) requested' (8)


    但是使用windows下的tftp服务器可以正常下载文件,另外烧开发板自带的uboot可以从linux服务器正常下载文件,还未找到是什么原因引起的,哪位兄弟知道吗?

    今天分析解决了此问题,详见我的另一篇文章(http://blog.chinaunix.net/u3/105764/showart.php?id=2091464

 

第六步 在内存中运行linux

tftp 32000000 tftp 32000000 uImage_T5_2440_480272-ts

bootm 32000000

然后启动到Starting kernel...后就没有信息了,参考文章http://blog.chinaunix.net/u3/105764/showart.php?id=2091539

原来是UBOOT arch_number 内核定义不匹配造成的,在include/asm-arm/mach-types.h中添加定义

#define MACH_TYPE_UTU2440 5244

    在board/samsung/utu2440/utu2440.c中添加

#if defined(CONFIG_UTU2440)
/* arch number of UTU2440-Board */
    gd->bd->bi_arch_number = MACH_TYPE_UTU2440 ;
#endif

   重新编译UBOOT,烧写后,可以在ram中正常启动linux内核了

U-Boot 2009.08 for utu2440 by Apollo5520 (http://Apollo5520.cublog.cn)
I2C:   ready
DRAM:  64 MB
Flash:  0 kB
NAND:  64 MiB
Video: 240x320x16 20kHz 62Hz
In:    serial
Out:   serial
Err:   serial
Net:   CS8900A
Hit any key to stop autoboot:  0
utu2440 #
utu2440 # tftp 32000000 uImage_T5_2440_480272-ts
TFTP from server 192.168.0.9; our IP address is 192.168.0.11
Filename 'uImage_T5_2440_480272-ts'.
Load address: 0x32000000
Loading: T #################################################################
         ####################################
done
Bytes transferred = 1479899 (1694db hex)
utu2440 # bootm 32000000
## Booting kernel from Legacy Image at 32000000 ...
   Image Name:   Linux-2.6.13-utulinux2440
   Created:      2007-11-04   7:12:20 UTC
   Image Type:   ARM Linux Kernel Image (gzip compressed)
   Data Size:    1479835 Bytes =  1.4 MB
   Load Address: 30008000
   Entry Point:  30008000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK
Starting kernel ...
Linux version 2.6.13-utulinux2440 () (gcc version 3.4.1) #336 Sun Nov 4 15:12:14 CST 2007
CPU: ARM920Tid(wb) [41129200] revision 0 (ARMv4T)
Machine: UTU-2440
Memory policy: ECC disabled, Data cache writeback
CPU S3C2440A (id 0x32440001)
S3C2440: core 405.000 MHz, memory 101.250 MHz, peripheral 50.625 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
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
Kernel command line: root=/dev/mtdblock2 rw console=ttySAC0,115200
irq: clearing pending ext status 00000200
irq: clearing subpending status 00000003
irq: clearing subpending status 00000002
PID hash table entries: 512 (order: 9, 8192 bytes)
timer tcon=00500000, tcnt a4ca, tcfg 00000200,00000000, usec 00001e57
Console: colour dummy device 80x30
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 64MB = 64MB total
Memory: 61184KB available (2456K code, 988K data, 228K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
USB Power Control, (c) 2004 Simtec Electronics
S3C2440: Initialising architecture
S3C2440: IRQ Support
S3C2440: Clock Support, UPLL 48.000 MHz
SCSI subsystem initialized
usbcore: registered new driver hub
S3C2410 DMA Driver, (c) 2003-2004 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
NetWinder Floating Point Emulator V0.97 (double precision)
yaffs Nov  4 2007 12:00:04 Installing.
Initializing Cryptographic API
Console: switching to colour frame buffer device 96x34
S3C24X0 fb0: s3c2410fb frame buffer device initialize done
GPIO L3 bus interface for S3C2440, installed
S3C2410 RTC, (c) 2004 Simtec Electronics
s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling
utu2440 LED Driver v1.00
s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2440
s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2440
s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2440
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
nbd: registered device at major 43
Cirrus Logic CS8900A driver for Linux (Modified for SMDK2410)
eth0: CS8900A rev E at 0xe0000300 irq=53, no eeprom , addr: 08: 0:3E:26:0A:5B
Linux video capture interface: v1.00
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c2440-nand: mapped registers at c4880000
s3c2440-nand: timing: Tacls 9ns, Twrph0 39ns, Twrph1 9ns
NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)
NAND_ECC_NONE selected by board driver. This is not recommended !!
Scanning device for bad blocks
Creating 3 MTD partitions on "NAND 64MiB 3,3V 8-bit":
0x00000000-0x00060000 : "bootloader"
mtd: Giving out device 0 to bootloader
0x00060000-0x00260000 : "kernel"
mtd: Giving out device 1 to kernel
0x00260000-0x03ffc000 : "root"
mtd: Giving out device 2 to root
usbmon: debugfs is not available
Initial S3C2440 USB HOST Driver!
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
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 2 ports detected
Initializing USB Mass Storage driver...
usbcore: registered new driver usb-storage
USB Mass Storage support registered.
usbcore: registered new driver usbhid
drivers/usb/input/hid-core.c: v2.01:USB HID core driver
usbcore: registered new driver ov511
drivers/usb/media/ov511.c: v1.64 for Linux 2.5 : ov511 USB Camera Driver
usbcore: registered new driver gspca
drivers/usb/media/gspca/gspca_core.c: gspca driver 00.60.00 registered
mice: PS/2 mouse device common for all mice
ts: Compaq touchscreen protocol output
Initial utulinux 2440 Buttons driver!
Todo: mknod c /dev/utu2440-buttons 254 0
s3c2440 TouchScreen successfully loaded
i2c /dev entries driver
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
mmci-s3c2410: probe: mapped sdi_base=c4d00000 irq=37 irq_cd=60 dma=0.
mmci-s3c2410: initialisation done.
UTU2440 SOUND driver register
UTU2440 SOUND driver probe!
UTU2440 UDA1341 audio driver initialized
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
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
MMC: sd_app_op_cond timed out. Probably no SD-Card here.
yaffs: dev is 32505858 name is "mtdblock2"
yaffs: Attempting MTD mount on 31.2, "mtdblock2"
**>>yaffs ecc error unfixed on chunk 0:0
**>>yaffs ecc error unfixed on chunk 0:1
**>> yaffs: getBlockInfo block 0 is not valid
**>>Block 0 marked for retirement
VFS: Mounted root (yaffs filesystem).
Freeing init memory: 228K
         _                     _   _
 _   _  | |_   _   _          | | (_)  _ __    _   _  __  __
| | | | | __| | | | |  _____  | | | | | '_ \  | | | | \ \/ /
| |_| | | |_  | |_| | |_____| | | | | | | | | | |_| |  >  <
 \__,_|  \__|  \__,_|         |_| |_| |_| |_|  \__,_| /_/\_\   
Starting udevd...
Stopping FTP server: vsftpdstart-stop-daemon: warning: failed to kill 793: No such process
.
Starting FTP server: vsftpd.
Please press Enter to activate this console. [02/Jan/2006:04:46:36 +0000] boa: server version Boa/0.94.13
[02/Jan/2006:04:46:36 +0000] boa: server built Feb 28 2004 at 21:47:23.
[02/Jan/2006:04:46:36 +0000] boa: starting server pid=828, port 80
 
BusyBox v1.3.2 (2007-08-11 01:44:25 CST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
[root@utu-linux /]#

 

第七步 从Nand Flash运行linux

1、用 nand scrub 命令擦除整片Flash,然后重新烧写UBOOT

2、烧写内核文件

 

tftp 30010000 uImage_T5_2440_480272-ts

nand erase 60000 200000

nand write.i 30010000 60000 200000

3、烧写文件系统


tftp 30010000 filesystem.yaffs-2440-qtopia-touchscreen

nand erase 260000 3d9c000

nand write.yaffs1 30010000 260000 3d9c000


4、启动参数配置 

#define CONFIG_BOOTARGS "root=/dev/mtdblock2 rw console=ttySAC0,115200"

#define CONFIG_BOOTCOMMAND "nand read.i 0x32000000 0x60000 0x200000; bootm 32000000"


5、启动linux

    系统启动一半 发现很多flash 坏块,接下来出现NECC错误,以前没有的,正在找解决办法。。。 


Scanning device for bad blocks
Bad eraseblock 3744 at 0x03a80000
Bad eraseblock 3745 at 0x03a84000
Bad eraseblock 3746 at 0x03a88000
Bad eraseblock 3747 at 0x03a8c000
Bad eraseblock 3748 at 0x03a90000
。。。。。。
。。。。。。
block 3822 is bad
block 3823 is bad
block 3824 is bad
block 3825 is bad
**>>yaffs ecc error unfixed on chunk 32:0
**>>yaffs ecc error unfixed on chunk 32:1
**>>Block 1 marked for retirement
**>>yaffs ecc error unfixed on chunk 33:0
**>>yaffs ecc error unfixed on chunk 33:1
**>>Block 1 marked for retirement
。。。。。。


    首先解决flash坏块的问题,我犯了一个低级错误,yaffs系统文件的大小是0x39d9020,但是我烧写命令写的是0x3d9c000,如果是写bootloaderlinux内核文件写大一点问题不大,但是在写yaffs时会写oob区,导致系统检测时会出现很多""flash坏块,换正确的命令后linux启动时不再报flash坏块错误,但是依然有很多ecc校验错误。

    分析一下出现ecc错误的原因,首先在以前使用同样的yaffs文件与linux内核文件没有问题,说明我的yaffs文件与linux内核的ecc校验是匹配的,不存在yaffs制作工具与内核版本不匹配导致ecc校验错误的问题。那会不会是新的uboot在写的oob时写错了呢,使用ubootnand dump.oob 命令查看第一个pageoob,与yaffs文件的oob做一下对比,发现两者完全一致。那就奇怪了,在网上查了一下针对utu2440uboot移植资料,没有找到有成功移植写yaffs的案例。只能自己来分析、查找了。

    考虑到使用开发板自带的uboot(无源代码)烧写yaffs是可以正常启动的,那就首先用开发板自带的uboot烧写一遍,dump出来看一下,然后再用新移植的ubootyaffs,将两者做一下对比。说干就干,写uboot、写yaffsdump oob、记录、比较,最终发现了其中的奥妙(^_^,开心啊):

 

yaffs 文件 page1 的oob信息:
        00 00 c0 ff ff ff 01 00 9a aa a7 a4 c1 0c f0 0f
 
新移植的uboot 写 page1 的oob
        00 00 c0 ff ff ff 01 00 9a aa a7 a4 c1 0c f0 0f
 
原 uboot 写 page1 的oob信息:
        00 00 c0 ff ff ff 01 00 aa 9a a7 a4 c1 f0 0c 0f


结论:

    针对utu2440的开发板在写oob时需要做以下变换:

    每次在写完512字节的数据后再写16个字节的oob,此时需要首先将oob的第8位、第9位互换,第13位、第14位互换。

{
            unsigned char ctemp;
            ctemp = chip->ops.oobbuf[8];
            chip->ops.oobbuf[8] = chip->ops.oobbuf[9];
            chip->ops.oobbuf[9] = ctemp;
            ctemp = chip->ops.oobbuf[13];
            chip->ops.oobbuf[13] = chip->ops.oobbuf[14];
            chip->ops.oobbuf[14] = ctemp;
}

 

    另外一点需要注意的是针对utu2440,在写yaffs是不能跳过第一个好块。

    至此linux系统可以正常启动了,说点题外话,在网上没有找到对oob做这样变换的例子,可能是厂商出于某种目的自己定义的吧(也可能是我见识不够广泛,不知道有这样的变换标准),这可害苦了我们这些搞研发的,linux讲究的就是开源,可是看看现在的所谓的技术公司,搞套开发板出来,做了一点点工作就藏着、噎着,只给可执行文件不给源码,随意践踏GPL协议,等等。。。,确实是阻碍了中国的linux的推广与发展。

    言归正传,继续做移植。

 

第八步 LED测试

 

      我的开发板的LED接在2440 GPIO F组的4567 IO口上,对应的寄存器地位分别为GPFCON = 0x56000050GPFDAT = 0x56000054 GPFUP = 0x56000058,在start.s中添加了LED的测试的代码(参考了网上的资源)

 

#if defined(CONFIG_UTU2440_LED)
    /* Clear all leds */
    LDR R0,=0x56000050
    MOV R1,#0x00005500
    STR R1,[R0]
    LDR R0,=0x56000054
    MOV R1,#0x000000f0
    STR R1,[R0]

    /* LED1 on */
    LDR R0,=0x56000050
    MOV R1,#0x00005500
    STR R1,[R0]
    LDR R0,=0x56000054
    MOV R1,#0x00000e0
    STR R1,[R0]

    /* LED1 & LED2 on */
    LDR R0,=0x56000050
    MOV R1,#0x00005500
    STR R1,[R0]
    LDR R0,=0x56000054
    MOV R1,#0x000000c0
    STR R1,[R0]

    /* LED1,2,3 on */
    LDR R0,=0x56000050
    MOV R1,#0x00005500
    STR R1,[R0]
    LDR R0,=0x56000054
    MOV R1,#0x00000080
    STR R1,[R0]

    /* LED1,2,3,4 on */
    LDR R0,=0x56000050
    MOV R1,#0x00005500
    STR R1,[R0]
    LDR R0,=0x56000054
    MOV R1,#0x00000000
    STR R1,[R0]
/*
aa:
    bl aa
*/
#endif


 

第九步 LCD测试

    我的LCD屏是4.3寸的分辨率为480x272,外面看不出是那个厂商的,找不到相关参数,只能是参考开发板自带的linux源码中的LCD驱动来改了,需要修改的文件有

board/samsung/utu2440/utu2440.c

drivers/video/s3c2410_fb.c

drivers/video/videomodes.c


具体修改的位置比较多,这里就不详写了,请参考补丁文件吧。具体参数的计算请看 http://blog.chinaunix.net/u3/105764/showart_2092990.html

 

总结

    至此移植工作可以告一段落了,在这个过程中感谢网上的兄弟姐妹无偿提供的各种资料,当然也要感谢google^_^

    交代一下我的平台配置

开发板 utu2440-F V3.1 64M ram64M flash4.3寸屏,CS8900A网络芯片

linux内核:2.6.13

编译器:arm-linux-3.3.2

服务器系统:Fedora 10

烧写工具: H-jtag(这个工具比sjf2440烧写快多了,稍后我会写一个详细操作说明)

请参考:http://blog.chinaunix.net/u3/105764/showart_2093789.html

最后附上补丁文件以及二进制文件(载完后请手工修改文件后缀为.tar.bz2,否则windows无法正常解压)

文件: u-boot-2009.08_utu2440.patch.tar.bz2
大小: 32KB
下载: 下载

 

文件: u-boot.bin.tar.bz2
大小: 122KB
下载: 下载

 
 

 

原创文章,转载请注明:转载自 风雨无阻博客(http://Apollo5520.cublog.cn

 本文链接地址:http://blog.chinaunix.net/u3/105764/showart_2091132.html

 

 


阅读(4836) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

hqgboy2010-08-30 11:29:28

请问SDRAM和FLASH的型号?我也用UTU2440.. SDRAM的地址? 谢谢。