* 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;
static struct sam4_chip *all_sam4_chips;
-static struct sam4_chip *get_current_sam4(struct command_context *cmd_ctx)
+static struct sam4_chip *get_current_sam4(struct command_invocation *cmd)
{
struct target *t;
static struct sam4_chip *p;
- t = get_current_target(cmd_ctx);
+ t = get_current_target(cmd->ctx);
if (!t) {
- command_print(cmd_ctx, "No current target?");
+ command_print(cmd, "No current target?");
return NULL;
}
if (!p) {
/* this should not happen */
/* the command is not registered until the chip is created? */
- command_print(cmd_ctx, "No SAM4 chips exist?");
+ command_print(cmd, "No SAM4 chips exist?");
return NULL;
}
return p;
p = p->next;
}
- command_print(cmd_ctx, "Cannot find SAM4 chip?");
+ command_print(cmd, "Cannot find SAM4 chip?");
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,
},
{
/* .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,
},
}
pChip->target = bank->target;
/* assumption is this runs at 32khz */
pChip->cfg.slow_freq = 32768;
- pChip->probed = 0;
+ pChip->probed = false;
}
switch (bank->base) {
((unsigned int)(bank->base)),
((unsigned int)(FLASH_BANK_BASE_S)));
return ERROR_FAIL;
- break;
/* at91sam4s series only has bank 0*/
/* at91sam4sd series has the same address for bank 0 (FLASH_BANK0_BASE_SD)*/
}
/**
- * 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()
*/
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 */
COMMAND_HANDLER(sam4_handle_info_command)
{
struct sam4_chip *pChip;
- pChip = get_current_sam4(CMD_CTX);
+ pChip = get_current_sam4(CMD);
if (!pChip)
return ERROR_OK;
if (pChip->details.bank[0].pBank == NULL) {
x = 0;
need_define:
- command_print(CMD_CTX,
+ command_print(CMD,
"Please define bank %d via command: flash bank %s ... ",
x,
at91sam4_flash.name);
int r, who;
struct sam4_chip *pChip;
- pChip = get_current_sam4(CMD_CTX);
+ pChip = get_current_sam4(CMD);
if (!pChip)
return ERROR_OK;
}
if (pChip->details.bank[0].pBank == NULL) {
- command_print(CMD_CTX, "Bank0 must be defined first via: flash bank %s ...",
+ command_print(CMD, "Bank0 must be defined first via: flash bank %s ...",
at91sam4_flash.name);
return ERROR_FAIL;
}
switch (CMD_ARGC) {
default:
return ERROR_COMMAND_SYNTAX_ERROR;
- break;
case 0:
goto showall;
- break;
case 1:
who = -1;
break;
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), x, &v);
if (r != ERROR_OK)
break;
- command_print(CMD_CTX, "sam4-gpnvm%u: %u", x, v);
+ command_print(CMD, "sam4-gpnvm%u: %u", x, v);
}
return r;
}
if ((who >= 0) && (((unsigned)(who)) < pChip->details.n_gpnvms)) {
r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v);
if (r == ERROR_OK)
- command_print(CMD_CTX, "sam4-gpnvm%u: %u", who, v);
+ command_print(CMD, "sam4-gpnvm%u: %u", who, v);
return r;
} else {
- command_print(CMD_CTX, "sam4-gpnvm invalid GPNVM: %u", who);
+ command_print(CMD, "sam4-gpnvm invalid GPNVM: %u", who);
return ERROR_COMMAND_SYNTAX_ERROR;
}
}
if (who == -1) {
- command_print(CMD_CTX, "Missing GPNVM number");
+ command_print(CMD, "Missing GPNVM number");
return ERROR_COMMAND_SYNTAX_ERROR;
}
(0 == strcmp("clear", CMD_ARGV[0]))) /* quietly accept both */
r = FLASHD_ClrGPNVM(&(pChip->details.bank[0]), who);
else {
- command_print(CMD_CTX, "Unknown command: %s", CMD_ARGV[0]);
+ command_print(CMD, "Unknown command: %s", CMD_ARGV[0]);
r = ERROR_COMMAND_SYNTAX_ERROR;
}
return r;
{
struct sam4_chip *pChip;
- pChip = get_current_sam4(CMD_CTX);
+ pChip = get_current_sam4(CMD);
if (!pChip)
return ERROR_OK;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], v);
if (v > 200000) {
/* absurd slow clock of 200Khz? */
- command_print(CMD_CTX, "Absurd/illegal slow clock freq: %d\n", (int)(v));
+ command_print(CMD, "Absurd/illegal slow clock freq: %d\n", (int)(v));
return ERROR_COMMAND_SYNTAX_ERROR;
}
pChip->cfg.slow_freq = v;
}
default:
/* error */
- command_print(CMD_CTX, "Too many parameters");
+ command_print(CMD, "Too many parameters");
return ERROR_COMMAND_SYNTAX_ERROR;
- break;
}
- command_print(CMD_CTX, "Slowclk freq: %d.%03dkhz",
+ command_print(CMD, "Slowclk freq: %d.%03dkhz",
(int)(pChip->cfg.slow_freq / 1000),
(int)(pChip->cfg.slow_freq % 1000));
return ERROR_OK;
.name = "info",
.handler = sam4_handle_info_command,
.mode = COMMAND_EXEC,
- .help = "Print information about the current at91sam4 chip"
+ .help = "Print information about the current at91sam4 chip "
"and its flash configuration.",
+ .usage = "",
},
{
.name = "slowclk",