* along with this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************/
-/* Some of the the lower level code was based on code supplied by
+/* Some of the lower level code was based on code supplied by
* ATMEL under this copyright. */
/* BEGIN ATMEL COPYRIGHT */
};
struct sam4_bank_private {
- int probed;
+ bool probed;
/* DANGER: THERE ARE DRAGONS HERE.. */
/* NOTE: If you add more 'ghost' pointers */
/* be aware that you must *manually* update */
struct sam4_chip {
struct sam4_chip *next;
- int probed;
+ bool probed;
/* this is "initialized" from the global const structure */
struct sam4_chip_details details;
t = get_current_target(cmd->ctx);
if (!t) {
- command_print(cmd, "No current target?");
+ command_print_sameline(cmd, "No current target?\n");
return NULL;
}
if (!p) {
/* this should not happen */
/* the command is not registered until the chip is created? */
- command_print(cmd, "No SAM4 chips exist?");
+ command_print_sameline(cmd, "No SAM4 chips exist?\n");
return NULL;
}
return p;
p = p->next;
}
- command_print(cmd, "Cannot find SAM4 chip?");
+ command_print_sameline(cmd, "Cannot find SAM4 chip?\n");
return NULL;
}
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK0_BASE_C32,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = { */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 1,
.base_address = FLASH_BANK1_BASE_C32,
.controller_address = 0x400e0c00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK0_BASE_C32,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = { */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 1,
.base_address = FLASH_BANK1_BASE_C32,
.controller_address = 0x400e0c00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_C,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_C,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_C,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 256 * 1024,
.nsectors = 32,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 256 * 1024,
.nsectors = 32,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 256 * 1024,
.nsectors = 32,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 256 * 1024,
.nsectors = 32,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 128 * 1024,
.nsectors = 16,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 128 * 1024,
.nsectors = 16,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
{
/* .bank[0] = {*/
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 128 * 1024,
.nsectors = 16,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK0_BASE_SD,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
/* .bank[1] = { */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 1,
.base_address = FLASH_BANK1_BASE_2048K_SD,
.controller_address = 0x400e0c00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK0_BASE_SD,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
/* .bank[1] = { */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 1,
.base_address = FLASH_BANK1_BASE_2048K_SD,
.controller_address = 0x400e0c00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 1024 * 1024,
.nsectors = 128,
.sector_size = 8192,
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK0_BASE_SD,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
/* .bank[1] = { */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 1,
.base_address = FLASH_BANK1_BASE_1024K_SD,
.controller_address = 0x400e0c00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
/* .bank[0] = { */
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK0_BASE_SD,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
/* .bank[1] = { */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 1,
.base_address = FLASH_BANK1_BASE_1024K_SD,
.controller_address = 0x400e0c00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
/* .bank[0] = {*/
{
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = {*/
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
}
},
- /* atsamg55g19 */
+ /* atsamg55g19 Rev.A */
{
.chipid_cidr = 0x24470ae0,
.name = "atsamg55g19",
{
/* .bank[0] = */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = */
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
}
},
- /* atsamg55j19 */
+ /* atsamg55g19 Rev.B */
+ {
+ .chipid_cidr = 0x24470ae1,
+ .name = "atsamg55g19b",
+ .total_flash_size = 512 * 1024,
+ .total_sram_size = 160 * 1024,
+ .n_gpnvms = 2,
+ .n_banks = 1,
+
+ {
+/* .bank[0] = */
+ {
+ .probed = false,
+ .pChip = NULL,
+ .pBank = NULL,
+ .bank_number = 0,
+ .base_address = FLASH_BANK_BASE_S,
+ .controller_address = 0x400e0a00,
+ .flash_wait_states = 5,
+ .present = true,
+ .size_bytes = 512 * 1024,
+ .nsectors = 64,
+ .sector_size = 8192,
+ .page_size = 512,
+ },
+/* .bank[1] = */
+ {
+ .present = false,
+ .probed = false,
+ .bank_number = 1,
+ },
+ }
+ },
+
+ /* atsamg55j19 Rev.A */
{
.chipid_cidr = 0x24570ae0,
.name = "atsamg55j19",
{
/* .bank[0] = */
{
- .probed = 0,
+ .probed = false,
.pChip = NULL,
.pBank = NULL,
.bank_number = 0,
.base_address = FLASH_BANK_BASE_S,
.controller_address = 0x400e0a00,
.flash_wait_states = 5,
- .present = 1,
+ .present = true,
.size_bytes = 512 * 1024,
.nsectors = 64,
.sector_size = 8192,
},
/* .bank[1] = */
{
- .present = 0,
- .probed = 0,
+ .present = false,
+ .probed = false,
+ .bank_number = 1,
+ },
+ }
+ },
+
+ /* atsamg55j19 Rev.B */
+ {
+ .chipid_cidr = 0x24570ae1,
+ .name = "atsamg55j19b",
+ .total_flash_size = 512 * 1024,
+ .total_sram_size = 160 * 1024,
+ .n_gpnvms = 2,
+ .n_banks = 1,
+
+ {
+/* .bank[0] = */
+ {
+ .probed = false,
+ .pChip = NULL,
+ .pBank = NULL,
+ .bank_number = 0,
+ .base_address = FLASH_BANK_BASE_S,
+ .controller_address = 0x400e0a00,
+ .flash_wait_states = 5,
+ .present = true,
+ .size_bytes = 512 * 1024,
+ .nsectors = 64,
+ .sector_size = 8192,
+ .page_size = 512,
+ },
+/* .bank[1] = */
+ {
+ .present = false,
+ .probed = false,
.bank_number = 1,
},
}
/**
* Erases the entire flash.
* @param pPrivate - the info about the bank.
+ * @param firstPage
+ * @param numPages
+ * @param status
*/
static int FLASHD_ErasePages(struct sam4_bank_private *pPrivate,
int firstPage,
}
/* show the basics */
- LOG_USER_N("\t%*s: %*" PRId32 " [0x%0*" PRIx32 "] ",
+ LOG_USER_N("\t%*s: %*" PRIu32 " [0x%0*" PRIx32 "] ",
REG_NAME_WIDTH, regname,
dwidth, v,
hwidth, v);
pChip->target = bank->target;
/* assumption is this runs at 32khz */
pChip->cfg.slow_freq = 32768;
- pChip->probed = 0;
+ pChip->probed = false;
}
switch (bank->base) {
}
/**
- * Remove all chips from the internal list without distingushing which one
+ * Remove all chips from the internal list without distinguishing which one
* is owned by this bank. This simplification works only for one shot
* deallocation like current flash_free_all_banks()
*/
sam4_explain_chipid_cidr(pPrivate->pChip);
return ERROR_FAIL;
} else {
- LOG_DEBUG("SAM4 Found chip %s, CIDR 0x%08x", pDetails->name, pDetails->chipid_cidr);
+ LOG_DEBUG("SAM4 Found chip %s, CIDR 0x%08" PRIx32, pDetails->name, pDetails->chipid_cidr);
}
/* DANGER: THERE ARE DRAGONS HERE */
return ERROR_OK;
}
-static int sam4_info(struct flash_bank *bank, char *buf, int buf_size)
+static int sam4_info(struct flash_bank *bank, struct command_invocation *cmd)
{
struct sam4_bank_private *pPrivate;
int k = bank->size / 1024;
pPrivate = get_sam4_bank_private(bank);
- if (pPrivate == NULL) {
- buf[0] = '\0';
+ if (pPrivate == NULL)
return ERROR_FAIL;
- }
- snprintf(buf, buf_size,
- "%s bank %d: %d kB at " TARGET_ADDR_FMT,
+ command_print_sameline(cmd, "%s bank %d: %d kB at " TARGET_ADDR_FMT,
pPrivate->pChip->details.name,
pPrivate->bank_number,
k,
static int sam4_probe(struct flash_bank *bank)
{
- unsigned x;
int r;
struct sam4_bank_private *pPrivate;
- LOG_DEBUG("Begin: Bank: %d", bank->bank_number);
+ LOG_DEBUG("Begin: Bank: %u", bank->bank_number);
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
return r;
/* update the flash bank size */
- for (x = 0; x < SAM4_MAX_FLASH_BANKS; x++) {
+ for (unsigned int x = 0; x < SAM4_MAX_FLASH_BANKS; x++) {
if (bank->base == pPrivate->pChip->details.bank[x].base_address) {
bank->size = pPrivate->pChip->details.bank[x].size_bytes;
LOG_DEBUG("SAM4 Set flash bank to " TARGET_ADDR_FMT " - "
}
bank->num_sectors = pPrivate->nsectors;
- for (x = 0; ((int)(x)) < bank->num_sectors; x++) {
+ for (unsigned int x = 0; x < bank->num_sectors; x++) {
bank->sectors[x].size = pPrivate->sector_size;
bank->sectors[x].offset = x * (pPrivate->sector_size);
/* mark as unknown */
}
}
- pPrivate->probed = 1;
+ pPrivate->probed = true;
r = sam4_protect_check(bank);
if (r != ERROR_OK)
return sam4_probe(bank);
}
-static int sam4_erase(struct flash_bank *bank, int first, int last)
+static int sam4_erase(struct flash_bank *bank, unsigned int first,
+ unsigned int last)
{
struct sam4_bank_private *pPrivate;
int r;
- int i;
int pageCount;
/*16 pages equals 8KB - Same size as a lock region*/
pageCount = 16;
if (!(pPrivate->probed))
return ERROR_FLASH_BANK_NOT_PROBED;
- if ((first == 0) && ((last + 1) == ((int)(pPrivate->nsectors)))) {
+ if ((first == 0) && ((last + 1) == pPrivate->nsectors)) {
/* whole chip */
LOG_DEBUG("Here");
return FLASHD_EraseEntireBank(pPrivate);
}
LOG_INFO("sam4 does not auto-erase while programming (Erasing relevant sectors)");
- LOG_INFO("sam4 First: 0x%08x Last: 0x%08x", (unsigned int)(first), (unsigned int)(last));
- for (i = first; i <= last; i++) {
+ LOG_INFO("sam4 First: 0x%08x Last: 0x%08x", first, last);
+ for (unsigned int i = first; i <= last; i++) {
/*16 pages equals 8KB - Same size as a lock region*/
r = FLASHD_ErasePages(pPrivate, (i * pageCount), pageCount, &status);
- LOG_INFO("Erasing sector: 0x%08x", (unsigned int)(i));
+ LOG_INFO("Erasing sector: 0x%08x", i);
if (r != ERROR_OK)
- LOG_ERROR("SAM4: Error performing Erase page @ lock region number %d",
- (unsigned int)(i));
+ LOG_ERROR("SAM4: Error performing Erase page @ lock region number %u",
+ i);
if (status & (1 << 2)) {
- LOG_ERROR("SAM4: Lock Region %d is locked", (unsigned int)(i));
+ LOG_ERROR("SAM4: Lock Region %u is locked", i);
return ERROR_FAIL;
}
if (status & (1 << 1)) {
- LOG_ERROR("SAM4: Flash Command error @lock region %d", (unsigned int)(i));
+ LOG_ERROR("SAM4: Flash Command error @lock region %u", i);
return ERROR_FAIL;
}
}
return ERROR_OK;
}
-static int sam4_protect(struct flash_bank *bank, int set, int first, int last)
+static int sam4_protect(struct flash_bank *bank, int set, unsigned int first,
+ unsigned int last)
{
struct sam4_bank_private *pPrivate;
int r;
return ERROR_FLASH_BANK_NOT_PROBED;
if (set)
- r = FLASHD_Lock(pPrivate, (unsigned)(first), (unsigned)(last));
+ r = FLASHD_Lock(pPrivate, first, last);
else
- r = FLASHD_Unlock(pPrivate, (unsigned)(first), (unsigned)(last));
+ r = FLASHD_Unlock(pPrivate, first, last);
LOG_DEBUG("End: r=%d", r);
return r;
struct sam4_bank_private *pPrivate;
uint8_t *pagebuffer;
- /* incase we bail further below, set this to null */
+ /* in case we bail further below, set this to null */
pagebuffer = NULL;
/* ignore dumb requests */
LOG_DEBUG("Done!");
r = ERROR_OK;
done:
- if (pagebuffer)
- free(pagebuffer);
+ free(pagebuffer);
return r;
}