aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexandre Pereira da Silva <aletes.xgr@gmail.com>2012-02-24 18:51:48 -0200
committerSpencer Oliver <spen@spen-soft.co.uk>2012-03-14 22:23:43 +0000
commit7151398cff16129764c79038a2701322f62da883 (patch)
tree7f18efbbc4c11b248510e7bce416df0d6db9aa36 /src
parent4a29a4a86d4ec3e12a9494371c80ace1b8ebedab (diff)
downloadriscv-openocd-7151398cff16129764c79038a2701322f62da883.zip
riscv-openocd-7151398cff16129764c79038a2701322f62da883.tar.gz
riscv-openocd-7151398cff16129764c79038a2701322f62da883.tar.bz2
stlink: fix alignment build warning
The {read,write}_mem32 interface functions was asking a 32 bits buffer but they don't need 32 bits alignment. This will change the interface to a 8 bits buffer to remove the alignment mismatch warning. This was causing build errors on platforms with strict aliasing rules. Change-Id: I338be8df5686f07a64ddb4f17c1bb494af583999 Signed-off-by: Alexandre Pereira da Silva <aletes.xgr@gmail.com> Reviewed-on: http://openocd.zylin.com/483 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/jtag/drivers/stlink_usb.c8
-rw-r--r--src/jtag/stlink/stlink_layout.h4
-rw-r--r--src/target/stm32_stlink.c14
3 files changed, 12 insertions, 14 deletions
diff --git a/src/jtag/drivers/stlink_usb.c b/src/jtag/drivers/stlink_usb.c
index 98eeb09..3312642 100644
--- a/src/jtag/drivers/stlink_usb.c
+++ b/src/jtag/drivers/stlink_usb.c
@@ -926,7 +926,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len,
h_u16_to_le(h->cmdbuf+h->cmdidx, len);
h->cmdidx += 2;
- res = stlink_usb_xfer(handle, (uint8_t *) buffer, len);
+ res = stlink_usb_xfer(handle, buffer, len);
if (res != ERROR_OK)
return res;
@@ -936,7 +936,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len,
/** */
static int stlink_usb_read_mem32(void *handle, uint32_t addr, uint16_t len,
- uint32_t *buffer)
+ uint8_t *buffer)
{
int res;
struct stlink_usb_handle_s *h;
@@ -968,7 +968,7 @@ static int stlink_usb_read_mem32(void *handle, uint32_t addr, uint16_t len,
/** */
static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
- const uint32_t *buffer)
+ const uint8_t *buffer)
{
int res;
struct stlink_usb_handle_s *h;
@@ -988,7 +988,7 @@ static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
h_u16_to_le(h->cmdbuf+h->cmdidx, len);
h->cmdidx += 2;
- res = stlink_usb_xfer(handle, (uint8_t *) buffer, len);
+ res = stlink_usb_xfer(handle, buffer, len);
if (res != ERROR_OK)
return res;
diff --git a/src/jtag/stlink/stlink_layout.h b/src/jtag/stlink/stlink_layout.h
index c0c89f5..59e6174 100644
--- a/src/jtag/stlink/stlink_layout.h
+++ b/src/jtag/stlink/stlink_layout.h
@@ -56,10 +56,10 @@ struct stlink_layout_api_s {
const uint8_t *buffer);
/** */
int (*read_mem32) (void *handle, uint32_t addr, uint16_t len,
- uint32_t *buffer);
+ uint8_t *buffer);
/** */
int (*write_mem32) (void *handle, uint32_t addr, uint16_t len,
- const uint32_t *buffer);
+ const uint8_t *buffer);
/** */
int (*idcode) (void *fd, uint32_t *idcode);
/** */
diff --git a/src/target/stm32_stlink.c b/src/target/stm32_stlink.c
index d2f38e5..7bec73f 100644
--- a/src/target/stm32_stlink.c
+++ b/src/target/stm32_stlink.c
@@ -586,7 +586,6 @@ static int stm32_stlink_read_memory(struct target *target, uint32_t address,
int res;
uint32_t buffer_threshold = 128;
uint32_t addr_increment = 4;
- uint8_t *dst = buffer;
uint32_t c;
struct stlink_interface_s *stlink_if = target_to_stlink(target);
@@ -612,16 +611,16 @@ static int stm32_stlink_read_memory(struct target *target, uint32_t address,
if (size != 4)
res = stlink_if->layout->api->read_mem8(stlink_if->fd,
- address, c, dst);
+ address, c, buffer);
else
res = stlink_if->layout->api->read_mem32(stlink_if->fd,
- address, c, (uint32_t *)dst);
+ address, c, buffer);
if (res != ERROR_OK)
return res;
address += (c * addr_increment);
- dst += (c * addr_increment);
+ buffer += (c * addr_increment);
count -= c;
}
@@ -635,7 +634,6 @@ static int stm32_stlink_write_memory(struct target *target, uint32_t address,
int res;
uint32_t buffer_threshold = 128;
uint32_t addr_increment = 4;
- const uint8_t *dst = buffer;
uint32_t c;
struct stlink_interface_s *stlink_if = target_to_stlink(target);
@@ -661,16 +659,16 @@ static int stm32_stlink_write_memory(struct target *target, uint32_t address,
if (size != 4)
res = stlink_if->layout->api->write_mem8(stlink_if->fd,
- address, c, dst);
+ address, c, buffer);
else
res = stlink_if->layout->api->write_mem32(stlink_if->fd,
- address, c, (uint32_t *)dst);
+ address, c, buffer);
if (res != ERROR_OK)
return res;
address += (c * addr_increment);
- dst += (c * addr_increment);
+ buffer += (c * addr_increment);
count -= c;
}