X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_flash.c;h=638e51e0ce7bc932e43b8c12cd5e81a332c97117;hp=153015c62ef53e118cffa31e98d3ad8fc06b254b;hb=01cefa181b04e53c20109ef8f3ffff633744da73;hpb=d4c8895b349998e02e03ed83466a0ca7afb3d99b diff --git a/src/ao_flash.c b/src/ao_flash.c index 153015c6..638e51e0 100644 --- a/src/ao_flash.c +++ b/src/ao_flash.c @@ -169,6 +169,7 @@ static __pdata uint8_t ao_flash_write_pending; static __pdata uint8_t ao_flash_setup_done; static __data uint32_t ao_flash_device_size; static __data uint8_t ao_flash_block_shift; +static __data uint16_t ao_flash_block_size; static void ao_flash_setup(void) @@ -183,7 +184,6 @@ ao_flash_setup(void) ao_mutex_put(&ao_flash_mutex); return; } - ao_flash_setup_done = 1; /* On first use, check to see if the flash chip has * been programmed to use 512 byte pages. If not, do so. @@ -238,6 +238,8 @@ ao_flash_setup(void) default: ao_panic(AO_PANIC_FLASH); } + ao_flash_block_size = 1 << ao_flash_block_shift; + ao_flash_setup_done = 1; ao_mutex_put(&ao_flash_mutex); } @@ -397,6 +399,7 @@ ao_ee_flush(void) __reentrant * Read/write the config block, which is in * the last block of the flash */ + uint8_t ao_ee_write_config(uint8_t *buf, uint16_t len) __reentrant { @@ -480,15 +483,46 @@ flash_store(void) __reentrant ao_ee_flush(); } +void +ao_ee_dump_config(void) __reentrant +{ + uint16_t i; + printf("Configuration block %d\n", FLASH_CONFIG_BLOCK); + ao_mutex_get(&ao_flash_mutex); { + ao_flash_flush_internal(); + ao_flash_block = FLASH_BLOCK_NONE; + ao_flash_fill(FLASH_CONFIG_BLOCK); + i = 0; + do { + if ((i & 7) == 0) { + if (i) + putchar('\n'); + ao_cmd_put16((uint16_t) i); + } + putchar(' '); + ao_cmd_put8(ao_flash_data[i]); + ++i; + } while (i < sizeof (ao_config)); + } ao_mutex_put(&ao_flash_mutex); +} + static void flash_status(void) __reentrant { uint8_t status; + ao_flash_setup(); ao_mutex_get(&ao_flash_mutex); { status = ao_flash_read_status(); printf ("Flash status: 0x%02x\n", status); + printf ("Flash block shift: %d\n", FLASH_BLOCK_SHIFT); + printf ("Flash block size: %d\n", FLASH_BLOCK_SIZE); + printf ("Flash block mask: %d\n", FLASH_BLOCK_MASK); + printf ("Flash device size: %ld\n", FLASH_DEVICE_SIZE); + printf ("Flash data size: %ld\n", FLASH_DATA_SIZE); + printf ("Flash config block: %d\n", FLASH_CONFIG_BLOCK); } ao_mutex_put(&ao_flash_mutex); + ao_ee_dump_config(); } __code struct ao_cmds ao_flash_cmds[] = {