You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: oharboe at B. <oh...@ma...> - 2009-04-21 13:33:32
|
Author: oharboe Date: 2009-04-21 13:33:29 +0200 (Tue, 21 Apr 2009) New Revision: 1493 Modified: trunk/src/jtag/jlink.c Log: Zach Welch <zw...@su...> fix jlink format warning Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-21 09:41:41 UTC (rev 1492) +++ trunk/src/jtag/jlink.c 2009-04-21 11:33:29 UTC (rev 1493) @@ -963,7 +963,7 @@ snprintf(s, 4, " %02x", buffer[j]); strcat(line, s); } - LOG_DEBUG(line); + LOG_DEBUG("%s", line); } } #endif |
From: oharboe at B. <oh...@ma...> - 2009-04-21 11:41:42
|
Author: oharboe Date: 2009-04-21 11:41:41 +0200 (Tue, 21 Apr 2009) New Revision: 1492 Modified: trunk/src/jtag/jlink.c Log: Zach Welch <zw...@su...> factor jlink usb_bulk_*_ex functions Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-21 09:08:43 UTC (rev 1491) +++ trunk/src/jtag/jlink.c 2009-04-21 09:41:41 UTC (rev 1492) @@ -859,15 +859,17 @@ } } -static int usb_bulk_write_ex(usb_dev_handle *dev, int ep, char *bytes, int size, - int timeout) { - +/* calls the given usb_bulk_* function, allowing for the data to trickle in with some timeouts */ +static int usb_bulk_with_retries( + int (*f)(usb_dev_handle *, int, char *, int, int), + usb_dev_handle *dev, int ep, + char *bytes, int size, int timeout) +{ int rc = 0, tries = 3, this_size; while (tries && size) { - this_size = usb_bulk_write (dev, ep, bytes, size, timeout); - + this_size = f(dev, ep, bytes, size, timeout); if (this_size > 0) { size -= this_size; @@ -877,36 +879,21 @@ } else tries --; } - return rc; - - } - -static int usb_bulk_read_ex(usb_dev_handle *dev, int ep, char *bytes, int size, - int timeout) { - - int rc = 0, tries = 3, this_size; - - while (tries && size) { - - this_size = usb_bulk_read (dev, ep, bytes, size, timeout); - - if (this_size > 0) { - - size -= this_size; - rc += this_size; - bytes += this_size; - - } else - tries --; - } - - return rc; - +static inline int usb_bulk_write_ex(usb_dev_handle *dev, int ep, + char *bytes, int size, int timeout) +{ + return usb_bulk_with_retries(&usb_bulk_write, + dev, ep, bytes, size, timeout); } +static inline int usb_bulk_read_ex(usb_dev_handle *dev, int ep, + char *bytes, int size, int timeout) +{ + return usb_bulk_with_retries(&usb_bulk_read, + dev, ep, bytes, size, timeout); +} - /* Write data from out_buffer to USB. */ static int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length) { |
From: ntfreak at B. <nt...@ma...> - 2009-04-21 11:08:46
|
Author: ntfreak Date: 2009-04-21 11:08:43 +0200 (Tue, 21 Apr 2009) New Revision: 1491 Added: trunk/src/target/interface/vsllink.cfg Modified: trunk/src/jtag/vsllink.c Log: - vsllink update from SimonQian [sim...@Si...] Modified: trunk/src/jtag/vsllink.c =================================================================== --- trunk/src/jtag/vsllink.c 2009-04-21 09:05:02 UTC (rev 1490) +++ trunk/src/jtag/vsllink.c 2009-04-21 09:08:43 UTC (rev 1491) @@ -49,12 +49,16 @@ #define DEBUG_JTAG_IO(expr ...) #endif -static u16 vsllink_vid; -static u16 vsllink_pid; -static u8 vsllink_bulkout; -static u8 vsllink_bulkin; +#define VSLLINK_MODE_NORMAL 0 +#define VSLLINK_MODE_DMA 1 -#define VSLLINK_USB_TIMEOUT 10000 +static u16 vsllink_usb_vid; +static u16 vsllink_usb_pid; +static u8 vsllink_usb_bulkout; +static u8 vsllink_usb_bulkin; +static u8 vsllink_usb_interface; +static u8 vsllink_mode = VSLLINK_MODE_NORMAL; +static int VSLLINK_USB_TIMEOUT = 10000; static int VSLLINK_BufferSize = 1024; @@ -74,6 +78,7 @@ #define VSLLINK_CMD_HW_JTAGSEQCMD 0xA0 #define VSLLINK_CMD_HW_JTAGHLCMD 0xA1 #define VSLLINK_CMD_HW_SWDCMD 0xA2 +#define VSLLINK_CMD_HW_JTAGRAWCMD 0xA3 #define VSLLINK_CMDJTAGSEQ_TMSBYTE 0x00 #define VSLLINK_CMDJTAGSEQ_TMSCLOCK 0x40 @@ -101,7 +106,7 @@ * 3: Pause-DR * 4: Shift-IR * 5: Pause-IR - * + * * SD->SD and SI->SI have to be caught in interface specific code */ static u8 VSLLINK_tap_move[6][6] = @@ -110,9 +115,9 @@ {0xff, 0x7f, 0x2f, 0x0a, 0x37, 0x16}, /* TLR */ {0xff, 0x00, 0x45, 0x05, 0x4b, 0x0b}, /* RTI */ {0xff, 0x61, 0x00, 0x01, 0x0f, 0x2f}, /* SD */ - {0xff, 0x60, 0x40, 0x5c, 0x3c, 0x5e}, /* PD */ + {0xfe, 0x60, 0x40, 0x5c, 0x3c, 0x5e}, /* PD */ {0xff, 0x61, 0x07, 0x17, 0x00, 0x01}, /* SI */ - {0xff, 0x60, 0x38, 0x5c, 0x40, 0x5e} /* PI */ + {0xfe, 0x60, 0x38, 0x5c, 0x40, 0x5e} /* PI */ }; typedef struct insert_insignificant_operation @@ -175,8 +180,8 @@ typedef struct { + int offset; int length; /* Number of bits to read */ - int offset; scan_command_t *command; /* Corresponding scan command */ u8 *buffer; } pending_scan_result_t; @@ -200,22 +205,42 @@ static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int vsllink_handle_mode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); /* Queue command functions */ static void vsllink_end_state(tap_state_t state); -static void vsllink_state_move(void); -static void vsllink_path_move(int num_states, tap_state_t *path); +static void vsllink_state_move_dma(void); +static void vsllink_state_move_normal(void); +static void (*vsllink_state_move)(void); +static void vsllink_path_move_dma(int num_states, tap_state_t *path); +static void vsllink_path_move_normal(int num_states, tap_state_t *path); +static void (*vsllink_path_move)(int num_states, tap_state_t *path); static void vsllink_runtest(int num_cycles); -static void vsllink_stableclocks(int num_cycles, int tms); -static void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void vsllink_stableclocks_dma(int num_cycles, int tms); +static void vsllink_stableclocks_normal(int num_cycles, int tms); +static void (*vsllink_stableclocks)(int num_cycles, int tms); +static void vsllink_scan_dma(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void vsllink_scan_normal(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void (*vsllink_scan)(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); static void vsllink_reset(int trst, int srst); static void vsllink_simple_command(u8 command); +static int vsllink_connect(void); +static int vsllink_disconnect(void); /* VSLLink tap buffer functions */ -static void vsllink_tap_init(void); -static int vsllink_tap_execute(void); -static void vsllink_tap_ensure_space(int scans, int bytes); -static void vsllink_tap_append_scan(int length, u8 *buffer, scan_command_t *command, int offset); +static void vsllink_tap_append_step(int tms, int tdi); +static void vsllink_tap_init_dma(void); +static void vsllink_tap_init_normal(void); +static void (*vsllink_tap_init)(void); +static int vsllink_tap_execute_dma(void); +static int vsllink_tap_execute_normal(void); +static int (*vsllink_tap_execute)(void); +static void vsllink_tap_ensure_space_dma(int scans, int length); +static void vsllink_tap_ensure_space_normal(int scans, int length); +static void (*vsllink_tap_ensure_space)(int scans, int length); +static void vsllink_tap_append_scan_dma(int length, u8 *buffer, scan_command_t *command); +static void vsllink_tap_append_scan_normal(int length, u8 *buffer, scan_command_t *command, int offset); /* VSLLink lowlevel functions */ typedef struct vsllink_jtag @@ -236,8 +261,15 @@ static int vsllink_tms_data_len = 0; static u8* vsllink_tms_cmd_pos; -static vsllink_jtag_t* vsllink_jtag_handle; +static int tap_length = 0; +static int tap_buffer_size = 0; +static u8 *tms_buffer = NULL; +static u8 *tdi_buffer = NULL; +static u8 *tdo_buffer = NULL; +static int last_tms; +static vsllink_jtag_t* vsllink_jtag_handle = NULL; + /***************************************************************************/ /* External interface implementation */ @@ -253,6 +285,19 @@ .quit = vsllink_quit }; +static void reset_command_pointer(void) +{ + if (vsllink_mode == VSLLINK_MODE_NORMAL) + { + vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; + vsllink_usb_out_buffer_idx = 3; + } + else + { + tap_length = 0; + } +} + static int vsllink_execute_queue(void) { jtag_command_t *cmd = jtag_command_queue; @@ -262,56 +307,55 @@ DEBUG_JTAG_IO("--------------------------------- vsllink -------------------------------------"); - vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; - vsllink_usb_out_buffer_idx = 3; + reset_command_pointer(); while (cmd != NULL) { switch (cmd->type) { case JTAG_END_STATE: DEBUG_JTAG_IO("end_state: %s", tap_state_name(cmd->cmd.end_state->end_state)); - + if (cmd->cmd.end_state->end_state != TAP_INVALID) { vsllink_end_state(cmd->cmd.end_state->end_state); } break; - + case JTAG_RUNTEST: DEBUG_JTAG_IO( "runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, \ tap_state_name(cmd->cmd.runtest->end_state)); - + if (cmd->cmd.runtest->end_state != TAP_INVALID) { vsllink_end_state(cmd->cmd.runtest->end_state); } vsllink_runtest(cmd->cmd.runtest->num_cycles); break; - + case JTAG_STATEMOVE: DEBUG_JTAG_IO("statemove end in %s", tap_state_name(cmd->cmd.statemove->end_state)); - + if (cmd->cmd.statemove->end_state != TAP_INVALID) { vsllink_end_state(cmd->cmd.statemove->end_state); } vsllink_state_move(); break; - + case JTAG_PATHMOVE: DEBUG_JTAG_IO("pathmove: %i states, end in %s", \ cmd->cmd.pathmove->num_states, \ tap_state_name(cmd->cmd.pathmove->path[cmd->cmd.pathmove->num_states - 1])); - + vsllink_path_move(cmd->cmd.pathmove->num_states, cmd->cmd.pathmove->path); break; - + case JTAG_SCAN: if (cmd->cmd.scan->end_state != TAP_INVALID) { vsllink_end_state(cmd->cmd.scan->end_state); } - + scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer); if (cmd->cmd.scan->ir_scan) { @@ -321,37 +365,34 @@ { DEBUG_JTAG_IO("JTAG Scan write DR(%d bits), end in %s:", scan_size, tap_state_name(cmd->cmd.scan->end_state)); } - + #ifdef _DEBUG_JTAG_IO_ vsllink_debug_buffer(buffer, (scan_size + 7) >> 3); #endif - + type = jtag_scan_type(cmd->cmd.scan); - + vsllink_scan(cmd->cmd.scan->ir_scan, type, buffer, scan_size, cmd->cmd.scan); break; - + case JTAG_RESET: DEBUG_JTAG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); - + vsllink_tap_execute(); - + if (cmd->cmd.reset->trst == 1) { tap_set_state(TAP_RESET); } vsllink_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst); - - vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; - vsllink_usb_out_buffer_idx = 3; break; - + case JTAG_SLEEP: DEBUG_JTAG_IO("sleep %i", cmd->cmd.sleep->us); vsllink_tap_execute(); jtag_sleep(cmd->cmd.sleep->us); break; - + case JTAG_STABLECLOCKS: DEBUG_JTAG_IO("add %d clocks", cmd->cmd.stableclocks->num_cycles); switch(tap_get_state()) @@ -375,27 +416,27 @@ } vsllink_stableclocks(cmd->cmd.stableclocks->num_cycles, scan_size); break; - + default: LOG_ERROR("BUG: unknown JTAG command type encountered: %d", cmd->type); exit(-1); } cmd = cmd->next; } - + return vsllink_tap_execute(); } static int vsllink_speed(int speed) { int result; - + vsllink_usb_out_buffer[0] = VSLLINK_CMD_SET_SPEED; vsllink_usb_out_buffer[1] = (speed >> 0) & 0xff; vsllink_usb_out_buffer[2] = (speed >> 8) & 0xFF; - + result = vsllink_usb_write(vsllink_jtag_handle, 3); - + if (result == 3) { return ERROR_OK; @@ -405,44 +446,30 @@ LOG_ERROR("VSLLink setting speed failed (%d)", result); return ERROR_JTAG_DEVICE_ERROR; } - + return ERROR_OK; } static int vsllink_khz(int khz, int *jtag_speed) { *jtag_speed = khz; - + return ERROR_OK; } static int vsllink_speed_div(int jtag_speed, int *khz) { *khz = jtag_speed; - + return ERROR_OK; } -static int vsllink_register_commands(struct command_context_s *cmd_ctx) -{ - register_command(cmd_ctx, NULL, "vsllink_usb_vid", vsllink_handle_usb_vid_command, - COMMAND_CONFIG, NULL); - register_command(cmd_ctx, NULL, "vsllink_usb_pid", vsllink_handle_usb_pid_command, - COMMAND_CONFIG, NULL); - register_command(cmd_ctx, NULL, "vsllink_usb_bulkin", vsllink_handle_usb_bulkin_command, - COMMAND_CONFIG, NULL); - register_command(cmd_ctx, NULL, "vsllink_usb_bulkout", vsllink_handle_usb_bulkout_command, - COMMAND_CONFIG, NULL); - - return ERROR_OK; -} - static int vsllink_init(void) { - int check_cnt; + int check_cnt, to_tmp; int result; char version_str[100]; - + vsllink_usb_in_buffer = malloc(VSLLINK_BufferSize); vsllink_usb_out_buffer = malloc(VSLLINK_BufferSize); if ((vsllink_usb_in_buffer == NULL) || (vsllink_usb_out_buffer == NULL)) @@ -450,34 +477,37 @@ LOG_ERROR("Not enough memory"); exit(-1); } - + vsllink_jtag_handle = vsllink_usb_open(); - + if (vsllink_jtag_handle == 0) { LOG_ERROR("Can't find USB JTAG Interface! Please check connection and permissions."); return ERROR_JTAG_INIT_FAILED; } - + LOG_DEBUG("vsllink found on %04X:%04X", vsllink_usb_vid, vsllink_usb_pid); + + to_tmp = VSLLINK_USB_TIMEOUT; + VSLLINK_USB_TIMEOUT = 100; check_cnt = 0; - while (check_cnt < 3) + while (check_cnt < 5) { - vsllink_simple_command(VSLLINK_CMD_CONN); + vsllink_simple_command(0x00); result = vsllink_usb_read(vsllink_jtag_handle); - + if (result > 2) { vsllink_usb_in_buffer[result] = 0; VSLLINK_BufferSize = vsllink_usb_in_buffer[0] + (vsllink_usb_in_buffer[1] << 8); strncpy(version_str, (char *)vsllink_usb_in_buffer + 2, sizeof(version_str)); LOG_INFO("%s", version_str); - + // free the pre-alloc memroy free(vsllink_usb_in_buffer); free(vsllink_usb_out_buffer); vsllink_usb_in_buffer = NULL; vsllink_usb_out_buffer = NULL; - + // alloc new memory vsllink_usb_in_buffer = malloc(VSLLINK_BufferSize); vsllink_usb_out_buffer = malloc(VSLLINK_BufferSize); @@ -490,20 +520,64 @@ { LOG_INFO("buffer size for USB is %d bytes", VSLLINK_BufferSize); } + // alloc memory for dma mode + if (vsllink_mode == VSLLINK_MODE_DMA) + { + tap_buffer_size = (VSLLINK_BufferSize - 3) / 2; + tms_buffer = (u8*)malloc(tap_buffer_size); + tdi_buffer = (u8*)malloc(tap_buffer_size); + tdo_buffer = (u8*)malloc(tap_buffer_size); + if ((tms_buffer == NULL) || (tdi_buffer == NULL) || (tdo_buffer == NULL)) + { + LOG_ERROR("Not enough memory"); + exit(-1); + } + } break; } vsllink_simple_command(VSLLINK_CMD_DISCONN); - check_cnt++; } - if (check_cnt == 3) { // It's dangerout to proced LOG_ERROR("VSLLink initial failed"); exit(-1); } - + VSLLINK_USB_TIMEOUT = to_tmp; + + // connect to vsllink + vsllink_connect(); + // initialize function pointers + if (vsllink_mode == VSLLINK_MODE_NORMAL) + { + // normal mode + vsllink_state_move = vsllink_state_move_normal; + vsllink_path_move = vsllink_path_move_normal; + vsllink_stableclocks = vsllink_stableclocks_normal; + vsllink_scan = vsllink_scan_normal; + + vsllink_tap_init = vsllink_tap_init_normal; + vsllink_tap_execute = vsllink_tap_execute_normal; + vsllink_tap_ensure_space = vsllink_tap_ensure_space_normal; + + LOG_INFO("vsllink run in NORMAL mode"); + } + else + { + // dma mode + vsllink_state_move = vsllink_state_move_dma; + vsllink_path_move = vsllink_path_move_dma; + vsllink_stableclocks = vsllink_stableclocks_dma; + vsllink_scan = vsllink_scan_dma; + + vsllink_tap_init = vsllink_tap_init_dma; + vsllink_tap_execute = vsllink_tap_execute_dma; + vsllink_tap_ensure_space = vsllink_tap_ensure_space_dma; + + LOG_INFO("vsllink run in DMA mode"); + } + // Set SRST and TRST to output, Set USR1 and USR2 to input vsllink_usb_out_buffer[0] = VSLLINK_CMD_SET_PORTDIR; vsllink_usb_out_buffer[1] = JTAG_PINMSK_SRST | JTAG_PINMSK_TRST | JTAG_PINMSK_USR1 | JTAG_PINMSK_USR2; @@ -513,13 +587,13 @@ LOG_ERROR("VSLLink USB send data error"); exit(-1); } - + vsllink_reset(0, 0); - + LOG_INFO("VSLLink JTAG Interface ready"); - + vsllink_tap_init(); - + return ERROR_OK; } @@ -536,31 +610,60 @@ LOG_ERROR("VSLLink USB send data error"); exit(-1); } - + // disconnect - vsllink_simple_command(VSLLINK_CMD_DISCONN); + vsllink_disconnect(); vsllink_usb_close(vsllink_jtag_handle); + vsllink_jtag_handle = NULL; } - + if (vsllink_usb_in_buffer != NULL) { free(vsllink_usb_in_buffer); + vsllink_usb_in_buffer = NULL; } if (vsllink_usb_out_buffer != NULL) { free(vsllink_usb_out_buffer); + vsllink_usb_out_buffer = NULL; } + return ERROR_OK; } +/***************************************************************************/ +/* Queue command implementations */ +static int vsllink_disconnect(void) +{ + vsllink_simple_command(VSLLINK_CMD_DISCONN); + return ERROR_OK; +} + +static int vsllink_connect(void) +{ + char vsllink_str[100]; + + vsllink_usb_out_buffer[0] = VSLLINK_CMD_CONN; + vsllink_usb_out_buffer[1] = vsllink_mode; + vsllink_usb_message(vsllink_jtag_handle, 2, 0); + if (vsllink_usb_read(vsllink_jtag_handle) > 2) + { + strncpy(vsllink_str, (char *)vsllink_usb_in_buffer + 2, sizeof(vsllink_str)); + LOG_INFO("%s", vsllink_str); + } + + return ERROR_OK; +} + // when vsllink_tms_data_len > 0, vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] is the byte that need to be appended. // length of VSLLINK_CMDJTAGSEQ_TMSBYTE has been set, no need to set it here. static void vsllink_append_tms(void) { u8 tms_scan = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state()); u16 tms2; - tap_state_t end_state = tap_get_end_state(); - + insert_insignificant_operation_t *insert = \ + &VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())]; + if (((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_DRPAUSE) && (tap_get_state() != TAP_IRPAUSE)) || \ (vsllink_tms_data_len <= 0) || (vsllink_tms_data_len >= 8) || \ (vsllink_tms_cmd_pos == NULL)) @@ -568,27 +671,24 @@ LOG_ERROR("There MUST be some bugs in the driver"); exit(-1); } - - tms2 = (tms_scan & VSLLINK_BIT_MSK[VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position]) << \ + + tms2 = (tms_scan & VSLLINK_BIT_MSK[insert->insert_position]) << \ vsllink_tms_data_len; - if (VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_value == 1) + if (insert->insert_value == 1) { tms2 |= VSLLINK_BIT_MSK[8 - vsllink_tms_data_len] << \ - (vsllink_tms_data_len + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position); + (vsllink_tms_data_len + insert->insert_position); } - tms2 |= (tms_scan >> VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position) << \ - (8 + VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(end_state)].insert_position); - + tms2 |= (tms_scan >> insert->insert_position) << \ + (8 + insert->insert_position); + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] |= (tms2 >> 0) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tms2 >> 8) & 0xff; - + vsllink_tms_data_len = 0; vsllink_tms_cmd_pos = NULL; } -/***************************************************************************/ -/* Queue command implementations */ - static void vsllink_end_state(tap_state_t state) { if (tap_is_state_stable(state)) @@ -603,7 +703,7 @@ } /* Goes to the end state. */ -static void vsllink_state_move(void) +static void vsllink_state_move_normal(void) { if (vsllink_tms_data_len > 0) { @@ -612,19 +712,65 @@ else { vsllink_tap_ensure_space(0, 2); - + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state()); } - + tap_set_state(tap_get_end_state()); } +static void vsllink_state_move_dma(void) +{ + int i, insert_length = (tap_length % 8) ? (8 - (tap_length % 8)) : 0; + insert_insignificant_operation_t *insert = \ + &VSLLINK_TAP_MOVE_INSERT_INSIGNIFICANT[tap_move_ndx(tap_get_state())][tap_move_ndx(tap_get_end_state())]; + u8 tms_scan = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state()); + + vsllink_tap_ensure_space(0, 8); + + if (tap_get_state() == TAP_RESET) + { + for (i = 0; i < 8; i++) + { + vsllink_tap_append_step(1, 0); + } + } + + if (insert_length > 0) + { + vsllink_tap_ensure_space(0, 16); + + for (i = 0; i < insert->insert_position; i++) + { + vsllink_tap_append_step((tms_scan >> i) & 1, 0); + } + for (i = 0; i < insert_length; i++) + { + vsllink_tap_append_step(insert->insert_value, 0); + } + for (i = insert->insert_position; i < 8; i++) + { + vsllink_tap_append_step((tms_scan >> i) & 1, 0); + } + } + else + { + vsllink_tap_ensure_space(0, 8); + + for (i = 0; i < 8; i++) + { + vsllink_tap_append_step((tms_scan >> i) & 1, 0); + } + } + + tap_set_state(tap_get_end_state()); +} // write tms from current vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] static void vsllink_add_path(int start, int num, tap_state_t *path) { int i; - + for (i = start; i < (start + num); i++) { if ((i & 7) == 0) @@ -635,7 +781,7 @@ } vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0; } - + if (path[i - start] == tap_state_transition(tap_get_state(), true)) { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] |= 1 << (i & 7); @@ -656,14 +802,14 @@ vsllink_usb_out_buffer_idx++; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] = 0; } - + tap_set_end_state(tap_get_state()); } -static void vsllink_path_move(int num_states, tap_state_t *path) +static void vsllink_path_move_normal(int num_states, tap_state_t *path) { int i, tms_len, tms_cmd_pos, path_idx = 0; - + if (vsllink_tms_data_len > 0) { // there are vsllink_tms_data_len more tms bits to be shifted @@ -714,7 +860,7 @@ // end last tms shift command vsllink_add_path(vsllink_tms_data_len, num_states, path); } - + vsllink_tms_data_len = (vsllink_tms_data_len + num_states) & 7; if (vsllink_tms_data_len == 0) { @@ -725,19 +871,19 @@ else { vsllink_add_path(vsllink_tms_data_len, 16 - vsllink_tms_data_len, path); - + path += 16 - vsllink_tms_data_len; num_states -= 16 - vsllink_tms_data_len; vsllink_tms_data_len = 0; vsllink_tms_cmd_pos = NULL; } } - + if (num_states > 0) { // Normal operation, don't need to append tms data vsllink_tms_data_len = num_states & 7; - + while (num_states > 0) { if (num_states > ((VSLLINK_CMDJTAGSEQ_LENMSK + 1) * 8)) @@ -752,13 +898,13 @@ vsllink_tap_ensure_space(0, tms_len + 2); tms_cmd_pos = vsllink_usb_out_buffer_idx; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_TMSBYTE | (tms_len - 1); - + vsllink_add_path(0, i, path + path_idx); - + path_idx += i; num_states -= i; } - + if (vsllink_tms_data_len > 0) { if (tms_len < (VSLLINK_CMDJTAGSEQ_LENMSK + 1)) @@ -769,7 +915,7 @@ else { vsllink_usb_out_buffer[tms_cmd_pos]--; - + tms_len = vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]; vsllink_tap_ensure_space(0, 3); vsllink_tms_cmd_pos = &vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]; @@ -779,12 +925,71 @@ } } } +static void vsllink_path_move_dma(int num_states, tap_state_t *path) +{ + int i, j = 0; + + if (tap_length & 7) + { + if ((8 - (tap_length & 7)) < num_states) + { + j = 8 - (tap_length & 7); + } + else + { + j = num_states; + } + for (i = 0; i < j; i++) + { + if (path[i] == tap_state_transition(tap_get_state(), false)) + { + vsllink_tap_append_step(0, 0); + } + else if (path[i] == tap_state_transition(tap_get_state(), true)) + { + vsllink_tap_append_step(1, 0); + } + else + { + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(path[i])); + exit(-1); + } + tap_set_state(path[i]); + } + num_states -= j; + } + + if (num_states > 0) + { + vsllink_tap_ensure_space(0, num_states); + + for (i = 0; i < num_states; i++) + { + if (path[j + i] == tap_state_transition(tap_get_state(), false)) + { + vsllink_tap_append_step(0, 0); + } + else if (path[j + i] == tap_state_transition(tap_get_state(), true)) + { + vsllink_tap_append_step(1, 0); + } + else + { + LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(tap_get_state()), tap_state_name(path[i])); + exit(-1); + } + tap_set_state(path[j + i]); + } + } + + tap_set_end_state(tap_get_state()); +} -static void vsllink_stableclocks(int num_cycles, int tms) +static void vsllink_stableclocks_normal(int num_cycles, int tms) { int tms_len; u16 tms_append_byte; - + if (vsllink_tms_data_len > 0) { // there are vsllink_tms_data_len more tms bits to be shifted @@ -850,7 +1055,7 @@ vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] |= (u8)(tms_append_byte & 0xFF); vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (u8)(tms_append_byte >> 8); } - + vsllink_tms_data_len = tms_len & 7; if (vsllink_tms_data_len == 0) { @@ -863,14 +1068,14 @@ // more shifts will be needed vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] |= (u8)(tms_append_byte & 0xFF); vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (u8)(tms_append_byte >> 8); - + num_cycles -= 16 - vsllink_tms_data_len; vsllink_tms_data_len = 0; vsllink_tms_cmd_pos = NULL; } } // from here vsllink_tms_data_len == 0 or num_cycles == 0 - + if (vsllink_tms_data_len > 0) { // num_cycles == 0 @@ -903,17 +1108,17 @@ vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tms_len >> 8) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tms_len >> 16) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tms_len >> 24) & 0xff; - + vsllink_usb_in_want_length += 1; pending_scan_results_buffer[pending_scan_results_length].buffer = NULL; pending_scan_results_length++; - + if (tms_len > 0xFFFF) { vsllink_tap_execute(); } } - + // post-process vsllink_tms_data_len = num_cycles & 7; if (vsllink_tms_data_len > 0) @@ -934,20 +1139,62 @@ } } } +static void vsllink_stableclocks_dma(int num_cycles, int tms) +{ + int i, cur_cycles; + + if (tap_length & 7) + { + if ((8 - (tap_length & 7)) < num_cycles) + { + cur_cycles = 8 - (tap_length & 7); + } + else + { + cur_cycles = num_cycles; + } + for (i = 0; i < cur_cycles; i++) + { + vsllink_tap_append_step(tms, 0); + } + num_cycles -= cur_cycles; + } + + while (num_cycles > 0) + { + if (num_cycles > 8 * tap_buffer_size) + { + cur_cycles = 8 * tap_buffer_size; + } + else + { + cur_cycles = num_cycles; + } + + vsllink_tap_ensure_space(0, cur_cycles); + + for (i = 0; i < cur_cycles; i++) + { + vsllink_tap_append_step(tms, 0); + } + + num_cycles -= cur_cycles; + } +} static void vsllink_runtest(int num_cycles) { tap_state_t saved_end_state = tap_get_end_state(); - + if (tap_get_state() != TAP_IDLE) { // enter into IDLE state vsllink_end_state(TAP_IDLE); vsllink_state_move(); } - + vsllink_stableclocks(num_cycles, 0); - + // post-process // set end_state vsllink_end_state(saved_end_state); @@ -958,29 +1205,29 @@ } } -static void vsllink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +static void vsllink_scan_normal(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) { tap_state_t saved_end_state; u8 bits_left, tms_tmp, tdi_len; int i; - + if (0 == scan_size ) { return; } - + tdi_len = ((scan_size + 7) >> 3); if ((tdi_len + 7) > VSLLINK_BufferSize) { LOG_ERROR("Your implementation of VSLLink has not enough buffer"); exit(-1); } - + saved_end_state = tap_get_end_state(); - + /* Move to appropriate scan state */ vsllink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT); - + if (vsllink_tms_data_len > 0) { if (tap_get_state() == tap_get_end_state()) @@ -1002,16 +1249,16 @@ tms_tmp = vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx]; *vsllink_tms_cmd_pos -= 2; } - + vsllink_tap_ensure_space(1, tdi_len + 7); - // VSLLINK_CMDJTAGSEQ_SCAN ored by 1 means that tms_before is valid + // VSLLINK_CMDJTAGSEQ_SCAN ored by 1 means that tms_before is valid // which is merged from the last tms shift command vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN | 1; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 0) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1)>> 8) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = tms_tmp; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = buffer[0] << (8 - vsllink_tms_data_len); - + for (i = 0; i < tdi_len; i++) { buffer[i] >>= 8 - vsllink_tms_data_len; @@ -1020,40 +1267,40 @@ buffer[i] += buffer[i + 1] << vsllink_tms_data_len; } } - - vsllink_tap_append_scan(scan_size - vsllink_tms_data_len, buffer, command, vsllink_tms_data_len); + + vsllink_tap_append_scan_normal(scan_size - vsllink_tms_data_len, buffer, command, vsllink_tms_data_len); scan_size -= 8 - vsllink_tms_data_len; vsllink_tms_data_len = 0; } else { - vsllink_append_tms(); + vsllink_state_move(); vsllink_tap_ensure_space(1, tdi_len + 5); - + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tdi_len >> 0) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = (tdi_len >> 8) & 0xff; - - vsllink_tap_append_scan(scan_size, buffer, command, 0); + + vsllink_tap_append_scan_normal(scan_size, buffer, command, 0); } } else { vsllink_tap_ensure_space(1, tdi_len + 7); - + vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_CMDJTAGSEQ_SCAN | 1; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1) >> 0) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = ((tdi_len + 1)>> 8) & 0xff; vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state()); vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0; - - vsllink_tap_append_scan(scan_size, buffer, command, 8); + + vsllink_tap_append_scan_normal(scan_size, buffer, command, 8); } vsllink_end_state(saved_end_state); - + bits_left = scan_size & 0x07; tap_set_state(ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE); - + if (bits_left > 0) { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 1 << (bits_left - 1); @@ -1062,7 +1309,7 @@ { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 1 << 7; } - + if (tap_get_state() != tap_get_end_state()) { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = VSLLINK_TAP_MOVE(tap_get_state(), tap_get_end_state()); @@ -1071,16 +1318,44 @@ { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = 0; } - + tap_set_state(tap_get_end_state()); } +static void vsllink_scan_dma(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +{ + tap_state_t saved_end_state; + + saved_end_state = tap_get_end_state(); + + /* Move to appropriate scan state */ + vsllink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT); + + vsllink_state_move(); + vsllink_end_state(saved_end_state); + + /* Scan */ + vsllink_tap_ensure_space(1, (scan_size + 7) & ~0x00000007); + vsllink_tap_append_scan_dma(scan_size, buffer, command); + + tap_set_state(ir_scan ? TAP_IRPAUSE : TAP_DRPAUSE); + while (tap_length % 8 != 0) + { + // more 0s in Pause + vsllink_tap_append_step(0, 0); + } + + if (tap_get_state() != tap_get_end_state()) + { + vsllink_state_move(); + } +} static void vsllink_reset(int trst, int srst) { int result; - + LOG_DEBUG("trst: %i, srst: %i", trst, srst); - + /* Signals are active low */ vsllink_usb_out_buffer[0] = VSLLINK_CMD_SET_PORT; vsllink_usb_out_buffer[1] = JTAG_PINMSK_SRST | JTAG_PINMSK_TRST; @@ -1093,7 +1368,7 @@ { vsllink_usb_out_buffer[2] |= JTAG_PINMSK_TRST; } - + result = vsllink_usb_write(vsllink_jtag_handle, 3); if (result != 3) { @@ -1104,92 +1379,202 @@ static void vsllink_simple_command(u8 command) { int result; - + DEBUG_JTAG_IO("0x%02x", command); - + vsllink_usb_out_buffer[0] = command; result = vsllink_usb_write(vsllink_jtag_handle, 1); - + if (result != 1) { LOG_ERROR("VSLLink command 0x%02x failed (%d)", command, result); } } -static int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int vsllink_register_commands(struct command_context_s *cmd_ctx) { + register_command(cmd_ctx, NULL, "vsllink_usb_vid", vsllink_handle_usb_vid_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_pid", vsllink_handle_usb_pid_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_bulkin", vsllink_handle_usb_bulkin_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_bulkout", vsllink_handle_usb_bulkout_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_usb_interface", vsllink_handle_usb_interface_command, + COMMAND_CONFIG, NULL); + register_command(cmd_ctx, NULL, "vsllink_mode", vsllink_handle_mode_command, + COMMAND_CONFIG, NULL); + + return ERROR_OK; +} + +static int vsllink_handle_mode_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ if (argc != 1) { LOG_ERROR("parameter error, should be one parameter for VID"); + return ERROR_FAIL; + } + + if (!strcmp(args[0], "normal")) + { + vsllink_mode = VSLLINK_MODE_NORMAL; + } + else if (!strcmp(args[0], "dma")) + { + vsllink_mode = VSLLINK_MODE_DMA; + } + else + { + LOG_ERROR("invalid vsllink_mode: %s", args[0]); + return ERROR_FAIL; + } + + return ERROR_OK; +} + +static int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc != 1) + { + LOG_ERROR("parameter error, should be one parameter for VID"); return ERROR_OK; } - - vsllink_vid = strtol(args[0], NULL, 0); - + + vsllink_usb_vid = strtol(args[0], NULL, 0); + return ERROR_OK; } static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - if (argc != 1) { + if (argc != 1) + { LOG_ERROR("parameter error, should be one parameter for PID"); return ERROR_OK; } - - vsllink_pid = strtol(args[0], NULL, 0); - + + vsllink_usb_pid = strtol(args[0], NULL, 0); + return ERROR_OK; } static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - if (argc != 1) { + if (argc != 1) + { LOG_ERROR("parameter error, should be one parameter for BULKIN endpoint"); return ERROR_OK; } - - vsllink_bulkin = strtol(args[0], NULL, 0) | 0x80; - + + vsllink_usb_bulkin = strtol(args[0], NULL, 0) | 0x80; + return ERROR_OK; } static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { - if (argc != 1) { + if (argc != 1) + { LOG_ERROR("parameter error, should be one parameter for BULKOUT endpoint"); return ERROR_OK; } + + vsllink_usb_bulkout = strtol(args[0], NULL, 0); + + return ERROR_OK; +} - vsllink_bulkout = strtol(args[0], NULL, 0); - +static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc != 1) + { + LOG_ERROR("parameter error, should be one parameter for interface number"); + return ERROR_OK; + } + + vsllink_usb_interface = strtol(args[0], NULL, 0); + return ERROR_OK; } /***************************************************************************/ /* VSLLink tap functions */ -static void vsllink_tap_init(void) +static void vsllink_tap_init_normal(void) { vsllink_usb_out_buffer_idx = 0; vsllink_usb_in_want_length = 0; pending_scan_results_length = 0; } +static void vsllink_tap_init_dma(void) +{ + tap_length = 0; + pending_scan_results_length = 0; +} -static void vsllink_tap_ensure_space(int scans, int bytes) +static void vsllink_tap_ensure_space_normal(int scans, int length) { int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; int available_bytes = VSLLINK_BufferSize - vsllink_usb_out_buffer_idx; - - if (scans > available_scans || bytes > available_bytes) + + if (scans > available_scans || length > available_bytes) { vsllink_tap_execute(); } } +static void vsllink_tap_ensure_space_dma(int scans, int length) +{ + int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; + int available_bytes = tap_buffer_size * 8 - tap_length; + + if (scans > available_scans || length > available_bytes) + { + vsllink_tap_execute(); + } +} -static void vsllink_tap_append_scan(int length, u8 *buffer, scan_command_t *command, int offset) +static void vsllink_tap_append_step(int tms, int tdi) { + last_tms = tms; + int index = tap_length / 8; + + if (index < tap_buffer_size) + { + int bit_index = tap_length % 8; + u8 bit = 1 << bit_index; + + if (tms) + { + tms_buffer[index] |= bit; + } + else + { + tms_buffer[index] &= ~bit; + } + + if (tdi) + { + tdi_buffer[index] |= bit; + } + else + { + tdi_buffer[index] &= ~bit; + } + + tap_length++; + } + else + { + LOG_ERROR("buffer overflow, tap_length=%d", tap_length); + } +} + +static void vsllink_tap_append_scan_normal(int length, u8 *buffer, scan_command_t *command, int offset) +{ pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; int i; - + if (offset > 0) { vsllink_usb_in_want_length += ((length + 7) >> 3) + 1; @@ -1202,30 +1587,47 @@ pending_scan_result->offset = offset; pending_scan_result->command = command; pending_scan_result->buffer = buffer; - + for (i = 0; i < ((length + 7) >> 3); i++) { vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx++] = buffer[i]; } - + pending_scan_results_length++; } +static void vsllink_tap_append_scan_dma(int length, u8 *buffer, scan_command_t *command) +{ + pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; + int i; + + pending_scan_result->offset = tap_length; + pending_scan_result->length = length; + pending_scan_result->command = command; + pending_scan_result->buffer = buffer; + + for (i = 0; i < length; i++) + { + vsllink_tap_append_step((i < length-1 ? 0 : 1), (buffer[i/8] >> (i%8)) & 1); + } + + pending_scan_results_length++; +} /* Pad and send a tap sequence to the device, and receive the answer. * For the purpose of padding we assume that we are in reset or idle or pause state. */ -static int vsllink_tap_execute(void) +static int vsllink_tap_execute_normal(void) { int i; int result; int first = 0; - + if (vsllink_tms_data_len > 0) { if((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_IRPAUSE) && (tap_get_state() != TAP_DRPAUSE)) { LOG_WARNING("%s is not in RESET or IDLE or PAUSR state", tap_state_name(tap_get_state())); } - + if (vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx] & (1 << (vsllink_tms_data_len - 1))) { // last tms bit is '1' @@ -1241,7 +1643,7 @@ vsllink_tms_data_len = 0; } } - + if (vsllink_usb_out_buffer_idx > 3) { if (vsllink_usb_out_buffer[0] == VSLLINK_CMD_HW_JTAGSEQCMD) @@ -1249,9 +1651,9 @@ vsllink_usb_out_buffer[1] = (vsllink_usb_out_buffer_idx >> 0) & 0xff; vsllink_usb_out_buffer[2] = (vsllink_usb_out_buffer_idx >> 8) & 0xff; } - + result = vsllink_usb_message(vsllink_jtag_handle, vsllink_usb_out_buffer_idx, vsllink_usb_in_want_length); - + if (result == vsllink_usb_in_want_length) { for (i = 0; i < pending_scan_results_length; i++) @@ -1261,24 +1663,24 @@ int length = pending_scan_result->length; int offset = pending_scan_result->offset; scan_command_t *command = pending_scan_result->command; - + if (buffer != NULL) { // IRSHIFT or DRSHIFT buf_set_buf(vsllink_usb_in_buffer, first * 8 + offset, buffer, 0, length); first += (length + offset + 7) >> 3; - + DEBUG_JTAG_IO("JTAG scan read(%d bits):", length); #ifdef _DEBUG_JTAG_IO_ vsllink_debug_buffer(buffer, (length + 7) >> 3); #endif - + if (jtag_read_buffer(buffer, command) != ERROR_OK) { vsllink_tap_init(); return ERROR_JTAG_QUEUE_FAILED; } - + free(pending_scan_result->buffer); pending_scan_result->buffer = NULL; } @@ -1293,68 +1695,162 @@ LOG_ERROR("vsllink_tap_execute, wrong result %d, expected %d", result, vsllink_usb_in_want_length); return ERROR_JTAG_QUEUE_FAILED; } - + vsllink_tap_init(); } - - vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGSEQCMD; - vsllink_usb_out_buffer_idx = 3; - + reset_command_pointer(); + return ERROR_OK; } +static int vsllink_tap_execute_dma(void) +{ + int byte_length; + int i; + int result; + + if (tap_length > 0) + { + /* Pad last byte so that tap_length is divisible by 8 */ + while (tap_length % 8 != 0) + { + /* More of the last TMS value keeps us in the same state, + * analogous to free-running JTAG interfaces. */ + vsllink_tap_append_step(last_tms, 0); + } + byte_length = tap_length / 8; + + vsllink_usb_out_buffer[0] = VSLLINK_CMD_HW_JTAGRAWCMD; + vsllink_usb_out_buffer[1] = ((byte_length * 2 + 3) >> 0) & 0xff; // package size + vsllink_usb_out_buffer[2] = ((byte_length * 2 + 3) >> 8) & 0xff; + + memcpy(&vsllink_usb_out_buffer[3], tdi_buffer, byte_length); + memcpy(&vsllink_usb_out_buffer[3 + byte_length], tms_buffer, byte_length); + + result = vsllink_usb_message(vsllink_jtag_handle, 3 + 2 * byte_length, byte_length); + if (result == byte_length) + { + for (i = 0; i < pending_scan_results_length; i++) + { + pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[i]; + u8 *buffer = pending_scan_result->buffer; + int length = pending_scan_result->length; + int first = pending_scan_result->offset; + + scan_command_t *command = pending_scan_result->command; + buf_set_buf(vsllink_usb_in_buffer, first, buffer, 0, length); + + DEBUG_JTAG_IO("JTAG scan read(%d bits, from %d bits):", length, first); +#ifdef _DEBUG_JTAG_IO_ + vsllink_debug_buffer(buffer, (length + 7) >> 3); +#endif + + if (jtag_read_buffer(buffer, command) != ERROR_OK) + { + vsllink_tap_init(); + return ERROR_JTAG_QUEUE_FAILED; + } + + if (pending_scan_result->buffer != NULL) + { + free(pending_scan_result->buffer); + } + } + } + else + { + LOG_ERROR("vsllink_tap_execute, wrong result %d, expected %d", result, byte_length); + return ERROR_JTAG_QUEUE_FAILED; + } + + vsllink_tap_init(); + } + + return ERROR_OK; +} /*****************************************************************************/ /* VSLLink USB low-level functions */ -vsllink_jtag_t* vsllink_usb_open(void) +static vsllink_jtag_t* vsllink_usb_open(void) { struct usb_bus *busses; struct usb_bus *bus; struct usb_device *dev; - + int ret; + vsllink_jtag_t *result; - + result = (vsllink_jtag_t*) malloc(sizeof(vsllink_jtag_t)); - + usb_init(); usb_find_busses(); usb_find_devices(); - + busses = usb_get_busses(); - + /* find vsllink_jtag device in usb bus */ - + for (bus = busses; bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { - if ((dev->descriptor.idVendor == vsllink_vid) && (dev->descriptor.idProduct == vsllink_pid)) + if ((dev->descriptor.idVendor == vsllink_usb_vid) && (dev->descriptor.idProduct == vsllink_usb_pid)) { result->usb_handle = usb_open(dev); - + if (NULL == result->usb_handle) + { + LOG_ERROR("failed to open %04X:%04X, not enough permissions?", vsllink_usb_vid, vsllink_usb_pid); + exit(-1); + } + /* usb_set_configuration required under win32 */ - usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue); - usb_claim_interface(result->usb_handle, 0); - + ret = usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue); + if (ret != 0) + { + LOG_ERROR("fail to set configuration to %d, %d returned, not enough permissions?", dev->config[0].bConfigurationValue, ret); + exit(-1); + } + ret = usb_claim_interface(result->usb_handle, vsllink_usb_interface); + if (ret != 0) + { + LOG_ERROR("fail to claim interface %d, %d returned", vsllink_usb_interface, ret); + exit(-1); + } + #if 0 - /* + /* * This makes problems under Mac OS X. And is not needed * under Windows. Hopefully this will not break a linux build */ usb_set_altinterface(result->usb_handle, 0); -#endif +#endif return result; } } } - + free(result); return NULL; } static void vsllink_usb_close(vsllink_jtag_t *vsllink_jtag) { - usb_close(vsllink_jtag->usb_handle); + int ret; + + ret = usb_release_interface(vsllink_jtag->usb_handle, vsllink_usb_interface); + if (ret != 0) + { + LOG_ERROR("fail to release interface %d, %d returned", vsllink_usb_interface, ret); + exit(-1); + } + + ret = usb_close(vsllink_jtag->usb_handle); + if (ret != 0) + { + LOG_ERROR("fail to close usb, %d returned", ret); + exit(-1); + } + free(vsllink_jtag); } @@ -1362,7 +1858,7 @@ static int vsllink_usb_message(vsllink_jtag_t *vsllink_jtag, int out_length, int in_length) { int result; - + result = vsllink_usb_write(vsllink_jtag, out_length); if (result == out_length) { @@ -1392,18 +1888,18 @@ static int vsllink_usb_write(vsllink_jtag_t *vsllink_jtag, int out_length) { int result; - + if (out_length > VSLLINK_BufferSize) { LOG_ERROR("vsllink_jtag_write illegal out_length=%d (max=%d)", out_length, VSLLINK_BufferSize); return -1; } - - result = usb_bulk_write(vsllink_jtag->usb_handle, vsllink_bulkout, \ + + result = usb_bulk_write(vsllink_jtag->usb_handle, vsllink_usb_bulkout, \ (char *)vsllink_usb_out_buffer, out_length, VSLLINK_USB_TIMEOUT); - + DEBUG_JTAG_IO("vsllink_usb_write, out_length = %d, result = %d", out_length, result); - + #ifdef _DEBUG_USB_COMMS_ LOG_DEBUG("USB out:"); vsllink_debug_buffer(vsllink_usb_out_buffer, out_length); @@ -1419,11 +1915,11 @@ /* Read data from USB into in_buffer. */ static int vsllink_usb_read(vsllink_jtag_t *vsllink_jtag) { - int result = usb_bulk_read(vsllink_jtag->usb_handle, vsllink_bulkin, \ + int result = usb_bulk_read(vsllink_jtag->usb_handle, vsllink_usb_bulkin, \ (char *)vsllink_usb_in_buffer, VSLLINK_BufferSize, VSLLINK_USB_TIMEOUT); - + DEBUG_JTAG_IO("vsllink_usb_read, result = %d", result); - + #ifdef _DEBUG_USB_COMMS_ LOG_DEBUG("USB in:"); vsllink_debug_buffer(vsllink_usb_in_buffer, result); @@ -1440,7 +1936,7 @@ char s[4]; int i; int j; - + for (i = 0; i < length; i += BYTES_PER_LINE) { snprintf(line, 5, "%04x", i); Added: trunk/src/target/interface/vsllink.cfg =================================================================== --- trunk/src/target/interface/vsllink.cfg 2009-04-21 09:05:02 UTC (rev 1490) +++ trunk/src/target/interface/vsllink.cfg 2009-04-21 09:08:43 UTC (rev 1491) @@ -0,0 +1,25 @@ +# +# Versaloon Link -- VSLLink +# +# http://www.simonqian.com/en/Versaloon +# + +interface vsllink + +#vsllink_usb_vid 0x03EB +#vsllink_usb_pid 0x2103 +#vsllink_usb_bulkin 0x02 +#vsllink_usb_bulkout 0x02 +#vsllink_usb_interface 0 + +vsllink_usb_vid 0x0483 +vsllink_usb_pid 0x5740 +vsllink_usb_bulkin 0x02 +vsllink_usb_bulkout 0x03 +vsllink_usb_interface 1 + +# vsllink mode, dma or normal +# for low jtag_khz, use normal +# for high jtag_khz, use dma +#vsllink_mode dma +vsllink_mode normal Property changes on: trunk/src/target/interface/vsllink.cfg ___________________________________________________________________ Name: svn:eol-style + native |
From: oharboe at B. <oh...@ma...> - 2009-04-21 11:05:03
|
Author: oharboe Date: 2009-04-21 11:05:02 +0200 (Tue, 21 Apr 2009) New Revision: 1490 Modified: trunk/configure.in Log: Zach Welch <zw...@su...> improve Linux ftd2xx configure-time support Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-04-21 09:02:42 UTC (rev 1489) +++ trunk/configure.in 2009-04-21 09:05:02 UTC (rev 1490) @@ -522,7 +522,6 @@ fi if test $build_ft2232_ftd2xx = yes ; then - AC_MSG_CHECKING([for libftd2xx.a (linux)]) # Must be linux - # Cause FTDICHIP does not supply a MAC-OS version if test $host_os != linux-gnu && test $host_os != linux ; then @@ -531,30 +530,26 @@ # Are we given a TAR directory? if test "${with_ftd2xx_linux_tardir+set}" = set then + AC_MSG_CHECKING([uninstalled ftd2xx distribution]) # The .H file is simple.. - f=$with_ftd2xx_linux_tardir/ftd2xx.h - if test ! -f $f ; then - AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: $f]) + FTD2XX_H=$with_ftd2xx_linux_tardir/ftd2xx.h + if test ! -f "${FTD2XX_H}"; then + AC_MSG_ERROR([Option: --with-ftd2xx-linux-tardir appears wrong, cannot find: ${FTD2XX_H}]) fi CFLAGS="$CFLAGS -I$with_ftd2xx_linux_tardir" - if test $with_ftd2xx_lib = shared - then - LDFLAGS="$LDFLAGS -L$with_ftd2xx_linux_tardir" - LIBS="$LIBS -lftd2xx" - AC_MSG_RESULT([ Assuming: -L$with_ftd2xx_linux_tardir -lftd2xx]) - else + FTD2XX_LDFLAGS="-L$with_ftd2xx_linux_tardir" + FTD2XX_LIB="-lftd2xx" + if test $with_ftd2xx_lib != shared; then # Test #1 - Future proof - if/when ftdichip fixes their distro. # Try it with the simple ".a" suffix. - f=$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a - if test -f $f ; then - # Yea we are done - LDFLAGS="$LDFLAGS -L$with_ftd2xx_linux_tardir/static_lib" - LIBS="$LIBS -lftd2xx" + FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a" + if test -f "${FTD2XX_LIB}"; then + FTD2XX_LDFLAGS="${FTD2XX_LDFLAGS}/static_lib" else # Test Number2. # Grr.. perhaps it exists as a version number? - f="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*" - count=`ls $f | wc -l` + FTD2XX_LIB="$with_ftd2xx_linux_tardir/static_lib/libftd2xx.a.*.*.*" + count=`ls ${FTD2XX_LIB} | wc -l` if test $count -gt 1 ; then AC_MSG_ERROR([Multiple libftd2xx.a files found in: $with_ftd2xx_linux_tardir/static_lib sorry cannot handle this yet]) fi @@ -563,17 +558,20 @@ fi # Because the "-l" rules do not understand version numbers... # we will just stuff the absolute path onto the LIBS variable - f=`ls $f` - # - LIBS="$LIBS $f -lpthread" - # No need to bother with LDFLAGS... + FTD2XX_LIB="`ls ${FTD2XX_LIB}` -lpthread" + FTD2XX_LDFLAGS="" fi - AC_MSG_RESULT([Found: $f]) fi + LDFLAGS="${LDFLAGS} ${FTD2XX_LDFLAGS}" + LIBS="${LIBS} ${FTD2XX_LIB}" + AC_MSG_RESULT([${FTD2XX_LDFLAGS} ${FTD2XX_LIB}]) else - LIBS="$LIBS -lftd2xx" - AC_MSG_RESULT([Assumed: installed]) - AC_MSG_WARN([The (linux) FTDICHIP.COM files ftd2xx.h and libftd2xx.so are assumed to be in a proper place]) + AC_CHECK_HEADER([ftd2xx.h],[],[ + AC_MSG_ERROR([You seem to be missing the FTD2xx driver header file.]) + ]) + AC_SEARCH_LIBS([FT_GetLibraryVersion],[ftd2xx],,[ + AC_MSG_ERROR([You appear to be missing the FTD2xx driver library.]) + ],[]) fi fi fi @@ -583,7 +581,7 @@ # Before we go any further - make sure we can *BUILD* and *RUN* # a simple app with the "ftd2xx.lib" file - in what ever form we where given # We should be able to compile, link and run this test program now - AC_MSG_CHECKING([Test: Build & Link with ftd2xx]) + AC_MSG_CHECKING([whether ftd2xx library works]) # # Save the LDFLAGS for later.. |
From: ntfreak at B. <nt...@ma...> - 2009-04-21 11:02:42
|
Author: ntfreak Date: 2009-04-21 11:02:42 +0200 (Tue, 21 Apr 2009) New Revision: 1489 Modified: trunk/src/helper/Makefile.am trunk/src/server/Makefile.am Log: - fix signed/unsigned build errors under win32. Thanks Zach Welch <zw...@su...> Modified: trunk/src/helper/Makefile.am =================================================================== --- trunk/src/helper/Makefile.am 2009-04-21 08:51:07 UTC (rev 1488) +++ trunk/src/helper/Makefile.am 2009-04-21 09:02:42 UTC (rev 1489) @@ -18,6 +18,11 @@ libhelper_a_SOURCES += ioutil.c endif +libhelper_a_CFLAGS = +if IS_MINGW +# FD_* macros are sloppy with their signs on MinGW32 platform +libhelper_a_CFLAGS += -Wno-sign-compare +endif noinst_HEADERS = binarybuffer.h configuration.h types.h log.h command.h \ time_support.h replacements.h fileio.h jim.h jim-eventloop.h \ Modified: trunk/src/server/Makefile.am =================================================================== --- trunk/src/server/Makefile.am 2009-04-21 08:51:07 UTC (rev 1488) +++ trunk/src/server/Makefile.am 2009-04-21 09:02:42 UTC (rev 1489) @@ -8,6 +8,11 @@ libserver_a_SOURCES += httpd.c endif +libserver_a_CFLAGS = +if IS_MINGW +# FD_* macros are sloppy with their signs on MinGW32 platform +libserver_a_CFLAGS += -Wno-sign-compare +endif # tcl server addons noinst_HEADERS += tcl_server.h |
From: ntfreak at B. <nt...@ma...> - 2009-04-21 10:51:09
|
Author: ntfreak Date: 2009-04-21 10:51:07 +0200 (Tue, 21 Apr 2009) New Revision: 1488 Modified: trunk/src/helper/jim.c Log: - remove environ warning under win32 build Modified: trunk/src/helper/jim.c =================================================================== --- trunk/src/helper/jim.c 2009-04-21 06:23:47 UTC (rev 1487) +++ trunk/src/helper/jim.c 2009-04-21 08:51:07 UTC (rev 1488) @@ -11976,7 +11976,10 @@ char *val; if (argc == 1) { + +#ifndef _WIN32 extern char **environ; +#endif int i; Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0); |
From: oharboe at B. <oh...@ma...> - 2009-04-21 08:23:49
|
Author: oharboe Date: 2009-04-21 08:23:47 +0200 (Tue, 21 Apr 2009) New Revision: 1487 Modified: trunk/src/jtag/at91rm9200.c Log: Zach Welch <zw...@su...> add static keywords to at91rm9200 Modified: trunk/src/jtag/at91rm9200.c =================================================================== --- trunk/src/jtag/at91rm9200.c 2009-04-21 05:42:18 UTC (rev 1486) +++ trunk/src/jtag/at91rm9200.c 2009-04-21 06:23:47 UTC (rev 1487) @@ -101,14 +101,14 @@ u32 SRST_MASK; /* SRST bitmask */ }; -struct device_t devices[] = +static struct device_t devices[] = { { "rea_ecr", PIOD, P27, PIOA, NC, PIOD, P23, PIOD, P24, PIOD, P26, PIOC, P5 }, { .name = NULL }, }; /* configuration */ -char* at91rm9200_device; +static char* at91rm9200_device; /* interface variables */ |
From: <oh...@ma...> - 2009-04-21 07:42:21
|
Author: oharboe Date: 2009-04-21 07:42:18 +0200 (Tue, 21 Apr 2009) New Revision: 1486 Modified: trunk/src/helper/jim.c Log: Zach Welch <zw...@su...> fix unused return value warnings (2 of 4) Modified: trunk/src/helper/jim.c =================================================================== --- trunk/src/helper/jim.c 2009-04-21 05:39:36 UTC (rev 1485) +++ trunk/src/helper/jim.c 2009-04-21 05:42:18 UTC (rev 1486) @@ -133,7 +133,9 @@ buf[sizeof(buf)-1] = 0; #else char *buf; - vasprintf( &buf, fmt, ap ); + int result; + result = vasprintf( &buf, fmt, ap ); + if (result < 0) exit(-1); #endif return buf; } @@ -8953,7 +8955,7 @@ const int cwd_len=2048; char *cwd=malloc(cwd_len); Jim_SetResult(interp, Jim_NewEmptyStringObj(interp)); - getcwd( cwd, cwd_len ); + if (!getcwd( cwd, cwd_len )) strcpy(cwd, "unknown"); Jim_AppendStrings(interp, Jim_GetResult(interp), "Error loading script \"", filename, "\"", " cwd: ", cwd, |
From: <oh...@ma...> - 2009-04-21 07:39:42
|
Author: oharboe Date: 2009-04-21 07:39:36 +0200 (Tue, 21 Apr 2009) New Revision: 1485 Modified: trunk/src/flash/at91sam7.c trunk/src/flash/pic32mx.c Log: Zach Welch <zw...@su...> fix at91sam7 uninitialized variable warnings Modified: trunk/src/flash/at91sam7.c =================================================================== --- trunk/src/flash/at91sam7.c 2009-04-21 05:36:53 UTC (rev 1484) +++ trunk/src/flash/at91sam7.c 2009-04-21 05:39:36 UTC (rev 1485) @@ -322,11 +322,11 @@ u16 bnk, sec; u16 arch; u32 cidr; - u8 banks_num; - u16 num_nvmbits; - u16 sectors_num; - u16 pages_per_sector; - u16 page_size; + u8 banks_num = 0; + u16 num_nvmbits = 0; + u16 sectors_num = 0; + u16 pages_per_sector = 0; + u16 page_size = 0; u32 ext_freq; u32 bank_size; u32 base_address = 0; Modified: trunk/src/flash/pic32mx.c =================================================================== --- trunk/src/flash/pic32mx.c 2009-04-21 05:36:53 UTC (rev 1484) +++ trunk/src/flash/pic32mx.c 2009-04-21 05:39:36 UTC (rev 1485) @@ -611,7 +611,7 @@ mips32_common_t *mips32 = target->arch_info; mips_ejtag_t *ejtag_info = &mips32->ejtag_info; int i; - u16 num_pages; + u16 num_pages = 0; u32 device_id; int page_size; @@ -704,7 +704,7 @@ mips32_common_t *mips32 = target->arch_info; mips_ejtag_t *ejtag_info = &mips32->ejtag_info; u32 device_id; - int printed, i; + int printed = 0, i; device_id = ejtag_info->idcode; |
From: <oh...@ma...> - 2009-04-21 07:36:58
|
Author: oharboe Date: 2009-04-21 07:36:53 +0200 (Tue, 21 Apr 2009) New Revision: 1484 Modified: trunk/src/flash/str9x.c Log: Zach Welch <zw...@su...> fix str9x type-punned pointer Modified: trunk/src/flash/str9x.c =================================================================== --- trunk/src/flash/str9x.c 2009-04-21 05:35:51 UTC (rev 1483) +++ trunk/src/flash/str9x.c 2009-04-21 05:36:53 UTC (rev 1484) @@ -194,6 +194,7 @@ int i; u32 adr; u32 status = 0; + u16 hstatus = 0; if (bank->target->state != TARGET_HALTED) { @@ -212,10 +213,11 @@ { return retval; } - if ((retval=target_read_u16(target, adr, (u16*)&status))!=ERROR_OK) + if ((retval=target_read_u16(target, adr, &hstatus))!=ERROR_OK) { return retval; } + status = hstatus; } else { @@ -237,10 +239,11 @@ { return retval; } - if ((retval=target_read_u16(target, adr, (u16*)&status))!=ERROR_OK) + if ((retval=target_read_u16(target, adr, &hstatus))!=ERROR_OK) { return retval; } + status = hstatus; } /* read array command */ |
From: <oh...@ma...> - 2009-04-21 07:35:57
|
Author: oharboe Date: 2009-04-21 07:35:51 +0200 (Tue, 21 Apr 2009) New Revision: 1483 Modified: trunk/configure.in Log: Zach Welch <zw...@su...> add -Wformat-security (4 of 4) Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-04-21 05:35:10 UTC (rev 1482) +++ trunk/configure.in 2009-04-21 05:35:51 UTC (rev 1483) @@ -692,7 +692,7 @@ AC_PROG_RANLIB # set default gcc warnings -GCC_WARNINGS="-Wall -Wstrict-prototypes" +GCC_WARNINGS="-Wall -Wstrict-prototypes -Wformat-security" if test "${gcc_wextra}" = yes; then GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter" fi |
From: <oh...@ma...> - 2009-04-21 07:35:13
|
Author: oharboe Date: 2009-04-21 07:35:10 +0200 (Tue, 21 Apr 2009) New Revision: 1482 Modified: trunk/src/target/target.c Log: Zach Welch <zw...@su...>fix unused return value warnings (3 of 4) Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-04-21 05:33:47 UTC (rev 1481) +++ trunk/src/target/target.c 2009-04-21 05:35:10 UTC (rev 1482) @@ -2491,20 +2491,27 @@ return retval; } +static void writeData(FILE *f, const void *data, size_t len) +{ + size_t written = fwrite(data, len, 1, f); + if (written != len) + LOG_ERROR("failed to write %u bytes: %s", len, strerror(errno)); +} + static void writeLong(FILE *f, int l) { int i; for (i=0; i<4; i++) { char c=(l>>(i*8))&0xff; - fwrite(&c, 1, 1, f); + writeData(f, &c, 1); } } static void writeString(FILE *f, char *s) { - fwrite(s, 1, strlen(s), f); + writeData(f, s, strlen(s)); } /* Dump a gmon.out histogram file. */ @@ -2514,13 +2521,14 @@ FILE *f=fopen(filename, "w"); if (f==NULL) return; - fwrite("gmon", 1, 4, f); + writeString(f, "gmon"); writeLong(f, 0x00000001); /* Version */ writeLong(f, 0); /* padding */ writeLong(f, 0); /* padding */ writeLong(f, 0); /* padding */ - fwrite("", 1, 1, f); /* GMON_TAG_TIME_HIST */ + u8 zero = 0; /* GMON_TAG_TIME_HIST */ + writeData(f, &zero, 1); /* figure out bucket size */ u32 min=samples[0]; @@ -2569,9 +2577,7 @@ writeLong(f, 64000000); /* 64MHz */ writeString(f, "seconds"); for (i=0; i<(15-strlen("seconds")); i++) - { - fwrite("", 1, 1, f); /* padding */ - } + writeData(f, &zero, 1); writeString(f, "s"); /*append binary memory gmon.out profile_hist_data (profile_hist_data + profile_hist_hdr.hist_size) */ @@ -2591,7 +2597,7 @@ data[i*2+1]=(val>>8)&0xff; } free(buckets); - fwrite(data, 1, length*2, f); + writeData(f, data, length * 2); free(data); } else { |
From: <oh...@ma...> - 2009-04-21 07:33:54
|
Author: oharboe Date: 2009-04-21 07:33:47 +0200 (Tue, 21 Apr 2009) New Revision: 1481 Modified: trunk/src/helper/options.c trunk/src/jtag/arm-jtag-ew.c trunk/src/jtag/jlink.c trunk/src/jtag/vsllink.c trunk/src/target/target.c trunk/src/xsvf/xsvf.c Log: Zach Welch <zw...@su...> fix -Wformat-security warnings (1 of 4) Modified: trunk/src/helper/options.c =================================================================== --- trunk/src/helper/options.c 2009-04-21 05:31:18 UTC (rev 1480) +++ trunk/src/helper/options.c 2009-04-21 05:33:47 UTC (rev 1481) @@ -54,7 +54,7 @@ int configuration_output_handler(struct command_context_s *context, const char* line) { - LOG_USER_N(line); + LOG_USER_N("%s", line); return ERROR_OK; } Modified: trunk/src/jtag/arm-jtag-ew.c =================================================================== --- trunk/src/jtag/arm-jtag-ew.c 2009-04-21 05:31:18 UTC (rev 1480) +++ trunk/src/jtag/arm-jtag-ew.c 2009-04-21 05:33:47 UTC (rev 1481) @@ -896,7 +896,7 @@ snprintf(s, 4, " %02x", buffer[j]); strcat(line, s); } - LOG_DEBUG(line); + LOG_DEBUG("%s", line); } } #endif Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-21 05:31:18 UTC (rev 1480) +++ trunk/src/jtag/jlink.c 2009-04-21 05:33:47 UTC (rev 1481) @@ -537,7 +537,7 @@ if (result == len) { usb_in_buffer[result] = 0; - LOG_INFO((char *)usb_in_buffer); + LOG_INFO("%s", (char *)usb_in_buffer); return ERROR_OK; } } Modified: trunk/src/jtag/vsllink.c =================================================================== --- trunk/src/jtag/vsllink.c 2009-04-21 05:31:18 UTC (rev 1480) +++ trunk/src/jtag/vsllink.c 2009-04-21 05:33:47 UTC (rev 1481) @@ -470,7 +470,7 @@ vsllink_usb_in_buffer[result] = 0; VSLLINK_BufferSize = vsllink_usb_in_buffer[0] + (vsllink_usb_in_buffer[1] << 8); strncpy(version_str, (char *)vsllink_usb_in_buffer + 2, sizeof(version_str)); - LOG_INFO(version_str); + LOG_INFO("%s", version_str); // free the pre-alloc memroy free(vsllink_usb_in_buffer); @@ -1449,7 +1449,7 @@ snprintf(s, 4, " %02x", buffer[j]); strcat(line, s); } - LOG_DEBUG(line); + LOG_DEBUG("%s", line); } } #endif // _DEBUG_USB_COMMS_ Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-04-21 05:31:18 UTC (rev 1480) +++ trunk/src/target/target.c 2009-04-21 05:33:47 UTC (rev 1481) @@ -3961,7 +3961,7 @@ }; LOG_DEBUG("Target command params:"); - LOG_DEBUG(Jim_Debug_ArgvString( interp, argc, argv) ); + LOG_DEBUG("%s", Jim_Debug_ArgvString(interp, argc, argv)); cmd_ctx = Jim_GetAssocData( interp, "context" ); Modified: trunk/src/xsvf/xsvf.c =================================================================== --- trunk/src/xsvf/xsvf.c 2009-04-21 05:31:18 UTC (rev 1480) +++ trunk/src/xsvf/xsvf.c 2009-04-21 05:33:47 UTC (rev 1481) @@ -761,7 +761,7 @@ comment[sizeof(comment)-1] = 0; /* regardless, terminate */ if (verbose) - LOG_USER(comment); + LOG_USER("%s", comment); } break; |
From: <oh...@ma...> - 2009-04-21 07:31:25
|
Author: oharboe Date: 2009-04-21 07:31:18 +0200 (Tue, 21 Apr 2009) New Revision: 1480 Modified: trunk/AUTHORS trunk/src/flash/cfi.c trunk/src/flash/cfi.h trunk/src/flash/non_cfi.c trunk/src/flash/non_cfi.h Log: Michael Schwingen <rin...@di...> add non-CFI SST flashs Modified: trunk/AUTHORS =================================================================== --- trunk/AUTHORS 2009-04-21 05:29:23 UTC (rev 1479) +++ trunk/AUTHORS 2009-04-21 05:31:18 UTC (rev 1480) @@ -5,3 +5,4 @@ Carsten Schlote <sc...@va...> Øyvind Harboe <oyv...@zy...> Duane Ellis <op...@du...> +Michael Schwingen <mi...@sc...> Modified: trunk/src/flash/cfi.c =================================================================== --- trunk/src/flash/cfi.c 2009-04-21 05:29:23 UTC (rev 1479) +++ trunk/src/flash/cfi.c 2009-04-21 05:31:18 UTC (rev 1480) @@ -296,13 +296,14 @@ int cfi_spansion_wait_status_busy(flash_bank_t *bank, int timeout) { u8 status, oldstatus; + cfi_flash_bank_t *cfi_info = bank->driver_priv; oldstatus = cfi_get_u8(bank, 0, 0x0); do { status = cfi_get_u8(bank, 0, 0x0); if ((status ^ oldstatus) & 0x40) { - if (status & 0x20) { + if (status & cfi_info->status_poll_mask & 0x20) { oldstatus = cfi_get_u8(bank, 0, 0x0); status = cfi_get_u8(bank, 0, 0x0); if ((status ^ oldstatus) & 0x40) { @@ -313,7 +314,7 @@ return(ERROR_OK); } } - } else { + } else { /* no toggle: finished, OK */ LOG_DEBUG("status: 0x%x", status); return(ERROR_OK); } @@ -2283,6 +2284,7 @@ break; /* AMD/Spansion, Atmel, ... command set */ case 0x0002: + cfi_info->status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7; /* default for all CFI flashs */ cfi_read_0002_pri_ext(bank); break; default: @@ -2303,7 +2305,7 @@ { return retval; } - } + } /* end CFI case */ /* apply fixups depending on the primary command set */ switch(cfi_info->pri_id) Modified: trunk/src/flash/cfi.h =================================================================== --- trunk/src/flash/cfi.h 2009-04-21 05:29:23 UTC (rev 1479) +++ trunk/src/flash/cfi.h 2009-04-21 05:31:18 UTC (rev 1480) @@ -23,11 +23,13 @@ #include "flash.h" #include "target.h" +#define CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7 0xE0 /* DQ5..DQ7 */ +#define CFI_STATUS_POLL_MASK_DQ6_DQ7 0xC0 /* DQ6..DQ7 */ + typedef struct cfi_flash_bank_s { working_area_t *write_algorithm; - int x16_as_x8; int jedec_probe; int not_cfi; @@ -58,6 +60,8 @@ u8 block_erase_timeout_max; u8 chip_erase_timeout_max; + u8 status_poll_mask; + /* flash geometry */ u32 dev_size; u16 interface_desc; Modified: trunk/src/flash/non_cfi.c =================================================================== --- trunk/src/flash/non_cfi.c 2009-04-21 05:29:23 UTC (rev 1479) +++ trunk/src/flash/non_cfi.c 2009-04-21 05:31:18 UTC (rev 1480) @@ -44,6 +44,7 @@ .dev_size = 64*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 1, .erase_region_info = { @@ -57,6 +58,7 @@ .dev_size = 128*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 1, .erase_region_info = { @@ -70,6 +72,7 @@ .dev_size = 256*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 1, .erase_region_info = { @@ -83,6 +86,7 @@ .dev_size = 512*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 1, .erase_region_info = { @@ -96,6 +100,7 @@ .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 1, .erase_region_info = { @@ -109,6 +114,7 @@ .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -125,6 +131,7 @@ .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -134,13 +141,102 @@ ERASE_REGION( 1, 16*KB) } }, + + /* SST 39VF* do not support DQ5 status polling - this currently is + only supported by the host algorithm, not by the target code using + the work area. */ { + .mfr = CFI_MFR_SST, + .id = 0x2782, /* SST39xF160 */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(512, 4*KB) + } + }, + { + .mfr = CFI_MFR_SST, + .id = 0x2783, /* SST39VF320 */ + .pri_id = 0x02, + .dev_size = 4*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(1024, 4*KB) + } + }, + { + .mfr = CFI_MFR_SST, + .id = 0x234b, /* SST39VF1601 */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(512, 4*KB) + } + }, + { + .mfr = CFI_MFR_SST, + .id = 0x234a, /* SST39VF1602 */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(512, 4*KB) + } + }, + { + .mfr = CFI_MFR_SST, + .id = 0x235b, /* SST39VF3201 */ + .pri_id = 0x02, + .dev_size = 4*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(1024, 4*KB) + } + }, + { + .mfr = CFI_MFR_SST, + .id = 0x235a, /* SST39VF3202 */ + .pri_id = 0x02, + .dev_size = 4*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(1024, 4*KB) + } + }, + { .mfr = CFI_MFR_AMD, .id = 0x22ab, /* AM29F400BB */ .pri_id = 0x02, .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -157,6 +253,7 @@ .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -173,6 +270,7 @@ .dev_size = 1*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -189,6 +287,7 @@ .dev_size = 1*MB, .interface_desc = 0x2, .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -205,6 +304,7 @@ .dev_size = 1*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -222,6 +322,7 @@ .dev_size = 2*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -238,6 +339,7 @@ .dev_size = 2*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -248,25 +350,13 @@ } }, { - .mfr = CFI_MFR_SST, - .id = 0x2782, /* SST39xF160 */ - .pri_id = 0x02, - .dev_size = 2*MB, - .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ - .max_buf_write_size = 0x0, - .num_erase_regions = 1, - .erase_region_info = - { - ERASE_REGION(512, 4*KB) - } - }, - { .mfr = CFI_MFR_ATMEL, .id = 0x00c0, /* Atmel 49BV1614 */ .pri_id = 0x02, .dev_size = 2*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 3, .erase_region_info = { @@ -282,6 +372,7 @@ .dev_size = 2*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 3, .erase_region_info = { @@ -297,6 +388,7 @@ .dev_size = 1*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, + .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7, .num_erase_regions = 4, .erase_region_info = { @@ -358,6 +450,7 @@ cfi_info->interface_desc = non_cfi->interface_desc; cfi_info->max_buf_write_size = non_cfi->max_buf_write_size; + cfi_info->status_poll_mask = non_cfi->status_poll_mask; cfi_info->num_erase_regions = non_cfi->num_erase_regions; cfi_info->erase_region_info = non_cfi->erase_region_info; cfi_info->dev_size = non_cfi->dev_size; Modified: trunk/src/flash/non_cfi.h =================================================================== --- trunk/src/flash/non_cfi.h 2009-04-21 05:29:23 UTC (rev 1479) +++ trunk/src/flash/non_cfi.h 2009-04-21 05:31:18 UTC (rev 1480) @@ -32,6 +32,7 @@ u16 max_buf_write_size; u8 num_erase_regions; u32 erase_region_info[6]; + u8 status_poll_mask; } non_cfi_t; extern non_cfi_t non_cfi_flashes[]; |
From: <oh...@ma...> - 2009-04-21 07:29:46
|
Author: oharboe Date: 2009-04-21 07:29:23 +0200 (Tue, 21 Apr 2009) New Revision: 1479 Modified: trunk/src/jtag/amt_jtagaccel.c trunk/src/jtag/arm-jtag-ew.c trunk/src/jtag/at91rm9200.c trunk/src/jtag/bitbang.c trunk/src/jtag/bitq.c trunk/src/jtag/dummy.c trunk/src/jtag/ep93xx.c trunk/src/jtag/ft2232.c trunk/src/jtag/gw16012.c trunk/src/jtag/jlink.c trunk/src/jtag/jtag.c trunk/src/jtag/parport.c trunk/src/jtag/presto.c trunk/src/jtag/usbprog.c trunk/src/jtag/vsllink.c Log: Zach Welch <zw...@su...> use static keyword in jtag layer and drivers Modified: trunk/src/jtag/amt_jtagaccel.c =================================================================== --- trunk/src/jtag/amt_jtagaccel.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/amt_jtagaccel.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -56,7 +56,7 @@ #include "log.h" /* configuration */ -u16 amt_jtagaccel_port; +static u16 amt_jtagaccel_port; /* interface variables */ @@ -68,28 +68,33 @@ #if PARPORT_USE_PPDEV == 1 static int device_handle; -int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR ; -int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA ; + +static int addr_mode = IEEE1284_MODE_EPP | IEEE1284_ADDR ; #define AMT_AW(val) do { ioctl(device_handle, PPSETMODE, &addr_mode); write(device_handle, &val, 1); } while (0) #define AMT_AR(val) do { ioctl(device_handle, PPSETMODE, &addr_mode); read(device_handle, &val, 1); } while (0) + +static int data_mode = IEEE1284_MODE_EPP | IEEE1284_DATA ; #define AMT_DW(val) do { ioctl(device_handle, PPSETMODE, &data_mode); write(device_handle, &val, 1); } while (0) #define AMT_DR(val) do { ioctl(device_handle, PPSETMODE, &data_mode); read(device_handle, &val, 1); } while (0) + #else + #define AMT_AW(val) do { outb(val, amt_jtagaccel_port + 3); } while (0) #define AMT_AR(val) do { val = inb(amt_jtagaccel_port + 3); } while (0) #define AMT_DW(val) do { outb(val, amt_jtagaccel_port + 4); } while (0) #define AMT_DR(val) do { val = inb(amt_jtagaccel_port + 4); } while (0) -#endif -int amt_jtagaccel_execute_queue(void); -int amt_jtagaccel_register_commands(struct command_context_s *cmd_ctx); -int amt_jtagaccel_speed(int speed); -int amt_jtagaccel_init(void); -int amt_jtagaccel_quit(void); +#endif // PARPORT_USE_PPDEV -int amt_jtagaccel_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int amt_jtagaccel_handle_rtck_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int amt_jtagaccel_execute_queue(void); +static int amt_jtagaccel_register_commands(struct command_context_s *cmd_ctx); +static int amt_jtagaccel_speed(int speed); +static int amt_jtagaccel_init(void); +static int amt_jtagaccel_quit(void); +static int amt_jtagaccel_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int amt_jtagaccel_handle_rtck_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); + /* tap_move[i][j]: tap movement command to go from state i to state j * 0: Test-Logic-Reset * 1: Run-Test/Idle @@ -98,7 +103,7 @@ * 4: Shift-IR * 5: Pause-IR */ -u8 amt_jtagaccel_tap_move[6][6][2] = +static u8 amt_jtagaccel_tap_move[6][6][2] = { /* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */ {{0x1f, 0x00}, {0x0f, 0x00}, {0x8a, 0x04}, {0x0a, 0x00}, {0x06, 0x00}, {0x96, 0x00}}, /* RESET */ @@ -122,7 +127,7 @@ .quit = amt_jtagaccel_quit, }; -int amt_jtagaccel_register_commands(struct command_context_s *cmd_ctx) +static int amt_jtagaccel_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "parport_port", amt_jtagaccel_handle_parport_port_command, COMMAND_CONFIG, NULL); @@ -132,7 +137,7 @@ return ERROR_OK; } -void amt_jtagaccel_reset(int trst, int srst) +static void amt_jtagaccel_reset(int trst, int srst) { if (trst == 1) aw_control_rst |= 0x4; @@ -147,7 +152,7 @@ AMT_AW(aw_control_rst); } -int amt_jtagaccel_speed(int speed) +static int amt_jtagaccel_speed(int speed) { aw_control_baudrate &= 0xf0; aw_control_baudrate |= speed & 0x0f; @@ -156,7 +161,7 @@ return ERROR_OK; } -void amt_jtagaccel_end_state(tap_state_t state) +static void amt_jtagaccel_end_state(tap_state_t state) { if (tap_is_state_stable(state)) tap_set_end_state(state); @@ -167,7 +172,7 @@ } } -void amt_wait_scan_busy(void) +static void amt_wait_scan_busy(void) { int timeout = 4096; u8 ar_status; @@ -183,7 +188,7 @@ } } -void amt_jtagaccel_state_move(void) +static void amt_jtagaccel_state_move(void) { u8 aw_scan_tms_5; u8 tms_scan[2]; @@ -210,7 +215,7 @@ tap_set_state(end_state); } -void amt_jtagaccel_runtest(int num_cycles) +static void amt_jtagaccel_runtest(int num_cycles) { int i = 0; u8 aw_scan_tms_5; @@ -243,7 +248,7 @@ amt_jtagaccel_state_move(); } -void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) +static void amt_jtagaccel_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) { int bits_left = scan_size; int bit_count = 0; @@ -325,7 +330,7 @@ tap_set_state(tap_get_end_state()); } -int amt_jtagaccel_execute_queue(void) +static int amt_jtagaccel_execute_queue(void) { jtag_command_t *cmd = jtag_command_queue; /* currently processed command */ int scan_size; @@ -431,7 +436,7 @@ } #endif -int amt_jtagaccel_init(void) +static int amt_jtagaccel_init(void) { #if PARPORT_USE_PPDEV == 1 char buffer[256]; @@ -536,13 +541,13 @@ return ERROR_OK; } -int amt_jtagaccel_quit(void) +static int amt_jtagaccel_quit(void) { return ERROR_OK; } -int amt_jtagaccel_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int amt_jtagaccel_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 0) return ERROR_OK; @@ -554,7 +559,7 @@ return ERROR_OK; } -int amt_jtagaccel_handle_rtck_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int amt_jtagaccel_handle_rtck_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 0) { Modified: trunk/src/jtag/arm-jtag-ew.c =================================================================== --- trunk/src/jtag/arm-jtag-ew.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/arm-jtag-ew.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -77,32 +77,32 @@ static u8 usb_out_buffer[ARMJTAGEW_OUT_BUFFER_SIZE]; /* External interface functions */ -int armjtagew_execute_queue(void); -int armjtagew_speed(int speed); -int armjtagew_khz(int khz, int *jtag_speed); -int armjtagew_register_commands(struct command_context_s *cmd_ctx); -int armjtagew_init(void); -int armjtagew_quit(void); +static int armjtagew_execute_queue(void); +static int armjtagew_speed(int speed); +static int armjtagew_khz(int khz, int *jtag_speed); +static int armjtagew_register_commands(struct command_context_s *cmd_ctx); +static int armjtagew_init(void); +static int armjtagew_quit(void); /* CLI command handler functions */ -int armjtagew_handle_armjtagew_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int armjtagew_handle_armjtagew_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); /* Queue command functions */ -void armjtagew_end_state(tap_state_t state); -void armjtagew_state_move(void); -void armjtagew_path_move(int num_states, tap_state_t *path); -void armjtagew_runtest(int num_cycles); -void armjtagew_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); -void armjtagew_reset(int trst, int srst); -void armjtagew_simple_command(u8 command); -int armjtagew_get_status(void); +static void armjtagew_end_state(tap_state_t state); +static void armjtagew_state_move(void); +static void armjtagew_path_move(int num_states, tap_state_t *path); +static void armjtagew_runtest(int num_cycles); +static void armjtagew_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void armjtagew_reset(int trst, int srst); +//static void armjtagew_simple_command(u8 command); +static int armjtagew_get_status(void); /* tap buffer functions */ -void armjtagew_tap_init(void); -int armjtagew_tap_execute(void); -void armjtagew_tap_ensure_space(int scans, int bits); -void armjtagew_tap_append_step(int tms, int tdi); -void armjtagew_tap_append_scan(int length, u8 *buffer, scan_command_t *command); +static void armjtagew_tap_init(void); +static int armjtagew_tap_execute(void); +static void armjtagew_tap_ensure_space(int scans, int bits); +static void armjtagew_tap_append_step(int tms, int tdi); +static void armjtagew_tap_append_scan(int length, u8 *buffer, scan_command_t *command); /* ARM-JTAG-EW lowlevel functions */ typedef struct armjtagew_jtag @@ -110,20 +110,20 @@ struct usb_dev_handle* usb_handle; } armjtagew_jtag_t; -armjtagew_jtag_t *armjtagew_usb_open(void); -void armjtagew_usb_close(armjtagew_jtag_t *armjtagew_jtag); -int armjtagew_usb_message(armjtagew_jtag_t *armjtagew_jtag, int out_length, int in_length); -int armjtagew_usb_write(armjtagew_jtag_t *armjtagew_jtag, int out_length); -int armjtagew_usb_read(armjtagew_jtag_t *armjtagew_jtag, int exp_in_length); +static armjtagew_jtag_t *armjtagew_usb_open(void); +static void armjtagew_usb_close(armjtagew_jtag_t *armjtagew_jtag); +static int armjtagew_usb_message(armjtagew_jtag_t *armjtagew_jtag, int out_length, int in_length); +static int armjtagew_usb_write(armjtagew_jtag_t *armjtagew_jtag, int out_length); +static int armjtagew_usb_read(armjtagew_jtag_t *armjtagew_jtag, int exp_in_length); /* helper functions */ -int armjtagew_get_version_info(void); +static int armjtagew_get_version_info(void); #ifdef _DEBUG_USB_COMMS_ -void armjtagew_debug_buffer(u8 *buffer, int length); +static void armjtagew_debug_buffer(u8 *buffer, int length); #endif -armjtagew_jtag_t* armjtagew_jtag_handle; +static armjtagew_jtag_t* armjtagew_jtag_handle; @@ -142,7 +142,7 @@ }; -int armjtagew_execute_queue(void) +static int armjtagew_execute_queue(void) { jtag_command_t *cmd = jtag_command_queue; int scan_size; @@ -239,7 +239,7 @@ /* Sets speed in kHz. */ -int armjtagew_speed(int speed) +static int armjtagew_speed(int speed) { int result; int speed_real; @@ -273,21 +273,21 @@ } -int armjtagew_khz(int khz, int *jtag_speed) +static int armjtagew_khz(int khz, int *jtag_speed) { *jtag_speed = khz; return ERROR_OK; } -int armjtagew_register_commands(struct command_context_s *cmd_ctx) +static int armjtagew_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "armjtagew_info", armjtagew_handle_armjtagew_info_command, COMMAND_EXEC, "query armjtagew info"); return ERROR_OK; } -int armjtagew_init(void) +static int armjtagew_init(void) { int check_cnt; @@ -325,7 +325,7 @@ return ERROR_OK; } -int armjtagew_quit(void) +static int armjtagew_quit(void) { armjtagew_usb_close(armjtagew_jtag_handle); return ERROR_OK; @@ -334,7 +334,7 @@ /***************************************************************************/ /* Queue command implementations */ -void armjtagew_end_state(tap_state_t state) +static void armjtagew_end_state(tap_state_t state) { if (tap_is_state_stable(state)) { @@ -348,7 +348,7 @@ } /* Goes to the end state. */ -void armjtagew_state_move(void) +static void armjtagew_state_move(void) { int i; int tms = 0; @@ -363,7 +363,7 @@ tap_set_state(tap_get_end_state()); } -void armjtagew_path_move(int num_states, tap_state_t *path) +static void armjtagew_path_move(int num_states, tap_state_t *path) { int i; @@ -394,7 +394,7 @@ tap_set_end_state(tap_get_state()); } -void armjtagew_runtest(int num_cycles) +static void armjtagew_runtest(int num_cycles) { int i; @@ -421,7 +421,7 @@ } } -void armjtagew_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +static void armjtagew_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) { tap_state_t saved_end_state; @@ -449,7 +449,7 @@ } } -void armjtagew_reset(int trst, int srst) +static void armjtagew_reset(int trst, int srst) { const u8 trst_mask = (1u<<5); const u8 srst_mask = (1u<<6); @@ -498,7 +498,7 @@ } -int armjtagew_get_status(void) +static int armjtagew_get_status(void) { int result; @@ -530,7 +530,7 @@ return ERROR_OK; } -int armjtagew_get_version_info(void) +static int armjtagew_get_version_info(void) { int result; char sn[16]; @@ -559,7 +559,7 @@ return ERROR_OK; } -int armjtagew_handle_armjtagew_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int armjtagew_handle_armjtagew_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (armjtagew_get_version_info() == ERROR_OK) { @@ -596,13 +596,13 @@ static int last_tms; -void armjtagew_tap_init(void) +static void armjtagew_tap_init(void) { tap_length = 0; pending_scan_results_length = 0; } -void armjtagew_tap_ensure_space(int scans, int bits) +static void armjtagew_tap_ensure_space(int scans, int bits) { int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; int available_bits = ARMJTAGEW_TAP_BUFFER_SIZE * 8 - tap_length; @@ -613,7 +613,7 @@ } } -void armjtagew_tap_append_step(int tms, int tdi) +static void armjtagew_tap_append_step(int tms, int tdi) { last_tms = tms; int index = tap_length / 8; @@ -668,7 +668,7 @@ /* Pad and send a tap sequence to the device, and receive the answer. * For the purpose of padding we assume that we are in idle or pause state. */ -int armjtagew_tap_execute(void) +static int armjtagew_tap_execute(void) { int byte_length; int tms_offset; @@ -764,7 +764,7 @@ /*****************************************************************************/ /* JLink USB low-level functions */ -armjtagew_jtag_t* armjtagew_usb_open() +static armjtagew_jtag_t* armjtagew_usb_open() { struct usb_bus *busses; struct usb_bus *bus; @@ -812,14 +812,14 @@ return NULL; } -void armjtagew_usb_close(armjtagew_jtag_t *armjtagew_jtag) +static void armjtagew_usb_close(armjtagew_jtag_t *armjtagew_jtag) { usb_close(armjtagew_jtag->usb_handle); free(armjtagew_jtag); } /* Send a message and receive the reply. */ -int armjtagew_usb_message(armjtagew_jtag_t *armjtagew_jtag, int out_length, int in_length) +static int armjtagew_usb_message(armjtagew_jtag_t *armjtagew_jtag, int out_length, int in_length) { int result; @@ -842,7 +842,7 @@ } /* Write data from out_buffer to USB. */ -int armjtagew_usb_write(armjtagew_jtag_t *armjtagew_jtag, int out_length) +static int armjtagew_usb_write(armjtagew_jtag_t *armjtagew_jtag, int out_length) { int result; @@ -864,7 +864,7 @@ } /* Read data from USB into in_buffer. */ -int armjtagew_usb_read(armjtagew_jtag_t *armjtagew_jtag, int exp_in_length) +static int armjtagew_usb_read(armjtagew_jtag_t *armjtagew_jtag, int exp_in_length) { int result = usb_bulk_read(armjtagew_jtag->usb_handle, ARMJTAGEW_EPT_BULK_IN, \ (char*)usb_in_buffer, exp_in_length, ARMJTAGEW_USB_TIMEOUT); @@ -881,7 +881,7 @@ #ifdef _DEBUG_USB_COMMS_ #define BYTES_PER_LINE 16 -void armjtagew_debug_buffer(u8 *buffer, int length) +static void armjtagew_debug_buffer(u8 *buffer, int length) { char line[81]; char s[4]; Modified: trunk/src/jtag/at91rm9200.c =================================================================== --- trunk/src/jtag/at91rm9200.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/at91rm9200.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -119,14 +119,14 @@ /* low level command set */ -int at91rm9200_read(void); -void at91rm9200_write(int tck, int tms, int tdi); -void at91rm9200_reset(int trst, int srst); +static int at91rm9200_read(void); +static void at91rm9200_write(int tck, int tms, int tdi); +static void at91rm9200_reset(int trst, int srst); -int at91rm9200_speed(int speed); -int at91rm9200_register_commands(struct command_context_s *cmd_ctx); -int at91rm9200_init(void); -int at91rm9200_quit(void); +static int at91rm9200_speed(int speed); +static int at91rm9200_register_commands(struct command_context_s *cmd_ctx); +static int at91rm9200_init(void); +static int at91rm9200_quit(void); jtag_interface_t at91rm9200_interface = { @@ -140,7 +140,7 @@ .quit = at91rm9200_quit, }; -bitbang_interface_t at91rm9200_bitbang = +static bitbang_interface_t at91rm9200_bitbang = { .read = at91rm9200_read, .write = at91rm9200_write, @@ -148,12 +148,12 @@ .blink = 0 }; -int at91rm9200_read(void) +static int at91rm9200_read(void) { return (pio_base[device->TDO_PIO + PIO_PDSR] & device->TDO_MASK) != 0; } -void at91rm9200_write(int tck, int tms, int tdi) +static void at91rm9200_write(int tck, int tms, int tdi) { if (tck) pio_base[device->TCK_PIO + PIO_SODR] = device->TCK_MASK; @@ -172,7 +172,7 @@ } /* (1) assert or (0) deassert reset lines */ -void at91rm9200_reset(int trst, int srst) +static void at91rm9200_reset(int trst, int srst) { if (trst == 0) pio_base[device->TRST_PIO + PIO_SODR] = device->TRST_MASK; @@ -185,13 +185,13 @@ pio_base[device->SRST_PIO + PIO_CODR] = device->SRST_MASK; } -int at91rm9200_speed(int speed) +static int at91rm9200_speed(int speed) { return ERROR_OK; } -int at91rm9200_handle_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int at91rm9200_handle_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 0) return ERROR_OK; @@ -206,14 +206,14 @@ return ERROR_OK; } -int at91rm9200_register_commands(struct command_context_s *cmd_ctx) +static int at91rm9200_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "at91rm9200_device", at91rm9200_handle_device_command, COMMAND_CONFIG, NULL); return ERROR_OK; } -int at91rm9200_init(void) +static int at91rm9200_init(void) { struct device_t *cur_device; @@ -284,7 +284,7 @@ return ERROR_OK; } -int at91rm9200_quit(void) +static int at91rm9200_quit(void) { return ERROR_OK; Modified: trunk/src/jtag/bitbang.c =================================================================== --- trunk/src/jtag/bitbang.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/bitbang.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -71,12 +71,9 @@ */ #define CLOCK_IDLE() 0 -int bitbang_execute_queue(void); - /* The bitbang driver leaves the TCK 0 when in idle */ - -void bitbang_end_state(tap_state_t state) +static void bitbang_end_state(tap_state_t state) { if (tap_is_state_stable(state)) tap_set_end_state(state); @@ -87,7 +84,7 @@ } } -void bitbang_state_move(void) +static void bitbang_state_move(void) { int i=0, tms=0; u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); @@ -103,7 +100,7 @@ tap_set_state(tap_get_end_state()); } -void bitbang_path_move(pathmove_command_t *cmd) +static void bitbang_path_move(pathmove_command_t *cmd) { int num_states = cmd->num_states; int state_count; @@ -139,7 +136,7 @@ tap_set_end_state(tap_get_state()); } -void bitbang_runtest(int num_cycles) +static void bitbang_runtest(int num_cycles) { int i; @@ -182,7 +179,7 @@ -void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) +static void bitbang_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) { tap_state_t saved_end_state = tap_get_end_state(); int bit_cnt; Modified: trunk/src/jtag/bitq.c =================================================================== --- trunk/src/jtag/bitq.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/bitq.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -36,10 +36,10 @@ bitq_interface_t* bitq_interface; /* low level bit queue interface */ -bitq_state_t bitq_in_state; /* state of input queue */ +static bitq_state_t bitq_in_state; /* state of input queue */ -u8* bitq_in_buffer; /* buffer dynamically reallocated as needed */ -int bitq_in_bufsize = 32; /* min. buffer size */ +static u8* bitq_in_buffer; /* buffer dynamically reallocated as needed */ +static int bitq_in_bufsize = 32; /* min. buffer size */ /* * input queue processing does not use jtag_read_buffer() to avoid unnecessary overhead Modified: trunk/src/jtag/dummy.c =================================================================== --- trunk/src/jtag/dummy.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/dummy.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -37,10 +37,10 @@ static u32 dummy_data; -int dummy_speed(int speed); -int dummy_register_commands(struct command_context_s *cmd_ctx); -int dummy_init(void); -int dummy_quit(void); +static int dummy_speed(int speed); +static int dummy_register_commands(struct command_context_s *cmd_ctx); +static int dummy_init(void); +static int dummy_quit(void); static int dummy_khz(int khz, int *jtag_speed); static int dummy_speed_div(int speed, int *khz); @@ -63,12 +63,12 @@ .quit = dummy_quit, }; -int dummy_read(void); -void dummy_write(int tck, int tms, int tdi); -void dummy_reset(int trst, int srst); -void dummy_led(int on); +static int dummy_read(void); +static void dummy_write(int tck, int tms, int tdi); +static void dummy_reset(int trst, int srst); +static void dummy_led(int on); -bitbang_interface_t dummy_bitbang = +static bitbang_interface_t dummy_bitbang = { .read = dummy_read, .write = dummy_write, @@ -76,7 +76,7 @@ .blink = dummy_led }; -int dummy_read(void) +static int dummy_read(void) { int data = 1 & dummy_data; dummy_data = (dummy_data >> 1) | (1<<31); @@ -84,7 +84,7 @@ } -void dummy_write(int tck, int tms, int tdi) +static void dummy_write(int tck, int tms, int tdi) { /* TAP standard: "state transitions occur on rising edge of clock" */ if( tck != dummy_clock ) @@ -121,7 +121,7 @@ } } -void dummy_reset(int trst, int srst) +static void dummy_reset(int trst, int srst) { dummy_clock = 0; @@ -158,29 +158,29 @@ return ERROR_OK; } -int dummy_speed(int speed) +static int dummy_speed(int speed) { return ERROR_OK; } -int dummy_register_commands(struct command_context_s *cmd_ctx) +static int dummy_register_commands(struct command_context_s *cmd_ctx) { return ERROR_OK; } -int dummy_init(void) +static int dummy_init(void) { bitbang_interface = &dummy_bitbang; return ERROR_OK; } -int dummy_quit(void) +static int dummy_quit(void) { return ERROR_OK; } -void dummy_led(int on) +static void dummy_led(int on) { } Modified: trunk/src/jtag/ep93xx.c =================================================================== --- trunk/src/jtag/ep93xx.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/ep93xx.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -50,14 +50,14 @@ /* low level command set */ -int ep93xx_read(void); -void ep93xx_write(int tck, int tms, int tdi); -void ep93xx_reset(int trst, int srst); +static int ep93xx_read(void); +static void ep93xx_write(int tck, int tms, int tdi); +static void ep93xx_reset(int trst, int srst); -int ep93xx_speed(int speed); -int ep93xx_register_commands(struct command_context_s *cmd_ctx); -int ep93xx_init(void); -int ep93xx_quit(void); +static int ep93xx_speed(int speed); +static int ep93xx_register_commands(struct command_context_s *cmd_ctx); +static int ep93xx_init(void); +static int ep93xx_quit(void); struct timespec ep93xx_zzzz; @@ -73,7 +73,7 @@ .quit = ep93xx_quit, }; -bitbang_interface_t ep93xx_bitbang = +static bitbang_interface_t ep93xx_bitbang = { .read = ep93xx_read, .write = ep93xx_write, @@ -81,12 +81,12 @@ .blink = 0, }; -int ep93xx_read(void) +static int ep93xx_read(void) { return !!(*gpio_data_register & TDO_BIT); } -void ep93xx_write(int tck, int tms, int tdi) +static void ep93xx_write(int tck, int tms, int tdi) { if (tck) output_value |= TCK_BIT; @@ -108,7 +108,7 @@ } /* (1) assert or (0) deassert reset lines */ -void ep93xx_reset(int trst, int srst) +static void ep93xx_reset(int trst, int srst) { if (trst == 0) output_value |= TRST_BIT; @@ -124,13 +124,13 @@ nanosleep(&ep93xx_zzzz, NULL); } -int ep93xx_speed(int speed) +static int ep93xx_speed(int speed) { return ERROR_OK; } -int ep93xx_register_commands(struct command_context_s *cmd_ctx) +static int ep93xx_register_commands(struct command_context_s *cmd_ctx) { return ERROR_OK; @@ -157,7 +157,7 @@ return ERROR_OK; } -int ep93xx_init(void) +static int ep93xx_init(void) { int ret; @@ -231,7 +231,7 @@ return ERROR_OK; } -int ep93xx_quit(void) +static int ep93xx_quit(void) { return ERROR_OK; Modified: trunk/src/jtag/ft2232.c =================================================================== --- trunk/src/jtag/ft2232.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/ft2232.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -70,20 +70,20 @@ #define _DEBUG_USB_COMMS_ #endif -int ft2232_execute_queue(void); +static int ft2232_execute_queue(void); -int ft2232_speed(int speed); -int ft2232_speed_div(int speed, int* khz); -int ft2232_khz(int khz, int* jtag_speed); -int ft2232_register_commands(struct command_context_s* cmd_ctx); -int ft2232_init(void); -int ft2232_quit(void); +static int ft2232_speed(int speed); +static int ft2232_speed_div(int speed, int* khz); +static int ft2232_khz(int khz, int* jtag_speed); +static int ft2232_register_commands(struct command_context_s* cmd_ctx); +static int ft2232_init(void); +static int ft2232_quit(void); -int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); -int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); -int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); -int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); -int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); +static int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); +static int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); +static int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); +static int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); +static int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc); /** @@ -97,11 +97,11 @@ static int ft2232_stableclocks(int num_cycles, jtag_command_t* cmd); -char * ft2232_device_desc_A = NULL; -char* ft2232_device_desc = NULL; -char* ft2232_serial = NULL; -char* ft2232_layout = NULL; -unsigned char ft2232_latency = 2; +static char * ft2232_device_desc_A = NULL; +static char* ft2232_device_desc = NULL; +static char* ft2232_serial = NULL; +static char* ft2232_layout = NULL; +static unsigned char ft2232_latency = 2; #define MAX_USB_IDS 8 /* vid = pid = 0 marks the end of the list */ @@ -117,31 +117,31 @@ } ft2232_layout_t; /* init procedures for supported layouts */ -int usbjtag_init(void); -int jtagkey_init(void); -int olimex_jtag_init(void); -int flyswatter_init(void); -int turtle_init(void); -int comstick_init(void); -int stm32stick_init(void); -int axm0432_jtag_init(void); -int sheevaplug_init(void); +static int usbjtag_init(void); +static int jtagkey_init(void); +static int olimex_jtag_init(void); +static int flyswatter_init(void); +static int turtle_init(void); +static int comstick_init(void); +static int stm32stick_init(void); +static int axm0432_jtag_init(void); +static int sheevaplug_init(void); /* reset procedures for supported layouts */ -void usbjtag_reset(int trst, int srst); -void jtagkey_reset(int trst, int srst); -void olimex_jtag_reset(int trst, int srst); -void flyswatter_reset(int trst, int srst); -void turtle_reset(int trst, int srst); -void comstick_reset(int trst, int srst); -void stm32stick_reset(int trst, int srst); -void axm0432_jtag_reset(int trst, int srst); -void sheevaplug_reset(int trst, int srst); +static void usbjtag_reset(int trst, int srst); +static void jtagkey_reset(int trst, int srst); +static void olimex_jtag_reset(int trst, int srst); +static void flyswatter_reset(int trst, int srst); +static void turtle_reset(int trst, int srst); +static void comstick_reset(int trst, int srst); +static void stm32stick_reset(int trst, int srst); +static void axm0432_jtag_reset(int trst, int srst); +static void sheevaplug_reset(int trst, int srst); /* blink procedures for layouts that support a blinking led */ -void olimex_jtag_blink(void); -void flyswatter_jtag_blink(void); -void turtle_jtag_blink(void); +static void olimex_jtag_blink(void); +static void flyswatter_jtag_blink(void); +static void turtle_jtag_blink(void); ft2232_layout_t ft2232_layouts[] = { @@ -200,7 +200,7 @@ .quit = ft2232_quit, }; -int ft2232_write(u8* buf, int size, u32* bytes_written) +static int ft2232_write(u8* buf, int size, u32* bytes_written) { #if BUILD_FT2232_FTD2XX == 1 FT_STATUS status; @@ -233,7 +233,7 @@ } -int ft2232_read(u8* buf, u32 size, u32* bytes_read) +static int ft2232_read(u8* buf, u32 size, u32* bytes_read) { #if BUILD_FT2232_FTD2XX == 1 DWORD dw_bytes_read; @@ -281,7 +281,7 @@ } -int ft2232_speed(int speed) +static int ft2232_speed(int speed) { u8 buf[3]; int retval; @@ -302,7 +302,7 @@ } -int ft2232_speed_div(int speed, int* khz) +static int ft2232_speed_div(int speed, int* khz) { /* Take a look in the FT2232 manual, * AN2232C-01 Command Processor for @@ -314,7 +314,7 @@ } -int ft2232_khz(int khz, int* jtag_speed) +static int ft2232_khz(int khz, int* jtag_speed) { if (khz==0) { @@ -355,7 +355,7 @@ } -int ft2232_register_commands(struct command_context_s* cmd_ctx) +static int ft2232_register_commands(struct command_context_s* cmd_ctx) { register_command(cmd_ctx, NULL, "ft2232_device_desc", ft2232_handle_device_desc_command, COMMAND_CONFIG, "the USB device description of the FTDI FT2232 device"); @@ -383,7 +383,7 @@ } -void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size) +static void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size) { int num_bytes = (scan_size + 7) / 8; int bits_left = scan_size; @@ -407,7 +407,7 @@ } -void ft2232_debug_dump_buffer(void) +static void ft2232_debug_dump_buffer(void) { int i; char line[256]; @@ -428,7 +428,7 @@ } -int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last) +static int ft2232_send_and_recv(jtag_command_t* first, jtag_command_t* last) { jtag_command_t* cmd; u8* buffer; @@ -546,7 +546,7 @@ } -void ft2232_add_pathmove(pathmove_command_t* cmd) +static void ft2232_add_pathmove(pathmove_command_t* cmd) { int num_states = cmd->num_states; int state_count = 0; @@ -742,7 +742,7 @@ } -int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, u8* buffer, int scan_size) +static int ft2232_large_scan(scan_command_t* cmd, enum scan_type type, u8* buffer, int scan_size) { int num_bytes = (scan_size + 7) / 8; int bits_left = scan_size; @@ -952,7 +952,7 @@ } -int ft2232_predict_scan_out(int scan_size, enum scan_type type) +static int ft2232_predict_scan_out(int scan_size, enum scan_type type) { int predicted_size = 3; int num_bytes = (scan_size - 1) / 8; @@ -979,7 +979,7 @@ } -int ft2232_predict_scan_in(int scan_size, enum scan_type type) +static int ft2232_predict_scan_in(int scan_size, enum scan_type type) { int predicted_size = 0; @@ -1001,7 +1001,7 @@ } -void usbjtag_reset(int trst, int srst) +static void usbjtag_reset(int trst, int srst) { if (trst == 1) { @@ -1040,7 +1040,7 @@ } -void jtagkey_reset(int trst, int srst) +static void jtagkey_reset(int trst, int srst) { if (trst == 1) { @@ -1081,7 +1081,7 @@ } -void olimex_jtag_reset(int trst, int srst) +static void olimex_jtag_reset(int trst, int srst) { if (trst == 1) { @@ -1116,7 +1116,7 @@ } -void axm0432_jtag_reset(int trst, int srst) +static void axm0432_jtag_reset(int trst, int srst) { if (trst == 1) { @@ -1146,7 +1146,7 @@ } -void flyswatter_reset(int trst, int srst) +static void flyswatter_reset(int trst, int srst) { if (trst == 1) { @@ -1174,7 +1174,7 @@ } -void turtle_reset(int trst, int srst) +static void turtle_reset(int trst, int srst) { trst = trst; @@ -1195,7 +1195,7 @@ } -void comstick_reset(int trst, int srst) +static void comstick_reset(int trst, int srst) { if (trst == 1) { @@ -1224,7 +1224,7 @@ } -void stm32stick_reset(int trst, int srst) +static void stm32stick_reset(int trst, int srst) { if (trst == 1) { @@ -1259,7 +1259,7 @@ -void sheevaplug_reset(int trst, int srst) +static void sheevaplug_reset(int trst, int srst) { if (trst == 1) high_output &= ~nTRST; @@ -1278,7 +1278,7 @@ LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); } -int ft2232_execute_queue() +static int ft2232_execute_queue() { jtag_command_t* cmd = jtag_command_queue; /* currently processed command */ u8* buffer; @@ -1755,7 +1755,7 @@ #endif /* BUILD_FT2232_LIBFTDI == 1 */ -int ft2232_init(void) +static int ft2232_init(void) { u8 buf[1]; int retval; @@ -1837,7 +1837,7 @@ } -int usbjtag_init(void) +static int usbjtag_init(void) { u8 buf[3]; u32 bytes_written; @@ -1912,7 +1912,7 @@ } -int axm0432_jtag_init(void) +static int axm0432_jtag_init(void) { u8 buf[3]; u32 bytes_written; @@ -1982,7 +1982,7 @@ } -int jtagkey_init(void) +static int jtagkey_init(void) { u8 buf[3]; u32 bytes_written; @@ -2064,7 +2064,7 @@ } -int olimex_jtag_init(void) +static int olimex_jtag_init(void) { u8 buf[3]; u32 bytes_written; @@ -2131,7 +2131,7 @@ } -int flyswatter_init(void) +static int flyswatter_init(void) { u8 buf[3]; u32 bytes_written; @@ -2178,7 +2178,7 @@ } -int turtle_init(void) +static int turtle_init(void) { u8 buf[3]; u32 bytes_written; @@ -2219,7 +2219,7 @@ } -int comstick_init(void) +static int comstick_init(void) { u8 buf[3]; u32 bytes_written; @@ -2263,7 +2263,7 @@ } -int stm32stick_init(void) +static int stm32stick_init(void) { u8 buf[3]; u32 bytes_written; @@ -2307,7 +2307,7 @@ } -int sheevaplug_init(void) +static int sheevaplug_init(void) { u8 buf[3]; u32 bytes_written; @@ -2358,7 +2358,7 @@ return ERROR_OK; } -void olimex_jtag_blink(void) +static void olimex_jtag_blink(void) { /* Olimex ARM-USB-OCD has a LED connected to ACBUS3 * ACBUS3 is bit 3 of the GPIOH port @@ -2380,7 +2380,7 @@ } -void flyswatter_jtag_blink(void) +static void flyswatter_jtag_blink(void) { /* * Flyswatter has two LEDs connected to ACBUS2 and ACBUS3 @@ -2393,7 +2393,7 @@ } -void turtle_jtag_blink(void) +static void turtle_jtag_blink(void) { /* * Turtelizer2 has two LEDs connected to ACBUS2 and ACBUS3 @@ -2413,7 +2413,7 @@ } -int ft2232_quit(void) +static int ft2232_quit(void) { #if BUILD_FT2232_FTD2XX == 1 FT_STATUS status; @@ -2434,7 +2434,7 @@ } -int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) +static int ft2232_handle_device_desc_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) { char *cp; char buf[200]; @@ -2469,7 +2469,7 @@ } -int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) +static int ft2232_handle_serial_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) { if (argc == 1) { @@ -2484,7 +2484,7 @@ } -int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) +static int ft2232_handle_layout_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) { if (argc == 0) return ERROR_OK; @@ -2496,7 +2496,7 @@ } -int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) +static int ft2232_handle_vid_pid_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) { int i; @@ -2529,7 +2529,7 @@ } -int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) +static int ft2232_handle_latency_command(struct command_context_s* cmd_ctx, char* cmd, char** args, int argc) { if (argc == 1) { Modified: trunk/src/jtag/gw16012.c =================================================================== --- trunk/src/jtag/gw16012.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/gw16012.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -89,13 +89,13 @@ static int device_handle; #endif -int gw16012_execute_queue(void); -int gw16012_register_commands(struct command_context_s *cmd_ctx); -int gw16012_speed(int speed); -int gw16012_init(void); -int gw16012_quit(void); +static int gw16012_execute_queue(void); +static int gw16012_register_commands(struct command_context_s *cmd_ctx); +static int gw16012_speed(int speed); +static int gw16012_init(void); +static int gw16012_quit(void); -int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); jtag_interface_t gw16012_interface = { @@ -109,7 +109,7 @@ .quit = gw16012_quit, }; -int gw16012_register_commands(struct command_context_s *cmd_ctx) +static int gw16012_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "parport_port", gw16012_handle_parport_port_command, COMMAND_CONFIG, NULL); @@ -117,7 +117,7 @@ return ERROR_OK; } -void gw16012_data(u8 value) +static void gw16012_data(u8 value) { value = (value & 0x7f) | gw16012_msb; gw16012_msb ^= 0x80; /* toggle MSB */ @@ -137,7 +137,7 @@ #endif } -void gw16012_control(u8 value) +static void gw16012_control(u8 value) { if (value != gw16012_control_value) { @@ -159,7 +159,7 @@ } } -void gw16012_input(u8 *value) +static void gw16012_input(u8 *value) { #if PARPORT_USE_PPDEV == 1 ioctl(device_handle, PPRSTATUS, value); @@ -173,7 +173,7 @@ } /* (1) assert or (0) deassert reset lines */ -void gw16012_reset(int trst, int srst) +static void gw16012_reset(int trst, int srst) { LOG_DEBUG("trst: %i, srst: %i", trst, srst); @@ -188,13 +188,13 @@ gw16012_control(0x0b); } -int gw16012_speed(int speed) +static int gw16012_speed(int speed) { return ERROR_OK; } -void gw16012_end_state(tap_state_t state) +static void gw16012_end_state(tap_state_t state) { if (tap_is_state_stable(state)) tap_set_end_state(state); @@ -205,7 +205,7 @@ } } -void gw16012_state_move(void) +static void gw16012_state_move(void) { int i=0, tms=0; u8 tms_scan = tap_get_tms_path(tap_get_state(), tap_get_end_state()); @@ -221,7 +221,7 @@ tap_set_state(tap_get_end_state()); } -void gw16012_path_move(pathmove_command_t *cmd) +static void gw16012_path_move(pathmove_command_t *cmd) { int num_states = cmd->num_states; int state_count; @@ -252,7 +252,7 @@ tap_set_end_state(tap_get_state()); } -void gw16012_runtest(int num_cycles) +static void gw16012_runtest(int num_cycles) { tap_state_t saved_end_state = tap_get_end_state(); int i; @@ -275,7 +275,7 @@ gw16012_state_move(); } -void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) +static void gw16012_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size) { int bits_left = scan_size; int bit_count = 0; @@ -348,7 +348,7 @@ } } -int gw16012_execute_queue(void) +static int gw16012_execute_queue(void) { jtag_command_t *cmd = jtag_command_queue; /* currently processed command */ int scan_size; @@ -436,7 +436,7 @@ } #if PARPORT_USE_GIVEIO == 1 -int gw16012_get_giveio_access() +static int gw16012_get_giveio_access() { HANDLE h; OSVERSIONINFO version; @@ -461,7 +461,7 @@ } #endif -int gw16012_init(void) +static int gw16012_init(void) { #if PARPORT_USE_PPDEV == 1 char buffer[256]; @@ -555,13 +555,13 @@ return ERROR_OK; } -int gw16012_quit(void) +static int gw16012_quit(void) { return ERROR_OK; } -int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int gw16012_handle_parport_port_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 0) return ERROR_OK; Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/jlink.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -77,33 +77,33 @@ #define JLINK_MAX_SPEED 12000 /* External interface functions */ -int jlink_execute_queue(void); -int jlink_speed(int speed); -int jlink_speed_div(int speed, int* khz); -int jlink_khz(int khz, int *jtag_speed); -int jlink_register_commands(struct command_context_s *cmd_ctx); -int jlink_init(void); -int jlink_quit(void); +static int jlink_execute_queue(void); +static int jlink_speed(int speed); +static int jlink_speed_div(int speed, int* khz); +static int jlink_khz(int khz, int *jtag_speed); +static int jlink_register_commands(struct command_context_s *cmd_ctx); +static int jlink_init(void); +static int jlink_quit(void); /* CLI command handler functions */ -int jlink_handle_jlink_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int jlink_handle_jlink_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); /* Queue command functions */ -void jlink_end_state(tap_state_t state); -void jlink_state_move(void); -void jlink_path_move(int num_states, tap_state_t *path); -void jlink_runtest(int num_cycles); -void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); -void jlink_reset(int trst, int srst); -void jlink_simple_command(u8 command); -int jlink_get_status(void); +static void jlink_end_state(tap_state_t state); +static void jlink_state_move(void); +static void jlink_path_move(int num_states, tap_state_t *path); +static void jlink_runtest(int num_cycles); +static void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command); +static void jlink_reset(int trst, int srst); +static void jlink_simple_command(u8 command); +static int jlink_get_status(void); /* J-Link tap buffer functions */ -void jlink_tap_init(void); -int jlink_tap_execute(void); -void jlink_tap_ensure_space(int scans, int bits); -void jlink_tap_append_step(int tms, int tdi); -void jlink_tap_append_scan(int length, u8 *buffer, scan_command_t *command); +static void jlink_tap_init(void); +static int jlink_tap_execute(void); +static void jlink_tap_ensure_space(int scans, int bits); +static void jlink_tap_append_step(int tms, int tdi); +static void jlink_tap_append_scan(int length, u8 *buffer, scan_command_t *command); /* Jlink lowlevel functions */ typedef struct jlink_jtag @@ -111,21 +111,21 @@ struct usb_dev_handle* usb_handle; } jlink_jtag_t; -jlink_jtag_t *jlink_usb_open(void); -void jlink_usb_close(jlink_jtag_t *jlink_jtag); -int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length); -int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length); -int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size); -int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag); +static jlink_jtag_t *jlink_usb_open(void); +static void jlink_usb_close(jlink_jtag_t *jlink_jtag); +static int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length); +static int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length); +static int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size); +static int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag); /* helper functions */ -int jlink_get_version_info(void); +static int jlink_get_version_info(void); #ifdef _DEBUG_USB_COMMS_ -void jlink_debug_buffer(u8 *buffer, int length); +static void jlink_debug_buffer(u8 *buffer, int length); #endif -jlink_jtag_t* jlink_jtag_handle; +static jlink_jtag_t* jlink_jtag_handle; /***************************************************************************/ /* External interface implementation */ @@ -142,7 +142,7 @@ .quit = jlink_quit }; -int jlink_execute_queue(void) +static int jlink_execute_queue(void) { jtag_command_t *cmd = jtag_command_queue; int scan_size; @@ -238,7 +238,7 @@ } /* Sets speed in kHz. */ -int jlink_speed(int speed) +static int jlink_speed(int speed) { int result; @@ -272,28 +272,28 @@ return ERROR_OK; } -int jlink_speed_div(int speed, int* khz) +static int jlink_speed_div(int speed, int* khz) { *khz = speed; return ERROR_OK; } -int jlink_khz(int khz, int *jtag_speed) +static int jlink_khz(int khz, int *jtag_speed) { *jtag_speed = khz; return ERROR_OK; } -int jlink_register_commands(struct command_context_s *cmd_ctx) +static int jlink_register_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, NULL, "jlink_info", jlink_handle_jlink_info_command, COMMAND_EXEC, "query jlink info"); return ERROR_OK; } -int jlink_init(void) +static int jlink_init(void) { int check_cnt; @@ -331,7 +331,7 @@ return ERROR_OK; } -int jlink_quit(void) +static int jlink_quit(void) { jlink_usb_close(jlink_jtag_handle); return ERROR_OK; @@ -340,7 +340,7 @@ /***************************************************************************/ /* Queue command implementations */ -void jlink_end_state(tap_state_t state) +static void jlink_end_state(tap_state_t state) { if (tap_is_state_stable(state)) { @@ -354,7 +354,7 @@ } /* Goes to the end state. */ -void jlink_state_move(void) +static void jlink_state_move(void) { int i; int tms = 0; @@ -369,7 +369,7 @@ tap_set_state(tap_get_end_state()); } -void jlink_path_move(int num_states, tap_state_t *path) +static void jlink_path_move(int num_states, tap_state_t *path) { int i; @@ -395,7 +395,7 @@ tap_set_end_state(tap_get_state()); } -void jlink_runtest(int num_cycles) +static void jlink_runtest(int num_cycles) { int i; @@ -422,7 +422,7 @@ } } -void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) +static void jlink_scan(int ir_scan, enum scan_type type, u8 *buffer, int scan_size, scan_command_t *command) { tap_state_t saved_end_state; @@ -453,7 +453,7 @@ } } -void jlink_reset(int trst, int srst) +static void jlink_reset(int trst, int srst) { LOG_DEBUG("trst: %i, srst: %i", trst, srst); @@ -477,7 +477,7 @@ } } -void jlink_simple_command(u8 command) +static void jlink_simple_command(u8 command) { int result; @@ -492,7 +492,7 @@ } } -int jlink_get_status(void) +static int jlink_get_status(void) { int result; @@ -520,7 +520,7 @@ return ERROR_OK; } -int jlink_get_version_info(void) +static int jlink_get_version_info(void) { int result; int len = 0; @@ -546,7 +546,7 @@ return ERROR_JTAG_DEVICE_ERROR; } -int jlink_handle_jlink_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int jlink_handle_jlink_info_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (jlink_get_version_info() == ERROR_OK) { @@ -583,13 +583,13 @@ static int last_tms; -void jlink_tap_init(void) +static void jlink_tap_init(void) { tap_length = 0; pending_scan_results_length = 0; } -void jlink_tap_ensure_space(int scans, int bits) +static void jlink_tap_ensure_space(int scans, int bits) { int available_scans = MAX_PENDING_SCAN_RESULTS - pending_scan_results_length; int available_bits = JLINK_TAP_BUFFER_SIZE * 8 - tap_length; @@ -600,7 +600,7 @@ } } -void jlink_tap_append_step(int tms, int tdi) +static void jlink_tap_append_step(int tms, int tdi) { last_tms = tms; int index = tap_length / 8; @@ -636,7 +636,7 @@ } } -void jlink_tap_append_scan(int length, u8 *buffer, scan_command_t *command) +static void jlink_tap_append_scan(int length, u8 *buffer, scan_command_t *command) { pending_scan_result_t *pending_scan_result = &pending_scan_results_buffer[pending_scan_results_length]; int i; @@ -655,7 +655,7 @@ /* Pad and send a tap sequence to the device, and receive the answer. * For the purpose of padding we assume that we are in idle or pause state. */ -int jlink_tap_execute(void) +static int jlink_tap_execute(void) { int byte_length; int tms_offset; @@ -745,7 +745,7 @@ /*****************************************************************************/ /* JLink USB low-level functions */ -jlink_jtag_t* jlink_usb_open() +static jlink_jtag_t* jlink_usb_open() { struct usb_bus *busses; struct usb_bus *bus; @@ -791,14 +791,14 @@ return NULL; } -void jlink_usb_close(jlink_jtag_t *jlink_jtag) +static void jlink_usb_close(jlink_jtag_t *jlink_jtag) { usb_close(jlink_jtag->usb_handle); free(jlink_jtag); } /* Send a message and receive the reply. */ -int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length) +static int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length) { int result; int result2; @@ -859,7 +859,7 @@ } } -int usb_bulk_write_ex(usb_dev_handle *dev, int ep, char *bytes, int size, +static int usb_bulk_write_ex(usb_dev_handle *dev, int ep, char *bytes, int size, int timeout) { int rc = 0, tries = 3, this_size; @@ -883,7 +883,7 @@ } -int usb_bulk_read_ex(usb_dev_handle *dev, int ep, char *bytes, int size, +static int usb_bulk_read_ex(usb_dev_handle *dev, int ep, char *bytes, int size, int timeout) { int rc = 0, tries = 3, this_size; @@ -908,7 +908,7 @@ /* Write data from out_buffer to USB. */ -int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length) +static int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length) { int result; @@ -930,7 +930,7 @@ } /* Read data from USB into in_buffer. */ -int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size) +static int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size) { int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, (char *)usb_in_buffer, expected_size, JLINK_USB_TIMEOUT); @@ -944,7 +944,7 @@ } /* Read the result from the previous EMU cmd into result_buffer. */ -int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag) +static int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag) { int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, (char *)usb_emu_result_buffer, 1 /* JLINK_EMU_RESULT_BUFFER_SIZE */, @@ -961,7 +961,7 @@ #ifdef _DEBUG_USB_COMMS_ #define BYTES_PER_LINE 16 -void jlink_debug_buffer(u8 *buffer, int length) +static void jlink_debug_buffer(u8 *buffer, int length) { char line[81]; char s[4]; Modified: trunk/src/jtag/jtag.c =================================================================== --- trunk/src/jtag/jtag.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/jtag.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -80,8 +80,8 @@ int jtag_verify_capture_ir = 1; /* how long the OpenOCD should wait before attempting JTAG communication after reset lines deasserted (in ms) */ -int jtag_nsrst_delay = 0; /* default to no nSRST delay */ -int jtag_ntrst_delay = 0; /* default to no nTRST delay */ +static int jtag_nsrst_delay = 0; /* default to no nSRST delay */ +static int jtag_ntrst_delay = 0; /* default to no nTRST delay */ /* maximum number of JTAG devices expected in the chain */ @@ -210,35 +210,35 @@ jtag_interface_t *jtag = NULL; /* configuration */ -jtag_interface_t *jtag_interface = NULL; +static jtag_interface_t *jtag_interface = NULL; int jtag_speed = 0; /* forward declarations */ -void jtag_add_pathmove(int num_states, tap_state_t *path); -void jtag_add_runtest(int num_cycles, tap_state_t endstate); -void jtag_add_end_state(tap_state_t endstate); -void jtag_add_sleep(u32 us); -int jtag_execute_queue(void); -tap_state_t tap_state_by_name(const char *name); +//void jtag_add_pathmove(int num_states, tap_state_t *path); +//void jtag_add_runtest(int num_cycles, tap_state_t endstate); +//void jtag_add_end_state(tap_state_t endstate); +//void jtag_add_sleep(u32 us); +//int jtag_execute_queue(void); +static tap_state_t tap_state_by_name(const char *name); /* jtag commands */ -int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); -int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *argv); +static int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *argv); -int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); +static int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); jtag_tap_t *jtag_AllTaps(void) { @@ -2305,7 +2305,7 @@ return ERROR_OK; } -int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { int i; int retval; @@ -2368,7 +2368,7 @@ return ERROR_JTAG_INVALID_INTERFACE; } -int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_jtag_device_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { int e; char buf[1024]; @@ -2429,7 +2429,7 @@ return e; } -int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_scan_chain_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { jtag_tap_t *tap; @@ -2466,7 +2466,7 @@ return ERROR_OK; } -int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc < 1) return ERROR_COMMAND_SYNTAX_ERROR; @@ -2542,7 +2542,7 @@ return ERROR_OK; } -int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_jtag_nsrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc < 1) { @@ -2557,7 +2557,7 @@ return ERROR_OK; } -int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_jtag_ntrst_delay_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc < 1) { @@ -2572,7 +2572,7 @@ return ERROR_OK; } -int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { int retval=ERROR_OK; @@ -2600,7 +2600,7 @@ return retval; } -int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { int retval=ERROR_OK; LOG_DEBUG("handle jtag khz"); @@ -2650,7 +2650,7 @@ } -int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { tap_state_t state; @@ -2673,7 +2673,7 @@ return ERROR_OK; } -int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_jtag_reset_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { int trst = -1; int srst = -1; @@ -2710,7 +2710,7 @@ return ERROR_OK; } -int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc < 1) { @@ -2724,7 +2724,7 @@ } -int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { int i; scan_field_t *fields; @@ -2799,7 +2799,7 @@ return ERROR_OK; } -int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args) +static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args) { int retval; scan_field_t *fields; @@ -2936,7 +2936,7 @@ return JIM_OK; } -int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static int handle_verify_ircapture_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { if (argc == 1) { @@ -3269,7 +3269,7 @@ return ret; } -tap_state_t tap_state_by_name( const char *name ) +static tap_state_t tap_state_by_name( const char *name ) { tap_state_t x; Modified: trunk/src/jtag/parport.c =================================================================== --- trunk/src/jtag/parport.c 2009-04-20 22:38:27 UTC (rev 1478) +++ trunk/src/jtag/parport.c 2009-04-21 05:29:23 UTC (rev 1479) @@ -96,7 +96,7 @@ u8 LED_MASK; /* data port bit for LED */ } cable_t; -cable_t cables[] = +static cable_t cables[] = ... [truncated message content] |
From: ntfreak at B. <nt...@ma...> - 2009-04-21 00:38:30
|
Author: ntfreak Date: 2009-04-21 00:38:27 +0200 (Tue, 21 Apr 2009) New Revision: 1478 Modified: trunk/src/jtag/at91rm9200.c trunk/src/target/target/lpc2124.cfg trunk/src/target/target/lpc2378.cfg Log: - fix at91rm9200 warning. Thanks Zach Welch <zw...@su...> - add missing svn props from previous commit Modified: trunk/src/jtag/at91rm9200.c =================================================================== --- trunk/src/jtag/at91rm9200.c 2009-04-20 10:52:08 UTC (rev 1477) +++ trunk/src/jtag/at91rm9200.c 2009-04-20 22:38:27 UTC (rev 1478) @@ -104,7 +104,7 @@ struct device_t devices[] = { { "rea_ecr", PIOD, P27, PIOA, NC, PIOD, P23, PIOD, P24, PIOD, P26, PIOC, P5 }, - { NULL, 0 } + { .name = NULL }, }; /* configuration */ Modified: trunk/src/target/target/lpc2124.cfg =================================================================== --- trunk/src/target/target/lpc2124.cfg 2009-04-20 10:52:08 UTC (rev 1477) +++ trunk/src/target/target/lpc2124.cfg 2009-04-20 22:38:27 UTC (rev 1478) @@ -1,38 +1,38 @@ -#LPC-2124 CPU - -if { [info exists CHIPNAME] } { - set _CHIPNAME $CHIPNAME -} else { - set _CHIPNAME lpc2124 -} - -if { [info exists ENDIAN] } { - set _ENDIAN $ENDIAN -} else { - set _ENDIAN little -} - -if { [info exists CPUTAPID ] } { - set _CPUTAPID $CPUTAPID -} else { - # force an error till we get a good number - set _CPUTAPID 0x4f1f0f0f -} - - -#use combined on interfaces or targets that can't set TRST/SRST separately -reset_config trst_and_srst srst_pulls_trst -jtag_nsrst_delay 10 -jtag_khz 1000 - -#jtag scan chain -jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID - -set _TARGETNAME [format "%s.cpu" $_CHIPNAME] -target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4 - -$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x4000 -work-area-backup 0 - - -#flash bank <driver> <base> <size> <chip_width> <bus_width> -flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14745 calc_checksum +#LPC-2124 CPU + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME lpc2124 +} + +if { [info exists ENDIAN] } { + set _ENDIAN $ENDIAN +} else { + set _ENDIAN little +} + +if { [info exists CPUTAPID ] } { + set _CPUTAPID $CPUTAPID +} else { + # force an error till we get a good number + set _CPUTAPID 0x4f1f0f0f +} + + +#use combined on interfaces or targets that can't set TRST/SRST separately +reset_config trst_and_srst srst_pulls_trst +jtag_nsrst_delay 10 +jtag_khz 1000 + +#jtag scan chain +jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID + +set _TARGETNAME [format "%s.cpu" $_CHIPNAME] +target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4 + +$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x4000 -work-area-backup 0 + + +#flash bank <driver> <base> <size> <chip_width> <bus_width> +flash bank lpc2000 0x0 0x40000 0 0 0 lpc2000_v1 14745 calc_checksum Property changes on: trunk/src/target/target/lpc2124.cfg ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/src/target/target/lpc2378.cfg =================================================================== --- trunk/src/target/target/lpc2378.cfg 2009-04-20 10:52:08 UTC (rev 1477) +++ trunk/src/target/target/lpc2378.cfg 2009-04-20 22:38:27 UTC (rev 1478) @@ -1,49 +1,49 @@ -# NXP LPC2378 ARM7TDMI-S with 512kB Flash and 32kB Local On-Chip SRAM (58kB total), clocked with 4MHz internal RC oscillator - -if { [info exists CHIPNAME] } { - set _CHIPNAME $CHIPNAME -} else { - set _CHIPNAME lpc2378 -} - -if { [info exists ENDIAN] } { - set _ENDIAN $ENDIAN -} else { - set _ENDIAN little -} - -if { [info exists CPUTAPID ] } { - set _CPUTAPID $CPUTAPID -} else { - set _CPUTAPID 0x4f1f0f0f -} - -#delays on reset lines -jtag_nsrst_delay 200 -jtag_ntrst_delay 200 - -# LPC2000 -> SRST causes TRST -reset_config trst_and_srst srst_pulls_trst - -jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID - -set _TARGETNAME [format "%s.cpu" $_CHIPNAME] -target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4 - -# LPC2378 has 32kB of SRAM on its main system bus (so-called Local On-Chip SRAM) -$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x8000 -work-area-backup 0 - -$_TARGETNAME configure -event reset-init { - # Force target into ARM state - soft_reset_halt - #do not remap 0x0000-0x0020 to anything but the flash - mwb 0xE01FC040 0x01 -} - -# LPC2378 has 512kB of FLASH, but upper 8kB are occupied by bootloader. -# After reset the chip uses its internal 4MHz RC oscillator -#flash bank lpc2000 <base> <size> 0 0 <target#> <variant> -flash bank lpc2000 0x0 0x0007D000 0 0 0 lpc2000_v2 4000 calc_checksum - -# 4MHz / 6 = 666kHz, so use 500 -jtag_khz 500 +# NXP LPC2378 ARM7TDMI-S with 512kB Flash and 32kB Local On-Chip SRAM (58kB total), clocked with 4MHz internal RC oscillator + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME lpc2378 +} + +if { [info exists ENDIAN] } { + set _ENDIAN $ENDIAN +} else { + set _ENDIAN little +} + +if { [info exists CPUTAPID ] } { + set _CPUTAPID $CPUTAPID +} else { + set _CPUTAPID 0x4f1f0f0f +} + +#delays on reset lines +jtag_nsrst_delay 200 +jtag_ntrst_delay 200 + +# LPC2000 -> SRST causes TRST +reset_config trst_and_srst srst_pulls_trst + +jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID + +set _TARGETNAME [format "%s.cpu" $_CHIPNAME] +target create $_TARGETNAME arm7tdmi -endian $_ENDIAN -chain-position $_TARGETNAME -variant arm7tdmi-s_r4 + +# LPC2378 has 32kB of SRAM on its main system bus (so-called Local On-Chip SRAM) +$_TARGETNAME configure -work-area-virt 0 -work-area-phys 0x40000000 -work-area-size 0x8000 -work-area-backup 0 + +$_TARGETNAME configure -event reset-init { + # Force target into ARM state + soft_reset_halt + #do not remap 0x0000-0x0020 to anything but the flash + mwb 0xE01FC040 0x01 +} + +# LPC2378 has 512kB of FLASH, but upper 8kB are occupied by bootloader. +# After reset the chip uses its internal 4MHz RC oscillator +#flash bank lpc2000 <base> <size> 0 0 <target#> <variant> +flash bank lpc2000 0x0 0x0007D000 0 0 0 lpc2000_v2 4000 calc_checksum + +# 4MHz / 6 = 666kHz, so use 500 +jtag_khz 500 Property changes on: trunk/src/target/target/lpc2378.cfg ___________________________________________________________________ Name: svn:eol-style + native |
From: oharboe at B. <oh...@ma...> - 2009-04-20 12:52:15
|
Author: oharboe Date: 2009-04-20 12:52:08 +0200 (Mon, 20 Apr 2009) New Revision: 1477 Modified: trunk/src/target/arm7_9_common.c Log: Holger Freyther <ze...@se...> Attempt to fix arm7_9 breakpoint handling Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-04-20 06:40:45 UTC (rev 1476) +++ trunk/src/target/arm7_9_common.c 2009-04-20 10:52:08 UTC (rev 1477) @@ -78,6 +78,26 @@ return jtag_execute_queue(); } +static void arm7_9_assign_wp(arm7_9_common_t *arm7_9, breakpoint_t *breakpoint) +{ + if (!arm7_9->wp0_used) + { + arm7_9->wp0_used = 1; + breakpoint->set = 1; + arm7_9->wp_available--; + } + else if (!arm7_9->wp1_used) + { + arm7_9->wp1_used = 1; + breakpoint->set = 2; + arm7_9->wp_available--; + } + else + { + LOG_ERROR("BUG: no hardware comparator available"); + } +} + /* set up embedded ice registers */ static int arm7_9_set_software_breakpoints(arm7_9_common_t *arm7_9) { @@ -182,6 +202,13 @@ { /* either an ARM (4 byte) or Thumb (2 byte) breakpoint */ u32 mask = (breakpoint->length == 4) ? 0x3u : 0x1u; + + /* reassign a hw breakpoint */ + if (breakpoint->set==0) + { + arm7_9_assign_wp(arm7_9, breakpoint); + } + if (breakpoint->set==1) { embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_VALUE], breakpoint->address); @@ -288,11 +315,13 @@ { embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 0x0); arm7_9->wp0_used = 0; + arm7_9->wp_available++; } else if (breakpoint->set == 2) { embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_CONTROL_VALUE], 0x0); arm7_9->wp1_used = 0; + arm7_9->wp_available++; } retval = jtag_execute_queue(); breakpoint->set = 0; @@ -367,22 +396,7 @@ if (breakpoint->type == BKPT_HARD) { - arm7_9->wp_available--; - - if (!arm7_9->wp0_used) - { - arm7_9->wp0_used = 1; - breakpoint->set = 1; - } - else if (!arm7_9->wp1_used) - { - arm7_9->wp1_used = 1; - breakpoint->set = 2; - } - else - { - LOG_ERROR("BUG: no hardware comparator available"); - } + arm7_9_assign_wp(arm7_9, breakpoint); } arm7_9->breakpoint_count++; |
From: oharboe at B. <oh...@ma...> - 2009-04-20 08:40:50
|
Author: oharboe Date: 2009-04-20 08:40:45 +0200 (Mon, 20 Apr 2009) New Revision: 1476 Modified: trunk/src/jtag/bitq.c trunk/src/jtag/ft2232.c trunk/src/jtag/presto.c Log: Zach Welch <zw...@su...> fix ft2232/presto warnings Modified: trunk/src/jtag/bitq.c =================================================================== --- trunk/src/jtag/bitq.c 2009-04-19 23:30:15 UTC (rev 1475) +++ trunk/src/jtag/bitq.c 2009-04-20 06:40:45 UTC (rev 1476) @@ -39,7 +39,7 @@ bitq_state_t bitq_in_state; /* state of input queue */ u8* bitq_in_buffer; /* buffer dynamically reallocated as needed */ -unsigned long bitq_in_bufsize = 32; /* min. buffer size */ +int bitq_in_bufsize = 32; /* min. buffer size */ /* * input queue processing does not use jtag_read_buffer() to avoid unnecessary overhead Modified: trunk/src/jtag/ft2232.c =================================================================== --- trunk/src/jtag/ft2232.c 2009-04-19 23:30:15 UTC (rev 1475) +++ trunk/src/jtag/ft2232.c 2009-04-20 06:40:45 UTC (rev 1476) @@ -158,7 +158,7 @@ { "stm32stick", stm32stick_init, stm32stick_reset, NULL }, { "axm0432_jtag", axm0432_jtag_init, axm0432_jtag_reset, NULL }, {"sheevaplug", sheevaplug_init, sheevaplug_reset, NULL }, - { NULL, NULL, NULL }, + { NULL, NULL, NULL, NULL }, }; static u8 nTRST, nTRSTnOE, nSRST, nSRSTnOE; @@ -233,7 +233,7 @@ } -int ft2232_read(u8* buf, int size, u32* bytes_read) +int ft2232_read(u8* buf, u32 size, u32* bytes_read) { #if BUILD_FT2232_FTD2XX == 1 DWORD dw_bytes_read; @@ -1607,7 +1607,7 @@ if (status == FT_OK) { char** desc_array = malloc( sizeof(char*) * (num_devices + 1) ); - int i; + u32 i; for (i = 0; i < num_devices; i++) desc_array[i] = malloc(64); Modified: trunk/src/jtag/presto.c =================================================================== --- trunk/src/jtag/presto.c 2009-04-19 23:30:15 UTC (rev 1475) +++ trunk/src/jtag/presto.c 2009-04-20 06:40:45 UTC (rev 1476) @@ -138,7 +138,7 @@ 0x80, 0xA0, 0xA8, 0xB0, 0xC0, 0xE0 }; -int presto_write(u8 *buf, int size) +int presto_write(u8 *buf, u32 size) { #if BUILD_PRESTO_FTD2XX == 1 DWORD ftbytes; @@ -160,14 +160,14 @@ if (ftbytes != size) { - LOG_ERROR("couldn't write the requested number of bytes to PRESTO (%i < %i)", ftbytes, size); + LOG_ERROR("couldn't write the requested number of bytes to PRESTO (%u < %u)", (u32)ftbytes, size); return ERROR_JTAG_DEVICE_ERROR; } return ERROR_OK; } -int presto_read(u8* buf, int size) +int presto_read(u8* buf, u32 size) { #if BUILD_PRESTO_FTD2XX == 1 DWORD ftbytes; @@ -202,7 +202,7 @@ if (ftbytes != size) { /* this is just a warning, there might have been timeout when detecting PRESTO, which is not fatal */ - LOG_WARNING("couldn't read the requested number of bytes from PRESTO (%i < %i)", ftbytes, size); + LOG_WARNING("couldn't read the requested number of bytes from PRESTO (%u < %u)", (u32)ftbytes, size); return ERROR_JTAG_DEVICE_ERROR; } @@ -212,7 +212,7 @@ #if BUILD_PRESTO_FTD2XX == 1 int presto_open_ftd2xx(char *req_serial) { - int i; + u32 i; DWORD numdevs; DWORD vidpid; char devname[FT_DEVICE_NAME_LEN]; @@ -238,7 +238,7 @@ return ERROR_JTAG_DEVICE_ERROR; } - LOG_DEBUG("FTDI devices available: %i", numdevs); + LOG_DEBUG("FTDI devices available: %lu", numdevs); for (i = 0; i < numdevs; i++) { if ((presto->status = FT_Open(i, &(presto->handle))) != FT_OK) @@ -257,7 +257,7 @@ break; } else - LOG_DEBUG("FT_GetDeviceInfo failed: %i", presto->status); + LOG_DEBUG("FT_GetDeviceInfo failed: %lu", presto->status); LOG_DEBUG("FTDI device %i does not match, closing", i); FT_Close(presto->handle); |
From: <oh...@ma...> - 2009-04-20 01:30:18
|
Author: oharboe Date: 2009-04-20 01:30:15 +0200 (Mon, 20 Apr 2009) New Revision: 1475 Modified: trunk/src/jtag/jlink.c Log: Nikolay Shadrin whoney at gmail.com, Zach Welch <zw...@su...> unstable USB J-Link in OpenOCD (revised patch provided) Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-19 23:27:17 UTC (rev 1474) +++ trunk/src/jtag/jlink.c 2009-04-19 23:30:15 UTC (rev 1475) @@ -115,7 +115,7 @@ void jlink_usb_close(jlink_jtag_t *jlink_jtag); int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length); int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length); -int jlink_usb_read(jlink_jtag_t *jlink_jtag); +int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size); int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag); /* helper functions */ @@ -497,7 +497,7 @@ int result; jlink_simple_command(EMU_CMD_GET_STATE); - result = jlink_usb_read(jlink_jtag_handle); + result = jlink_usb_read(jlink_jtag_handle, 8); if (result == 8) { @@ -527,12 +527,12 @@ /* query hardware version */ jlink_simple_command(EMU_CMD_VERSION); - result = jlink_usb_read(jlink_jtag_handle); + result = jlink_usb_read(jlink_jtag_handle, 2); if (result == 2) { len = buf_get_u32(usb_in_buffer, 0, 16); - result = jlink_usb_read(jlink_jtag_handle); + result = jlink_usb_read(jlink_jtag_handle, len); if (result == len) { @@ -806,7 +806,7 @@ result = jlink_usb_write(jlink_jtag, out_length); if (result == out_length) { - result = jlink_usb_read(jlink_jtag); + result = jlink_usb_read(jlink_jtag, in_length); if (result == in_length || result == in_length+1) { if (result == in_length) @@ -859,6 +859,54 @@ } } +int usb_bulk_write_ex(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout) { + + int rc = 0, tries = 3, this_size; + + while (tries && size) { + + this_size = usb_bulk_write (dev, ep, bytes, size, timeout); + + if (this_size > 0) { + + size -= this_size; + rc += this_size; + bytes += this_size; + + } else + tries --; + } + + return rc; + + +} + +int usb_bulk_read_ex(usb_dev_handle *dev, int ep, char *bytes, int size, + int timeout) { + + int rc = 0, tries = 3, this_size; + + while (tries && size) { + + this_size = usb_bulk_read (dev, ep, bytes, size, timeout); + + if (this_size > 0) { + + size -= this_size; + rc += this_size; + bytes += this_size; + + } else + tries --; + } + + return rc; + +} + + /* Write data from out_buffer to USB. */ int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length) { @@ -870,7 +918,7 @@ return -1; } - result = usb_bulk_write(jlink_jtag->usb_handle, JLINK_WRITE_ENDPOINT, + result = usb_bulk_write_ex(jlink_jtag->usb_handle, JLINK_WRITE_ENDPOINT, (char *)usb_out_buffer, out_length, JLINK_USB_TIMEOUT); DEBUG_JTAG_IO("jlink_usb_write, out_length = %d, result = %d", out_length, result); @@ -882,10 +930,10 @@ } /* Read data from USB into in_buffer. */ -int jlink_usb_read(jlink_jtag_t *jlink_jtag) +int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size) { - int result = usb_bulk_read(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, - (char *)usb_in_buffer, JLINK_IN_BUFFER_SIZE, JLINK_USB_TIMEOUT); + int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, + (char *)usb_in_buffer, expected_size, JLINK_USB_TIMEOUT); DEBUG_JTAG_IO("jlink_usb_read, result = %d", result); @@ -898,8 +946,8 @@ /* Read the result from the previous EMU cmd into result_buffer. */ int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag) { - int result = usb_bulk_read(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, - (char *)usb_emu_result_buffer, JLINK_EMU_RESULT_BUFFER_SIZE, + int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, + (char *)usb_emu_result_buffer, 1 /* JLINK_EMU_RESULT_BUFFER_SIZE */, JLINK_USB_TIMEOUT); DEBUG_JTAG_IO("jlink_usb_read_result, result = %d", result); |
From: <oh...@ma...> - 2009-04-20 01:27:19
|
Author: oharboe Date: 2009-04-20 01:27:17 +0200 (Mon, 20 Apr 2009) New Revision: 1474 Modified: trunk/src/target/armv4_5.h Log: Zach Welch <zw...@su...> use ARM4_5_MODE_ANY instead of -1 Modified: trunk/src/target/armv4_5.h =================================================================== --- trunk/src/target/armv4_5.h 2009-04-19 21:04:34 UTC (rev 1473) +++ trunk/src/target/armv4_5.h 2009-04-19 23:27:17 UTC (rev 1474) @@ -133,7 +133,7 @@ case 6: return ARMV4_5_MODE_SYS; break; default: LOG_ERROR("mode index out of bounds"); - return -1; + return ARMV4_5_MODE_ANY; } }; |
From: <oh...@ma...> - 2009-04-19 23:04:36
|
Author: oharboe Date: 2009-04-19 23:04:34 +0200 (Sun, 19 Apr 2009) New Revision: 1473 Modified: trunk/configure.in Log: Zach Welch <zw...@su...> treat warnings as errors Modified: trunk/configure.in =================================================================== --- trunk/configure.in 2009-04-19 20:51:16 UTC (rev 1472) +++ trunk/configure.in 2009-04-19 21:04:34 UTC (rev 1473) @@ -178,9 +178,18 @@ ) AC_ARG_ENABLE(gccwarnings, - AS_HELP_STRING([--enable-gccwarnings], [Enable compiler warnings, default yes]), + AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]), [gcc_warnings=$enableval], [gcc_warnings=yes]) +AC_ARG_ENABLE(wextra, + AS_HELP_STRING([--disable-wextra], [Disable extra compiler warnings]), + [gcc_wextra=$enableval], [gcc_wextra=$gcc_warnings]) + +AC_ARG_ENABLE(werror, + AS_HELP_STRING([--disable-werror], [Do not treat warnings as errors]), + [gcc_werror=$enableval], [gcc_werror=$gcc_warnings]) + + AC_ARG_ENABLE(parport, AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]), [build_parport=$enableval], [build_parport=no]) @@ -684,6 +693,12 @@ # set default gcc warnings GCC_WARNINGS="-Wall -Wstrict-prototypes" +if test "${gcc_wextra}" = yes; then + GCC_WARNINGS="${GCC_WARNINGS} -Wextra -Wno-unused-parameter" +fi +if test "${gcc_werror}" = yes; then + GCC_WARNINGS="${GCC_WARNINGS} -Werror" +fi # overide default gcc cflags if test $gcc_warnings = yes; then |
From: <oh...@ma...> - 2009-04-19 22:51:30
|
Author: oharboe Date: 2009-04-19 22:51:16 +0200 (Sun, 19 Apr 2009) New Revision: 1472 Modified: trunk/src/helper/binarybuffer.c trunk/src/jtag/jtag.c trunk/src/jtag/rlink/rlink.c trunk/src/pld/virtex2.c trunk/src/pld/xilinx_bit.c trunk/src/server/gdb_server.c trunk/src/svf/svf.c trunk/src/target/arm720t.h trunk/src/target/arm7_9_common.c trunk/src/target/arm7_9_common.h trunk/src/target/arm920t.h trunk/src/target/arm926ejs.h trunk/src/target/arm_jtag.h trunk/src/target/armv4_5.c trunk/src/target/armv7m.c trunk/src/target/cortex_m3.c trunk/src/target/embeddedice.c trunk/src/target/etb.c trunk/src/target/etb.h trunk/src/target/etm.c trunk/src/target/feroceon.c trunk/src/target/mips32.h trunk/src/target/mips_ejtag.c trunk/src/target/oocd_trace.c trunk/src/target/register.h trunk/src/target/target.c trunk/src/target/target_request.c trunk/src/target/trace.c trunk/src/target/trace.h trunk/src/target/xscale.c trunk/src/xsvf/xsvf.c Log: Zach Welch <zw...@su...> fix -Werror warnings Modified: trunk/src/helper/binarybuffer.c =================================================================== --- trunk/src/helper/binarybuffer.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/helper/binarybuffer.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -55,7 +55,7 @@ u8* buf_cpy(u8 *from, u8 *to, int size) { - int num_bytes = CEIL(size, 8); + unsigned int num_bytes = CEIL(size, 8); unsigned int i; if (from == NULL) @@ -244,7 +244,7 @@ int str_to_buf(const char *str, int str_len, u8 *buf, int buf_len, int radix) { char *charbuf; - u32 tmp; + char tmp; float factor; u8 *b256_buf; int b256_len; Modified: trunk/src/jtag/jtag.c =================================================================== --- trunk/src/jtag/jtag.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/jtag/jtag.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -1758,7 +1758,7 @@ jteap = tap->event_action; /* replace existing? */ while (jteap) { - if (jteap->event == n->value) { + if (jteap->event == (enum jtag_tap_event)n->value) { break; } jteap = jteap->next; Modified: trunk/src/jtag/rlink/rlink.c =================================================================== --- trunk/src/jtag/rlink/rlink.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/jtag/rlink/rlink.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -268,7 +268,7 @@ USB_TIMEOUT_MS ); - if(usb_ret < sizeof(usb_buffer)) { + if((size_t)usb_ret < sizeof(usb_buffer)) { break; } @@ -363,7 +363,7 @@ buffer += sizeof(*header); length -= sizeof(*header); - if(length < header->length + 1) { + if(length < (size_t)header->length + 1) { LOG_ERROR("Malformed DTC image\n"); exit(1); } @@ -605,8 +605,8 @@ struct { dtc_reply_queue_entry_t *rq_head; dtc_reply_queue_entry_t *rq_tail; - int cmd_index; - int reply_index; + u32 cmd_index; + u32 reply_index; u8 cmd_buffer[USB_EP2BANK_SIZE]; } dtc_queue; @@ -617,7 +617,7 @@ static struct { - int length; + u32 length; u32 buffer; } tap_state_queue; Modified: trunk/src/pld/virtex2.c =================================================================== --- trunk/src/pld/virtex2.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/pld/virtex2.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -161,7 +161,7 @@ virtex2_pld_device_t *virtex2_info = pld_device->driver_priv; xilinx_bit_file_t bit_file; int retval; - int i; + unsigned int i; scan_field_t field; Modified: trunk/src/pld/xilinx_bit.c =================================================================== --- trunk/src/pld/xilinx_bit.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/pld/xilinx_bit.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -40,7 +40,7 @@ int read_section(FILE *input_file, int length_size, char section, u32 *buffer_length, u8 **buffer) { u8 length_buffer[4]; - u32 length; + int length; char section_char; int read_count; Modified: trunk/src/server/gdb_server.c =================================================================== --- trunk/src/server/gdb_server.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/server/gdb_server.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -348,7 +348,7 @@ char local_buffer[1024]; local_buffer[0] = '$'; - if (len+4 <= sizeof(local_buffer)) + if ((size_t)len + 4 <= sizeof(local_buffer)) { /* performance gain on smaller packets by only a single call to gdb_write() */ memcpy(local_buffer+1, buffer, len++); @@ -1213,7 +1213,7 @@ { hex_buffer = malloc(len * 2 + 1); - int i; + u32 i; for (i = 0; i < len; i++) { u8 t = buffer[i]; @@ -1243,7 +1243,7 @@ u8 *buffer; - int i; + u32 i; int retval; /* skip command character */ @@ -1540,12 +1540,12 @@ int gdb_calc_blocksize(flash_bank_t *bank) { - int i; - int block_size = 0xffffffff; + u32 i; + u32 block_size = 0xffffffff; /* loop through all sectors and return smallest sector size */ - for (i = 0; i < bank->num_sectors; i++) + for (i = 0; i < (u32)bank->num_sectors; i++) { if (bank->sectors[i].size < block_size) block_size = bank->sectors[i].size; Modified: trunk/src/svf/svf.c =================================================================== --- trunk/src/svf/svf.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/svf/svf.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -103,7 +103,7 @@ "ABSENT" }; -char *svf_tap_state_name[16]; +char *svf_tap_state_name[TAP_NUM_STATES]; #define XXR_TDI (1 << 0) #define XXR_TDO (1 << 1) @@ -316,7 +316,7 @@ svf_buffer_size = 2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT; memcpy(&svf_para, &svf_para_init, sizeof(svf_para)); - for (i = 0; i < dimof(svf_tap_state_name); i++) + for (i = 0; i < (int)dimof(svf_tap_state_name); i++) { svf_tap_state_name[i] = (char *)tap_state_name(i); } @@ -515,7 +515,7 @@ static int svf_tap_state_is_valid(tap_state_t state) { - return ((state >= 0) && (state < sizeof(svf_tap_state_name))); + return state >= 0 && state < TAP_NUM_STATES; } static int svf_find_string_in_array(char *str, char **strs, int num_of_element) Modified: trunk/src/target/arm720t.h =================================================================== --- trunk/src/target/arm720t.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/arm720t.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -32,7 +32,7 @@ typedef struct arm720t_common_s { - int common_magic; + u32 common_magic; armv4_5_mmu_common_t armv4_5_mmu; arm7tdmi_common_t arm7tdmi_common; u32 cp15_control_reg; Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/arm7_9_common.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -655,7 +655,8 @@ arm7_9_common_t *arm7_9 = armv4_5->arch_info; arm_jtag_t *jtag_info = &arm7_9->jtag_info; u32 *data; - int i, retval = ERROR_OK; + int retval = ERROR_OK; + u32 i; data = malloc(size * (sizeof(u32))); @@ -1956,7 +1957,7 @@ arm7_9_common_t *arm7_9 = armv4_5->arch_info; u32 reg[16]; - int num_accesses = 0; + u32 num_accesses = 0; int thisrun_accesses; int i; u32 cpsr; @@ -2133,7 +2134,7 @@ reg_t *dbg_ctrl = &arm7_9->eice_cache->reg_list[EICE_DBG_CTRL]; u32 reg[16]; - int num_accesses = 0; + u32 num_accesses = 0; int thisrun_accesses; int i; u32 cpsr; @@ -2466,7 +2467,7 @@ 0x04C11DB7 /* CRC32XOR: .word 0x04C11DB7 */ }; - int i; + u32 i; if (target_alloc_working_area(target, sizeof(arm7_9_crc_code), &crc_algorithm) != ERROR_OK) { @@ -2518,7 +2519,7 @@ reg_param_t reg_params[3]; armv4_5_algorithm_t armv4_5_info; int retval; - int i; + u32 i; u32 erase_check_code[] = { Modified: trunk/src/target/arm7_9_common.h =================================================================== --- trunk/src/target/arm7_9_common.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/arm7_9_common.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -40,7 +40,7 @@ typedef struct arm7_9_common_s { - int common_magic; + u32 common_magic; arm_jtag_t jtag_info; reg_cache_t *eice_cache; Modified: trunk/src/target/arm920t.h =================================================================== --- trunk/src/target/arm920t.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/arm920t.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -32,7 +32,7 @@ typedef struct arm920t_common_s { - int common_magic; + u32 common_magic; armv4_5_mmu_common_t armv4_5_mmu; arm9tdmi_common_t arm9tdmi_common; u32 cp15_control_reg; Modified: trunk/src/target/arm926ejs.h =================================================================== --- trunk/src/target/arm926ejs.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/arm926ejs.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -32,7 +32,7 @@ typedef struct arm926ejs_common_s { - int common_magic; + u32 common_magic; armv4_5_mmu_common_t armv4_5_mmu; arm9tdmi_common_t arm9tdmi_common; int (*read_cp15)(target_t *target, u32 op1, u32 op2, u32 CRn, u32 CRm, u32 *value); Modified: trunk/src/target/arm_jtag.h =================================================================== --- trunk/src/target/arm_jtag.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/arm_jtag.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -30,9 +30,9 @@ { jtag_tap_t *tap; - int scann_size; + u32 scann_size; u32 scann_instr; - int cur_scan_chain; + u32 cur_scan_chain; u32 intest_instr; } arm_jtag_t; Modified: trunk/src/target/armv4_5.c =================================================================== --- trunk/src/target/armv4_5.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/armv4_5.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -231,7 +231,7 @@ } } - if (armv4_5_target->core_mode != (value & 0x1f)) + if (armv4_5_target->core_mode != (enum armv4_5_mode)(value & 0x1f)) { LOG_DEBUG("changing ARM core mode to '%s'", armv4_5_mode_strings[armv4_5_mode_to_number(value & 0x1f)]); armv4_5_target->core_mode = value & 0x1f; Modified: trunk/src/target/armv7m.c =================================================================== --- trunk/src/target/armv7m.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/armv7m.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -591,7 +591,7 @@ 0x1DB7, 0x04C1 /* CRC32XOR: .word 0x04C11DB7 */ }; - int i; + u32 i; if (target_alloc_working_area(target, sizeof(cortex_m3_crc_code), &crc_algorithm) != ERROR_OK) { @@ -640,7 +640,7 @@ reg_param_t reg_params[3]; armv7m_algorithm_t armv7m_info; int retval; - int i; + u32 i; u16 erase_check_code[] = { Modified: trunk/src/target/cortex_m3.c =================================================================== --- trunk/src/target/cortex_m3.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/cortex_m3.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -1475,7 +1475,7 @@ swjdp_common_t *swjdp = &cortex_m3->swjdp_info; u8 data; u8 ctrl; - int i; + u32 i; for (i = 0; i < (size * 4); i++) { Modified: trunk/src/target/embeddedice.c =================================================================== --- trunk/src/target/embeddedice.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/embeddedice.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -484,7 +484,7 @@ u8 field1_out[1]; u8 field2_out[1]; int retval; - int hsact; + u32 hsact; struct timeval lap; struct timeval now; @@ -544,7 +544,7 @@ gettimeofday(&now, NULL); } - while ((now.tv_sec-lap.tv_sec)*1000 + (now.tv_usec-lap.tv_usec)/1000 <= timeout); + while ((u32)((now.tv_sec-lap.tv_sec)*1000 + (now.tv_usec-lap.tv_usec)/1000) <= timeout); return ERROR_TARGET_TIMEOUT; } Modified: trunk/src/target/etb.c =================================================================== --- trunk/src/target/etb.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/etb.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -453,7 +453,7 @@ arm7_9->etm_ctx->capture_driver_priv = etb; etb->tap = tap; - etb->cur_scan_chain = -1; + etb->cur_scan_chain = ~0UL; etb->reg_cache = NULL; etb->ram_width = 0; etb->ram_depth = 0; Modified: trunk/src/target/etb.h =================================================================== --- trunk/src/target/etb.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/etb.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -46,17 +46,17 @@ { etm_context_t *etm_ctx; jtag_tap_t *tap; - int cur_scan_chain; + u32 cur_scan_chain; reg_cache_t *reg_cache; /* ETB parameters */ - int ram_depth; - int ram_width; + u32 ram_depth; + u32 ram_width; } etb_t; typedef struct etb_reg_s { - int addr; + u32 addr; etb_t *etb; } etb_reg_t; Modified: trunk/src/target/etm.c =================================================================== --- trunk/src/target/etm.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/etm.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -647,7 +647,7 @@ u8 packet; int shift = 0; int apo; - int i; + u32 i; /* quit analysis if less than two cycles are left in the trace * because we can't extract the APO */ @@ -998,7 +998,7 @@ if (((instruction.type == ARM_B) || (instruction.type == ARM_BL) || (instruction.type == ARM_BLX)) && - (instruction.info.b_bl_bx_blx.target_address != -1)) + (instruction.info.b_bl_bx_blx.target_address != ~0UL)) { next_pc = instruction.info.b_bl_bx_blx.target_address; } @@ -1543,7 +1543,7 @@ armv4_5_common_t *armv4_5; arm7_9_common_t *arm7_9; etm_context_t *etm_ctx; - int i; + u32 i; if (argc != 1) { @@ -1611,7 +1611,7 @@ armv4_5_common_t *armv4_5; arm7_9_common_t *arm7_9; etm_context_t *etm_ctx; - int i; + u32 i; if (argc != 1) { Modified: trunk/src/target/feroceon.c =================================================================== --- trunk/src/target/feroceon.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/feroceon.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -517,7 +517,7 @@ arm7_9_common_t *arm7_9 = armv4_5->arch_info; enum armv4_5_state core_state = armv4_5->core_state; u32 x, flip, shift, save[7]; - int i; + u32 i; /* * We can't use the dcc flow control bits, so let's transfer data @@ -547,7 +547,7 @@ 0xeafffff3, /* b 3b */ }; - int dcc_size = sizeof(dcc_code); + u32 dcc_size = sizeof(dcc_code); if (!arm7_9->dcc_downloads) return target->type->write_memory(target, address, 4, count, buffer); Modified: trunk/src/target/mips32.h =================================================================== --- trunk/src/target/mips32.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/mips32.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -47,7 +47,7 @@ typedef struct mips32_common_s { - int common_magic; + u32 common_magic; void *arch_info; reg_cache_t *core_cache; mips_ejtag_t ejtag_info; Modified: trunk/src/target/mips_ejtag.c =================================================================== --- trunk/src/target/mips_ejtag.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/mips_ejtag.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -40,7 +40,7 @@ if (tap==NULL) return ERROR_FAIL; - if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != new_instr) + if (buf_get_u32(tap->cur_instr, 0, tap->ir_length) != (u32)new_instr) { scan_field_t field; u8 t[4]; Modified: trunk/src/target/oocd_trace.c =================================================================== --- trunk/src/target/oocd_trace.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/oocd_trace.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -78,7 +78,8 @@ int oocd_trace_read_memory(oocd_trace_t *oocd_trace, u8 *data, u32 address, u32 size) { - size_t bytes_written, bytes_read, bytes_to_read; + size_t bytes_written, bytes_to_read; + ssize_t bytes_read; u8 cmd; oocd_trace_write_reg(oocd_trace, OOCD_TRACE_ADDRESS, address); @@ -188,7 +189,7 @@ u32 first_frame = 0x0; u32 num_frames = 1048576; u8 *trace_data; - int i; + u32 i; oocd_trace_read_reg(oocd_trace, OOCD_TRACE_STATUS, &status); oocd_trace_read_reg(oocd_trace, OOCD_TRACE_ADDRESS, &address); Modified: trunk/src/target/register.h =================================================================== --- trunk/src/target/register.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/register.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -40,7 +40,7 @@ u8 *value; int dirty; int valid; - int size; + u32 size; bitfield_desc_t *bitfield_desc; int num_bitfields; void *arch_info; Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/target.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -985,7 +985,7 @@ /* handle unaligned head bytes */ if (address % 4) { - int unaligned = 4 - (address % 4); + u32 unaligned = 4 - (address % 4); if (unaligned > size) unaligned = size; @@ -1060,7 +1060,7 @@ /* handle unaligned head bytes */ if (address % 4) { - int unaligned = 4 - (address % 4); + u32 unaligned = 4 - (address % 4); if (unaligned > size) unaligned = size; @@ -1100,7 +1100,7 @@ { u8 *buffer; int retval; - int i; + u32 i; u32 checksum = 0; if (!target->type->examined) { @@ -2273,7 +2273,7 @@ retval = target->type->read_memory(target, image.sections[i].base_address, size, count, data); if (retval == ERROR_OK) { - int t; + u32 t; for (t = 0; t < buf_cnt; t++) { if (data[t] != buffer[t]) @@ -2508,9 +2508,9 @@ } /* Dump a gmon.out histogram file. */ -static void writeGmon(u32 *samples, int sampleNum, char *filename) +static void writeGmon(u32 *samples, u32 sampleNum, char *filename) { - int i; + u32 i; FILE *f=fopen(filename, "w"); if (f==NULL) return; @@ -2539,8 +2539,8 @@ int addressSpace=(max-min+1); - static int const maxBuckets=256*1024; /* maximum buckets. */ - int length=addressSpace; + static const u32 maxBuckets = 256 * 1024; /* maximum buckets. */ + u32 length = addressSpace; if (length > maxBuckets) { length=maxBuckets; @@ -2747,7 +2747,8 @@ u32 v; const char *varname; u8 buffer[4096]; - int i, n, e, retval; + int n, e, retval; + u32 i; /* argv[1] = name of array to receive the data * argv[2] = desired width @@ -2928,7 +2929,8 @@ u32 v; const char *varname; u8 buffer[4096]; - int i, n, e, retval; + int n, e, retval; + u32 i; /* argv[1] = name of array to get the data * argv[2] = desired width @@ -3200,7 +3202,7 @@ teap = target->event_action; /* replace existing? */ while( teap ){ - if( teap->event == n->value ){ + if( teap->event == (enum target_event)n->value ){ break; } teap = teap->next; Modified: trunk/src/target/target_request.c =================================================================== --- trunk/src/target/target_request.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/target_request.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -73,7 +73,7 @@ char line[128]; int line_len; debug_msg_receiver_t *c = target->dbgmsg; - int i; + u32 i; LOG_DEBUG("size: %i, length: %i", size, length); Modified: trunk/src/target/trace.c =================================================================== --- trunk/src/target/trace.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/trace.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -31,7 +31,7 @@ #include <string.h> #include <inttypes.h> -int trace_point(target_t *target, int number) +int trace_point(target_t *target, u32 number) { trace_t *trace = target->trace_info; @@ -60,7 +60,7 @@ if (argc == 0) { - int i; + u32 i; for (i = 0; i < trace->num_trace_points; i++) { @@ -125,9 +125,9 @@ } else { - int i; - int first = 0; - int last = trace->trace_history_pos; + u32 i; + u32 first = 0; + u32 last = trace->trace_history_pos; if ( !trace->trace_history_size ) { command_print(cmd_ctx, "trace history buffer is not allocated"); Modified: trunk/src/target/trace.h =================================================================== --- trunk/src/target/trace.h 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/trace.h 2009-04-19 20:51:16 UTC (rev 1472) @@ -32,12 +32,12 @@ typedef struct trace_s { - int num_trace_points; - int trace_points_size; + u32 num_trace_points; + u32 trace_points_size; trace_point_t *trace_points; - int trace_history_size; + u32 trace_history_size; u32 *trace_history; - int trace_history_pos; + u32 trace_history_pos; int trace_history_overflowed; } trace_t; @@ -50,7 +50,7 @@ TRACE_OVERFLOWED = 0x8, } trace_status_t; -extern int trace_point(struct target_s *target, int number); +extern int trace_point(struct target_s *target, u32 number); extern int trace_register_commands(struct command_context_s *cmd_ctx); #define ERROR_TRACE_IMAGE_UNAVAILABLE -(1500) Modified: trunk/src/target/xscale.c =================================================================== --- trunk/src/target/xscale.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/target/xscale.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -1631,7 +1631,7 @@ u32 binary_size; u32 buf_cnt; - int i; + u32 i; int retval; breakpoint_t *breakpoint = target->breakpoints; @@ -1928,7 +1928,7 @@ armv4_5_common_t *armv4_5 = target->arch_info; xscale_common_t *xscale = armv4_5->arch_info; u32 *buf32; - int i; + u32 i; int retval; LOG_DEBUG("address: 0x%8.8x, size: 0x%8.8x, count: 0x%8.8x", address, size, count); @@ -2933,7 +2933,7 @@ (((instruction.type == ARM_B) || (instruction.type == ARM_BL) || (instruction.type == ARM_BLX)) && - (instruction.info.b_bl_bx_blx.target_address != -1))) + (instruction.info.b_bl_bx_blx.target_address != ~0UL))) { xscale->trace.current_pc = instruction.info.b_bl_bx_blx.target_address; } Modified: trunk/src/xsvf/xsvf.c =================================================================== --- trunk/src/xsvf/xsvf.c 2009-04-19 19:15:09 UTC (rev 1471) +++ trunk/src/xsvf/xsvf.c 2009-04-19 20:51:16 UTC (rev 1472) @@ -743,7 +743,7 @@ case XCOMMENT: { - int ndx = 0; + unsigned int ndx = 0; char comment[128]; do |
From: <mi...@ma...> - 2009-04-19 21:15:22
|
Author: mifi Date: 2009-04-19 21:15:09 +0200 (Sun, 19 Apr 2009) New Revision: 1471 Modified: trunk/src/jtag/jlink.c trunk/src/jtag/usbprog.c Log: Partially fix USBprog and JLink adapters on XScale target Thanks to Peter Denison <openwrt(at)marshadder.org> Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-19 14:51:51 UTC (rev 1470) +++ trunk/src/jtag/jlink.c 2009-04-19 19:15:09 UTC (rev 1471) @@ -433,7 +433,10 @@ /* Move to appropriate scan state */ jlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT); - jlink_state_move(); + /* Only move if we're not already there */ + if (tap_get_state() != tap_get_end_state()) + jlink_state_move(); + jlink_end_state(saved_end_state); /* Scan */ Modified: trunk/src/jtag/usbprog.c =================================================================== --- trunk/src/jtag/usbprog.c 2009-04-19 14:51:51 UTC (rev 1470) +++ trunk/src/jtag/usbprog.c 2009-04-19 19:15:09 UTC (rev 1471) @@ -265,6 +265,10 @@ int num_states = cmd->num_states; int state_count; + /* There may be queued transitions, and before following a specified + path, we must flush those queued transitions */ + usbprog_jtag_tms_send(usbprog_jtag_handle); + state_count = 0; while (num_states) { @@ -323,6 +327,10 @@ usbprog_write(0, 0, 0); } +#ifdef _DEBUG_JTAG_IO_ + LOG_DEBUG("runtest: cur_state %s end_state %s", tap_state_name(tap_get_state()), tap_state_name(tap_get_end_state())); +#endif + /* finish in end_state */ /* usbprog_end_state(saved_end_state); @@ -340,9 +348,10 @@ else usbprog_end_state(TAP_DRSHIFT); - /* usbprog_jtag_tms_send(usbprog_jtag_handle); */ + /* Only move if we're not already there */ + if (tap_get_state() != tap_get_end_state()) + usbprog_state_move(); - usbprog_state_move(); usbprog_end_state(saved_end_state); usbprog_jtag_tms_send(usbprog_jtag_handle); @@ -358,6 +367,7 @@ } f(usbprog_jtag_handle, (char *)buffer, scan_size); + /* The adapter does the transition to PAUSE internally */ if (ir_scan) tap_set_state(TAP_IRPAUSE); else |
From: <mi...@ma...> - 2009-04-19 16:52:04
|
Author: mifi Date: 2009-04-19 16:51:51 +0200 (Sun, 19 Apr 2009) New Revision: 1470 Modified: trunk/src/jtag/jlink.c Log: Added functionality to support jtag_khz for the jlink. Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-04-19 12:06:49 UTC (rev 1469) +++ trunk/src/jtag/jlink.c 2009-04-19 14:51:51 UTC (rev 1470) @@ -79,6 +79,7 @@ /* External interface functions */ int jlink_execute_queue(void); int jlink_speed(int speed); +int jlink_speed_div(int speed, int* khz); int jlink_khz(int khz, int *jtag_speed); int jlink_register_commands(struct command_context_s *cmd_ctx); int jlink_init(void); @@ -134,6 +135,7 @@ .name = "jlink", .execute_queue = jlink_execute_queue, .speed = jlink_speed, + .speed_div = jlink_speed_div, .khz = jlink_khz, .register_commands = jlink_register_commands, .init = jlink_init, @@ -270,6 +272,13 @@ return ERROR_OK; } +int jlink_speed_div(int speed, int* khz) +{ + *khz = speed; + + return ERROR_OK; +} + int jlink_khz(int khz, int *jtag_speed) { *jtag_speed = khz; |
From: <oh...@ma...> - 2009-04-19 14:06:53
|
Author: oharboe Date: 2009-04-19 14:06:49 +0200 (Sun, 19 Apr 2009) New Revision: 1469 Modified: trunk/src/flash/cfi.c trunk/src/flash/cfi.h trunk/src/flash/non_cfi.c trunk/src/flash/non_cfi.h Log: Michael Schwingen <rin...@di...> enhanced non-CFI flash support Modified: trunk/src/flash/cfi.c =================================================================== --- trunk/src/flash/cfi.c 2009-04-19 08:18:46 UTC (rev 1468) +++ trunk/src/flash/cfi.c 2009-04-19 12:06:49 UTC (rev 1469) @@ -1,6 +1,8 @@ /*************************************************************************** * Copyright (C) 2005, 2007 by Dominic Rath * * Dom...@gm... * + * Copyright (C) 2009 Michael Schwingen * + * mi...@sc... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -82,24 +84,6 @@ static void cfi_fixup_0002_unlock_addresses(flash_bank_t *flash, void *param); static void cfi_fixup_atmel_reversed_erase_regions(flash_bank_t *flash, void *param); -/* fixup after identifying JEDEC manufactuer and ID */ -static cfi_fixup_t cfi_jedec_fixups[] = { - {CFI_MFR_SST, 0x00D4, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_SST, 0x00D5, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_SST, 0x00D6, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_SST, 0x00D7, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_SST, 0x2780, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_ST, 0x00D5, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_ST, 0x00D6, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_AMD, 0x2223, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_AMD, 0x22ab, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_FUJITSU, 0x226b, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_AMIC, 0xb31a, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_MX, 0x225b, cfi_fixup_non_cfi, NULL}, - {CFI_MFR_AMD, 0x225b, cfi_fixup_non_cfi, NULL}, - {0, 0, NULL, NULL} -}; - /* fixup after reading cmdset 0002 primary query table */ static cfi_fixup_t cfi_0002_fixups[] = { {CFI_MFR_SST, 0x00D4, cfi_fixup_0002_unlock_addresses, &cfi_unlock_addresses[CFI_UNLOCK_5555_2AAA]}, @@ -633,6 +617,8 @@ { cfi_flash_bank_t *cfi_info; int i; + (void) cmd_ctx; + (void) cmd; if (argc < 6) { @@ -964,7 +950,7 @@ cfi_intel_protect(bank, set, first, last); break; default: - LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id); + LOG_ERROR("protect: cfi primary command set %i unsupported", cfi_info->pri_id); break; } @@ -1843,7 +1829,7 @@ return cfi_intel_write_words(bank, word, wordcount, address); break; case 2: - return cfi_spansion_write_words(bank, word, wordcount, address); + return cfi_spansion_write_words(bank, word, wordcount, address); break; default: LOG_ERROR("cfi primary command set %i unsupported", cfi_info->pri_id); @@ -1965,7 +1951,7 @@ LOG_ERROR("Unsupported chip width %d", bank->chip_width); return ERROR_FLASH_OPERATION_FAILED; } - + bufferwsize/=(bank->bus_width / bank->chip_width); /* fall back to memory writes */ @@ -2064,6 +2050,7 @@ static void cfi_fixup_atmel_reversed_erase_regions(flash_bank_t *bank, void *param) { + (void) param; cfi_flash_bank_t *cfi_info = bank->driver_priv; cfi_spansion_pri_ext_t *pri_ext = cfi_info->pri_ext; @@ -2075,6 +2062,7 @@ int i; cfi_flash_bank_t *cfi_info = bank->driver_priv; cfi_spansion_pri_ext_t *pri_ext = cfi_info->pri_ext; + (void) param; if ((pri_ext->_reversed_geometry) || (pri_ext->TopBottom == 3)) { @@ -2110,7 +2098,6 @@ int num_sectors = 0; int i; int sector = 0; - u32 offset = 0; u32 unlock1 = 0x555; u32 unlock2 = 0x2aa; int retval; @@ -2175,6 +2162,7 @@ } } + LOG_INFO("Flash Manufacturer/Device: 0x%04x 0x%04x", cfi_info->manufacturer, cfi_info->device_id); /* switch back to read array mode */ cfi_command(bank, 0xf0, command); if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK) @@ -2187,7 +2175,8 @@ return retval; } - cfi_fixup(bank, cfi_jedec_fixups); + /* check device/manufacturer ID for known non-CFI flashes. */ + cfi_fixup_non_cfi(bank); /* query only if this is a CFI compatible flash, * otherwise the relevant info has already been filled in @@ -2225,7 +2214,7 @@ { return retval; } - LOG_ERROR("Could not probe bank"); + LOG_ERROR("Could not probe bank: no QRY"); return ERROR_FLASH_BANK_INVALID; } @@ -2261,18 +2250,13 @@ (1 << cfi_info->block_erase_timeout_max) * (1 << cfi_info->block_erase_timeout_typ), (1 << cfi_info->chip_erase_timeout_max) * (1 << cfi_info->chip_erase_timeout_typ)); - cfi_info->dev_size = cfi_query_u8(bank, 0, 0x27); + cfi_info->dev_size = 1<<cfi_query_u8(bank, 0, 0x27); cfi_info->interface_desc = cfi_query_u16(bank, 0, 0x28); cfi_info->max_buf_write_size = cfi_query_u16(bank, 0, 0x2a); cfi_info->num_erase_regions = cfi_query_u8(bank, 0, 0x2c); - LOG_DEBUG("size: 0x%x, interface desc: %i, max buffer write size: %x", 1 << cfi_info->dev_size, cfi_info->interface_desc, (1 << cfi_info->max_buf_write_size)); + LOG_DEBUG("size: 0x%x, interface desc: %i, max buffer write size: %x", cfi_info->dev_size, cfi_info->interface_desc, (1 << cfi_info->max_buf_write_size)); - if ((u32)((1 << cfi_info->dev_size) * bank->bus_width / bank->chip_width) != bank->size) - { - LOG_WARNING("configuration specifies 0x%x size, but a 0x%x size flash was found", bank->size, 1 << cfi_info->dev_size); - } - if (cfi_info->num_erase_regions) { cfi_info->erase_region_info = malloc(4 * cfi_info->num_erase_regions); @@ -2338,6 +2322,11 @@ break; } + if ((cfi_info->dev_size * bank->bus_width / bank->chip_width) != bank->size) + { + LOG_WARNING("configuration specifies 0x%x size, but a 0x%x size flash was found", bank->size, cfi_info->dev_size); + } + if (cfi_info->num_erase_regions == 0) { /* a device might have only one erase block, spanning the whole device */ @@ -2351,6 +2340,8 @@ } else { + u32 offset = 0; + for (i = 0; i < cfi_info->num_erase_regions; i++) { num_sectors += (cfi_info->erase_region_info[i] & 0xffff) + 1; @@ -2372,8 +2363,12 @@ sector++; } } + if (offset != cfi_info->dev_size) + { + LOG_WARNING("CFI size is 0x%x, but total sector size is 0x%x", cfi_info->dev_size, offset); + } } - + cfi_info->probed = 1; return ERROR_OK; @@ -2504,7 +2499,7 @@ } if (cfi_info->not_cfi == 0) - printed = snprintf(buf, buf_size, "\ncfi information:\n"); + printed = snprintf(buf, buf_size, "\ncfi information:\n"); else printed = snprintf(buf, buf_size, "\nnon-cfi flash:\n"); buf += printed; @@ -2546,7 +2541,7 @@ buf_size -= printed; printed = snprintf(buf, buf_size, "size: 0x%x, interface desc: %i, max buffer write size: %x\n", - 1 << cfi_info->dev_size, + cfi_info->dev_size, cfi_info->interface_desc, 1 << cfi_info->max_buf_write_size); buf += printed; Modified: trunk/src/flash/cfi.h =================================================================== --- trunk/src/flash/cfi.h 2009-04-19 08:18:46 UTC (rev 1468) +++ trunk/src/flash/cfi.h 2009-04-19 12:06:49 UTC (rev 1469) @@ -26,8 +26,8 @@ typedef struct cfi_flash_bank_s { working_area_t *write_algorithm; - + int x16_as_x8; int jedec_probe; int not_cfi; @@ -59,7 +59,7 @@ u8 chip_erase_timeout_max; /* flash geometry */ - u8 dev_size; + u32 dev_size; u16 interface_desc; u16 max_buf_write_size; u8 num_erase_regions; Modified: trunk/src/flash/non_cfi.c =================================================================== --- trunk/src/flash/non_cfi.c 2009-04-19 08:18:46 UTC (rev 1468) +++ trunk/src/flash/non_cfi.c 2009-04-19 12:06:49 UTC (rev 1469) @@ -1,6 +1,8 @@ /*************************************************************************** * Copyright (C) 2007 by Dominic Rath * * Dom...@gm... * + * Copyright (C) 2009 Michael Schwingen * + * mi...@sc... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -29,212 +31,279 @@ #include "cfi.h" #include "non_cfi.h" +#define KB 1024 +#define MB (1024*1024) +#define ERASE_REGION(num, size) (((size/256)<<16)|(num-1)) + /* non-CFI compatible flashes */ non_cfi_t non_cfi_flashes[] = { { .mfr = CFI_MFR_SST, .id = 0xd4, .pri_id = 0x02, - .dev_size = 0x10, /* 2^16 = 64KB */ + .dev_size = 64*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, .num_erase_regions = 1, .erase_region_info = { - 0x0010000f, /* 16x 4KB */ - 0x00000000 + ERASE_REGION(16, 4*KB) } }, { .mfr = CFI_MFR_SST, .id = 0xd5, .pri_id = 0x02, - .dev_size = 0x11, /* 2^17 = 128KB */ + .dev_size = 128*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, .num_erase_regions = 1, .erase_region_info = { - 0x0010001f, - 0x00000000 + ERASE_REGION(32, 4*KB) } }, { .mfr = CFI_MFR_SST, .id = 0xd6, .pri_id = 0x02, - .dev_size = 0x12, /* 2^18 = 256KB */ + .dev_size = 256*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, .num_erase_regions = 1, .erase_region_info = { - 0x0010003f, - 0x00000000 + ERASE_REGION(64, 4*KB) } }, { .mfr = CFI_MFR_SST, .id = 0xd7, .pri_id = 0x02, - .dev_size = 0x13, /* 2^19 = 512KB */ + .dev_size = 512*KB, .interface_desc = 0x0, /* x8 only device */ .max_buf_write_size = 0x0, .num_erase_regions = 1, .erase_region_info = { - 0x0010007f, - 0x00000000 + ERASE_REGION(128, 4*KB) } }, { .mfr = CFI_MFR_SST, .id = 0x2780, .pri_id = 0x02, - .dev_size = 0x13, /* 2^19 = 512KB */ + .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device */ .max_buf_write_size = 0x0, .num_erase_regions = 1, .erase_region_info = { - 0x0010007f, - 0x00000000 + ERASE_REGION(128, 4*KB) } }, { .mfr = CFI_MFR_ST, .id = 0xd6, /* ST29F400BB */ .pri_id = 0x02, - .dev_size = 0x13, /* 2^19 = 512KB */ + .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x00400000, /* 1x 16KB */ - 0x00200001, /* 2x 8KB */ - 0x00800000, /* 1x 32KB */ - 0x01000006, /* 7x 64KB */ - 0x00000000 + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION( 7, 64*KB) } }, { .mfr = CFI_MFR_ST, .id = 0xd5, /* ST29F400BT */ .pri_id = 0x02, - .dev_size = 0x13, /* 2^19 = 512KB */ + .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x01000006, /* 7x 64KB */ - 0x00800000, /* 1x 32KB */ - 0x00200001, /* 2x 8KB */ - 0x00400000, /* 1x 16KB */ - 0x00000000 + ERASE_REGION( 7, 64*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 16*KB) } }, { .mfr = CFI_MFR_AMD, .id = 0x22ab, /* AM29F400BB */ .pri_id = 0x02, - .dev_size = 0x13, /* 2^19 = 512KB */ + .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x00400000, /* 1x 16KB */ - 0x00200001, /* 2x 8KB */ - 0x00800000, /* 1x 32KB */ - 0x01000006, /* 7x 64KB */ - 0x00000000 + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION( 7, 64*KB) } }, { .mfr = CFI_MFR_AMD, .id = 0x2223, /* AM29F400BT */ .pri_id = 0x02, - .dev_size = 0x13, /* 2^19 = 512KB */ + .dev_size = 512*KB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x01000006, /* 7x 64KB */ - 0x00800000, /* 1x 32KB */ - 0x00200001, /* 2x 8KB */ - 0x00400000, /* 1x 16KB */ - 0x00000000 + ERASE_REGION( 7, 64*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 16*KB) } }, { .mfr = CFI_MFR_FUJITSU, .id = 0x226b, /* AM29SL800DB */ .pri_id = 0x02, - .dev_size = 0x14, /* 2^20 = 1MB */ + .dev_size = 1*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x00400000, /* 1x 16KB */ - 0x00200001, /* 2x 8KB */ - 0x00800000, /* 1x 32KB */ - 0x0100000e, /* 15x 64KB */ - 0x00000000 + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION(15, 64*KB) } }, { .mfr = CFI_MFR_AMIC, .id = 0xb31a, /* A29L800A */ .pri_id = 0x02, - .dev_size = 0x14, + .dev_size = 1*MB, .interface_desc = 0x2, .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x00400000, /* 1x 16KB */ - 0x00200001, /* 2x 8KB */ - 0x00800000, /* 1x 32KB */ - 0x0100000e, /* 15x 64KB */ - 0x00000000 + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION(15, 64*KB) } }, { .mfr = CFI_MFR_MX, .id = 0x225b, /* MX29LV800B */ .pri_id = 0x02, - .dev_size = 0x14, /* 2^20 = 1MB */ + .dev_size = 1*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x00400000, /* 1x 16KB */ - 0x00200001, /* 2x 8KB */ - 0x00800000, /* 1x 32KB */ - 0x0100000e, /* 15x 64KB */ - 0x00000000 + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION(15, 64*KB) } }, + { + .mfr = CFI_MFR_MX, + .id = 0x2249, /* MX29LV160AB: 2MB */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .num_erase_regions = 4, + .erase_region_info = + { + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION(31, 64*KB) + } + }, + { + .mfr = CFI_MFR_MX, + .id = 0x22C4, /* MX29LV160AT: 2MB */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .num_erase_regions = 4, + .erase_region_info = + { + ERASE_REGION(31, 64*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 16*KB) + } + }, + { + .mfr = CFI_MFR_SST, + .id = 0x2782, /* SST39xF160 */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .num_erase_regions = 1, + .erase_region_info = + { + ERASE_REGION(512, 4*KB) + } + }, + { + .mfr = CFI_MFR_ATMEL, + .id = 0x00c0, /* Atmel 49BV1614 */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .num_erase_regions = 3, + .erase_region_info = + { + ERASE_REGION( 8, 8*KB), + ERASE_REGION( 2, 32*KB), + ERASE_REGION(30, 64*KB) + } + }, + { + .mfr = CFI_MFR_ATMEL, + .id = 0xC2, /* Atmel 49BV1614T */ + .pri_id = 0x02, + .dev_size = 2*MB, + .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ + .max_buf_write_size = 0x0, + .num_erase_regions = 3, + .erase_region_info = + { + ERASE_REGION(30, 64*KB), + ERASE_REGION( 2, 32*KB), + ERASE_REGION( 8, 8*KB) + } + }, + { .mfr = CFI_MFR_AMD, .id = 0x225b, /* S29AL008D */ .pri_id = 0x02, - .dev_size = 0x14, /* 2^20 = 1MB */ + .dev_size = 1*MB, .interface_desc = 0x2, /* x8 or x16 device with nBYTE */ .max_buf_write_size = 0x0, .num_erase_regions = 4, .erase_region_info = { - 0x00400000, /* 1x 16KB */ - 0x00200001, /* 2x 8KB */ - 0x00800000, /* 1x 32KB */ - 0x0100000e, /* 15x 64KB */ - 0x00000000 + ERASE_REGION( 1, 16*KB), + ERASE_REGION( 2, 8*KB), + ERASE_REGION( 1, 32*KB), + ERASE_REGION(15, 64*KB) } }, { @@ -243,23 +312,26 @@ } }; -void cfi_fixup_non_cfi(flash_bank_t *bank, void *param) +void cfi_fixup_non_cfi(flash_bank_t *bank) { cfi_flash_bank_t *cfi_info = bank->driver_priv; non_cfi_t *non_cfi = non_cfi_flashes; - - while (non_cfi->mfr) + + for (non_cfi = non_cfi_flashes; non_cfi->mfr; non_cfi++) { if ((cfi_info->manufacturer == non_cfi->mfr) && (cfi_info->device_id == non_cfi->id)) { break; } - non_cfi++; } - + + /* only fixup jedec flashs found in table */ + if (!non_cfi->mfr) + return; + cfi_info->not_cfi = 1; - + /* fill in defaults for non-critical data */ cfi_info->vcc_min = 0x0; cfi_info->vcc_max = 0x0; @@ -273,22 +345,23 @@ cfi_info->buf_write_timeout_max = 0x0; cfi_info->block_erase_timeout_max = 0x0; cfi_info->chip_erase_timeout_max = 0x0; - + cfi_info->qry[0] = 'Q'; cfi_info->qry[1] = 'R'; cfi_info->qry[2] = 'Y'; - + cfi_info->pri_id = non_cfi->pri_id; cfi_info->pri_addr = 0x0; cfi_info->alt_id = 0x0; cfi_info->alt_addr = 0x0; cfi_info->alt_ext = NULL; - + cfi_info->interface_desc = non_cfi->interface_desc; cfi_info->max_buf_write_size = non_cfi->max_buf_write_size; cfi_info->num_erase_regions = non_cfi->num_erase_regions; cfi_info->erase_region_info = non_cfi->erase_region_info; - + cfi_info->dev_size = non_cfi->dev_size; + if (cfi_info->pri_id == 0x2) { cfi_spansion_pri_ext_t *pri_ext = malloc(sizeof(cfi_spansion_pri_ext_t)); @@ -296,10 +369,10 @@ pri_ext->pri[0] = 'P'; pri_ext->pri[1] = 'R'; pri_ext->pri[2] = 'I'; - + pri_ext->major_version = '1'; pri_ext->minor_version = '0'; - + pri_ext->SiliconRevision = 0x0; pri_ext->EraseSuspend = 0x0; pri_ext->EraseSuspend = 0x0; @@ -312,9 +385,11 @@ pri_ext->VppMin = 0x0; pri_ext->VppMax = 0x0; pri_ext->TopBottom = 0x0; - + + pri_ext->_unlock1 = 0x5555; + pri_ext->_unlock2 = 0x2AAA; pri_ext->_reversed_geometry = 0; - + cfi_info->pri_ext = pri_ext; } else if ((cfi_info->pri_id == 0x1) || (cfi_info->pri_id == 0x3)) { Modified: trunk/src/flash/non_cfi.h =================================================================== --- trunk/src/flash/non_cfi.h 2009-04-19 08:18:46 UTC (rev 1468) +++ trunk/src/flash/non_cfi.h 2009-04-19 12:06:49 UTC (rev 1469) @@ -27,7 +27,7 @@ u16 mfr; u16 id; u16 pri_id; - u8 dev_size; + u32 dev_size; u16 interface_desc; u16 max_buf_write_size; u8 num_erase_regions; @@ -35,6 +35,6 @@ } non_cfi_t; extern non_cfi_t non_cfi_flashes[]; -extern void cfi_fixup_non_cfi(flash_bank_t *bank, void *param); +extern void cfi_fixup_non_cfi(flash_bank_t *bank); #endif /* NON_CFI_H */ |