diff --git a/src/Makefile b/src/Makefile index 7a1f141..7ea7865 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,7 +9,7 @@ endif BUILDDATE := `date +"%Y%m%d"` -CFLAGS += -Wall -Wextra -Wno-pointer-sign -Wno-char-subscripts\ +CFLAGS += -Wall -Wextra -Wno-char-subscripts\ -Wno-sign-compare \ -O2 -std=gnu99 -g3 -DBUILDDATE=\"$(BUILDDATE)\"\ -I. -Iinclude -Iplatforms/common -I$(PLATFORM_DIR) \ diff --git a/src/cortexm.c b/src/cortexm.c index 71d0c6c..b3b657f 100644 --- a/src/cortexm.c +++ b/src/cortexm.c @@ -853,7 +853,8 @@ static int cortexm_hostio_request(target *t) uint32_t pflag = flags[params[1] >> 1]; char filename[4]; - target_mem_read_bytes(t, filename, params[0], sizeof(filename)); + target_mem_read_bytes(t, (uint8_t *)filename, + params[0], sizeof(filename)); /* handle requests for console i/o */ if (!strcmp(filename, ":tt")) { if (pflag == FILEIO_O_RDONLY) diff --git a/src/gdb_main.c b/src/gdb_main.c index 0c3dd77..ab4fc8a 100644 --- a/src/gdb_main.c +++ b/src/gdb_main.c @@ -41,7 +41,7 @@ #define ERROR_IF_NO_TARGET() \ if(!cur_target) { gdb_putpacketz("EFF"); break; } -static unsigned char pbuf[BUF_SIZE]; +static char pbuf[BUF_SIZE]; static target *cur_target; static target *last_target; @@ -287,7 +287,7 @@ handle_q_string_reply(const char *str, const char *param) return; } if (addr < strlen (str)) { - uint8_t reply[len+2]; + char reply[len+2]; reply[0] = 'm'; strncpy (reply + 1, &str[addr], len); if(len > strlen(&str[addr])) @@ -305,7 +305,7 @@ handle_q_packet(char *packet, int len) uint32_t addr, alen; if(!strncmp(packet, "qRcmd,", 6)) { - unsigned char *data; + char *data; int datalen; /* calculate size and allocate buffer for command */ diff --git a/src/gdb_packet.c b/src/gdb_packet.c index 4dc934f..fb3335e 100644 --- a/src/gdb_packet.c +++ b/src/gdb_packet.c @@ -29,8 +29,7 @@ #include -int -gdb_getpacket(unsigned char *packet, int size) +int gdb_getpacket(char *packet, int size) { unsigned char c; unsigned char csum; @@ -89,7 +88,7 @@ gdb_getpacket(unsigned char *packet, int size) return i; } -void gdb_putpacket(unsigned char *packet, int size) +void gdb_putpacket(const char *packet, int size) { int i; unsigned char csum; @@ -130,7 +129,7 @@ void gdb_putpacket(unsigned char *packet, int size) } while((gdb_if_getchar_to(2000) != '+') && (tries++ < 3)); } -void gdb_putpacket_f(const unsigned char *fmt, ...) +void gdb_putpacket_f(const char *fmt, ...) { va_list ap; char *buf; diff --git a/src/hex_utils.c b/src/hex_utils.c index 45382ff..e18df58 100644 --- a/src/hex_utils.c +++ b/src/hex_utils.c @@ -24,15 +24,16 @@ #include "general.h" #include "hex_utils.h" -static char hexdigits[] = "0123456789abcdef"; +static const char hexdigits[] = "0123456789abcdef"; -char * hexify(char *hex, const unsigned char *buf, int size) +char * hexify(char *hex, const void *buf, size_t size) { char *tmp = hex; + const uint8_t *b = buf; - while(size--) { - *tmp++ = hexdigits[*buf >> 4]; - *tmp++ = hexdigits[*buf++ & 0xF]; + while (size--) { + *tmp++ = hexdigits[*b >> 4]; + *tmp++ = hexdigits[*b++ & 0xF]; } *tmp++ = 0; @@ -49,11 +50,12 @@ static uint8_t unhex_digit(char hex) return tmp; } -char * unhexify(unsigned char *buf, const char *hex, int size) +char * unhexify(void *buf, const char *hex, size_t size) { - while(size--) { - *buf = unhex_digit(*hex++) << 4; - *buf++ |= unhex_digit(*hex++); + uint8_t *b = buf; + while (size--) { + *b = unhex_digit(*hex++) << 4; + *b++ |= unhex_digit(*hex++); } return buf; } diff --git a/src/include/gdb_packet.h b/src/include/gdb_packet.h index 222b86d..aa1a654 100644 --- a/src/include/gdb_packet.h +++ b/src/include/gdb_packet.h @@ -21,10 +21,10 @@ #ifndef __GDB_PACKET_H #define __GDB_PACKET_H -int gdb_getpacket(unsigned char *packet, int size); -void gdb_putpacket(unsigned char *packet, int size); +int gdb_getpacket(char *packet, int size); +void gdb_putpacket(const char *packet, int size); #define gdb_putpacketz(packet) gdb_putpacket((packet), strlen(packet)) -void gdb_putpacket_f(const unsigned char *packet, ...); +void gdb_putpacket_f(const char *packet, ...); void gdb_out(const char *buf); void gdb_outf(const char *fmt, ...); diff --git a/src/include/hex_utils.h b/src/include/hex_utils.h index 3aa210b..8a0d092 100644 --- a/src/include/hex_utils.h +++ b/src/include/hex_utils.h @@ -21,9 +21,8 @@ #ifndef __HEX_UTILS_H #define __HEX_UTILS_H -char * hexify(char *hex, const unsigned char *buf, int size); - -char * unhexify(unsigned char *buf, const char *hex, int size); +char * hexify(char *hex, const void *buf, size_t size); +char * unhexify(void *buf, const char *hex, size_t size); #endif diff --git a/src/jtag_scan.c b/src/jtag_scan.c index 208a1db..c4e80cf 100644 --- a/src/jtag_scan.c +++ b/src/jtag_scan.c @@ -74,7 +74,7 @@ static struct jtag_dev_descr_s { }; /* bucket of ones for don't care TDI */ -static const char ones[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"; +static const uint8_t ones[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF"; /* Scan JTAG chain for devices, store IR length and IDCODE (if present). * Reset TAP state machine. diff --git a/src/platforms/libftdi/jtagtap.c b/src/platforms/libftdi/jtagtap.c index c9bc876..c416892 100644 --- a/src/platforms/libftdi/jtagtap.c +++ b/src/platforms/libftdi/jtagtap.c @@ -97,7 +97,7 @@ jtagtap_tms_seq(uint32_t MS, int ticks) void jtagtap_tdi_seq(const uint8_t final_tms, const uint8_t *DI, int ticks) { - char *tmp; + uint8_t *tmp; int index = 0; int rticks; diff --git a/src/platforms/libftdi/swdptap.c b/src/platforms/libftdi/swdptap.c index eb6e65e..6aafa7d 100644 --- a/src/platforms/libftdi/swdptap.c +++ b/src/platforms/libftdi/swdptap.c @@ -45,7 +45,7 @@ int swdptap_init(void) abort(); } - assert(ftdi_write_data(ftdic, "\xAB\xA8", 2) == 2); + assert(ftdi_write_data(ftdic, (void*)"\xAB\xA8", 2) == 2); /* This must be investigated in more detail. * As described in STM32 Reference Manual... */ @@ -70,7 +70,6 @@ static void swdptap_turnaround(uint8_t dir) { static uint8_t olddir = 0; - /*DEBUG("%s", dir ? "\n-> ":"\n<- ");*/ platform_buffer_flush(); if(dir == olddir) return; @@ -80,7 +79,7 @@ static void swdptap_turnaround(uint8_t dir) assert(ftdi_set_bitmode(ftdic, 0xA3, BITMODE_BITBANG) == 0); /* One clock cycle */ - ftdi_write_data(ftdic, "\xAB\xA8", 2); + ftdi_write_data(ftdic, (void *)"\xAB\xA8", 2); if(!dir) /* SWDIO goes to output */ assert(ftdi_set_bitmode(ftdic, 0xAB, BITMODE_BITBANG) == 0); @@ -90,12 +89,9 @@ static uint8_t swdptap_bit_in(void) { uint8_t ret; - //ftdi_read_data(ftdic, &ret, 1); ftdi_read_pins(ftdic, &ret); ret &= 0x08; - ftdi_write_data(ftdic, "\xA1\xA0", 2); - - //DEBUG("%d", ret?1:0); + ftdi_write_data(ftdic, (void *)"\xA1\xA0", 2); return ret; } @@ -104,13 +100,10 @@ static void swdptap_bit_out(uint8_t val) { uint8_t buf[3] = "\xA0\xA1\xA0"; - //DEBUG("%d", val); - if(val) { for(int i = 0; i < 3; i++) buf[i] |= 0x08; } - //ftdi_write_data(ftdic, buf, 3); platform_buffer_write(buf, 3); }