diff --git a/src/target/stm32f1.c b/src/target/stm32f1.c index 2e1de5e6203..d05bcfc2df0 100644 --- a/src/target/stm32f1.c +++ b/src/target/stm32f1.c @@ -682,6 +682,9 @@ static bool stm32f1_flash_write(target_flash_s *flash, target_addr_t dest, const const size_t offset = stm32f1_bank1_length(dest, len); DEBUG_TARGET("%s: at %08" PRIx32 " for %zu bytes\n", __func__, dest, len); + /* Allow wider writes on Gigadevices (is there a better way to hook this?) */ + const align_e psize = (!strncmp(target->driver, "GD32", 4)) ? ALIGN_32BIT : ALIGN_16BIT; + /* Start by writing any bank 1 data */ if (offset) { stm32f1_flash_clear_eop(target, FLASH_BANK1_OFFSET); @@ -691,7 +694,7 @@ static bool stm32f1_flash_write(target_flash_s *flash, target_addr_t dest, const if (target->designer_code == JEP106_MANUFACTURER_RV_GIGADEVICE && target->cpuid == 0x80000022U) target_mem_write(target, dest, src, offset); else - cortexm_mem_write_sized(target, dest, src, offset, ALIGN_16BIT); + cortexm_mem_write_sized(target, dest, src, offset, psize); /* Wait for completion or an error */ if (!stm32f1_flash_busy_wait(target, FLASH_BANK1_OFFSET, NULL)) @@ -709,7 +712,7 @@ static bool stm32f1_flash_write(target_flash_s *flash, target_addr_t dest, const if (target->designer_code == JEP106_MANUFACTURER_RV_GIGADEVICE && target->cpuid == 0x80000022U) target_mem_write(target, dest + offset, data + offset, remainder); else - cortexm_mem_write_sized(target, dest + offset, data + offset, remainder, ALIGN_16BIT); + cortexm_mem_write_sized(target, dest + offset, data + offset, remainder, psize); /* Wait for completion or an error */ if (!stm32f1_flash_busy_wait(target, FLASH_BANK2_OFFSET, NULL))