*/
struct lpc2900_flash_bank
{
+ /**
+ * This flag is set when the device has been successfully probed.
+ */
+ bool is_probed;
+
/**
* Holds the value read from CHIPID register.
* The driver will not load if the chipid doesn't match the expected
uint32_t addr_from, uint32_t addr_to,
uint32_t (*signature)[4] );
static uint32_t lpc2900_address2sector(struct flash_bank *bank, uint32_t offset);
-static uint32_t lpc2900_calc_tr( uint32_t clock, uint32_t time );
+static uint32_t lpc2900_calc_tr(uint32_t clock_var, uint32_t time_var);
/*********************** Helper functions **************************/
{
struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv;
- if( lpc2900_info->chipid != EXPECTED_CHIPID )
+ if( !lpc2900_info->is_probed )
{
return ERROR_FLASH_BANK_NOT_PROBED;
}
/* ((time[µs]/1e6) * f[Hz]) + 511
* FPTR.TR = -------------------------------
* 512
- *
- * The result is the
*/
uint32_t tr_val = (uint32_t)((((time_var / 1e6) * clock_var) + 511.0) / 512.0);
if( CMD_ARGC < 1 )
{
- LOG_WARNING( "Too few arguments. Call: lpc2900 signature <bank#>" );
- return ERROR_FLASH_BANK_INVALID;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
struct flash_bank *bank;
static const struct command_registration lpc2900_exec_command_handlers[] = {
{
.name = "signature",
+ .usage = "<bank>",
.handler = lpc2900_handle_signature_command,
.mode = COMMAND_EXEC,
- .usage = "bank_id",
.help = "Calculate and display signature of flash bank.",
},
{
if (CMD_ARGC < 6)
{
- LOG_WARNING("incomplete flash_bank LPC2900 configuration");
- return ERROR_FLASH_BANK_INVALID;
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
lpc2900_info = malloc(sizeof(struct lpc2900_flash_bank));
/* Chip ID will be obtained by probing the device later */
lpc2900_info->chipid = 0;
+ lpc2900_info->is_probed = false;
return ERROR_OK;
}
return ERROR_TARGET_NOT_HALTED;
}
- /* We want to do this only once. Check if we already have a valid CHIPID,
- * because then we will have already successfully probed the device.
- */
- if (lpc2900_info->chipid == EXPECTED_CHIPID)
+ /* We want to do this only once. */
+ if (lpc2900_info->is_probed)
{
return ERROR_OK;
}
else if ( package_code == 4 )
{
/* 144-pin package */
- if ( (bank->size == 512*KiB) && (feat3 == 0xFFFFFCF0) )
+ if ( (bank->size == 256*KiB) && (feat3 == 0xFFFFFFE9) )
+ {
+ lpc2900_info->target_name = "LPC2926";
+ }
+ else if ( (bank->size == 512*KiB) && (feat3 == 0xFFFFFCF0) )
{
lpc2900_info->target_name = "LPC2917/01";
}
if ( !found )
{
- LOG_WARNING("Unknown LPC29xx derivative");
+ LOG_WARNING("Unknown LPC29xx derivative"
+ " (FEATx="
+ "%08" PRIx32 ":%08" PRIx32 ":%08" PRIx32 ":%08" PRIx32 ")",
+ feat0, feat1, feat2, feat3
+ );
return ERROR_FLASH_OPERATION_FAILED;
}
offset += bank->sectors[i].size;
}
+ lpc2900_info->is_probed = true;
+
/* Read sector security status */
if ( lpc2900_read_security_status(bank) != ERROR_OK )
{