diff --git a/flashstub/Makefile b/flashstub/Makefile index f6c6738..a18cd23 100644 --- a/flashstub/Makefile +++ b/flashstub/Makefile @@ -11,17 +11,12 @@ endif CFLAGS=-Os -std=gnu99 -mcpu=cortex-m0 -mthumb -I../libopencm3/include ASFLAGS=-mcpu=cortex-m3 -mthumb -all: lmi.stub stm32f4.stub stm32l4.stub nrf51.stub stm32f1.stub +all: lmi.stub stm32f4.stub stm32l4.stub nrf51.stub stm32f1.stub efm32.stub -stm32f1.o: stm32f1.c - $(Q)echo " CC $<" - $(Q)$(CC) $(CFLAGS) -DSTM32F1 -o $@ -c $< +stm32f1.o: CFLAGS += -DSTM32F1 +stm32f4.o: CFLAGS += -DSTM32F4 -stm32f4.o: stm32f4.c - $(Q)echo " CC $<" - $(Q)$(CC) $(CFLAGS) -DSTM32F4 -o $@ -c $< - -stm32l4.o: stm32l4.c +%.o: %.c $(Q)echo " CC $<" $(Q)$(CC) $(CFLAGS) -o $@ -c $< diff --git a/src/crc32.c b/src/crc32.c index 6f1c0e3..16cc565 100644 --- a/src/crc32.c +++ b/src/crc32.c @@ -97,13 +97,19 @@ uint32_t crc32_calc(uint32_t crc, uint8_t data) uint32_t generic_crc32(target *t, uint32_t base, int len) { uint32_t crc = -1; - uint8_t byte; + static uint8_t bytes[128]; - while (len--) { - byte = target_mem_read8(t, base); + while (len) { + uint32_t i; + uint32_t read_len = len >= 128 ? 128 : len; - crc = crc32_calc(crc, byte); - base++; + target_mem_read(t, bytes, base, read_len); + + for (i=0; itarget_options |= CORTEXM_TOPT_INHIBIT_SRST; t->driver = variant_string; gdb_outf("flash size %d page size %d\n", flash_size, flash_page_size); target_add_ram (t, SRAM_BASE, ram_size); diff --git a/src/gdb_main.c b/src/gdb_main.c index 6b2059f..cec5822 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 char pbuf[BUF_SIZE]; +static char pbuf[BUF_SIZE+1]; static target *cur_target; static target *last_target;