24 #define LOAD_TIMER_ERASE 0
25 #define LOAD_TIMER_WRITE 1
27 #define FLASH_PAGE_SIZE 512
30 #define DBGU_CIDR 0x8000507C
32 #define F_CTRL 0x80102000
33 #define F_STAT 0x80102004
34 #define F_PROG_TIME 0x80102008
35 #define F_WAIT 0x80102010
36 #define F_CLK_TIME 0x8010201C
38 #define F_INTEN_CLR 0x80102FD8
39 #define F_INTEN_SET 0x80102FDC
40 #define F_INT_STAT 0x80102FE0
41 #define F_INTEN 0x80102FE4
42 #define F_INT_CLR 0x80102FE8
43 #define F_INT_SET 0x80102FEC
44 #define FLASH_PD 0x80005030
46 #define FLASH_INIT 0x80005034
51 #define FC_FUNC 0x0002
53 #define FC_RD_LATCH 0x0020
54 #define FC_PROTECT 0x0080
55 #define FC_SET_DATA 0x0400
56 #define FC_RSSL 0x0800
57 #define FC_PROG_REQ 0x1000
58 #define FC_CLR_BUF 0x4000
59 #define FC_LOAD_REQ 0x8000
61 #define FS_DONE 0x0001
62 #define FS_PROGGNT 0x0002
66 #define FPT_TIME_MASK 0x7FFF
68 #define FPT_ENABLE 0x8000
70 #define FW_WAIT_STATES_MASK 0x00FF
71 #define FW_SET_MASK 0xC000
74 #define FCT_CLK_DIV_MASK 0x0FFF
120 if (lpc288x_info->
cidr == 0x0102100A)
127 if (cidr != 0x0102100A) {
128 LOG_WARNING(
"Cannot identify target as an LPC288X (%08" PRIx32
")", cidr);
132 lpc288x_info->
cidr = cidr;
138 bank->num_sectors = 23;
141 for (i = 0; i < 15; i++) {
143 bank->sectors[i].size = 64 * 1024;
145 bank->sectors[i].is_erased = -1;
146 bank->sectors[i].is_protected = 1;
148 for (i = 15; i < 23; i++) {
150 bank->sectors[i].size = 8 * 1024;
152 bank->sectors[i].is_erased = -1;
153 bank->sectors[i].is_protected = 1;
174 bank->driver_priv = lpc288x_info;
177 lpc288x_info->
cidr = 0;
192 clk_time = (lpc288x_info->
cclk / 66000) / 3;
214 if (lpc288x_info->
cidr == 0)
234 if ((last < first) || (last >=
bank->num_sectors)) {
242 for (
unsigned int sector = first; sector <= last; sector++) {
260 uint32_t
status, source_offset, dest_offset;
262 uint32_t bytes_remaining =
count;
263 uint32_t first_sector, last_sector, sector, page;
271 first_sector = last_sector = 0xffffffff;
274 for (
unsigned int i = 0; i <
bank->num_sectors; i++) {
277 (first_sector == 0xffffffff)) {
282 "offset 0x%" PRIx32
" breaks required alignment 0x%" PRIx32
"",
284 bank->sectors[i].size);
290 (last_sector == 0xffffffff))
295 if (first_sector == 0xffffffff || last_sector == 0xffffffff) {
307 for (sector = first_sector; sector <= last_sector; sector++) {
309 if (bytes_remaining == 0) {
313 count = bytes_remaining;
315 memcpy(page_buffer, &
buffer[source_offset],
count);
318 memcpy(page_buffer, &
buffer[source_offset],
count);
332 LOG_INFO(
"Write to flash buffer failed");
337 source_offset +=
count;
338 bytes_remaining -=
count;
356 if (lpc288x_info->
cidr != 0)
382 if ((last < first) || (last >=
bank->num_sectors))
388 for (
unsigned int lockregion = first; lockregion <= last; lockregion++) {
406 .flash_bank_command = lpc288x_flash_bank_command,
Support functions to access arbitrary bits in a byte array.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define ERROR_FLASH_SECTOR_INVALID
#define ERROR_FLASH_BANK_NOT_PROBED
#define ERROR_FLASH_OPERATION_FAILED
#define ERROR_FLASH_DST_BREAKS_ALIGNMENT
#define ERROR_FLASH_DST_OUT_OF_BANK
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
void alive_sleep(uint64_t ms)
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
static int lpc288x_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static void lpc288x_set_flash_clk(struct flash_bank *bank)
static void lpc288x_load_timer(int erase, struct target *target)
static uint32_t lpc288x_system_ready(struct flash_bank *bank)
static int lpc288x_read_part_info(struct flash_bank *bank)
static uint32_t lpc288x_wait_status_busy(struct flash_bank *bank, int timeout)
static int lpc288x_protect_check(struct flash_bank *bank)
static int lpc288x_probe(struct flash_bank *bank)
const struct flash_driver lpc288x_flash
static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
FLASH_BANK_COMMAND_HANDLER(lpc288x_flash_bank_command)
static int lpc288x_protect(struct flash_bank *bank, int set, unsigned int first, unsigned int last)
Provides details of a flash bank, available either on-chip or through a major interface.
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
Describes the geometry and status of a single flash sector within a flash bank.
uint32_t sector_size_break
uint32_t working_area_size
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
#define ERROR_TARGET_NOT_HALTED