diff options
-rw-r--r-- | src/flash/aduc702x.c | 42 | ||||
-rw-r--r-- | src/flash/avrf.c | 89 | ||||
-rw-r--r-- | src/flash/ocl.c | 44 | ||||
-rw-r--r-- | src/flash/stellaris.c | 59 | ||||
-rw-r--r-- | src/flash/tms470.c | 39 |
5 files changed, 103 insertions, 170 deletions
diff --git a/src/flash/aduc702x.c b/src/flash/aduc702x.c index a4007d07..7d6fa24e 100644 --- a/src/flash/aduc702x.c +++ b/src/flash/aduc702x.c @@ -29,16 +29,6 @@ #include "time_support.h" -static int aduc702x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int aduc702x_register_commands(struct command_context_s *cmd_ctx); -static int aduc702x_erase(struct flash_bank_s *bank, int first, int last); -static int aduc702x_protect(struct flash_bank_s *bank, int set, int first, int last); -static int aduc702x_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int aduc702x_write_single(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int aduc702x_write_block(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int aduc702x_probe(struct flash_bank_s *bank); -static int aduc702x_info(struct flash_bank_s *bank, char *buf, int buf_size); -static int aduc702x_protect_check(struct flash_bank_s *bank); static int aduc702x_build_sector_list(struct flash_bank_s *bank); static int aduc702x_check_flash_completion(target_t* target, unsigned int timeout_ms); static int aduc702x_set_write_enable(target_t *target, int enable); @@ -69,26 +59,6 @@ typedef struct working_area_t *write_algorithm; } aduc702x_flash_bank_t; -flash_driver_t aduc702x_flash = -{ - .name = "aduc702x", - .register_commands = aduc702x_register_commands, - .flash_bank_command = aduc702x_flash_bank_command, - .erase = aduc702x_erase, - .protect = aduc702x_protect, - .write = aduc702x_write, - .probe = aduc702x_probe, - .auto_probe = aduc702x_probe, - .erase_check = default_flash_blank_check, - .protect_check = aduc702x_protect_check, - .info = aduc702x_info -}; - -static int aduc702x_register_commands(struct command_context_s *cmd_ctx) -{ - return ERROR_OK; -} - /* flash bank aduc702x 0 0 0 0 <target#> * The ADC7019-28 devices all have the same flash layout */ static int aduc702x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank) @@ -452,3 +422,15 @@ static int aduc702x_check_flash_completion(target_t* target, unsigned int timeou else return ERROR_OK; } +flash_driver_t aduc702x_flash = { + .name = "aduc702x", + .flash_bank_command = &aduc702x_flash_bank_command, + .erase = &aduc702x_erase, + .protect = &aduc702x_protect, + .write = &aduc702x_write, + .probe = &aduc702x_probe, + .auto_probe = &aduc702x_probe, + .erase_check = &default_flash_blank_check, + .protect_check = &aduc702x_protect_check, + .info = &aduc702x_info + }; diff --git a/src/flash/avrf.c b/src/flash/avrf.c index 2b95b8a1..b0459093 100644 --- a/src/flash/avrf.c +++ b/src/flash/avrf.c @@ -56,46 +56,18 @@ avrf_type_t avft_chips_info[] = {"atmega128", 0x9702, 256, 512, 8, 512}, }; -static int avrf_register_commands(struct command_context_s *cmd_ctx); -static int avrf_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int avrf_erase(struct flash_bank_s *bank, int first, int last); -static int avrf_protect(struct flash_bank_s *bank, int set, int first, int last); -static int avrf_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int avrf_probe(struct flash_bank_s *bank); -static int avrf_auto_probe(struct flash_bank_s *bank); -//static int avrf_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -static int avrf_protect_check(struct flash_bank_s *bank); -static int avrf_info(struct flash_bank_s *bank, char *buf, int buf_size); - -static int avrf_handle_mass_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); - -extern int avr_jtag_sendinstr(jtag_tap_t *tap, uint8_t *ir_in, uint8_t ir_out); -extern int avr_jtag_senddat(jtag_tap_t *tap, uint32_t *dr_in, uint32_t dr_out, int len); - -extern int mcu_write_ir(jtag_tap_t *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_len, int rti); -extern int mcu_write_dr(jtag_tap_t *tap, uint8_t *ir_in, uint8_t *ir_out, int dr_len, int rti); -extern int mcu_write_ir_u8(jtag_tap_t *tap, uint8_t *ir_in, uint8_t ir_out, int ir_len, int rti); -extern int mcu_write_dr_u8(jtag_tap_t *tap, uint8_t *ir_in, uint8_t ir_out, int dr_len, int rti); -extern int mcu_write_ir_u16(jtag_tap_t *tap, uint16_t *ir_in, uint16_t ir_out, int ir_len, int rti); -extern int mcu_write_dr_u16(jtag_tap_t *tap, uint16_t *ir_in, uint16_t ir_out, int dr_len, int rti); -extern int mcu_write_ir_u32(jtag_tap_t *tap, uint32_t *ir_in, uint32_t ir_out, int ir_len, int rti); -extern int mcu_write_dr_u32(jtag_tap_t *tap, uint32_t *ir_in, uint32_t ir_out, int dr_len, int rti); -extern int mcu_execute_queue(void); - -flash_driver_t avr_flash = -{ - .name = "avr", - .register_commands = avrf_register_commands, - .flash_bank_command = avrf_flash_bank_command, - .erase = avrf_erase, - .protect = avrf_protect, - .write = avrf_write, - .probe = avrf_probe, - .auto_probe = avrf_auto_probe, - .erase_check = default_flash_mem_blank_check, - .protect_check = avrf_protect_check, - .info = avrf_info -}; +int avr_jtag_sendinstr(jtag_tap_t *tap, uint8_t *ir_in, uint8_t ir_out); +int avr_jtag_senddat(jtag_tap_t *tap, uint32_t *dr_in, uint32_t dr_out, int len); + +int mcu_write_ir(jtag_tap_t *tap, uint8_t *ir_in, uint8_t *ir_out, int ir_len, int rti); +int mcu_write_dr(jtag_tap_t *tap, uint8_t *ir_in, uint8_t *ir_out, int dr_len, int rti); +int mcu_write_ir_u8(jtag_tap_t *tap, uint8_t *ir_in, uint8_t ir_out, int ir_len, int rti); +int mcu_write_dr_u8(jtag_tap_t *tap, uint8_t *ir_in, uint8_t ir_out, int dr_len, int rti); +int mcu_write_ir_u16(jtag_tap_t *tap, uint16_t *ir_in, uint16_t ir_out, int ir_len, int rti); +int mcu_write_dr_u16(jtag_tap_t *tap, uint16_t *ir_in, uint16_t ir_out, int dr_len, int rti); +int mcu_write_ir_u32(jtag_tap_t *tap, uint32_t *ir_in, uint32_t ir_out, int ir_len, int rti); +int mcu_write_dr_u32(jtag_tap_t *tap, uint32_t *ir_in, uint32_t ir_out, int dr_len, int rti); +int mcu_execute_queue(void); /* avr program functions */ static int avr_jtag_reset(avr_common_t *avr, uint32_t reset) @@ -208,17 +180,6 @@ static int avr_jtagprg_writeflashpage(avr_common_t *avr, uint8_t *page_buf, uint return ERROR_OK; } -/* interface command */ -static int avrf_register_commands(struct command_context_s *cmd_ctx) -{ - command_t *avr_cmd = register_command(cmd_ctx, NULL, "avr", NULL, COMMAND_ANY, "avr flash specific commands"); - - register_command(cmd_ctx, avr_cmd, "mass_erase", avrf_handle_mass_erase_command, COMMAND_EXEC, - "mass erase device"); - - return ERROR_OK; -} - static int avrf_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank) { avrf_flash_bank_t *avrf_info; @@ -487,3 +448,29 @@ static int avrf_handle_mass_erase_command(struct command_context_s *cmd_ctx, cha LOG_DEBUG("%s", __FUNCTION__); return ERROR_OK; } + +static int avrf_register_commands(struct command_context_s *cmd_ctx) +{ + command_t *avr_cmd = register_command(cmd_ctx, NULL, "avr", + NULL, COMMAND_ANY, "avr flash specific commands"); + + register_command(cmd_ctx, avr_cmd, "mass_erase", + avrf_handle_mass_erase_command, COMMAND_EXEC, + "mass erase device"); + + return ERROR_OK; +} + +flash_driver_t avr_flash = { + .name = "avr", + .register_commands = &avrf_register_commands, + .flash_bank_command = &avrf_flash_bank_command, + .erase = &avrf_erase, + .protect = &avrf_protect, + .write = &avrf_write, + .probe = &avrf_probe, + .auto_probe = &avrf_auto_probe, + .erase_check = &default_flash_mem_blank_check, + .protect_check = &avrf_protect_check, + .info = &avrf_info, + }; diff --git a/src/flash/ocl.c b/src/flash/ocl.c index a2dac50a..51ccc961 100644 --- a/src/flash/ocl.c +++ b/src/flash/ocl.c @@ -26,32 +26,6 @@ #include "embeddedice.h" -static int ocl_register_commands(struct command_context_s *cmd_ctx); -static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int ocl_erase(struct flash_bank_s *bank, int first, int last); -static int ocl_protect(struct flash_bank_s *bank, int set, int first, int last); -static int ocl_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int ocl_probe(struct flash_bank_s *bank); -static int ocl_erase_check(struct flash_bank_s *bank); -static int ocl_protect_check(struct flash_bank_s *bank); -static int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size); -static int ocl_auto_probe(struct flash_bank_s *bank); - -flash_driver_t ocl_flash = -{ - .name = "ocl", - .register_commands = ocl_register_commands, - .flash_bank_command = ocl_flash_bank_command, - .erase = ocl_erase, - .protect = ocl_protect, - .write = ocl_write, - .probe = ocl_probe, - .erase_check = ocl_erase_check, - .protect_check = ocl_protect_check, - .info = ocl_info, - .auto_probe = ocl_auto_probe -}; - typedef struct ocl_priv_s { arm_jtag_t *jtag_info; @@ -59,11 +33,6 @@ typedef struct ocl_priv_s unsigned int bufalign; } ocl_priv_t; -static int ocl_register_commands(struct command_context_s *cmd_ctx) -{ - return ERROR_OK; -} - static int ocl_erase_check(struct flash_bank_s *bank) { return ERROR_OK; @@ -378,3 +347,16 @@ static int ocl_auto_probe(struct flash_bank_s *bank) return ERROR_OK; } + +flash_driver_t ocl_flash = { + .name = "ocl", + .flash_bank_command = &ocl_flash_bank_command, + .erase = &ocl_erase, + .protect = &ocl_protect, + .write = &ocl_write, + .probe = &ocl_probe, + .erase_check = &ocl_erase_check, + .protect_check = &ocl_protect_check, + .info = &ocl_info, + .auto_probe = &ocl_auto_probe, + }; diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index b482ce2e..bd561a61 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -34,39 +34,14 @@ #define DID0_VER(did0) ((did0 >> 28)&0x07) -static int stellaris_register_commands(struct command_context_s *cmd_ctx); -static int stellaris_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int stellaris_erase(struct flash_bank_s *bank, int first, int last); -static int stellaris_protect(struct flash_bank_s *bank, int set, int first, int last); -static int stellaris_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int stellaris_auto_probe(struct flash_bank_s *bank); -static int stellaris_probe(struct flash_bank_s *bank); -static int stellaris_protect_check(struct flash_bank_s *bank); -static int stellaris_info(struct flash_bank_s *bank, char *buf, int buf_size); static int stellaris_read_part_info(struct flash_bank_s *bank); static uint32_t stellaris_get_flash_status(flash_bank_t *bank); static void stellaris_set_flash_mode(flash_bank_t *bank,int mode); //static uint32_t stellaris_wait_status_busy(flash_bank_t *bank, uint32_t waitbits, int timeout); -static int stellaris_handle_mass_erase_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); static int stellaris_mass_erase(struct flash_bank_s *bank); -flash_driver_t stellaris_flash = -{ - .name = "stellaris", - .register_commands = stellaris_register_commands, - .flash_bank_command = stellaris_flash_bank_command, - .erase = stellaris_erase, - .protect = stellaris_protect, - .write = stellaris_write, - .probe = stellaris_probe, - .auto_probe = stellaris_auto_probe, - .erase_check = default_flash_mem_blank_check, - .protect_check = stellaris_protect_check, - .info = stellaris_info -}; - static struct { uint32_t partno; char *partname; @@ -264,14 +239,6 @@ static int stellaris_flash_bank_command(struct command_context_s *cmd_ctx, char return ERROR_OK; } -static int stellaris_register_commands(struct command_context_s *cmd_ctx) -{ - command_t *stm32x_cmd = register_command(cmd_ctx, NULL, "stellaris", NULL, COMMAND_ANY, "stellaris flash specific commands"); - - register_command(cmd_ctx, stm32x_cmd, "mass_erase", stellaris_handle_mass_erase_command, COMMAND_EXEC, "mass erase device"); - return ERROR_OK; -} - static int stellaris_info(struct flash_bank_s *bank, char *buf, int buf_size) { int printed, device_class; @@ -1192,3 +1159,29 @@ static int stellaris_handle_mass_erase_command(struct command_context_s *cmd_ctx return ERROR_OK; } + +static int stellaris_register_commands(struct command_context_s *cmd_ctx) +{ + command_t *stm32x_cmd = register_command(cmd_ctx, NULL, "stellaris", + NULL, COMMAND_ANY, "stellaris flash specific commands"); + + register_command(cmd_ctx, stm32x_cmd, "mass_erase", + stellaris_handle_mass_erase_command, COMMAND_EXEC, + "mass erase device"); + return ERROR_OK; +} + + +flash_driver_t stellaris_flash = { + .name = "stellaris", + .register_commands = &stellaris_register_commands, + .flash_bank_command = &stellaris_flash_bank_command, + .erase = &stellaris_erase, + .protect = &stellaris_protect, + .write = &stellaris_write, + .probe = &stellaris_probe, + .auto_probe = &stellaris_auto_probe, + .erase_check = &default_flash_mem_blank_check, + .protect_check = &stellaris_protect_check, + .info = &stellaris_info, + }; diff --git a/src/flash/tms470.c b/src/flash/tms470.c index 58210ac6..1348697a 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -24,31 +24,6 @@ #include "tms470.h" -static int tms470_register_commands(struct command_context_s *cmd_ctx); -static int tms470_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int tms470_erase(struct flash_bank_s *bank, int first, int last); -static int tms470_protect(struct flash_bank_s *bank, int set, int first, int last); -static int tms470_write(struct flash_bank_s *bank, uint8_t * buffer, uint32_t offset, uint32_t count); -static int tms470_probe(struct flash_bank_s *bank); -static int tms470_auto_probe(struct flash_bank_s *bank); -static int tms470_erase_check(struct flash_bank_s *bank); -static int tms470_protect_check(struct flash_bank_s *bank); -static int tms470_info(struct flash_bank_s *bank, char *buf, int buf_size); - -flash_driver_t tms470_flash = { - .name = "tms470", - .register_commands = tms470_register_commands, - .flash_bank_command = tms470_flash_bank_command, - .erase = tms470_erase, - .protect = tms470_protect, - .write = tms470_write, - .probe = tms470_probe, - .auto_probe = tms470_auto_probe, - .erase_check = tms470_erase_check, - .protect_check = tms470_protect_check, - .info = tms470_info -}; - /* ---------------------------------------------------------------------- Internal Support, Helpers ---------------------------------------------------------------------- */ @@ -1260,3 +1235,17 @@ static int tms470_flash_bank_command(struct command_context_s *cmd_ctx, char *cm return ERROR_OK; } + +flash_driver_t tms470_flash = { + .name = "tms470", + .register_commands = &tms470_register_commands, + .flash_bank_command = &tms470_flash_bank_command, + .erase = &tms470_erase, + .protect = &tms470_protect, + .write = &tms470_write, + .probe = &tms470_probe, + .auto_probe = &tms470_auto_probe, + .erase_check = &tms470_erase_check, + .protect_check = &tms470_protect_check, + .info = &tms470_info, + }; |