* Indication of protection status: 0 = unprotected/unlocked,
* 1 = protected/locked, other = unknown. Set by
* @c flash_driver_s::protect_check.
+ *
+ * This information must be considered stale immediately.
+ * A million things could make it stale: power cycle,
+ * reset of target, code running on target, etc.
*/
int is_protected;
};
/// Registers the 'flash' subsystem commands
int flash_register_commands(struct command_context *cmd_ctx);
-/// Initializes the 'flash' subsystem drivers
-int flash_init_drivers(struct command_context *cmd_ctx);
/**
* Erases @a length bytes in the @a target flash, starting at @a addr.
+ * The range @a addr to @a addr + @a length - 1 must be strictly
+ * sector aligned, unless @a pad is true. Setting @a pad true extends
+ * the range, at beginning and/or end, if needed for sector alignment.
* @returns ERROR_OK if successful; otherwise, an error code.
*/
int flash_erase_address_range(struct target *target,
- uint32_t addr, uint32_t length);
+ bool pad, uint32_t addr, uint32_t length);
+
+int flash_unlock_address_range(struct target *target, uint32_t addr,
+ uint32_t length);
+
/**
* Writes @a image into the @a target flash. The @a written parameter
* will contain the
*/
int flash_write(struct target *target,
struct image *image, uint32_t *written, int erase);
+
/**
* Forces targets to re-examine their erase/protection state.
* This routine must be called when the system may modify the status.
/**
* Returns a flash bank by the specified flash_bank_s bank_number, @a num.
* @param num The flash bank number.
- * @returns A struct flash_bank for flash bank @a num, or NULL
+ * @param bank returned bank if fn returns ERROR_OK
+ * @returns ERROR_OK if successful
*/
-struct flash_bank *get_flash_bank_by_num(int num);
+int get_flash_bank_by_num(int num, struct flash_bank **bank);
/**
* Retreives @a bank from a command argument, reporting errors parsing
* the bank identifier or retreiving the specified bank. The bank