OpenOCD
|
Go to the source code of this file.
Data Structures | |
struct | lpc2900_flash_bank |
Private data for lpc2900 flash driver. More... | |
Macros | |
#define | CHIPID 0xE0000000 /* Chip ID */ |
#define | EEADDR 0x20200084 /* EEPROM address */ |
#define | EECLKDIV 0x20200094 /* EEPROM clock divider */ |
#define | EECMD 0x20200080 /* EEPROM command */ |
#define | EEMSSIG 0x202000A4 /* EEPROM 24-bit BIST signature */ |
#define | EEMSSTART 0x2020009C /* EEPROM BIST start address */ |
#define | EEMSSTOP 0x202000A0 /* EEPROM BIST stop address */ |
#define | EEMSSTOP_STRTBIST (1 << 31) |
#define | EEPWRDWN 0x20200098 /* EEPROM power-down/start */ |
#define | EERDATA 0x2020008C /* EEPROM read data */ |
#define | EEWDATA 0x20200088 /* EEPROM write data */ |
#define | EEWSTATE 0x20200090 /* EEPROM wait state */ |
#define | EXPECTED_CHIPID 0x209CE02B /* Chip ID of all LPC2900 devices */ |
#define | FBWST 0x20200010 /* Flash bridge wait-state */ |
#define | FCRA 0x2020001C /* Flash clock divider */ |
#define | FCTR 0x20200000 /* Flash control */ |
#define | FCTR_FS_CACHEBYP (1 << 13) |
#define | FCTR_FS_CACHECLR (1 << 14) |
#define | FCTR_FS_CS (1 << 0) |
#define | FCTR_FS_DCR (1 << 4) |
#define | FCTR_FS_ISS (1 << 6) |
#define | FCTR_FS_LOADREQ (1 << 15) |
#define | FCTR_FS_PD (1 << 9) |
#define | FCTR_FS_PDL (1 << 10) |
#define | FCTR_FS_PROGREQ (1 << 12) |
#define | FCTR_FS_RLD (1 << 5) |
#define | FCTR_FS_RLS (1 << 11) |
#define | FCTR_FS_WEB (1 << 2) |
#define | FCTR_FS_WPB (1 << 7) |
#define | FCTR_FS_WRE (1 << 1) |
#define | FEAT0 0xE0000100 /* Chip feature 0 */ |
#define | FEAT1 0xE0000104 /* Chip feature 1 */ |
#define | FEAT2 0xE0000108 /* Chip feature 2 (contains flash size indicator) */ |
#define | FEAT3 0xE000010C /* Chip feature 3 */ |
#define | FLASH_ERASE_TIME 100000 /* microseconds */ |
#define | FLASH_PAGE_SIZE 512 /* bytes */ |
#define | FLASH_PROGRAM_TIME 1000 /* microseconds */ |
#define | FMS16 0x20200028 /* Flash 16-bit signature */ |
#define | FMSSTART 0x20200020 /* Flash Built-In Self Test start address */ |
#define | FMSSTOP 0x20200024 /* Flash Built-In Self Test stop address */ |
#define | FMSSTOP_MISR_START (1 << 17) |
#define | FMSW0 0x2020002C /* Flash 128-bit signature Word 0 */ |
#define | FMSW1 0x20200030 /* Flash 128-bit signature Word 1 */ |
#define | FMSW2 0x20200034 /* Flash 128-bit signature Word 2 */ |
#define | FMSW3 0x20200038 /* Flash 128-bit signature Word 3 */ |
#define | FPTR 0x20200008 /* Flash program-time */ |
#define | FPTR_EN_T (1 << 15) |
#define | FTCTR 0x2020000C /* Flash test control */ |
#define | FTCTR_FS_BYPASS_R (1 << 29) |
#define | FTCTR_FS_BYPASS_W (1 << 28) |
#define | INT_CLR_ENABLE 0x20200FD8 /* Flash/EEPROM interrupt clear enable */ |
#define | INT_CLR_STATUS 0x20200FE8 /* Flash/EEPROM interrupt clear status */ |
#define | INT_ENABLE 0x20200FE4 /* Flash/EEPROM interrupt enable */ |
#define | INT_SET_ENABLE 0x20200FDC /* Flash/EEPROM interrupt set enable */ |
#define | INT_SET_STATUS 0x20200FEC /* Flash/EEPROM interrupt set status */ |
#define | INT_STATUS 0x20200FE0 /* Flash/EEPROM interrupt status */ |
#define | INTSRC_END_OF_BIST (1 << 27) |
#define | INTSRC_END_OF_BURN (1 << 1) |
#define | INTSRC_END_OF_ERASE (1 << 0) |
#define | INTSRC_END_OF_MISR (1 << 2) |
#define | INTSRC_END_OF_PROG (1 << 28) |
#define | INTSRC_END_OF_RDWR (1 << 26) |
#define | ISS_CUSTOMER_END1 (0xA00) |
#define | ISS_CUSTOMER_END2 (0xC00) |
#define | ISS_CUSTOMER_NWORDS1 (ISS_CUSTOMER_SIZE1 / 4) |
#define | ISS_CUSTOMER_NWORDS2 (ISS_CUSTOMER_SIZE2 / 4) |
#define | ISS_CUSTOMER_SIZE (ISS_CUSTOMER_SIZE1 + ISS_CUSTOMER_SIZE2) |
#define | ISS_CUSTOMER_SIZE1 (ISS_CUSTOMER_END1 - ISS_CUSTOMER_START1) |
#define | ISS_CUSTOMER_SIZE2 (ISS_CUSTOMER_END2 - ISS_CUSTOMER_START2) |
#define | ISS_CUSTOMER_START1 (0x830) |
#define | ISS_CUSTOMER_START2 (0xA40) |
#define | ISS_PASSWORD "I_know_what_I_am_doing" |
#define | KiB 1024 |
Functions | |
COMMAND_HANDLER (lpc2900_handle_password_command) | |
Enter password to enable potentially dangerous options. More... | |
COMMAND_HANDLER (lpc2900_handle_read_custom_command) | |
Store customer info in file. More... | |
COMMAND_HANDLER (lpc2900_handle_secure_jtag_command) | |
Activate JTAG protection. More... | |
COMMAND_HANDLER (lpc2900_handle_secure_sector_command) | |
Activate 'sector security' for a range of sectors. More... | |
COMMAND_HANDLER (lpc2900_handle_signature_command) | |
Command to determine the signature of the whole flash. More... | |
COMMAND_HANDLER (lpc2900_handle_write_custom_command) | |
Write customer info from file to the index sector. More... | |
FLASH_BANK_COMMAND_HANDLER (lpc2900_flash_bank_command) | |
Evaluate flash bank command. More... | |
static unsigned int | lpc2900_address2sector (struct flash_bank *bank, uint32_t offset) |
Return sector number for given address. More... | |
static uint32_t | lpc2900_calc_tr (uint32_t clock_var, uint32_t time_var) |
Calculate FPTR.TR register value for desired program/erase time. More... | |
static int | lpc2900_erase (struct flash_bank *bank, unsigned int first, unsigned int last) |
Erase sector(s). More... | |
static int | lpc2900_erase_check (struct flash_bank *bank) |
Run a blank check for each sector. More... | |
static uint32_t | lpc2900_is_ready (struct flash_bank *bank) |
Check if device is ready. More... | |
static int | lpc2900_probe (struct flash_bank *bank) |
Try and identify the device. More... | |
static int | lpc2900_protect_check (struct flash_bank *bank) |
Get protection (sector security) status. More... | |
static uint32_t | lpc2900_read_security_status (struct flash_bank *bank) |
Read the status of sector security from the index sector. More... | |
static uint32_t | lpc2900_run_bist128 (struct flash_bank *bank, uint32_t addr_from, uint32_t addr_to, uint32_t signature[4]) |
Use BIST to calculate a 128-bit hash value over a range of flash. More... | |
static void | lpc2900_setup (struct flash_bank *bank) |
Set up the flash for erase/program operations. More... | |
static uint32_t | lpc2900_wait_status (struct flash_bank *bank, uint32_t mask, int timeout) |
Wait for an event in mask to occur in INT_STATUS. More... | |
static int | lpc2900_write (struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) |
Write data to flash. More... | |
static int | lpc2900_write_index_page (struct flash_bank *bank, int pagenum, uint8_t page[FLASH_PAGE_SIZE]) |
Write one page to the index sector. More... | |
Variables | |
static const struct command_registration | lpc2900_command_handlers [] |
static const struct command_registration | lpc2900_exec_command_handlers [] |
const struct flash_driver | lpc2900_flash |
#define FMSSTART 0x20200020 /* Flash Built-In Self Test start address */ |
#define FMSSTOP 0x20200024 /* Flash Built-In Self Test stop address */ |
#define FMSW0 0x2020002C /* Flash 128-bit signature Word 0 */ |
#define FMSW1 0x20200030 /* Flash 128-bit signature Word 1 */ |
#define FMSW2 0x20200034 /* Flash 128-bit signature Word 2 */ |
#define FMSW3 0x20200038 /* Flash 128-bit signature Word 3 */ |
#define INT_CLR_ENABLE 0x20200FD8 /* Flash/EEPROM interrupt clear enable */ |
#define INT_ENABLE 0x20200FE4 /* Flash/EEPROM interrupt enable */ |
#define INT_SET_ENABLE 0x20200FDC /* Flash/EEPROM interrupt set enable */ |
#define ISS_CUSTOMER_NWORDS1 (ISS_CUSTOMER_SIZE1 / 4) |
#define ISS_CUSTOMER_NWORDS2 (ISS_CUSTOMER_SIZE2 / 4) |
#define ISS_CUSTOMER_SIZE (ISS_CUSTOMER_SIZE1 + ISS_CUSTOMER_SIZE2) |
#define ISS_CUSTOMER_SIZE1 (ISS_CUSTOMER_END1 - ISS_CUSTOMER_START1) |
#define ISS_CUSTOMER_SIZE2 (ISS_CUSTOMER_END2 - ISS_CUSTOMER_START2) |
#define ISS_PASSWORD "I_know_what_I_am_doing" |
COMMAND_HANDLER | ( | lpc2900_handle_password_command | ) |
Enter password to enable potentially dangerous options.
Definition at line 569 of file lpc2900.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ISS_PASSWORD, and lpc2900_flash_bank::risky.
COMMAND_HANDLER | ( | lpc2900_handle_read_custom_command | ) |
Store customer info in file.
Read customer info from index sector, and store that block of data into a disk file. The format is binary.
Definition at line 507 of file lpc2900.c.
References bank, CALL_COMMAND_HANDLER, CMD_ARGC, CMD_ARGV, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, FCTR, FCTR_FS_CS, FCTR_FS_ISS, FCTR_FS_WEB, FILEIO_BINARY, fileio_close(), fileio_open(), fileio_write(), FILEIO_WRITE, ISS_CUSTOMER_NWORDS1, ISS_CUSTOMER_NWORDS2, ISS_CUSTOMER_START1, ISS_CUSTOMER_START2, LOG_ERROR, LOG_WARNING, lpc2900_flash_bank::risky, target::state, TARGET_HALTED, target_read_memory(), and target_write_u32().
COMMAND_HANDLER | ( | lpc2900_handle_secure_jtag_command | ) |
Activate JTAG protection.
Definition at line 778 of file lpc2900.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, FLASH_PAGE_SIZE, LOG_ERROR, LOG_INFO, lpc2900_write_index_page(), and lpc2900_flash_bank::risky.
COMMAND_HANDLER | ( | lpc2900_handle_secure_sector_command | ) |
Activate 'sector security' for a range of sectors.
Definition at line 697 of file lpc2900.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, FLASH_PAGE_SIZE, LOG_ERROR, lpc2900_read_security_status(), lpc2900_write_index_page(), and lpc2900_flash_bank::risky.
COMMAND_HANDLER | ( | lpc2900_handle_signature_command | ) |
Command to determine the signature of the whole flash.
Uses the Built-In-Self-Test (BIST) to generate a 128-bit hash value of the flash content.
Definition at line 469 of file lpc2900.c.
References bank, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, LOG_ERROR, lpc2900_run_bist128(), status, and TARGET_HALTED.
COMMAND_HANDLER | ( | lpc2900_handle_write_custom_command | ) |
Write customer info from file to the index sector.
Definition at line 599 of file lpc2900.c.
References bank, imagesection::base_address, image::base_address, image::base_address_set, CALL_COMMAND_HANDLER, CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, ERROR_TARGET_NOT_HALTED, FLASH_PAGE_SIZE, image_close(), image_open(), image_read_section(), ISS_CUSTOMER_SIZE, ISS_CUSTOMER_SIZE1, ISS_CUSTOMER_SIZE2, ISS_CUSTOMER_START1, ISS_CUSTOMER_START2, LOG_ERROR, lpc2900_write_index_page(), NULL, image::num_sections, offset, lpc2900_flash_bank::risky, image::sections, imagesection::size, image::start_address_set, target::state, TARGET_HALTED, and type.
FLASH_BANK_COMMAND_HANDLER | ( | lpc2900_flash_bank_command | ) |
Evaluate flash bank command.
Definition at line 886 of file lpc2900.c.
References bank, lpc2900_flash_bank::chipid, lpc2900_flash_bank::clk_sys_fmc, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, ERROR_COMMAND_SYNTAX_ERROR, ERROR_FLASH_BANK_INVALID, ERROR_OK, FLASH_ERASE_TIME, FLASH_PROGRAM_TIME, lpc2900_flash_bank::is_probed, and LOG_WARNING.
|
static |
Return sector number for given address.
Return the (logical) sector number for a given relative address. No sanity check is done. It assumed that the address is valid.
bank | Pointer to the flash bank descriptor |
offset | Offset address relative to bank start |
Definition at line 348 of file lpc2900.c.
Referenced by lpc2900_write().
|
static |
Calculate FPTR.TR register value for desired program/erase time.
clock_var | System clock in Hz |
time_var | Program/erase time in µs |
Definition at line 448 of file lpc2900.c.
Referenced by lpc2900_erase(), lpc2900_write(), and lpc2900_write_index_page().
|
static |
Erase sector(s).
bank | Pointer to the flash bank descriptor |
first | First sector to be erased |
last | Last sector (including) to be erased |
Definition at line 935 of file lpc2900.c.
References bank, lpc2900_flash_bank::clk_sys_fmc, ERROR_FLASH_OPERATION_FAILED, ERROR_FLASH_SECTOR_INVALID, ERROR_OK, FCTR, FCTR_FS_CS, FCTR_FS_LOADREQ, FCTR_FS_PROGREQ, FCTR_FS_WEB, FCTR_FS_WPB, FCTR_FS_WRE, FLASH_ERASE_TIME, FPTR, FPTR_EN_T, INT_CLR_STATUS, INTSRC_END_OF_ERASE, LOG_INFO, lpc2900_calc_tr(), lpc2900_is_ready(), lpc2900_read_security_status(), lpc2900_setup(), lpc2900_wait_status(), status, and target_write_u32().
|
static |
Run a blank check for each sector.
For speed reasons, the device isn't read word by word. A hash value is calculated by the hardware ("BIST") for each sector. This value is then compared against the known hash of an empty sector.
bank | Pointer to the flash bank descriptor |
Definition at line 1519 of file lpc2900.c.
References bank, ERROR_OK, KiB, LOG_INFO, lpc2900_is_ready(), lpc2900_run_bist128(), and status.
|
static |
Check if device is ready.
Check if device is ready for flash operation: Must have been successfully probed. Must be halted.
Definition at line 227 of file lpc2900.c.
References bank, ERROR_FLASH_BANK_NOT_PROBED, ERROR_OK, ERROR_TARGET_NOT_HALTED, lpc2900_flash_bank::is_probed, LOG_ERROR, and TARGET_HALTED.
Referenced by lpc2900_erase(), lpc2900_erase_check(), lpc2900_read_security_status(), and lpc2900_write().
|
static |
Try and identify the device.
Determine type number and its memory layout.
bank | Pointer to the flash bank descriptor |
Definition at line 1360 of file lpc2900.c.
References bank, CHIPID, lpc2900_flash_bank::chipid, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, ERROR_TARGET_NOT_HALTED, EXPECTED_CHIPID, FEAT0, FEAT1, FEAT2, FEAT3, lpc2900_flash_bank::is_probed, KiB, LOG_ERROR, LOG_INFO, LOG_WARNING, lpc2900_read_security_status(), lpc2900_flash_bank::max_ram_block, offset, target::state, TARGET_HALTED, lpc2900_flash_bank::target_name, and target_read_u32().
|
static |
|
static |
Read the status of sector security from the index sector.
bank | Pointer to the flash bank descriptor |
Definition at line 247 of file lpc2900.c.
References bank, ERROR_OK, FCTR, FCTR_FS_CS, FCTR_FS_ISS, FCTR_FS_WEB, lpc2900_is_ready(), status, target_read_memory(), and target_write_u32().
Referenced by COMMAND_HANDLER(), lpc2900_erase(), lpc2900_probe(), and lpc2900_write().
|
static |
Use BIST to calculate a 128-bit hash value over a range of flash.
bank | Pointer to the flash bank descriptor |
addr_from | |
addr_to | |
signature |
Definition at line 312 of file lpc2900.c.
References bank, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, FMSSTART, FMSSTOP, FMSSTOP_MISR_START, FMSW0, INT_CLR_STATUS, INTSRC_END_OF_MISR, lpc2900_wait_status(), target_buffer_get_u32_array(), target_read_memory(), and target_write_u32().
Referenced by COMMAND_HANDLER(), and lpc2900_erase_check().
|
static |
Set up the flash for erase/program operations.
Enable the flash, and set the correct CRA clock of 66 kHz.
bank | Pointer to the flash bank descriptor |
Definition at line 208 of file lpc2900.c.
References bank, lpc2900_flash_bank::clk_sys_fmc, FCRA, FCTR, FCTR_FS_CS, FCTR_FS_WEB, and target_write_u32().
Referenced by lpc2900_erase(), lpc2900_write(), and lpc2900_write_index_page().
|
static |
Wait for an event in mask to occur in INT_STATUS.
Return when an event occurs, or after a timeout.
[in] | bank | Pointer to the flash bank descriptor |
[in] | mask | Mask to be used for INT_STATUS |
[in] | timeout | Timeout in ms |
Definition at line 180 of file lpc2900.c.
References alive_sleep(), bank, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, INT_STATUS, LOG_DEBUG, mask, and target_read_u32().
Referenced by lpc2900_erase(), lpc2900_run_bist128(), lpc2900_write(), and lpc2900_write_index_page().
|
static |
Write data to flash.
bank | Pointer to the flash bank descriptor |
buffer | Buffer with data |
offset | Start address (relative to bank start) |
count | Number of bytes to be programmed |
Definition at line 1045 of file lpc2900.c.
References working_area::address, ARM_COMMON_MAGIC, ARM_MODE_SVC, ARM_STATE_ARM, ARRAY_SIZE, bank, buf_set_u32(), buffer, lpc2900_flash_bank::clk_sys_fmc, arm_algorithm::common_magic, arm_algorithm::core_mode, arm_algorithm::core_state, count, destroy_reg_param(), ERROR_FLASH_OPERATION_FAILED, ERROR_OK, FCTR, FCTR_FS_CS, FCTR_FS_LOADREQ, FCTR_FS_PROGREQ, FCTR_FS_WEB, FCTR_FS_WPB, FCTR_FS_WRE, FLASH_PAGE_SIZE, FLASH_PROGRAM_TIME, FPTR, FPTR_EN_T, init_reg_param(), INT_CLR_STATUS, INTSRC_END_OF_BURN, KiB, LOG_DEBUG, LOG_ERROR, LOG_INFO, lpc2900_address2sector(), lpc2900_calc_tr(), lpc2900_is_ready(), lpc2900_read_security_status(), lpc2900_setup(), lpc2900_wait_status(), lpc2900_flash_bank::max_ram_block, NULL, offset, PARAM_OUT, status, target_alloc_working_area_try(), target_buffer_set_u32_array(), target_free_all_working_areas(), target_run_algorithm(), target_write_buffer(), target_write_memory(), and target_write_u32().
|
static |
Write one page to the index sector.
bank | Pointer to the flash bank descriptor |
pagenum | Page number (0...7) |
page | Page array (FLASH_PAGE_SIZE bytes) |
Definition at line 371 of file lpc2900.c.
References bank, lpc2900_flash_bank::clk_sys_fmc, ERROR_COMMAND_ARGUMENT_INVALID, ERROR_FLASH_OPERATION_FAILED, ERROR_OK, ERROR_TARGET_NOT_HALTED, FCTR, FCTR_FS_CS, FCTR_FS_ISS, FCTR_FS_LOADREQ, FCTR_FS_PROGREQ, FCTR_FS_WEB, FCTR_FS_WPB, FCTR_FS_WRE, FLASH_PAGE_SIZE, FLASH_PROGRAM_TIME, FPTR, FPTR_EN_T, INT_CLR_STATUS, INTSRC_END_OF_BURN, LOG_ERROR, lpc2900_calc_tr(), lpc2900_setup(), lpc2900_wait_status(), target::state, TARGET_HALTED, target_write_memory(), and target_write_u32().
Referenced by COMMAND_HANDLER().
|
static |
|
static |
const struct flash_driver lpc2900_flash |