comparison packages/redboot/current/src/flash.c @ 1717:faaea4243d52

* cdl/redboot.cdl: Fixed the type of CYGNUM_REDBOOT_FLASH_BASE * src/flash.c (fis_[un]lock): Fix compiler warnings * src/flash.c (do_flash_init): Removed the MIPS br0ken condition which i wrongly added. My problem was actually a / 0. This roundup is needed otherwise the workspace goes off the end of the RAM.
author asl
date Mon, 16 Aug 2004 08:35:33 +0000
parents bbdd4a302a64
children 16115b7a4b8c
comparison
equal deleted inserted replaced
1716:e4f7f465ee77 1717:faaea4243d52
231 #ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG 231 #ifdef CYGSEM_REDBOOT_FLASH_COMBINED_FIS_AND_CONFIG
232 memcpy((char *)fis_work_block+fisdir_size, config, cfg_size); 232 memcpy((char *)fis_work_block+fisdir_size, config, cfg_size);
233 #endif 233 #endif
234 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL 234 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
235 // Ensure [quietly] that the directory is unlocked before trying to update 235 // Ensure [quietly] that the directory is unlocked before trying to update
236 cyg_flash_unlock((void *)fis_addr, flash_block_size, &err_addr); 236 cyg_flash_unlock(fis_addr, flash_block_size, &err_addr);
237 #endif 237 #endif
238 if ((stat = cyg_flash_erase(fis_addr, flash_block_size, &err_addr)) != 0) { 238 if ((stat = cyg_flash_erase(fis_addr, flash_block_size, &err_addr)) != 0) {
239 diag_printf("Error erasing FIS directory at %p: %s\n", err_addr, cyg_flash_errmsg(stat)); 239 diag_printf("Error erasing FIS directory at %p: %s\n", err_addr, cyg_flash_errmsg(stat));
240 } else { 240 } else {
241 if ((stat = cyg_flash_program(fis_addr, fis_work_block, flash_block_size, 241 if ((stat = cyg_flash_program(fis_addr, fis_work_block, flash_block_size,
244 err_addr, cyg_flash_errmsg(stat)); 244 err_addr, cyg_flash_errmsg(stat));
245 } 245 }
246 } 246 }
247 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL 247 #ifdef CYGSEM_REDBOOT_FLASH_LOCK_SPECIAL
248 // Ensure [quietly] that the directory is locked after the update 248 // Ensure [quietly] that the directory is locked after the update
249 cyg_flash_lock((void *)fis_addr, flash_block_size, &err_addr); 249 cyg_flash_lock(fis_addr, flash_block_size, &err_addr);
250 #endif 250 #endif
251 } 251 }
252 252
253 static void 253 static void
254 fis_init(int argc, char *argv[]) 254 fis_init(int argc, char *argv[])
1372 bool 1372 bool
1373 do_flash_init(void) 1373 do_flash_init(void)
1374 { 1374 {
1375 int stat; 1375 int stat;
1376 cyg_flashaddr_t err_addr; 1376 cyg_flashaddr_t err_addr;
1377 #ifdef CYGNUM_REDBOOT_FLASH_BASE
1378 cyg_flash_info_t info;
1379 #endif
1377 1380
1378 if (!__flash_init) { 1381 if (!__flash_init) {
1379 __flash_init = 1; 1382 __flash_init = 1;
1380 1383
1381 if ((stat = cyg_flash_init(diag_printf)) != 0) { 1384 if ((stat = cyg_flash_init(diag_printf)) != 0) {
1382 diag_printf("FLASH: driver init failed: %s\n", cyg_flash_errmsg(stat)); 1385 diag_printf("FLASH: driver init failed: %s\n", cyg_flash_errmsg(stat));
1383 return false; 1386 return false;
1384 } 1387 }
1385 1388
1389 #ifdef CYGNUM_REDBOOT_FLASH_BASE
1390 stat = cyg_flash_get_info_addr(CYGNUM_REDBOOT_FLASH_BASE, &info);
1391 if (stat != CYG_FLASH_ERR_OK) {
1392 diag_printf("FLASH: driver init failed: %s\n",
1393 cyg_flash_errmsg(stat));
1394 return false;
1395 }
1396 flash_start = info.start;
1397 flash_end = info.end;
1398 #else
1386 if ((stat = cyg_flash_get_limits(&flash_start, &flash_end)) != 0) { 1399 if ((stat = cyg_flash_get_limits(&flash_start, &flash_end)) != 0) {
1387 diag_printf("FLASH: driver init failed: %s\n", 1400 diag_printf("FLASH: driver init failed: %s\n",
1388 cyg_flash_errmsg(stat)); 1401 cyg_flash_errmsg(stat));
1389 return false; 1402 return false;
1390 } 1403 }
1391 1404 #endif
1392 // Keep 'end' address as last valid location, to avoid wrap around problems 1405 // Keep 'end' address as last valid location, to avoid wrap around problems
1393 flash_end = ((CYG_ADDRESS)flash_end - 1); 1406 flash_end = ((CYG_ADDRESS)flash_end - 1);
1394 cyg_flash_get_block_info(&flash_block_size, &flash_num_blocks); 1407 cyg_flash_get_block_info(&flash_block_size, &flash_num_blocks);
1395 1408
1396 #ifdef CYGOPT_REDBOOT_FIS 1409 #ifdef CYGOPT_REDBOOT_FIS
1397 fisdir_size = CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT * CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE; 1410 fisdir_size = CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT * CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE;
1398
1399 #ifndef CYGPKG_HAL_MIPS // FIXME: compiler is b0rken
1400 fisdir_size = ((fisdir_size + flash_block_size - 1) / flash_block_size) * flash_block_size; 1411 fisdir_size = ((fisdir_size + flash_block_size - 1) / flash_block_size) * flash_block_size;
1401 #endif
1402 # if defined(CYGPRI_REDBOOT_ZLIB_FLASH) && defined(CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER) 1412 # if defined(CYGPRI_REDBOOT_ZLIB_FLASH) && defined(CYGOPT_REDBOOT_FIS_ZLIB_COMMON_BUFFER)
1403 fis_work_block = fis_zlib_common_buffer; 1413 fis_work_block = fis_zlib_common_buffer;
1404 if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < fisdir_size) { 1414 if(CYGNUM_REDBOOT_FIS_ZLIB_COMMON_BUFFER_SIZE < fisdir_size) {
1405 diag_printf("FLASH: common buffer too small\n"); 1415 diag_printf("FLASH: common buffer too small\n");
1406 return false; 1416 return false;