Chinaunix首页 | 论坛 | 博客
  • 博客访问: 79292
  • 博文数量: 26
  • 博客积分: 46
  • 博客等级: 民兵
  • 技术积分: 170
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-19 23:01
文章分类
文章存档

2012年(26)

我的朋友

分类:

2012-05-28 11:30:34

原文地址:S3C6410开发板实践实录2 作者:hpuyuxuan

硬件平台:
MainBoard:OK6410
CPU: S3C6410
RAM: 256M
FLASH:1G K9GAG08U0D
Kernel:Linux2.6.28
BootLoader:Uboot1.1.6
 
3.使用TFTP升级Uboot
 
发现使用tftp升级uboot的时候无法成功,但是升级fs和kernel的时候可以。
后发现S3C6410启动的时候会通过 NAND控制器将nandflash的头4K拷贝到SRAM中执行,这一步叫做steppingstone,SRAM的大小有8K,但是 steppingstone只用了其中的4K,另外NAND控制器支持每FLASH页读取的大小为512B/2K,所以当flash页大小为4K的时候, 它只能每块读取前2K,这里就需要在写Uboot的时候前面个PAGE每个只能写入2K,也即
 
  1. nand erase 0 100000
  2. nand write 50008000 0 1000
  3. nand write 50008800 1000 1000
  4. nand write 50009000 2000 FF000
飞凌提供的SD卡升级方式利用了SDRAM的全部大小,也即8K,所以它的写入步骤为:
  1. nand erase 0 100000
  2. nand write 50008000 0 1000
  3. nand write 50008800 1000 1000
  4. nand write 50009000 2000 1000
  5. nand write 50009800 3000 1000
  6. nand write 5000A000 4000 FE000
至此解决了TFTP升级Uboot问题。另外在do_nane中添加了命令nand write.uboot命令,可以直接一个命令搞定uboot升级,添加如下代码:
 
  1. else if(!read && !strcmp(s, ".uboot"))
  2.         {
  3.             /* for Page 2048 then just do normal writing */
  4.             if(nand->writesize == 0x800)
  5.                 goto write;
  6.             else if(nand->writesize == 0x1000)
  7.             {
  8.                 /* try to simulate a 0x800 page size flash and do a remap */
  9.                 int blocks = 5, i = 0;
  10.                 
  11.                 for(; i < blocks; i++)
  12.                 {
  13.                     if(i == blocks - 1)
  14.                         size = 0xfe000;
  15.                     else
  16.                         size = 0x1000;
  17.                         
  18.                     printf("Write at Offset %x from Addr:%x with Size %x\n", off + i * 0x1000, addr + i * 0x800, size);
  19.                     ret = nand_write(nand, off + i * 0x1000, &size, (u_char *)(addr + i * 0x800));
  20.             
  21.                     if(ret == 0)
  22.                     {
  23.                         uint *magic = (uint*)(PHYS_SDRAM_1);
  24.                         if((0x24564236 == magic[0]) && (0x20764316 == magic[1]))
  25.                         magic[0] = 0x27051956;
  26.                     }
  27.                     
  28.                     if(ret)
  29.                     {
  30.                         printf(" 0x%x bytes %s to 0x%x %s\n", size, read ? "read" : "written", off + i * 0x1000, 0x1000,
  31.                                     ret ? "ERROR" : "OK");
  32.                         return 1;                
  33.                     }
  34.                 }
  35.                 
  36.                 printf("Uboot have been updated, please do reset!\n");
  37.                 return 0;
  38.             }
  39.             else
  40.             {
  41.                 printf("Only support page size 2K and 4K!\n");
  42.                 return 1;
  43.             }
  44.         }
阅读(1491) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~