projects
/
fw
/
openocd
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Clean up many C99 integer types format specifiers
[fw/openocd]
/
src
/
flash
/
nor
/
stm32f2x.c
diff --git
a/src/flash/nor/stm32f2x.c
b/src/flash/nor/stm32f2x.c
index 91baec4b86620676a454991da9c02cde44410644..1dee6230c488d6ce298adfde70f91ae295d8af68 100644
(file)
--- a/
src/flash/nor/stm32f2x.c
+++ b/
src/flash/nor/stm32f2x.c
@@
-111,7
+111,9
@@
#define FLASH_PSIZE_16 (1 << 8)
#define FLASH_PSIZE_32 (2 << 8)
#define FLASH_PSIZE_64 (3 << 8)
#define FLASH_PSIZE_16 (1 << 8)
#define FLASH_PSIZE_32 (2 << 8)
#define FLASH_PSIZE_64 (3 << 8)
-#define FLASH_SNB(a) ((a) << 3)
+/* The sector number encoding is not straight binary for dual bank flash.
+ * Warning: evaluates the argument multiple times */
+#define FLASH_SNB(a) ((((a) >= 12) ? 0x10 | ((a) - 12) : (a)) << 3)
#define FLASH_LOCK (1 << 31)
/* FLASH_SR register bits */
#define FLASH_LOCK (1 << 31)
/* FLASH_SR register bits */
@@
-256,7
+258,7
@@
static int stm32x_unlock_reg(struct target *target)
return retval;
if (ctrl & FLASH_LOCK) {
return retval;
if (ctrl & FLASH_LOCK) {
- LOG_ERROR("flash not unlocked STM32_FLASH_CR: %
x"
, ctrl);
+ LOG_ERROR("flash not unlocked STM32_FLASH_CR: %
" PRIx32
, ctrl);
return ERROR_TARGET_FAILURE;
}
return ERROR_TARGET_FAILURE;
}
@@
-288,7
+290,7
@@
static int stm32x_unlock_option_reg(struct target *target)
return retval;
if (ctrl & OPT_LOCK) {
return retval;
if (ctrl & OPT_LOCK) {
- LOG_ERROR("options not unlocked STM32_FLASH_OPTCR: %
x"
, ctrl);
+ LOG_ERROR("options not unlocked STM32_FLASH_OPTCR: %
" PRIx32
, ctrl);
return ERROR_TARGET_FAILURE;
}
return ERROR_TARGET_FAILURE;
}
@@
-403,6
+405,9
@@
static int stm32x_erase(struct flash_bank *bank, int first, int last)
struct target *target = bank->target;
int i;
struct target *target = bank->target;
int i;
+ assert(first < bank->num_sectors);
+ assert(last < bank->num_sectors);
+
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
@@
-418,7
+423,7
@@
static int stm32x_erase(struct flash_bank *bank, int first, int last)
To erase a sector, follow the procedure below:
1. Check that no Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register
To erase a sector, follow the procedure below:
1. Check that no Flash memory operation is ongoing by checking the BSY bit in the
FLASH_SR register
- 2. Set the SER bit and select the sector
(out of the 12 sectors in the main memory block)
+ 2. Set the SER bit and select the sector
you wish to erase (SNB) in the FLASH_CR register
3. Set the STRT bit in the FLASH_CR register
4. Wait for the BSY bit to be cleared
you wish to erase (SNB) in the FLASH_CR register
3. Set the STRT bit in the FLASH_CR register
4. Wait for the BSY bit to be cleared
@@
-584,7
+589,7
@@
static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
LOG_ERROR("flash memory write protected");
if (error != 0) {
LOG_ERROR("flash memory write protected");
if (error != 0) {
- LOG_ERROR("flash write failed = %08
x"
, error);
+ LOG_ERROR("flash write failed = %08
" PRIx32
, error);
/* Clear but report errors */
target_write_u32(target, STM32_FLASH_SR, error);
retval = ERROR_FAIL;
/* Clear but report errors */
target_write_u32(target, STM32_FLASH_SR, error);
retval = ERROR_FAIL;
@@
-914,6
+919,10
@@
static int get_stm32x_info(struct flash_bank *bank, char *buf, int buf_size)
case 0x1001:
rev_str = "Z";
break;
case 0x1001:
rev_str = "Z";
break;
+
+ case 0x1003:
+ rev_str = "Y";
+ break;
}
break;
}
break;