Mercurial > ecos
comparison packages/redboot/current/src/flash.c @ 126:518f42066aba ecos-sw-2000-09-19
Merge from eCos master repository on 2000-09-19-06:25:26-BST
| author | jlarmour |
|---|---|
| date | Tue, 19 Sep 2000 05:53:51 +0000 |
| parents | 6bd9d475ed4b |
| children | eb9fd8c04db3 |
comparison
equal
deleted
inserted
replaced
| 125:b4407dc7f59d | 126:518f42066aba |
|---|---|
| 183 img = (struct image_desc *)fis_work_block; | 183 img = (struct image_desc *)fis_work_block; |
| 184 memset(img, 0, sizeof(*img)); | 184 memset(img, 0, sizeof(*img)); |
| 185 strcpy(img->name, "RedBoot"); | 185 strcpy(img->name, "RedBoot"); |
| 186 img->flash_base = (unsigned long)flash_start; | 186 img->flash_base = (unsigned long)flash_start; |
| 187 img->mem_base = (unsigned long)flash_start; | 187 img->mem_base = (unsigned long)flash_start; |
| 188 img->size = 0; | 188 img->size = block_size; |
| 189 img++; img_count++; | 189 img++; img_count++; |
| 190 // And a backup image | 190 // And a backup image |
| 191 memset(img, 0, sizeof(*img)); | 191 memset(img, 0, sizeof(*img)); |
| 192 strcpy(img->name, "RedBoot[backup]"); | 192 strcpy(img->name, "RedBoot[backup]"); |
| 193 img->flash_base = (unsigned long)flash_start+block_size; | 193 img->flash_base = (unsigned long)flash_start+block_size; |
| 194 img->mem_base = (unsigned long)flash_start+block_size; | 194 img->mem_base = (unsigned long)flash_start+block_size; |
| 195 img->size = 0; | 195 img->size = block_size; |
| 196 img++; img_count++; | 196 img++; img_count++; |
| 197 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG | 197 #ifdef CYGSEM_REDBOOT_FLASH_CONFIG |
| 198 // And a descriptor for the configuration data | 198 // And a descriptor for the configuration data |
| 199 memset(img, 0, sizeof(*img)); | 199 memset(img, 0, sizeof(*img)); |
| 200 strcpy(img->name, "RedBoot config"); | 200 strcpy(img->name, "RedBoot config"); |
| 360 printf(" valid range is %p-%p\n", (void *)flash_start, (void *)flash_end); | 360 printf(" valid range is %p-%p\n", (void *)flash_start, (void *)flash_end); |
| 361 return; | 361 return; |
| 362 } | 362 } |
| 363 if ((mem_addr < (unsigned long)ram_start) || | 363 if ((mem_addr < (unsigned long)ram_start) || |
| 364 ((mem_addr+length) >= (unsigned long)ram_end)) { | 364 ((mem_addr+length) >= (unsigned long)ram_end)) { |
| 365 printf("Invalid RAM address: %p\n", (void *)mem_addr); | 365 printf("** WARNING: RAM address: %p may be invalid\n", (void *)mem_addr); |
| 366 printf(" valid range is %p-%p\n", (void *)ram_start, (void *)ram_end); | 366 printf(" valid range is %p-%p\n", (void *)ram_start, (void *)ram_end); |
| 367 return; | |
| 368 } | 367 } |
| 369 if (strlen(name) >= sizeof(img->name)) { | 368 if (strlen(name) >= sizeof(img->name)) { |
| 370 printf("Name is too long, must be less than %d chars\n", (int)sizeof(img->name)); | 369 printf("Name is too long, must be less than %d chars\n", (int)sizeof(img->name)); |
| 371 return; | 370 return; |
| 372 } | 371 } |
| 380 fis_addr = (void *)((unsigned long)flash_end - block_size); | 379 fis_addr = (void *)((unsigned long)flash_end - block_size); |
| 381 memcpy(fis_work_block, fis_addr, block_size); | 380 memcpy(fis_work_block, fis_addr, block_size); |
| 382 img = (struct image_desc *)fis_work_block; | 381 img = (struct image_desc *)fis_work_block; |
| 383 for (i = 0; i < block_size/sizeof(*img); i++, img++) { | 382 for (i = 0; i < block_size/sizeof(*img); i++, img++) { |
| 384 if ((img->name[0] != (unsigned char)0xFF) && (strcmp(name, img->name) == 0)) { | 383 if ((img->name[0] != (unsigned char)0xFF) && (strcmp(name, img->name) == 0)) { |
| 385 if (img->flash_base != flash_addr) { | 384 if (flash_addr_set && (img->flash_base != flash_addr)) { |
| 386 printf("Image found, but FLASH address incorrect\n"); | 385 printf("Image found, but FLASH address incorrect\n"); |
| 386 return; | |
| 387 } | |
| 388 if (img->size != length) { | |
| 389 printf("Image found, but LENGTH is incorrect\n"); | |
| 387 return; | 390 return; |
| 388 } | 391 } |
| 389 if (!verify_action("An image named '%s' exists", name)) { | 392 if (!verify_action("An image named '%s' exists", name)) { |
| 390 return; | 393 return; |
| 391 } else { | 394 } else { |
| 1050 { | 1053 { |
| 1051 void *cfg_base; | 1054 void *cfg_base; |
| 1052 bool use_boot_script; | 1055 bool use_boot_script; |
| 1053 | 1056 |
| 1054 config_ok = false; | 1057 config_ok = false; |
| 1058 script = (unsigned char *)0; | |
| 1055 if (!do_flash_init()) return; | 1059 if (!do_flash_init()) return; |
| 1056 cfg_base = (void *)((unsigned long)flash_end - (2*block_size)); | 1060 cfg_base = (void *)((unsigned long)flash_end - (2*block_size)); |
| 1057 memcpy(&config, cfg_base, sizeof(config)); | 1061 memcpy(&config, cfg_base, sizeof(config)); |
| 1058 if ((_cksum((unsigned long *)&config, sizeof(config)-sizeof(config.cksum)) != config.cksum) || | 1062 if ((_cksum((unsigned long *)&config, sizeof(config)-sizeof(config.cksum)) != config.cksum) || |
| 1059 (config.key1 != CONFIG_KEY1)|| (config.key2 != CONFIG_KEY2)) { | 1063 (config.key1 != CONFIG_KEY1)|| (config.key2 != CONFIG_KEY2)) { |
| 1060 printf("FLASH configuration checksum error or invalid key\n"); | 1064 printf("FLASH configuration checksum error or invalid key\n"); |
| 1061 script = (unsigned char *)0; | |
| 1062 memset(&config, 0, sizeof(config)); | 1065 memset(&config, 0, sizeof(config)); |
| 1063 return; | 1066 return; |
| 1064 } | 1067 } |
| 1065 flash_get_config("boot_script", &use_boot_script, CONFIG_BOOL); | 1068 flash_get_config("boot_script", &use_boot_script, CONFIG_BOOL); |
| 1066 if (use_boot_script) { | 1069 if (use_boot_script) { |
