The setup, a JTAG chain comprising 3 pic32 devices 2 * pic23mx110f016d, 1 pic32mx695f512
Things that are working. I can connect to any of these chips using JlinkGDBServer and run / examine code that has previously been programmed into the device using sourcery mips-sde-elf-gdb. The code is working code developed in mplabx and sucessfully programmed using an ICD3.
If I attempt to program using the JLink plus hardware
Using mips-sde-elf-gdb:
JTAG configuration changed: IRPre = 0, DRPre = 0
Selecting device: pic32mx110f016d
(gdb) target remote localhost:2331
A program is being debugged already. Kill it? (y or n) y
Remote debugging using localhost:2331
0x0000c0bf in ?? ()
(gdb) monitor jtagconf 0 0
JTAG configuration changed: IRPre = 0, DRPre = 0
(gdb) load D1204-IntMdu-pic-slave.X.production.elf
.... snipped ...
Downloading 8 bytes @ address 0x9D003F5C
Downloading 8 bytes @ address 0x9D003F64
Downloading 8 bytes @ address 0x9D003F6C
Downloading 4 bytes @ address 0xA0000000
ERROR: PC of target system has unexpected value after checking target RAM. (PC = 0x00000800)!
---- Registers ----
R2 = 00000000, R3 = 000000FF, R4 = 00000000, R5 = 00000000,
R6 = 00000000, R7 = 00000000, R16 = 00000000, R17 = 00000000,
R29 (SP) = 80001020, ErrorPC = FF200000, Status = 00501C05, Cause = 10800000
Failed to prepare for programming.
Failed to execute RAMCode for RAM check!
Downloading 4 bytes @ address 0xA0000004
Downloading 44 bytes @ address 0xA0000008
Downloading 96 bytes @ address 0xA00007B0
Downloading 32 bytes @ address 0xA0000830
Downloading 460 bytes @ address 0xBFC00000
Downloading 16 bytes @ address 0xBFC00380
Downloading 4 bytes @ address 0xBFC00BF0
Downloading 4 bytes @ address 0xBFC00BF4
Downloading 4 bytes @ address 0xBFC00BF8
Downloading 4 bytes @ address 0xBFC00BFC
Read 4 bytes @ address 0xBFC00000 (Data = 0x0FF00002)
Using JLinkExe:
J-Link>device pic32mx110f016d
Info: Device "PIC32MX110F016D" selected.
Reconnecting to target...
Info: TotalIRLen = 15, IRPrint = 0x0421
Info: Found PIC32 device with MIPS M4K core.
Info: CPU supports 6 code & 2 data breakpoints
J-Link>loadfile D1204-IntMdu-pic-slave.X.production.hex
Downloading file [D1204-IntMdu-pic-slave.X.production.hex]...
****** Error: PC of target system has unexpected value after checking target RAM. (PC = 0x00000800)!
---- Registers ----
R2 = 00000000, R3 = 000000FF, R4 = 00000000, R5 = 00000000,
R6 = 00000000, R7 = 00000000, R16 = 00000000, R17 = 00000000,
R29 (SP) = 80001020, ErrorPC = 9D003D94, Status = 00501C06, Cause = 5080001C
Failed to prepare for programming.
Failed to execute RAMCode for RAM check!
Unspecified error -1
J-Link>
From this example I should be able to perform a simple erase on the chip.
microchip.wikidot.com/tls5000:jlink-commander
J-Link>device pic32mx110f016d
Info: Device "PIC32MX110F016D" selected.
Reconnecting to target...
Info: TotalIRLen = 15, IRPrint = 0x0421
Info: Found PIC32 device with MIPS M4K core.
Info: CPU supports 6 code & 2 data breakpoints
J-Link>erase
Erasing device (PIC32MX110F016D)...
****** Error: PC of target system has unexpected value after checking target RAM. (PC = 0x00000800)!
---- Registers ----
R2 = 00000000, R3 = 000000FF, R4 = 00000000, R5 = 00000000,
R6 = 00000000, R7 = 00000000, R16 = 00000000, R17 = 00000000,
R29 (SP) = 80001020, ErrorPC = 9D003D94, Status = 00501C06, Cause = 5080001C
Failed to prepare for programming.
Failed to execute RAMCode for RAM check!
ERROR: Erase returned with error code -1.
All are complaining about failing to execute ramcode
Looking at the Openocd initialisations for the pic32, there are comments relating to the enabling of ram execution
...
#
# from reset the pic32 cannot execute code in ram - enable ram execution
# minimum offset from start of ram is 2k
#
global _PIC32MX_DATASIZE
global _WORKAREASIZE
# BMXCON set 0 wait state option by clearing BMXWSDRM bit, bit 6
mww 0xbf882000 0x001f0000
# BMXDKPBA: 2k kernel data @ 0xa0000000
mww 0xbf882010 $_PIC32MX_DATASIZE
# BMXDUDBA: 14k kernel program @ 0xa0000800 - (BMXDUDBA - BMXDKPBA)
mww 0xbf882020 $_WORKAREASIZE
# BMXDUPBA: 0k user program - (BMXDUPBA - BMXDUDBA)
mww 0xbf882030 $_WORKAREASIZE
...
Could this be related?
I presume I have missed something simple somewhere, but am now out of ideas.
Any insight as to what could be the matter here would be greatly apreciated.
Things that are working. I can connect to any of these chips using JlinkGDBServer and run / examine code that has previously been programmed into the device using sourcery mips-sde-elf-gdb. The code is working code developed in mplabx and sucessfully programmed using an ICD3.
If I attempt to program using the JLink plus hardware
Using mips-sde-elf-gdb:
JTAG configuration changed: IRPre = 0, DRPre = 0
Selecting device: pic32mx110f016d
(gdb) target remote localhost:2331
A program is being debugged already. Kill it? (y or n) y
Remote debugging using localhost:2331
0x0000c0bf in ?? ()
(gdb) monitor jtagconf 0 0
JTAG configuration changed: IRPre = 0, DRPre = 0
(gdb) load D1204-IntMdu-pic-slave.X.production.elf
.... snipped ...
Downloading 8 bytes @ address 0x9D003F5C
Downloading 8 bytes @ address 0x9D003F64
Downloading 8 bytes @ address 0x9D003F6C
Downloading 4 bytes @ address 0xA0000000
ERROR: PC of target system has unexpected value after checking target RAM. (PC = 0x00000800)!
---- Registers ----
R2 = 00000000, R3 = 000000FF, R4 = 00000000, R5 = 00000000,
R6 = 00000000, R7 = 00000000, R16 = 00000000, R17 = 00000000,
R29 (SP) = 80001020, ErrorPC = FF200000, Status = 00501C05, Cause = 10800000
Failed to prepare for programming.
Failed to execute RAMCode for RAM check!
Downloading 4 bytes @ address 0xA0000004
Downloading 44 bytes @ address 0xA0000008
Downloading 96 bytes @ address 0xA00007B0
Downloading 32 bytes @ address 0xA0000830
Downloading 460 bytes @ address 0xBFC00000
Downloading 16 bytes @ address 0xBFC00380
Downloading 4 bytes @ address 0xBFC00BF0
Downloading 4 bytes @ address 0xBFC00BF4
Downloading 4 bytes @ address 0xBFC00BF8
Downloading 4 bytes @ address 0xBFC00BFC
Read 4 bytes @ address 0xBFC00000 (Data = 0x0FF00002)
Using JLinkExe:
J-Link>device pic32mx110f016d
Info: Device "PIC32MX110F016D" selected.
Reconnecting to target...
Info: TotalIRLen = 15, IRPrint = 0x0421
Info: Found PIC32 device with MIPS M4K core.
Info: CPU supports 6 code & 2 data breakpoints
J-Link>loadfile D1204-IntMdu-pic-slave.X.production.hex
Downloading file [D1204-IntMdu-pic-slave.X.production.hex]...
****** Error: PC of target system has unexpected value after checking target RAM. (PC = 0x00000800)!
---- Registers ----
R2 = 00000000, R3 = 000000FF, R4 = 00000000, R5 = 00000000,
R6 = 00000000, R7 = 00000000, R16 = 00000000, R17 = 00000000,
R29 (SP) = 80001020, ErrorPC = 9D003D94, Status = 00501C06, Cause = 5080001C
Failed to prepare for programming.
Failed to execute RAMCode for RAM check!
Unspecified error -1
J-Link>
From this example I should be able to perform a simple erase on the chip.
microchip.wikidot.com/tls5000:jlink-commander
J-Link>device pic32mx110f016d
Info: Device "PIC32MX110F016D" selected.
Reconnecting to target...
Info: TotalIRLen = 15, IRPrint = 0x0421
Info: Found PIC32 device with MIPS M4K core.
Info: CPU supports 6 code & 2 data breakpoints
J-Link>erase
Erasing device (PIC32MX110F016D)...
****** Error: PC of target system has unexpected value after checking target RAM. (PC = 0x00000800)!
---- Registers ----
R2 = 00000000, R3 = 000000FF, R4 = 00000000, R5 = 00000000,
R6 = 00000000, R7 = 00000000, R16 = 00000000, R17 = 00000000,
R29 (SP) = 80001020, ErrorPC = 9D003D94, Status = 00501C06, Cause = 5080001C
Failed to prepare for programming.
Failed to execute RAMCode for RAM check!
ERROR: Erase returned with error code -1.
All are complaining about failing to execute ramcode
Looking at the Openocd initialisations for the pic32, there are comments relating to the enabling of ram execution
...
#
# from reset the pic32 cannot execute code in ram - enable ram execution
# minimum offset from start of ram is 2k
#
global _PIC32MX_DATASIZE
global _WORKAREASIZE
# BMXCON set 0 wait state option by clearing BMXWSDRM bit, bit 6
mww 0xbf882000 0x001f0000
# BMXDKPBA: 2k kernel data @ 0xa0000000
mww 0xbf882010 $_PIC32MX_DATASIZE
# BMXDUDBA: 14k kernel program @ 0xa0000800 - (BMXDUDBA - BMXDKPBA)
mww 0xbf882020 $_WORKAREASIZE
# BMXDUPBA: 0k user program - (BMXDUPBA - BMXDUDBA)
mww 0xbf882030 $_WORKAREASIZE
...
Could this be related?
I presume I have missed something simple somewhere, but am now out of ideas.
Any insight as to what could be the matter here would be greatly apreciated.