20 #define P4_FLASH_MAIN_SIZE_REG 0xE0043020
21 #define P4_FLASH_INFO_SIZE_REG 0xE0043024
22 #define P4_DEVICE_ID_REG 0x0020100C
23 #define P4_HARDWARE_REV_REG 0x00201010
26 #define E4_DID0_REG 0x400FE000
27 #define E4_DID1_REG 0x400FE004
29 #define FLASH_TIMEOUT 8000
31 #define SUPPORT_MESSAGE \
32 "Your pre-production MSP432P401x silicon is not fully supported\n" \
33 "You can find more information at www.ti.com/product/MSP432P401R"
50 #include "../../../contrib/loaders/flash/msp432/msp432p401x_algo.inc"
55 #include "../../../contrib/loaders/flash/msp432/msp432p411x_algo.inc"
60 #include "../../../contrib/loaders/flash/msp432/msp432e4x_algo.inc"
66 uint32_t hardware_rev)
73 if (device_id == 0x180C0002) {
74 if (hardware_rev == 0x102DC06E) {
77 }
else if (hardware_rev == 0x1032E076) {
100 if (hardware_rev == 0x41 || hardware_rev == 0x42) {
103 }
else if (hardware_rev >= 0x43 && hardware_rev <= 0x49) {
122 if (hardware_rev >= 0x41 && hardware_rev <= 0x49) {
135 if (device_id < 0xA010) {
151 switch (return_code) {
155 return "FLASH_SUCCESS";
157 return "FLASH_ERROR";
159 return "FLASH_TIMEOUT_ERROR";
161 return "FLASH_VERIFY_WRONG";
163 return "FLASH_WRONG_COMMAND";
165 return "FLASH_POWER_ERROR";
167 return "UNDEFINED_RETURN_CODE";
185 *algo_params, uint32_t
command)
209 uint32_t return_code = 0;
211 long long elapsed_ms;
216 while ((return_code == 0) || (return_code ==
FLASH_BUSY)) {
222 if (elapsed_ms > 500)
229 LOG_ERROR(
"msp432: Flash operation failed: %s",
240 uint32_t status_addr;
242 long long elapsed_ms;
264 if (elapsed_ms > 500)
272 "msp432: Flash operation failed: buffer not written to flash");
286 const uint8_t *loader_code;
287 uint32_t loader_size;
288 uint32_t algo_entry_addr;
326 "msp432: Unrecognized MSP432P4 Device ID and Hardware "
331 "msp432: MSP432P401x pre-production device (deprecated "
336 "msp432: Unrecognized MSP432E4 DID0 and DID1 values "
369 sizeof(algo_params), (uint8_t *)&algo_params);
382 LOG_ERROR(
"msp432: Failed to start flash helper algorithm");
497 if (strcmp(
CMD_ARGV[1],
"main") == 0)
499 else if (strcmp(
CMD_ARGV[1],
"all") == 0)
520 LOG_INFO(
"msp432: Mass erase of flash is complete");
522 LOG_INFO(
"msp432: Mass erase of %s is complete",
523 all ?
"main + information flash" :
"main flash");
546 LOG_WARNING(
"msp432: MSP432E4 does not have a BSL region");
551 if (strcmp(
CMD_ARGV[1],
"lock") == 0)
553 else if (strcmp(
CMD_ARGV[1],
"unlock") == 0)
562 LOG_INFO(
"msp432: BSL flash region is currently %slocked",
616 if (is_main && (first == 0) && (last == (
bank->num_sectors - 1))) {
637 for (
unsigned int i = first; i <= last; i++) {
640 if (is_info && 1 == i)
644 if (is_info && (2 == i || 3 == i) &&
682 long long elapsed_ms;
701 uint32_t
start = 0x1000;
718 uint32_t skip = end -
offset;
767 LOG_ERROR(
"Unable to write data to target memory");
790 if (elapsed_ms > 500)
818 unsigned int num_sectors;
881 }
else if (is_info) {
913 if (num_sectors > 0) {
920 bank->write_start_alignment = 0;
921 bank->write_end_alignment = 0;
922 bank->num_sectors = num_sectors;
925 for (
unsigned int i = 0; i < num_sectors; i++) {
928 bank->sectors[i].is_erased = -1;
929 bank->sectors[i].is_protected = 0;
945 char *
name = malloc(strlen(
bank->name) + 3);
1015 "Unrecognized MSP432E4 DID0 and DID1 IDs (%08" PRIX32
", %08" PRIX32
")",
1022 "Unrecognized MSP432P4 Device ID and Hardware Rev (%04" PRIX32
", %02" PRIX32
")",
1043 free(
bank->driver_priv);
1051 .
name =
"mass_erase",
1052 .handler = msp432_mass_erase_command,
1054 .help =
"Erase entire flash memory on device.",
1055 .usage =
"bank_id ['main' | 'all']",
1059 .handler = msp432_bsl_command,
1061 .help =
"Allow BSL to be erased or written by flash commands.",
1062 .usage =
"bank_id ['unlock' | 'lock']",
1071 .help =
"MSP432 flash command group",
1081 .flash_bank_command = msp432_flash_bank_command,
void init_reg_param(struct reg_param *param, char *reg_name, uint32_t size, enum param_direction direction)
void destroy_reg_param(struct reg_param *param)
#define ARMV7M_COMMON_MAGIC
Support functions to access arbitrary bits in a byte array.
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#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_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_FLASH_OPERATION_FAILED
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
void flash_bank_add(struct flash_bank *bank)
Adds a new NOR bank to the global list of banks.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
#define LOG_WARNING(expr ...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
static int msp432_protect_check(struct flash_bank *bank)
static int msp432_probe(struct flash_bank *bank)
static int msp432_auto_probe(struct flash_bank *bank)
static int msp432_wait_inactive(struct target *target, uint32_t buffer)
static int msp432_wait_return_code(struct target *target)
const struct flash_driver msp432_flash
static const struct command_registration msp432_command_handlers[]
FLASH_BANK_COMMAND_HANDLER(msp432_flash_bank_command)
static int msp432_mass_erase(struct flash_bank *bank, bool all)
static int msp432_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static const struct command_registration msp432_exec_command_handlers[]
#define P4_FLASH_MAIN_SIZE_REG
#define P4_HARDWARE_REV_REG
static int msp432_device_type(uint32_t family_type, uint32_t device_id, uint32_t hardware_rev)
static int msp432_quit(struct flash_bank *bank)
static const char * msp432_return_text(uint32_t return_code)
static const uint8_t msp432p411x_algo[]
static void msp432_init_params(struct msp432_algo_params *algo_params)
#define P4_FLASH_INFO_SIZE_REG
static int msp432_info(struct flash_bank *bank, struct command_invocation *cmd)
static int msp432_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static int msp432_exec_cmd(struct target *target, struct msp432_algo_params *algo_params, uint32_t command)
static int msp432_init(struct flash_bank *bank)
COMMAND_HANDLER(msp432_mass_erase_command)
static void msp432_flash_free_driver_priv(struct flash_bank *bank)
static const uint8_t msp432p401x_algo[]
static const uint8_t msp432e4x_algo[]
#define ALGO_PARAMS_BASE_ADDR
#define ALGO_BUFFER2_STATUS_ADDR
#define ALGO_BUFFER1_STATUS_ADDR
#define ALGO_STACK_POINTER_ADDR
#define BUFFER_DATA_READY
#define P4_ALGO_ENTRY_ADDR
#define ALGO_FLASH_COMMAND_ADDR
#define FLASH_WRONG_COMMAND
#define FLASH_POWER_ERROR
#define E4_ALGO_ENTRY_ADDR
#define FLASH_VERIFY_ERROR
#define MSP432P411X_GUESS
#define P4_FLASH_INFO_BASE
#define FLASH_SECTOR_ERASE
#define ALGO_WORKING_SIZE
#define ALGO_BUFFER1_ADDR
#define FLASH_TIMEOUT_ERROR
#define MSP432P401X_GUESS
#define ALGO_RETURN_CODE_ADDR
size_t size
Size of the control block search area.
unsigned int common_magic
When run_command is called, a new instance will be created on the stack, filled with the proper value...
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.
uint8_t buffer2_status[4]
uint8_t buffer1_status[4]
struct working_area * working_area
struct armv7m_algorithm armv7m_info
int target_halt(struct target *target)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
int target_wait_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Waits for an algorithm started with target_start_algorithm() to complete.
int target_start_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, void *arch_info)
Executes a target-specific native code algorithm and leaves it running.
#define ERROR_TARGET_NOT_HALTED
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static struct ublast_lowlevel_priv info