#include <flash/common.h>
+/**
+ * @file
+ * Upper level NOR flash interfaces.
+ */
+
struct image;
#define FLASH_MAX_ERROR_STR (128)
/// 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);
+
/**
* 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);
+
+/* invalidate cached state (targets may modify their own flash) */
+void nor_resume(struct target *target);
+
/**
* 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