/* Flash controller configuration values */
#define FLASH_ID_XMC4500 0xA2
-#define FLASH_ID_XMC4700_4800 0x92
+#define FLASH_ID_XMC4300_XMC4700_4800 0x92
#define FLASH_ID_XMC4100_4200 0x9C
#define FLASH_ID_XMC4400 0x9F
bank->num_sectors = 12;
LOG_DEBUG("XMC4xxx: XMC4500 detected.");
break;
- case FLASH_ID_XMC4700_4800:
+ case FLASH_ID_XMC4300_XMC4700_4800:
bank->num_sectors = 16;
LOG_DEBUG("XMC4xxx: XMC4700/4800 detected.");
break;
memcpy(&tmp_buf[start_pad], buffer, remaining);
if (end_pad) {
- LOG_INFO("Padding end of page @%08"PRIx32" by %d bytes",
+ LOG_INFO("Padding end of page @" TARGET_ADDR_FMT " by %d bytes",
bank->base + offset, end_pad);
memset(&tmp_buf[256 - end_pad], 0xff, end_pad);
}
break;
}
break;
+ case 0x300:
+ dev_str = "XMC4300";
+
+ switch (rev_id) {
+ case 0x1:
+ rev_str = "AA";
+ }
+ break;
case 0x400:
dev_str = "XMC4400";
/* If OTP Write protection is enabled (User 2), list each
* sector that has it enabled */
- char otp_str[8];
+ char otp_str[14];
if (otp_enabled) {
strcat(prot_str, "\nOTP Protection is enabled for sectors:\n");
for (int i = 0; i < bank->num_sectors; i++) {
if (fb->write_prot_otp[i]) {
snprintf(otp_str, sizeof(otp_str), "- %d\n", i);
- strncat(prot_str, otp_str, ARRAY_SIZE(otp_str));
+ strncat(prot_str, otp_str, sizeof(prot_str) - strlen(prot_str) - 1);
}
}
}
uint32_t addr;
int res;
- if ((level < 0) || (level > 1)) {
- LOG_ERROR("Invalid user level. Must be 0-1");
- return ERROR_FAIL;
- }
-
switch (level) {
case 0:
addr = UCB0_BASE;
case 1:
addr = UCB1_BASE;
break;
+ default:
+ LOG_ERROR("Invalid user level. Must be 0-1");
+ return ERROR_FAIL;
}
res = xmc4xxx_erase_sector(bank, addr, true);
.usage = "bank_id user_level[0-1]",
.help = "Permanently Removes flash protection (read and write) "
"for the specified user level",
- }, COMMAND_REGISTRATION_DONE
+ },
+ COMMAND_REGISTRATION_DONE
};
static const struct command_registration xmc4xxx_command_handlers[] = {
COMMAND_REGISTRATION_DONE
};
-struct flash_driver xmc4xxx_flash = {
+const struct flash_driver xmc4xxx_flash = {
.name = "xmc4xxx",
.commands = xmc4xxx_command_handlers,
.flash_bank_command = xmc4xxx_flash_bank_command,
.info = xmc4xxx_get_info_command,
.protect_check = xmc4xxx_protect_check,
.protect = xmc4xxx_protect,
+ .free_driver_priv = default_flash_free_driver_priv,
};