Mercurial > flash_v2
changeset 1729:e290a0372578
* src/flash.c (cyg_flash_init): Add assert checking that the
end address matches the block information.
* src/legacy_dev.c (legacy_flash_init): Ensure that the end
address is the last valid address, not the first invalid address.
| author | asl |
|---|---|
| date | Tue, 14 Sep 2004 16:04:53 +0000 |
| parents | b16e2895566e |
| children | 3f6b1c304c7a |
| files | packages/io/flash/current/ChangeLog packages/io/flash/current/src/flash.c packages/io/flash/current/src/legacy_dev.c |
| diffstat | 3 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/io/flash/current/ChangeLog +++ b/packages/io/flash/current/ChangeLog @@ -1,3 +1,10 @@ +2004-09-14 Andrew Lunn <andrew.lunn@ascom.ch> + + * src/flash.c (cyg_flash_init): Add assert checking that the + end address matches the block information. + * src/legacy_dev.c (legacy_flash_init): Ensure that the end + address is the last valid address, not the first invalid address. + 2004-09-09 Andrew Lunn <andrew.lunn@ascom.ch> * src/flash.c: Support flash blocks of arbitary size. The
--- a/packages/io/flash/current/src/flash.c +++ b/packages/io/flash/current/src/flash.c @@ -170,7 +170,16 @@ cyg_flash_init(cyg_flash_printf *pf) CYG_ASSERT(dev->funs->flash_erase_block, "No erase function"); CYG_ASSERT(dev->funs->flash_program, "No program function"); CYG_ASSERT(dev->funs->flash_hwr_map_error, "No hwr map error function"); - +#ifdef CYGDBG_USE_ASSERTS + { + int i; + cyg_flashaddr_t addr = dev->start; + for (i = 0; i < dev->num_block_infos; i++) { + addr += dev->block_info[i].block_size * dev->block_info[i].blocks; + } + CYG_ASSERT(dev->end == addr-1, "Invalid end address"); + } +#endif dev->init = true; dev->next = flash_head; flash_head = dev;
--- a/packages/io/flash/current/src/legacy_dev.c +++ b/packages/io/flash/current/src/legacy_dev.c @@ -92,7 +92,7 @@ legacy_flash_init (struct cyg_flash_dev if (!err) { dev->start = (cyg_flashaddr_t)flash_info.start; - dev->end = (cyg_flashaddr_t)flash_info.end; + dev->end = flash_info.block_size * flash_info.blocks - 1; dev->num_block_infos = 1; dev->block_info = block_info; block_info[0].block_size = flash_info.block_size;
