summaryrefslogtreecommitdiff
path: root/src/flash/pic32mx.c
diff options
context:
space:
mode:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-07 00:21:59 +0000
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2009-05-07 00:21:59 +0000
commitfdf114ab0a5078ea0a46d060bb79f882954589ea (patch)
tree087cf616f0d3749acffc2187e45e387e8a8450f2 /src/flash/pic32mx.c
parenta3b6236289fc696d2569ea451ba21415f678a1e0 (diff)
downloadopenocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.tar.gz
openocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.tar.bz2
openocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.tar.xz
openocd+libswd-fdf114ab0a5078ea0a46d060bb79f882954589ea.zip
Fix stm32x and pic32mx flash pointer cast alignment warnings, simplify their last word handling.
git-svn-id: svn://svn.berlios.de/openocd/trunk@1626 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/flash/pic32mx.c')
-rw-r--r--src/flash/pic32mx.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c
index 77c9f407..94ec7458 100644
--- a/src/flash/pic32mx.c
+++ b/src/flash/pic32mx.c
@@ -463,9 +463,10 @@ static int pic32mx_write_block(struct flash_bank_s *bank, u8 *buffer, u32 offset
while(count > 0)
{
- u32 status;
+ u32 value;
+ memcpy(&value, buffer, sizeof(u32));
- status = pic32mx_write_word(bank, address, *(u32*)buffer);
+ u32 status = pic32mx_write_word(bank, address, value);
if( status & NVMCON_NVMERR ) {
LOG_ERROR("Flash write error NVMERR (status=0x%08x)", status);
retval = ERROR_FLASH_OPERATION_FAILED;
@@ -568,8 +569,10 @@ static int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32
while (words_remaining > 0)
{
- status = pic32mx_write_word(bank, address, *(u32*)(buffer + bytes_written));
+ u32 value;
+ memcpy(&value, buffer + bytes_written, sizeof(u32));
+ status = pic32mx_write_word(bank, address, value);
if( status & NVMCON_NVMERR )
return ERROR_FLASH_OPERATION_FAILED;
if( status & NVMCON_LVDERR )
@@ -582,19 +585,10 @@ static int pic32mx_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32
if (bytes_remaining)
{
- u8 last_word[4] = {0xff, 0xff, 0xff, 0xff};
- int i = 0;
-
- while(bytes_remaining > 0)
- {
- /* Assumes little endian */
- last_word[i++] = *(buffer + bytes_written);
- bytes_remaining--;
- bytes_written++;
- }
-
- status = pic32mx_write_word(bank, address, *(u32*)last_word);
+ u32 value = 0xffffffff;
+ memcpy(&value, buffer + bytes_written, bytes_remaining);
+ status = pic32mx_write_word(bank, address, value);
if( status & NVMCON_NVMERR )
return ERROR_FLASH_OPERATION_FAILED;
if( status & NVMCON_LVDERR )