⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 һ

📁 对linux下边的gzip的文件的分析的代码
💻
📖 第 1 页 / 共 2 页
字号:
=> saveenv 
Saving Environment to Flash... 
Un-Protected 1 sectors 
Erasing Flash... 
done 
Erased 1 sectors 
Writing to Flash... done 
Protected 1 sectors 
ð printenv 

但重新启动机器后,参数没有起作用,还是缺省的.仔细看了环境变量的程序,发现是由于ENV_IS_EMBEDDED定义造成的,而此变量定义是在./tools/envcrc.c中: 
# if (CFG_ENV_ADDR >= CFG_MONITOR_BASE) && \ 
((CFG_ENV_ADDR + CFG_ENV_SIZE) <= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) 
# define ENV_IS_EMBEDDED 1 
# endif 

因此在wx20.h中增加了: 
#define CFG_MONITOR_BASE PHYS_SDRAM_1 (我还没搞清楚这个变量干啥的.) 
主要是去除ENV_IS_EMBEDDED的定义。 

结果确实准备使用flash的环境变量,但每次总是说标志头错误,经过仔细调试,最终发现flash写出现错误,原因是我忘了修改wx/common/flash.c中的CONFIG_B2为CONFIG_WX20. 修改后就正常了. 

(11) arm-linux和arm-elf 
上面调试一直是arm-elf,原因是以前有问题时怀疑编译器问题而修改了,因此没有改变。改用arm-linux编译后: 

U-Boot 1.1.3 (Jul 3 2005 - 07:01:36) 

U-Boot code: 0C100000 -> 0C117DA0 BSS: -> 0C11C0F0 
RAM Configuration: 
Bank #0: 0c000000 8 MB 
env_init flash_addr=20000 
flash_addr=20000 env_ptr=20000 env_ptr->data=bootargs=setenv bootargs root=/dev/ram ip=192.168.1.100:::::eth0ff ether=25,0,0,0,eth0 ethaddr=00:50:c2:1e:af:fb 
envptr->crc=1470de2 1470de2 
buffer->crc=1470de2 
[flash_get_size, 224] Entering ... 
[flash_get_size, 232] value=bf 
[flash_get_size, 255] value=234b 
Flash: 2 MB 
env_ptr=20000 
gd->env_addr=20004 gd->env_valid=1 
env_relocate[211] offset = 0x0 
env_relocate[229] malloced ENV at 00000000 
In: 
Out: 
Err: 

死机!!! 

然后改回arm-elf编译: 
U-Boot 1.1.3 (Jul 3 2005 - 07:04:48) 

U-Boot code: 0C100000 -> 0C119B98 BSS: -> 0C11DCD8 
RAM Configuration: 
Bank #0: 0c000000 8 MB 
env_init flash_addr=20000 
flash_addr=20000 env_ptr=20000 env_ptr->data=bootargs=setenv bootargs root=/dev/ram ip=192.168.1.100:::::eth0ff ether=25,0,0,0,eth0 ethaddr=00:50:c2:1e:af:fb 
envptr->crc=1470de2 1470de2 
buffer->crc=1470de2 
[flash_get_size, 224] Entering ... 
[flash_get_size, 232] value=bf 
[flash_get_size, 255] value=234b 
Flash: 2 MB 
env_ptr=20000 
gd->env_addr=20004 gd->env_valid=1 
env_relocate[211] offset = 0x0 
env_relocate[229] malloced ENV at 0c0dfc08 
In: serial 
Out: serial 
Err: serial 
rtl8019 MAC: 2a:2a:2a:2a:2a:2a 
Hit any key to stop autoboot: 0 
=> 

正常!因此最好是用arm-elf编译. 我在看网上查资料时记得有人说过"用arm-linux编译时,malloc返回0,而改成arm-elf编译时就好了".有个印象,具体帖子不记得在哪里了.所以后来我就一直使用arm-elf编译,没有再去试arm-linux编译. 

(12) 网卡调试 
剩下来的事情就是调网络了.根据上面配置rtl8019as后,网络仍然不同,然后参考uclinux驱动中的寄存器定义修改,网络就可以了.具体修改是: 
drivers/rtl8019.h 
36 #define ETH_ADDR_SFT (8) 
37 #define EI_SHIFT(x) ((x)<<ETH_ADDR_SFT) 
38 
39 #define RTL8019_REG_00 (RTL8019_BASE + EI_SHIFT(0x00)) 
40 #define RTL8019_REG_01 (RTL8019_BASE + EI_SHIFT(0x01)) 
...... 


(13) 开始load uclinux 
设置好本机ip地址,服务器ip地址, 下载文件名这些参数后,就可以load uclinux了. 

=> tftpboot 
eth_init...00:50:c2:1e:af:fb 
TFTP from server 192.168.1.25; our IP address is 192.168.1.100 
Filename 'image.bin'. 
Load address: 0xc008000 
Loading: ################################################################# 
################################################################# 
################################################################# 
################################################################# 
################################################################# 
################################################################# 
############################### 
死机! 

原因是我们现在的u-boot入口地址是C100000,而uclinux内核大约2M,因此load过来就冲突了.因此我们把u-boot的入口地址改成C300000,具体修改在board/wx/wx20/config.mk: 
TEXT_BASE = 0x0C300000 
重新编译运行就可以了. 

(14) 设置自动运行uclinux 
刚才我们是用命令load uclinux并执行的.自动运行需要设置bootcmd环境变量: 
=> setenv bootcmd "tftpboot; go 0xc008000" ==》设置错误 
## Starting application at 0x0C008000 ... 
=> setenv bootcmd "tftpboot\; go 0xc008000" ==》需要有个\ 
=> saveenv 

重新开机运行u-boot: 
Hit any key to stop autoboot: 0 
Unknown command '"tftpboot' - try 'help' 
## Starting application at 0x0C008000 ... 
结果还是不能自动下载uclinux和运行.经过调试才发现在设置bootcmd时多加了引号造成的!正确的设法是: 
=> setenv bootcmd tftpboot \; go 0xc008000 ==》正确的设置 

此时可以成功自动下载uclinux和运行了. 


(15) flash运行 
刻录到flash后,运行uclinux出现问题,运行到:uclinux 开中断后就死机,提示: 
Linux version 2.4.24-uc0 (root@samfei) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/)) #46 &Aacute;ù 7&Ocirc;&Acirc; 2 15:52:55 CST 2005 
Processor: Samsung S3C44B0X revision 0 
Architecture: S3C44B0X 
On node 0 totalpages: 2048 
zone(0): 0 pages. 
zone(1): 2048 pages. 
zone(2): 0 pages. 
Kernel command line: root=/dev/rom0 init=/linuxrc 

前面一直用armsys的bootloader,将u-boot下载到0xc300000运行,然后再load linux到0xc0080000运行,正常.而将u-boot刻录到flash后运行不正常,经过调试uclinux,到init/main.c中sti()函数后出现死机.因此怀疑中断向量设置问题. 

将cpu/s3c44b0/start.S中代码修改成; 
40 .globl _start 
41 _start: b reset 
42 /* 
43 add pc, pc, #0x0c000000 
44 add pc, pc, #0x0c000000 
45 add pc, pc, #0x0c000000 
46 add pc, pc, #0x0c000000 
47 add pc, pc, #0x0c000000 
48 add pc, pc, #0x0c000000 
49 add pc, pc, #0x0c000000 
50 */ 
51 LDR PC, Undefined_Addr 
52 LDR PC, SWI_Addr 
53 LDR PC, Prefetch_Addr 
54 LDR PC, Abort_Addr 
55 LDR PC,RESERVE_Addr 
56 LDR PC, IRQ_Addr 
57 /* subs pc,lr,#4*/ 
58 LDR PC, IRQ_Addr 
59 /* subs pc,lr,#4*/ 

114 Undefined_Addr: 
115 .word 0x0c000004 
116 SWI_Addr: 
117 .word 0x0c000008 
118 Prefetch_Addr: 
119 .word 0x0c00000C 
120 Abort_Addr: 
121 .word 0x0c000010 
122 RESERVE_Addr: 
123 .word 0x0c000014 
124 IRQ_Addr: 
125 .word 0x0c000018 
126 FIQ_Addr: 
127 .word 0x0c00001C 
128 
129 /* 
130 * the actual reset code 
131 */ 
132 
133 reset: 
后编译,刻录,然后运行.正常了!!! 

(16) 补丁制作和测试 
[root@samfei u-boot]# make distclean 
[root@samfei 44b0]# mv u-boot u-boot.wx 
[root@samfei 44b0]# cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/u-boot login 
Logging in to server:anonymous@cvs.sourceforge.net:2401/cvsroot/u-boot 
CVS password: 
[root@samfei 44b0]# cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/u-boot co -P u-boot 
cvs checkout: Updating u-boot 
U u-boot/CHANGELOG 
U u-boot/COPYING 
U u-boot/CREDITS 
U u-boot/MAINTAINERS 
。。。。。。 

[root@samfei 44b0]# diff -Naur u-boot u-boot.wx > uboot-wx-20050703.patch 
[root@samfei 44b0]# vi uboot-wx-20050703.patch 
去掉没有用的文件.做补丁的好处就是自己可以很清楚的知道哪些文件修改了!做完了,别忘了测试一下. 

[root@samfei 44b0]# cd u-boot 
[root@samfei u-boot]# patch -p1 < ../uboot-wx-20050703.patch 
[root@samfei u-boot]# make wx20_config 
[root@samfei u-boot]# make 


(17) 后记 
写这份材料化了不少时间.由于在调试的时候记录了大部分的调试信息,因此不用费脑筋去回忆.写完了这个经历,非常开心..一则自己可以温故而知新,二则就是与人共享啊.在开源的世界里,与人共享应该是件很快乐的一件事情. 
目前micetek的板子坏了,手上没有,等我拿到板子再将u-boot移植上去.那时就不用那么麻烦了.呵呵. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -