On Sun, May 05, 2013 at 12:46:49AM +0400, Paul Fertser wrote:
> It might be nice to be able to wait for the target to wake up on its
> own but if it's not going to wake up, BMP becomes absolutely
> unresponsive. Probably the timeout should be made configurable or some
> other workaround invented.
Here's what I've tried so far (obviously not knowing enough about
ADIv5) and how it fails:
diff --git a/src/adiv5.c b/src/adiv5.c
index 45bf94f..8e086ae 100644
--- a/src/adiv5.c
+++ b/src/adiv5.c
@@ -124,6 +124,8 @@ void adiv5_dp_init(ADIv5_DP_t *dp)
tmpap.apsel = i;
tmpap.idr = adiv5_ap_read(&tmpap, ADIV5_AP_IDR);
+ gdb_outf("panic: %d, apsel: %d, idr: %8x\n", tmpap.dp->fatal_on_timeout,
+ tmpap.apsel, tmpap.idr);
if(!tmpap.idr) /* IDR Invalid - Should we not continue here? */
break;
diff --git a/src/adiv5_swdp.c b/src/adiv5_swdp.c
index 866fec1..63503a0 100644
--- a/src/adiv5_swdp.c
+++ b/src/adiv5_swdp.c
@@ -68,10 +68,12 @@ int adiv5_swdp_scan(void)
return -1;
}
+ gdb_outf("idcode dp: %08x\n", dp->idcode);
dp->dp_write = adiv5_swdp_write;
dp->dp_read = adiv5_swdp_read;
dp->error = adiv5_swdp_error;
dp->low_access = adiv5_swdp_low_access;
+ dp->fatal_on_timeout = true;
adiv5_dp_init(dp);
@@ -135,8 +137,12 @@ static uint32_t adiv5_swdp_low_access(ADIv5_DP_t *dp, uint8_t APnDP, uint8_t RnW
ack = swdptap_seq_in(3);
} while(--tries && ack == SWDP_ACK_WAIT);
- if(!tries)
- PLATFORM_FATAL_ERROR(1);
+ if(!tries) {
+ if (dp->fatal_on_timeout)
+ PLATFORM_FATAL_ERROR(1);
+ else
+ return 0;
+ }
if(ack == SWDP_ACK_FAULT) {
dp->fault = 1;
diff --git a/src/cortexm.c b/src/cortexm.c
index 130f683..c554ea2 100644
--- a/src/cortexm.c
+++ b/src/cortexm.c
@@ -586,6 +586,7 @@ cortexm_halt_request(struct target_s *target)
adiv5_ap_mem_write(ap, CORTEXM_DHCSR,
CORTEXM_DHCSR_DBGKEY | CORTEXM_DHCSR_C_HALT | CORTEXM_DHCSR_C_DEBUGEN);
+ ap->dp->fatal_on_timeout = true;
}
static int
@@ -654,6 +655,7 @@ cortexm_halt_resume(struct target_s *target, bool step)
}
adiv5_ap_mem_write(ap, CORTEXM_DHCSR, dhcsr);
+ ap->dp->fatal_on_timeout = false;
}
static int cortexm_fault_unwind(struct target_s *target)
diff --git a/src/include/adiv5.h b/src/include/adiv5.h
index d2d4be0..6a557f7 100644
--- a/src/include/adiv5.h
+++ b/src/include/adiv5.h
@@ -106,6 +106,8 @@ typedef struct ADIv5_DP_s {
uint32_t idcode;
+ bool fatal_on_timeout;
+
void (*dp_write)(struct ADIv5_DP_s *dp, uint8_t addr, uint32_t value);
uint32_t (*dp_read)(struct ADIv5_DP_s *dp, uint8_t addr);
diff --git a/src/platforms/stlink/platform.h b/src/platforms/stlink/platform.h
index 1ee944c..1ab1f8f 100644
--- a/src/platforms/stlink/platform.h
+++ b/src/platforms/stlink/platform.h
@@ -147,13 +147,13 @@ extern uint16_t led_idle_run;
#define SET_IDLE_STATE(state) {gpio_set_val(LED_PORT, led_idle_run, state);}
#define PLATFORM_SET_FATAL_ERROR_RECOVERY() {setjmp(fatal_error_jmpbuf);}
-#define PLATFORM_FATAL_ERROR(error) { \
+#define PLATFORM_FATAL_ERROR(error) do { \
if(running_status) gdb_putpacketz("X1D"); \
else gdb_putpacketz("EFF"); \
running_status = 0; \
target_list_free(); \
longjmp(fatal_error_jmpbuf, (error)); \
-}
+} while(0)
int platform_init(void);
void morse(const char *msg, char repeat);
diff --git a/src/stm32f1.c b/src/stm32f1.c
index 4cc7b2a..265814f 100644
--- a/src/stm32f1.c
+++ b/src/stm32f1.c
@@ -157,6 +157,7 @@ bool stm32f1_probe(struct target_s *target)
{
target->idcode = adiv5_ap_mem_read(adiv5_target_ap(target), DBGMCU_IDCODE) & 0xfff;
+ gdb_outf("target idcode: %4x\n", target->idcode);
switch(target->idcode) {
case 0x410: /* Medium density */
case 0x412: /* Low denisty */
Gdb session:
(gdb) tar ext /dev/ttyACM0
Remote debugging using /dev/ttyACM0
(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
panic: 1, apsel: 0, idr: 14770011
�(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
�(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
�(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
�(gdb)mon conn enable
(gdb) mon con
Assert SRST during connect: enabled
(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
panic: 1, apsel: 0, idr: 14770011
target idcode: 420
panic: 1, apsel: 1, idr: 0
Available Targets:
No. Att Driver
1 STM32, Medium density.
(gdb) attach 1
Attached to Remote target
reset_handler () at ../../cm3/vector.c:70
70 __asm__("MSR msp, %0" : : "r"(&_stack));
(gdb) c
Continuing.
^C
Program terminated with signal SIGLOST, Resource lost.
The program no longer exists.
(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
panic: 1, apsel: 0, idr: 0
No usable targets found.
(gdb) mon swdp_scan
Target voltage: unknown
idcode dp: 1ba01477
panic: 1, apsel: 0, idr: 0
No usable targets found.
(gdb)
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:fer...@gm...
|