[app][mdebug] version 1.0
- protocol now correctly reports SWO and SWCLK clock rates on set - remove some debug printfs that were causing fw hangs (investigate later) - allow setting a 1MHz SWCLK rate - CMD_ATTACH now supports an argument to select one of several special reset or escape sequences: ATTACH_SWD_RESET: 60 HI, 4 LO, basic line reset ATTACH_JTAG_SWD: escape sequence for JTAG -> SWD mode switch ATTACH_DORMANT_TO_SWD: escape squence to exit dormant mode ATTACH_SWD_TO_DORMANT: and go back again - add special support for writing to DP TARGETSEL register (response phase must be ignored), needed for SWD multidrop support - bump protocol version to 1.3 - bump firmware version to 1.0 (it's long overdue)
This commit is contained in:
@@ -103,6 +103,16 @@ m0_fault:
|
||||
// r4 CLK0_IN const
|
||||
// r3 outbits data
|
||||
|
||||
snooze_1m:
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
snooze_2m:
|
||||
nop ; nop ; nop ; nop
|
||||
nop ; nop ; nop ; nop
|
||||
@@ -234,6 +244,9 @@ write_1:
|
||||
read_4:
|
||||
push {lr}
|
||||
b _read_4
|
||||
read_5:
|
||||
push {lr}
|
||||
b _read_5
|
||||
read_32:
|
||||
push {lr}
|
||||
ONE_BIT_IN
|
||||
@@ -263,6 +276,7 @@ read_32:
|
||||
ONE_BIT_IN
|
||||
ONE_BIT_IN
|
||||
ONE_BIT_IN
|
||||
_read_5:
|
||||
ONE_BIT_IN
|
||||
_read_4:
|
||||
ONE_BIT_IN
|
||||
@@ -281,6 +295,7 @@ init:
|
||||
ldr r0, =CLK0_OUT
|
||||
mov r10, r0
|
||||
ldr r0, =(snooze_4m + 1)
|
||||
ldr r0, =(snooze_1m + 1)
|
||||
mov r9, r0
|
||||
ldr r0, =COMM_BASE
|
||||
mov r8, r0
|
||||
@@ -413,20 +428,95 @@ wr_okay:
|
||||
#endif
|
||||
pop {pc}
|
||||
|
||||
cmd_reset:
|
||||
// write without caring about the response
|
||||
cmd_write_blind:
|
||||
push {lr}
|
||||
ldr r3, =0xffffffff
|
||||
mov r12, r3
|
||||
bl write_32
|
||||
mov r3, r12
|
||||
|
||||
ldr r3, [r3, #COMM_ARG0]
|
||||
bl write_16
|
||||
push {r3} // stash parity bit
|
||||
|
||||
ldr r3, =OEN_IN // ignore Trn/Rsp/Trn
|
||||
str r3, [r7, #OFF_OEN]
|
||||
bl read_5
|
||||
|
||||
ldr r3, =OEN_OUT
|
||||
str r3, [r7, #OFF_OEN]
|
||||
|
||||
mov r3, r8
|
||||
ldr r3, [r3, #COMM_ARG1]
|
||||
bl write_32
|
||||
|
||||
pop {r3} // recover parity bit
|
||||
bl write_1
|
||||
|
||||
mov r3, r8 // get COMM_BASE
|
||||
movs r0, #0
|
||||
str r0, [r3, #COMM_RESP]
|
||||
#if REPORT_DELAY
|
||||
mov r0, =MAX_RETRY
|
||||
str r0, [r3, #COMM_RETRY]
|
||||
#endif
|
||||
pop {pc}
|
||||
|
||||
|
||||
cmd_jtag_to_swd:
|
||||
push {lr}
|
||||
ldr r3, =0xffffffff
|
||||
bl write_32
|
||||
ldr r3, =0xffffffff
|
||||
bl write_32
|
||||
ldr r3, =0b1110011110011110
|
||||
bl write_16
|
||||
|
||||
mov r3, r12
|
||||
mov r3, r8
|
||||
movs r0, #0
|
||||
str r0, [r3, #COMM_RESP]
|
||||
pop {pc}
|
||||
|
||||
cmd_swd_to_dormant:
|
||||
push {lr}
|
||||
ldr r3, =0xffffffff
|
||||
bl write_32
|
||||
mov r3, r12
|
||||
ldr r3, =0xffffffff
|
||||
bl write_32
|
||||
ldr r3, =0xE3BC
|
||||
bl write_16
|
||||
|
||||
mov r3, r8
|
||||
movs r0, #0
|
||||
str r0, [r3, #COMM_RESP]
|
||||
pop {pc}
|
||||
|
||||
cmd_dormant_to_swd:
|
||||
push {lr}
|
||||
// at least 8 HI
|
||||
ldr r3, =0xffff
|
||||
bl write_16
|
||||
// activation sequence (128bit)
|
||||
ldr r3, =0x6209F392
|
||||
bl write_32
|
||||
ldr r3, =0x86852D95
|
||||
bl write_32
|
||||
ldr r3, =0xE3DDAFE9
|
||||
bl write_32
|
||||
ldr r3, =0x19BC0EA2
|
||||
bl write_32
|
||||
// 4 LO, selection sequence, 4 HI
|
||||
ldr r3, =0xF1A0
|
||||
bl write_16
|
||||
|
||||
mov r3, r8
|
||||
movs r0, #0
|
||||
str r0, [r3, #COMM_RESP]
|
||||
pop {pc}
|
||||
|
||||
cmd_reset:
|
||||
push {lr}
|
||||
// 50+ HI (60 here), 2+ LO (4 here)
|
||||
ldr r3, =0xffffffff
|
||||
bl write_32
|
||||
ldr r3, =0x0fffffff
|
||||
bl write_32
|
||||
|
||||
mov r3, r8
|
||||
@@ -445,7 +535,7 @@ m0_irq:
|
||||
|
||||
mov r3, r8 // get COMM_BASE
|
||||
ldr r0, [r3, #COMM_CMD]
|
||||
cmp r0, #5
|
||||
cmp r0, #9
|
||||
bls good_cmd
|
||||
movs r0, #0
|
||||
good_cmd:
|
||||
@@ -456,7 +546,7 @@ good_cmd:
|
||||
|
||||
pop {pc}
|
||||
|
||||
.align 2
|
||||
.align 4
|
||||
cmd_table:
|
||||
.word cmd_invalid + 1
|
||||
.word cmd_nop + 1
|
||||
@@ -464,6 +554,10 @@ cmd_table:
|
||||
.word cmd_write_txn + 1
|
||||
.word cmd_reset + 1
|
||||
.word cmd_setclock + 1
|
||||
.word cmd_write_blind + 1
|
||||
.word cmd_jtag_to_swd + 1
|
||||
.word cmd_dormant_to_swd + 1
|
||||
.word cmd_swd_to_dormant + 1
|
||||
|
||||
cmd_invalid:
|
||||
movs r0, #9
|
||||
@@ -481,19 +575,19 @@ cmd_setclock:
|
||||
bls good_clock
|
||||
movs r0, #0
|
||||
good_clock:
|
||||
lsls r0, r0, #2
|
||||
lsls r2, r0, #2
|
||||
adr r1, snooze_table
|
||||
ldr r1, [r1, r0]
|
||||
ldr r1, [r1, r2]
|
||||
mov r9, r1
|
||||
|
||||
movs r0, #0
|
||||
// return actual clock used
|
||||
str r0, [r3, #COMM_RESP]
|
||||
bx lr
|
||||
|
||||
.align 2
|
||||
.align 4
|
||||
snooze_table:
|
||||
.word snooze_2m + 1
|
||||
.word snooze_2m + 1
|
||||
.word snooze_1m + 1
|
||||
.word snooze_1m + 1
|
||||
.word snooze_2m + 1
|
||||
.word snooze_3m + 1
|
||||
.word snooze_4m + 1
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
unsigned char zero_bin[] = {
|
||||
0xf0, 0x3f, 0x00, 0x18, 0x41, 0x08, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18,
|
||||
0xf0, 0x3f, 0x00, 0x18, 0x25, 0x09, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18,
|
||||
0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18,
|
||||
0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18,
|
||||
0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18,
|
||||
0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18,
|
||||
0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18, 0xc5, 0x07, 0x00, 0x18,
|
||||
0x49, 0x00, 0x00, 0x18, 0x49, 0x00, 0x00, 0x18, 0x91, 0x08, 0x00, 0x18,
|
||||
0x04, 0x48, 0x05, 0x49, 0xef, 0xf3, 0x03, 0x82, 0xff, 0x23, 0x1a, 0x40,
|
||||
0x11, 0x43, 0x01, 0x60, 0xfe, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
|
||||
0x00, 0x00, 0xee, 0xee, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
@@ -13,6 +13,12 @@ unsigned char zero_bin[] = {
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0x70, 0x47, 0x00, 0xb5, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47, 0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc8, 0x47, 0x7d, 0x60, 0x30, 0x40, 0x80, 0x0b, 0xc0, 0x46,
|
||||
@@ -84,8 +90,12 @@ unsigned char zero_bin[] = {
|
||||
0x7a, 0x60, 0x5b, 0x08, 0x59, 0x44, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47,
|
||||
0x79, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x9a, 0x03, 0x32, 0x40, 0x11, 0x00,
|
||||
0x52, 0x44, 0xc8, 0x47, 0x7a, 0x60, 0x5b, 0x08, 0x59, 0x44, 0xc0, 0x46,
|
||||
0xc0, 0x46, 0xc8, 0x47, 0x79, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x34, 0xe1,
|
||||
0x00, 0xb5, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0xc8, 0x47,
|
||||
0xc0, 0x46, 0xc8, 0x47, 0x79, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x36, 0xe1,
|
||||
0x00, 0xb5, 0x29, 0xe1, 0x00, 0xb5, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08,
|
||||
0x03, 0x43, 0xc8, 0x47, 0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc8, 0x47, 0x7d, 0x60, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43,
|
||||
0xc8, 0x47, 0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47,
|
||||
0x7d, 0x60, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0xc8, 0x47,
|
||||
0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47, 0x7d, 0x60,
|
||||
0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0xc8, 0x47, 0x7c, 0x60,
|
||||
0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47, 0x7d, 0x60, 0x30, 0x40,
|
||||
@@ -140,47 +150,59 @@ unsigned char zero_bin[] = {
|
||||
0x03, 0x43, 0xc8, 0x47, 0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0xc8, 0x47, 0x7d, 0x60, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43,
|
||||
0xc8, 0x47, 0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47,
|
||||
0x7d, 0x60, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0xc8, 0x47,
|
||||
0x7c, 0x60, 0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47, 0x7d, 0x60,
|
||||
0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0xc8, 0x47, 0x7c, 0x60,
|
||||
0x38, 0x68, 0xc0, 0x46, 0xc0, 0x46, 0xc8, 0x47, 0x7d, 0x60, 0x30, 0x40,
|
||||
0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0x00, 0xbd, 0x5f, 0x48, 0x83, 0x46,
|
||||
0x5f, 0x48, 0x82, 0x46, 0x5f, 0x48, 0x81, 0x46, 0x5f, 0x48, 0x80, 0x46,
|
||||
0x5f, 0x4f, 0x60, 0x4e, 0x60, 0x4d, 0x61, 0x4c, 0x70, 0x47, 0x03, 0x20,
|
||||
0x43, 0x46, 0xd8, 0x60, 0x00, 0xbd, 0x02, 0x20, 0x43, 0x46, 0xd8, 0x60,
|
||||
0x00, 0xbd, 0x00, 0xb5, 0x5c, 0x48, 0x84, 0x46, 0x5b, 0x68, 0xff, 0xf7,
|
||||
0xeb, 0xfc, 0x52, 0x4b, 0xbb, 0x60, 0xff, 0xf7, 0x79, 0xfe, 0x5b, 0x0f,
|
||||
0x01, 0x2b, 0x09, 0xd0, 0x57, 0x49, 0xb9, 0x60, 0x02, 0x2b, 0xe6, 0xd1,
|
||||
0x60, 0x46, 0x01, 0x38, 0x84, 0x46, 0xe6, 0xd0, 0x43, 0x46, 0xeb, 0xe7,
|
||||
0xff, 0xf7, 0x6c, 0xfe, 0xff, 0xf7, 0xbd, 0xfc, 0x50, 0x49, 0xb9, 0x60,
|
||||
0x59, 0x46, 0x31, 0x43, 0x79, 0x60, 0x41, 0x46, 0x4b, 0x60, 0x88, 0x60,
|
||||
0x00, 0x20, 0xc8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x49, 0x48, 0x84, 0x46,
|
||||
0x5b, 0x68, 0xff, 0xf7, 0xc5, 0xfc, 0x08, 0xb4, 0x3e, 0x4b, 0xbb, 0x60,
|
||||
0xff, 0xf7, 0x52, 0xfe, 0x5b, 0x0f, 0x01, 0x2b, 0x0a, 0xd0, 0x01, 0xbc,
|
||||
0x43, 0x49, 0xb9, 0x60, 0x02, 0x2b, 0xbe, 0xd1, 0x60, 0x46, 0x01, 0x38,
|
||||
0x84, 0x46, 0xbe, 0xd0, 0x43, 0x46, 0xe9, 0xe7, 0x3e, 0x4b, 0xbb, 0x60,
|
||||
0xff, 0xf7, 0x32, 0xfe, 0x43, 0x46, 0x9b, 0x68, 0xff, 0xf7, 0xac, 0xfc,
|
||||
0x08, 0xbc, 0xff, 0xf7, 0x2b, 0xfe, 0x43, 0x46, 0x00, 0x20, 0xd8, 0x60,
|
||||
0x00, 0xbd, 0x00, 0xb5, 0x37, 0x4b, 0x9c, 0x46, 0xff, 0xf7, 0xa0, 0xfc,
|
||||
0x63, 0x46, 0xff, 0xf7, 0x9d, 0xfc, 0x35, 0x4b, 0xff, 0xf7, 0x98, 0xfc,
|
||||
0x63, 0x46, 0xff, 0xf7, 0x97, 0xfc, 0x63, 0x46, 0xff, 0xf7, 0x94, 0xfc,
|
||||
0x43, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x2f, 0x48,
|
||||
0x00, 0x21, 0x01, 0x60, 0x43, 0x46, 0x18, 0x68, 0x05, 0x28, 0x00, 0xd9,
|
||||
0x00, 0x20, 0x80, 0x00, 0x01, 0xa1, 0x0a, 0x58, 0x90, 0x47, 0x00, 0xbd,
|
||||
0xf9, 0x07, 0x00, 0x18, 0xff, 0x07, 0x00, 0x18, 0xff, 0x06, 0x00, 0x18,
|
||||
0x4b, 0x07, 0x00, 0x18, 0x9b, 0x07, 0x00, 0x18, 0x05, 0x08, 0x00, 0x18,
|
||||
0x09, 0x20, 0xd8, 0x60, 0x70, 0x47, 0x00, 0x20, 0xd8, 0x60, 0x70, 0x47,
|
||||
0x58, 0x68, 0x08, 0x28, 0x00, 0xd9, 0x00, 0x20, 0x80, 0x00, 0x03, 0xa1,
|
||||
0x09, 0x58, 0x89, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x70, 0x47, 0xc0, 0x46,
|
||||
0x65, 0x00, 0x00, 0x18, 0x65, 0x00, 0x00, 0x18, 0x65, 0x00, 0x00, 0x18,
|
||||
0x85, 0x00, 0x00, 0x18, 0x95, 0x00, 0x00, 0x18, 0x95, 0x00, 0x00, 0x18,
|
||||
0xa5, 0x00, 0x00, 0x18, 0xa5, 0x00, 0x00, 0x18, 0xad, 0x00, 0x00, 0x18,
|
||||
0x11, 0x48, 0x12, 0x49, 0x01, 0x60, 0xff, 0xf7, 0x45, 0xff, 0x11, 0x48,
|
||||
0x7d, 0x60, 0x30, 0x40, 0x40, 0x04, 0x5b, 0x08, 0x03, 0x43, 0x00, 0xbd,
|
||||
0x85, 0x48, 0x83, 0x46, 0x85, 0x48, 0x82, 0x46, 0x85, 0x48, 0x86, 0x48,
|
||||
0x81, 0x46, 0x86, 0x48, 0x80, 0x46, 0x86, 0x4f, 0x86, 0x4e, 0x87, 0x4d,
|
||||
0x87, 0x4c, 0x70, 0x47, 0x03, 0x20, 0x43, 0x46, 0xd8, 0x60, 0x00, 0xbd,
|
||||
0x02, 0x20, 0x43, 0x46, 0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x83, 0x48,
|
||||
0x84, 0x46, 0x5b, 0x68, 0xff, 0xf7, 0xe8, 0xfc, 0x77, 0x4b, 0xbb, 0x60,
|
||||
0xff, 0xf7, 0x76, 0xfe, 0x5b, 0x0f, 0x01, 0x2b, 0x09, 0xd0, 0x7e, 0x49,
|
||||
0xb9, 0x60, 0x02, 0x2b, 0xe6, 0xd1, 0x60, 0x46, 0x01, 0x38, 0x84, 0x46,
|
||||
0xe6, 0xd0, 0x43, 0x46, 0xeb, 0xe7, 0xff, 0xf7, 0x6b, 0xfe, 0xff, 0xf7,
|
||||
0xba, 0xfc, 0x77, 0x49, 0xb9, 0x60, 0x59, 0x46, 0x31, 0x43, 0x79, 0x60,
|
||||
0x41, 0x46, 0x4b, 0x60, 0x88, 0x60, 0x00, 0x20, 0xc8, 0x60, 0x00, 0xbd,
|
||||
0x00, 0xb5, 0x70, 0x48, 0x84, 0x46, 0x5b, 0x68, 0xff, 0xf7, 0xc2, 0xfc,
|
||||
0x08, 0xb4, 0x64, 0x4b, 0xbb, 0x60, 0xff, 0xf7, 0x4f, 0xfe, 0x5b, 0x0f,
|
||||
0x01, 0x2b, 0x0a, 0xd0, 0x01, 0xbc, 0x6a, 0x49, 0xb9, 0x60, 0x02, 0x2b,
|
||||
0xbe, 0xd1, 0x60, 0x46, 0x01, 0x38, 0x84, 0x46, 0xbe, 0xd0, 0x43, 0x46,
|
||||
0xe9, 0xe7, 0x65, 0x4b, 0xbb, 0x60, 0xff, 0xf7, 0x2f, 0xfe, 0x43, 0x46,
|
||||
0x9b, 0x68, 0xff, 0xf7, 0xa9, 0xfc, 0x08, 0xbc, 0xff, 0xf7, 0x28, 0xfe,
|
||||
0x43, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x5b, 0x68,
|
||||
0xff, 0xf7, 0x9c, 0xfc, 0x08, 0xb4, 0x51, 0x4b, 0xbb, 0x60, 0xff, 0xf7,
|
||||
0x2b, 0xfe, 0x59, 0x4b, 0xbb, 0x60, 0x43, 0x46, 0x9b, 0x68, 0xff, 0xf7,
|
||||
0x93, 0xfc, 0x08, 0xbc, 0xff, 0xf7, 0x12, 0xfe, 0x43, 0x46, 0x00, 0x20,
|
||||
0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x53, 0x4b, 0xff, 0xf7, 0x88, 0xfc,
|
||||
0x51, 0x4b, 0xff, 0xf7, 0x85, 0xfc, 0x51, 0x4b, 0xff, 0xf7, 0x80, 0xfc,
|
||||
0x43, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x4c, 0x4b,
|
||||
0xff, 0xf7, 0x7a, 0xfc, 0x4a, 0x4b, 0xff, 0xf7, 0x77, 0xfc, 0x4b, 0x4b,
|
||||
0xff, 0xf7, 0x72, 0xfc, 0x43, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x00, 0xbd,
|
||||
0x00, 0xb5, 0x48, 0x4b, 0xff, 0xf7, 0x6a, 0xfc, 0x47, 0x4b, 0xff, 0xf7,
|
||||
0x69, 0xfc, 0x47, 0x4b, 0xff, 0xf7, 0x66, 0xfc, 0x46, 0x4b, 0xff, 0xf7,
|
||||
0x63, 0xfc, 0x46, 0x4b, 0xff, 0xf7, 0x60, 0xfc, 0x45, 0x4b, 0xff, 0xf7,
|
||||
0x5b, 0xfc, 0x43, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5,
|
||||
0x39, 0x4b, 0xff, 0xf7, 0x55, 0xfc, 0x41, 0x4b, 0xff, 0xf7, 0x52, 0xfc,
|
||||
0x43, 0x46, 0x00, 0x20, 0xd8, 0x60, 0x00, 0xbd, 0x00, 0xb5, 0x3e, 0x48,
|
||||
0x00, 0x21, 0x01, 0x60, 0x43, 0x46, 0x18, 0x68, 0x09, 0x28, 0x00, 0xd9,
|
||||
0x00, 0x20, 0x80, 0x00, 0x02, 0xa1, 0x0a, 0x58, 0x90, 0x47, 0x00, 0xbd,
|
||||
0xc0, 0x46, 0xc0, 0x46, 0xd9, 0x08, 0x00, 0x18, 0xdf, 0x08, 0x00, 0x18,
|
||||
0x4d, 0x07, 0x00, 0x18, 0x99, 0x07, 0x00, 0x18, 0x7b, 0x08, 0x00, 0x18,
|
||||
0xe5, 0x08, 0x00, 0x18, 0xe9, 0x07, 0x00, 0x18, 0x15, 0x08, 0x00, 0x18,
|
||||
0x4d, 0x08, 0x00, 0x18, 0x31, 0x08, 0x00, 0x18, 0x09, 0x20, 0xd8, 0x60,
|
||||
0x70, 0x47, 0x00, 0x20, 0xd8, 0x60, 0x70, 0x47, 0x58, 0x68, 0x08, 0x28,
|
||||
0x00, 0xd9, 0x00, 0x20, 0x82, 0x00, 0x04, 0xa1, 0x89, 0x58, 0x89, 0x46,
|
||||
0xd8, 0x60, 0x70, 0x47, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46, 0xc0, 0x46,
|
||||
0x65, 0x00, 0x00, 0x18, 0x65, 0x00, 0x00, 0x18, 0xad, 0x00, 0x00, 0x18,
|
||||
0xcd, 0x00, 0x00, 0x18, 0xdd, 0x00, 0x00, 0x18, 0xdd, 0x00, 0x00, 0x18,
|
||||
0xed, 0x00, 0x00, 0x18, 0xed, 0x00, 0x00, 0x18, 0xf5, 0x00, 0x00, 0x18,
|
||||
0x1a, 0x48, 0x1b, 0x49, 0x01, 0x60, 0xff, 0xf7, 0xf9, 0xfe, 0x1a, 0x48,
|
||||
0x02, 0x21, 0x01, 0x60, 0x30, 0xbf, 0xfd, 0xe7, 0x00, 0x88, 0x00, 0x00,
|
||||
0x00, 0x80, 0x00, 0x00, 0x95, 0x00, 0x00, 0x18, 0x00, 0x40, 0x00, 0x18,
|
||||
0x10, 0x12, 0x10, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00,
|
||||
0xff, 0xff, 0xff, 0xff, 0x9e, 0xe7, 0x00, 0x00, 0x30, 0x31, 0x04, 0x40,
|
||||
0x00, 0x80, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x18, 0x65, 0x00, 0x00, 0x18,
|
||||
0x00, 0x40, 0x00, 0x18, 0x10, 0x12, 0x10, 0x40, 0x00, 0x40, 0x00, 0x00,
|
||||
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
|
||||
0x00, 0xc8, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x9e, 0xe7, 0x00, 0x00,
|
||||
0xbc, 0xe3, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x92, 0xf3, 0x09, 0x62,
|
||||
0x95, 0x2d, 0x85, 0x86, 0xe9, 0xaf, 0xdd, 0xe3, 0xa2, 0x0e, 0xbc, 0x19,
|
||||
0xa0, 0xf1, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x30, 0x31, 0x04, 0x40,
|
||||
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xaa, 0xaa, 0x00, 0xe1, 0x00, 0xe0
|
||||
};
|
||||
unsigned int zero_bin_len = 2196;
|
||||
unsigned int zero_bin_len = 2460;
|
||||
|
||||
@@ -54,7 +54,7 @@ static u8 optable[16] = {
|
||||
};
|
||||
|
||||
static const char *board_str = TARGET;
|
||||
static const char *build_str = "fw v0.91 (" __DATE__ ", " __TIME__ ")";
|
||||
static const char *build_str = "fw v1.00 (" __DATE__ ", " __TIME__ ")";
|
||||
|
||||
static void _reboot(void) {
|
||||
platform_halt(HALT_ACTION_REBOOT, HALT_REASON_SW_RESET);
|
||||
@@ -121,7 +121,7 @@ void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
|
||||
mode = MODE_SWD;
|
||||
swd_init();
|
||||
}
|
||||
swd_reset();
|
||||
swd_reset(op);
|
||||
continue;
|
||||
case CMD_JTAG_IO:
|
||||
if (mode != MODE_JTAG) {
|
||||
@@ -212,14 +212,15 @@ void process_txn(u32 txnid, u32 *rx, int rxc, u32 *tx) {
|
||||
continue;
|
||||
case CMD_SET_CLOCK:
|
||||
n = swd_set_clock(n);
|
||||
printf("swdp clock is now %d KHz\n", n);
|
||||
if (host_version >= RSWD_VERSION_1_0) {
|
||||
tx[txc++] = RSWD_MSG(CMD_CLOCK_KHZ, 0, n);
|
||||
}
|
||||
continue;
|
||||
case CMD_SWO_CLOCK:
|
||||
n = swo_set_clock(n);
|
||||
printf("swo clock is now %d KHz\n", n);
|
||||
if (host_version >= RSWD_VERSION_1_0) {
|
||||
tx[txc++] = RSWD_MSG(CMD_CLOCK_KHZ, 1, n);
|
||||
}
|
||||
continue;
|
||||
case CMD_VERSION:
|
||||
host_version = n;
|
||||
|
||||
@@ -63,6 +63,12 @@
|
||||
#define CMD_JTAG_RX 0x0E /* tms=op.0, tdi=op.1, arg=bitcount, return (count/32) words */
|
||||
#define CMD_JTAG_VRFY 0x0F /* arg=bitcount, tms/tdi data/mask, error if tdo&mask != data */
|
||||
|
||||
/* ATTACH ops */
|
||||
#define ATTACH_SWD_RESET 0
|
||||
#define ATTACH_JTAG_TO_SWD 1
|
||||
#define ATTACH_DORMANT_TO_SWD 2
|
||||
#define ATTACH_SWD_TO_DORMANT 3
|
||||
|
||||
/* valid: target to host */
|
||||
#define CMD_STATUS 0x10 /* op=errorcode, arg=commands since last TXN_START */
|
||||
#define CMD_SWD_DATA 0x11 /* op=0 arg=count, payload: data x count */
|
||||
@@ -87,11 +93,13 @@
|
||||
#define ERR_PARITY 4
|
||||
#define ERR_BAD_MATCH 5
|
||||
|
||||
#define RSWD_VERSION 0x0102
|
||||
|
||||
#define RSWD_VERSION_1_0 0x0100
|
||||
#define RSWD_VERSION_1_1 0x0101
|
||||
#define RSWD_VERSION_1_2 0x0102
|
||||
#define RSWD_VERSION_1_3 0x0103
|
||||
|
||||
#define RSWD_VERSION RSWD_VERSION_1_3
|
||||
|
||||
// Pre-1.0
|
||||
// - max packet size fixed at 2048 bytes
|
||||
@@ -105,6 +113,9 @@
|
||||
//
|
||||
// Version 1.2
|
||||
// - CMD_JTAG_IO, CMD_JTAG_RX, CMD_JTAG_TX, CMD_JTAG_VRFY, CMD_JTAG_DATA added
|
||||
//
|
||||
// Version 1.3
|
||||
// - CMD_ATTACH ops (ATTACH_xyz), CMD_CLOCK_KHZ op indicates 0=SWCLK, 1=SWO
|
||||
|
||||
/* CMD_SWD_OP operations - combine for direct AP/DP io */
|
||||
#define OP_RD 0x00
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <platform/lpc43xx-sgpio.h>
|
||||
#include <platform/lpc43xx-clocks.h>
|
||||
|
||||
#include "swd.h"
|
||||
#include "rswdp.h"
|
||||
|
||||
#include "lpclink2.h"
|
||||
@@ -78,12 +79,16 @@ static unsigned parity(unsigned n) {
|
||||
#define COMM_ARG2 0x18004008
|
||||
#define COMM_RESP 0x1800400C
|
||||
|
||||
#define M0_CMD_ERR 0
|
||||
#define M0_CMD_NOP 1
|
||||
#define M0_CMD_READ 2
|
||||
#define M0_CMD_WRITE 3
|
||||
#define M0_CMD_RESET 4
|
||||
#define M0_CMD_SETCLOCK 5
|
||||
#define M0_CMD_ERR 0
|
||||
#define M0_CMD_NOP 1
|
||||
#define M0_CMD_READ 2
|
||||
#define M0_CMD_WRITE 3
|
||||
#define M0_CMD_RESET 4
|
||||
#define M0_CMD_SETCLOCK 5
|
||||
#define M0_CMD_WRITE_BLIND 6
|
||||
#define M0_CMD_JTAG_TO_SWD 7
|
||||
#define M0_CMD_DORMANT_TO_SWD 8
|
||||
#define M0_CMD_SWD_TO_DORMANT 9
|
||||
|
||||
#define RSP_BUSY 0xFFFFFFFF
|
||||
|
||||
@@ -116,8 +121,13 @@ void swd_init(void) {
|
||||
int swd_write(unsigned hdr, unsigned data) {
|
||||
unsigned n;
|
||||
unsigned p = parity(data);
|
||||
writel(M0_CMD_WRITE, COMM_CMD);
|
||||
if (hdr == WR_BUFFER) {
|
||||
writel(M0_CMD_WRITE_BLIND, COMM_CMD);
|
||||
} else {
|
||||
writel(M0_CMD_WRITE, COMM_CMD);
|
||||
}
|
||||
writel((hdr << 8) | (p << 16), COMM_ARG1);
|
||||
//writel(0b00111111 | (hdr << 8) | (p << 16), COMM_ARG1);
|
||||
writel(data, COMM_ARG2);
|
||||
writel(RSP_BUSY, COMM_RESP);
|
||||
DSB;
|
||||
@@ -148,15 +158,29 @@ int swd_read(unsigned hdr, unsigned *val) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void swd_reset(void) {
|
||||
void swd_reset(unsigned kind) {
|
||||
unsigned n;
|
||||
writel(M0_CMD_RESET, COMM_CMD);
|
||||
|
||||
switch (kind) {
|
||||
case ATTACH_SWD_RESET: kind = M0_CMD_RESET; break;
|
||||
case ATTACH_JTAG_TO_SWD: kind = M0_CMD_JTAG_TO_SWD; break;
|
||||
case ATTACH_DORMANT_TO_SWD: kind = M0_CMD_DORMANT_TO_SWD; break;
|
||||
case ATTACH_SWD_TO_DORMANT: kind = M0_CMD_SWD_TO_DORMANT; break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
writel(kind, COMM_CMD);
|
||||
writel(RSP_BUSY, COMM_RESP);
|
||||
DSB;
|
||||
asm("sev");
|
||||
while ((n = readl(COMM_RESP)) == RSP_BUSY) ;
|
||||
}
|
||||
|
||||
// align w/ snooze_table in fw
|
||||
static unsigned clocktab[9] = {
|
||||
1000, 1000, 2000, 3000, 4000, 4000, 6000, 6000, 8000
|
||||
};
|
||||
|
||||
unsigned swd_set_clock(unsigned khz) {
|
||||
unsigned n;
|
||||
if (khz > 8000) {
|
||||
@@ -169,8 +193,7 @@ unsigned swd_set_clock(unsigned khz) {
|
||||
asm("sev");
|
||||
while ((n = readl(COMM_RESP)) == RSP_BUSY) ;
|
||||
|
||||
// todo: accurate value
|
||||
return khz;
|
||||
return clocktab[n];
|
||||
}
|
||||
|
||||
void swd_hw_reset(int assert) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#define _SWDP_H_
|
||||
|
||||
void swd_init(void);
|
||||
void swd_reset(void);
|
||||
void swd_reset(unsigned kind);
|
||||
int swd_write(unsigned reg, unsigned val);
|
||||
int swd_read(unsigned reg, unsigned *val);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user