diff options
author | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-08-18 17:07:56 +0000 |
---|---|---|
committer | oharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-08-18 17:07:56 +0000 |
commit | d1356149f08a87a52823ab0e096c75846006a594 (patch) | |
tree | 60a3572dc38d36bad9cdca8d6641ca2c707bc6ce /src | |
parent | 20feb0431a2c86194f8f464dcdf752940723cc5d (diff) | |
download | openocd+libswd-d1356149f08a87a52823ab0e096c75846006a594.tar.gz openocd+libswd-d1356149f08a87a52823ab0e096c75846006a594.tar.bz2 openocd+libswd-d1356149f08a87a52823ab0e096c75846006a594.tar.xz openocd+libswd-d1356149f08a87a52823ab0e096c75846006a594.zip |
added error handling to avoid false error messages.
git-svn-id: svn://svn.berlios.de/openocd/trunk@927 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src')
-rw-r--r-- | src/flash/str9x.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/flash/str9x.c b/src/flash/str9x.c index 5e28d307..89f67376 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -262,27 +262,46 @@ int str9x_erase(struct flash_bank_s *bank, int first, int last) for (i = first; i <= last; i++) { + int retval; adr = bank->base + bank->sectors[i].offset; /* erase sectors */ - target_write_u16(target, adr, erase_cmd); - target_write_u16(target, adr, 0xD0); + if ((retval=target_write_u16(target, adr, erase_cmd))!=ERROR_OK) + { + return retval; + } + if ((retval=target_write_u16(target, adr, 0xD0))!=ERROR_OK) + { + return retval; + } /* get status */ - target_write_u16(target, adr, 0x70); + if ((retval=target_write_u16(target, adr, 0x70))!=ERROR_OK) + { + return retval; + } while (1) { - target_read_u8(target, adr, &status); + if ((retval=target_read_u8(target, adr, &status))!=ERROR_OK) + { + return retval; + } if( status & 0x80 ) break; usleep(1000); } /* clear status, also clear read array */ - target_write_u16(target, adr, 0x50); + if ((retval=target_write_u16(target, adr, 0x50))!=ERROR_OK) + { + return retval; + } /* read array command */ - target_write_u16(target, adr, 0xFF); + if ((retval=target_write_u16(target, adr, 0xFF))!=ERROR_OK) + { + return retval; + } if( status & 0x22 ) { |