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>__archive__
parent
4a29a4a86d
commit
7151398cff
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
/** */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue