Chinaunix首页 | 论坛 | 博客
  • 博客访问: 487271
  • 博文数量: 104
  • 博客积分: 3045
  • 博客等级: 少校
  • 技术积分: 1230
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-29 10:18
文章分类

全部博文(104)

文章存档

2011年(72)

2010年(1)

2009年(1)

2008年(30)

分类:

2008-04-07 17:33:28

启动uboot的时候总是出现
*** Warning - bad CRC, using default environment
不知到怎么回事,检查一下于那代码看看
236 void start_armboot (void)
237 {
238         init_fnc_t **init_fnc_ptr;
239         char *s;
240 #ifndef CFG_NO_FLASH
241         ulong size;
242 #endif
243 #if defined(CONFIG_VFD) || defined(CONFIG_LCD)
244         unsigned long addr;
245 #endif
246
247         /* Pointer is writable since we allocated a register for it */
248         gd = (gd_t*)(_armboot_start - CFG_MALLOC_LEN - sizeof(gd_t));
249         /* compiler optimization barrier needed for GCC >= 3.4 */
250         __asm__ __volatile__("": : :"memory");
251
252         memset ((void*)gd, 0, sizeof (gd_t));
253         gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
254         memset (gd->bd, 0, sizeof (bd_t));
255
256         monitor_flash_len = _bss_start - _armboot_start;
257
258         for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
259                 if ((*init_fnc_ptr)() != 0) {
260                         hang ();
261                 }
262         }
263
264 #ifndef CFG_NO_FLASH
265         /* configure available FLASH banks */
266         size = flash_init ();
267         display_flash_config (size);
268 #endif /* CFG_NO_FLASH */
269
270 #ifdef CONFIG_VFD
271 #       ifndef PAGE_SIZE
272 #         define PAGE_SIZE 4096
273 #       endif
274         /*
275          * reserve memory for VFD display (always full pages)
276          */
277         /* bss_end is defined in the board-specific linker script */
278         addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
279         size = vfd_setmem (addr);
280         gd->fb_base = addr;
281 #endif /* CONFIG_VFD */
282
283 #ifdef CONFIG_LCD
284 #       ifndef PAGE_SIZE
285 #         define PAGE_SIZE 4096
286 #       endif
287         /*
288          * reserve memory for LCD display (always full pages)
289          */
290         /* bss_end is defined in the board-specific linker script */
291         addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
292         size = lcd_setmem (addr);
293         gd->fb_base = addr;
294 #endif /* CONFIG_LCD */
295
296         /* armboot_start is defined in the board-specific linker script */
297         mem_malloc_init (_armboot_start - CFG_MALLOC_LEN);
298
299 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
300         puts ("NAND:  ");
301         nand_init();            /* go init the NAND */
302 #endif
303
304 #ifdef CONFIG_HAS_DATAFLASH
305         AT91F_DataflashInit();
306         dataflash_print_info();
307 #endif
308
309         /* initialize environment */
310         env_relocate ();
311
312 #ifdef CONFIG_VFD
313         /* must do this after the framebuffer is allocated */
314         drv_vfd_init();
315 #endif /* CONFIG_VFD */
316
317         /* IP Address */
318         gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
319
320         /* MAC Address */
321         {
322                 int i;
323                 ulong reg;
324                 char *s, *e;
325                 char tmp[64];
326
327                 i = getenv_r ("ethaddr", tmp, sizeof (tmp));
328                 s = (i > 0) ? tmp : NULL;
329
330                 for (reg = 0; reg < 6; ++reg) {
331                         gd->bd->bi_enetaddr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
332                         if (s)
333                                 s = (*e) ? e + 1 : e;
334                 }
335
336 #ifdef CONFIG_HAS_ETH1
337                 i = getenv_r ("eth1addr", tmp, sizeof (tmp));
338                 s = (i > 0) ? tmp : NULL;
339
340                 for (reg = 0; reg < 6; ++reg) {
341                         gd->bd->bi_enet1addr[reg] = s ? simple_strtoul (s, &e, 16) : 0;
342                         if (s)
343                                 s = (*e) ? e + 1 : e;
344                 }
345 #endif
346         }
347
348         devices_init ();        /* get the devices list going. */
349
350 #ifdef CONFIG_CMC_PU2
351         load_sernum_ethaddr ();
352 #endif /* CONFIG_CMC_PU2 */
353
354         jumptable_init ();
355
356         console_init_r ();      /* fully init console as a device */
357
358 #if defined(CONFIG_MISC_INIT_R)
359         /* miscellaneous platform dependent initialisations */
360         misc_init_r ();
361 #endif
362
363         /* enable exceptions */
364         enable_interrupts ();
366         /* Perform network card initialisation if necessary */
367 #ifdef CONFIG_DRIVER_CS8900
368         cs8900_get_enetaddr (gd->bd->bi_enetaddr);
369 #endif
370
371 #if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
372         if (getenv ("ethaddr")) {
373                 smc_set_mac_addr(gd->bd->bi_enetaddr);
374         }
375 #endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
376
377         /* Initialize from environment */
378         if ((s = getenv ("loadaddr")) != NULL) {
379                 load_addr = simple_strtoul (s, NULL, 16);
380         }
381 #if (CONFIG_COMMANDS & CFG_CMD_NET)
382         if ((s = getenv ("bootfile")) != NULL) {
383                 copy_filename (BootFile, s, sizeof (BootFile));
384         }
385 #endif  /* CFG_CMD_NET */
386
387 #ifdef BOARD_LATE_INIT
388         board_late_init ();
389 #endif
390 #if (CONFIG_COMMANDS & CFG_CMD_NET)
391 #if defined(CONFIG_NET_MULTI)
392         puts ("Net:   ");
393 #endif
394         eth_initialize(gd->bd);
395 #endif
396         /* main_loop() can return to retry autoboot, if so just run it again. */
397         for (;;) {
398                 main_loop ();
399         }
400
401         /* NOTREACHED - no way out of command loop except booting */
402 }
其中

258         for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
259                 if ((*init_fnc_ptr)() != 0) {
260                         hang ();
261                 }
262         }
用来初始化
 init_fnc_t *init_sequence[] = {
217         cpu_init,               /* basic cpu dependent setup */
218         board_init,             /* basic board dependent setup */
219         interrupt_init,         /* set up exceptions */
220         env_init,               /* initialize environment */
221         init_baudrate,          /* initialze baudrate settings */
222         serial_init,            /* serial communications setup */
223         console_init_f,         /* stage 1 init of console */
224         display_banner,         /* say that we are here */
225 #if defined(CONFIG_DISPLAY_CPUINFO)
226         print_cpuinfo,          /* display cpu info (and speed) */
227 #endif
228 #if defined(CONFIG_DISPLAY_BOARDINFO)
229         checkboard,             /* display board info */
230 #endif
231         dram_init,              /* configure available RAM banks */
232         display_dram_config,
233         NULL,
234 };
        env_init()用来初始华环境变量
102 int env_init(void)
103 {        如果环境变量是嵌入到目标代码中的时候
104 #if defined(ENV_IS_EMBEDDED)
105         ulong total;
106         int crc1_ok = 0, crc2_ok = 0;
107         env_t *tmp_env1, *tmp_env2;
108         
109         total = CFG_ENV_SIZE;
110                                        
111         tmp_env1 = env_ptr;         
112         tmp_env2 = (env_t *)((ulong)env_ptr + CFG_ENV_SIZE);
113
114         crc1_ok = (crc32(0, tmp_env1->data, ENV_SIZE) == tmp_env1->crc);
115         crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc);
116
117         if (!crc1_ok && !crc2_ok)
118                 gd->env_valid = 0;
119         else if(crc1_ok && !crc2_ok)
120                 gd->env_valid = 1;
121         else if(!crc1_ok && crc2_ok)
122                 gd->env_valid = 2;
123         else {
124                 /* both ok - check serial */
125                 if(tmp_env1->flags == 255 && tmp_env2->flags == 0)
126                         gd->env_valid = 2;
127                 else if(tmp_env2->flags == 255 && tmp_env1->flags == 0)
128                         gd->env_valid = 1;
129                 else if(tmp_env1->flags > tmp_env2->flags)
130                         gd->env_valid = 1;
131                 else if(tmp_env2->flags > tmp_env1->flags)
132                         gd->env_valid = 2;
133                 else /* flags are equal - almost impossible */
134                         gd->env_valid = 1;
135         }
136
137         if (gd->env_valid == 1)
138                 env_ptr = tmp_env1;
139         else if (gd->env_valid == 2)
140                 env_ptr = tmp_env2;
141 #else /* ENV_IS_EMBEDDED */
142         gd->env_addr  = (ulong)&default_environment[0];
143         gd->env_valid = 1;
144 #endif /* ENV_IS_EMBEDDED */
145
146         return (0);
147 }
 其中
            //8***        extern uchar environment[]        
            //******    env_t *env_ptr = (env_t *)(&environment[0]);
   追踪过去                     
            /****** struct partition_block
 
 97 struct partition_block
 98 {
 99     u32 id;
100     u32 summed_longs;
101     s32 chk_sum;
102     u32 host_id;
103     u32 next;
104     u32 flags;
105     u32 reserved_1[2];
106     u32 dev_flags;
107     char drive_name[32];
108     u32 reserved_2[15];
109     u32 environment[17];
110     u32 reserved_3[15];
111 };
environment 是在上上面的函数定义的  
如果初始化成功则  gd->env_valid = 1;
则后面不会出现  *** Warning - bad CRC, using default environment  可是我到现在还没找到初始化他的程序。
   env_relocate (); 设置环境变量
194 void env_relocate (void)
195 {
196         DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,                                                                                                                                   
197                 gd->reloc_off);                                                                                                                                                                     
198
199 #ifdef CONFIG_AMIGAONEG3SE       
200         enable_nvram();
201 #endif
202
203 #ifdef ENV_IS_EMBEDDED
204         /*
205          * The environment buffer is embedded with the text segment,
206          * just relocate the environment pointer                                                                                                                                                    
207          */
208         env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
209         DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);                                                                                                                      
210 #else
211         /*
212          * We must allocate a buffer for the environment                                                                                                                                            
213          */
214         env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
215         DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);                                                                                                                      
216 #endif
217
218         /*
219          * After relocation to RAM, we can always use the "memory" functions                                                                                                                        
220          */
221         env_get_char = env_get_char_memory;                                                                                                                                                         
222   
223         if (gd->env_valid == 0) {
224 #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE)  /* Environment not changable */                                                                                                             
225                 puts ("Using default environment\n\n");                                                                                                                                             
226 #else
227                 puts ("*** Warning - bad CRC, using default environment\n\n");                                                                                                                      
228                 show_boot_progress (-60);                                                                                                                                                           
229 #endif
230
231                 if (sizeof(default_environment) > ENV_SIZE)                                                                                                                                         
232                 {   
233                         puts ("*** Error - default environment is too large\n\n");                                                                                                                  
234                         return;          
235                 }
236   
237                 memset (env_ptr, 0, sizeof(env_t));
238                 memcpy (env_ptr->data,           
239                         default_environment,     
240                         sizeof(default_environment));
241 #ifdef CFG_REDUNDAND_ENVIRONMENT         
242                 env_ptr->flags = 0xFF;                                                                                                                                                              
243 #endif
244                 env_crc_update ();       
245                 gd->env_valid = 1;
246         }
247         else {
248                 env_relocate_spec ();                                                                                                                                                               
249         }
250         gd->env_addr = (ulong)&(env_ptr->data);                                                                                                                                                     
251
252 #ifdef CONFIG_AMIGAONEG3SE
2 #ifdef CONFIG_AMIGAONEG3SE
253         disable_nvram();
254 #endif
255 }
该程序的主要作用是将环境变量从 flash 转移到ram 中  来 并  gd->env_addr = (ulong)&(env_ptr->data);  赋值  
暂时 分析到这里 ,有哪位 对这个问题 有独到的看法 ,请不吝赐教!
阅读(7019) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

lanmanck2010-07-27 17:00:16

正常,你没保存当然是crc错误了。 blog.csdn.net/lanmanck