I have a MR-CANHUBK344 development board, which I am debugging using a J-Link base v11.0. The J-Link has the latest firmware, and I'm using the latest J-Flash tools/drivers for ARM64. I'm running S32DS in a virtual windows machine on MacOS, and everything has been working OK with that. I've been able to attach to the target and flash code. I'm using S32DS 3.5 and RTD 3.0.0-P07
Yesterday I managed to put together a working demo using the RTD, using the PORT driver and DIO drivers to flash the RGB LEDs. However, ever since flashing that firmware, I haven't been able to attach to the target. I had flashed other firmwares which didn't cause this problem, and I have verified that I am still able to attach to a different target running the firmware which shipped on the dev board.
So, my questions are:
- What did I do to cause this (and how can I avoid it in the future)?
- How can I recover this board?
I've attached my project. Main.c contains some code for the SIUL2 driver which was my first attempt at blinking the LEDs, and the PORT/DIO code which actually does cause the LEDs to flash, but which apparently prevents flashing via the debugger.
S32DS packages:
Output from J-Flash when attempting to connect:
Connecting ...
- Connecting via USB to probe/ programmer device 0
- Probe/ Programmer firmware: J-Link V11 compiled Jun 20 2023 17:59:57
- Probe/ Programmer S/N: 51005535
- Device "S32K344" selected.
- Target interface speed: 4000 kHz (Fixed)
- VTarget = 3.328V
- ConfigTargetSettings() start
- ConfigTargetSettings() end - Took 10us
- InitTarget() start
- Unknown SDA AP Id detected: 0xFFFFFFFF
- InitTarget() end - Took 110ms
- ConfigTargetSettings() start
- ConfigTargetSettings() end - Took 15us
- InitTarget() start
- Unknown SDA AP Id detected: 0xFFFFFFFF
- InitTarget() end - Took 111ms
Solved! Go to Solution.
Hi @gbh_s,
The pins are configured for JTAG/SWD by default out of reset.
You need to connect the debugger while the MCU is in reset or before it gets reconfigured by the driver.
Can you try this solution?
If you reconfigured the reset_b pin (PTA5) too, the MCU can be reset by POR only.
Regards,
Daniel
Hi @gbh_s,
The pins are configured for JTAG/SWD by default out of reset.
You need to connect the debugger while the MCU is in reset or before it gets reconfigured by the driver.
Can you try this solution?
If you reconfigured the reset_b pin (PTA5) too, the MCU can be reset by POR only.
Regards,
Daniel
Thanks for your help. I now have a different error message, which is progress!
First attempt, which follows the workflow in the other post:
- Run jlink.exe
- r0
- erase
Result: same error
Type "connect" to establish a target connection, '?' for help
J-Link>r0
J-Link>erase
Target connection not established yet but required for command.
Please specify device / core. <Default>: S32K344
Type '?' for selection dialog
Device>
Please specify target interface:
J) JTAG (Default)
S) SWD
T) cJTAG
TIF>j
Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect
JTAGConf>
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>
Device "S32K344" selected.
Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 76us
InitTarget() start
Unknown SDA AP Id detected: 0xFFFFFFFF
InitTarget() end - Took 13.5ms
Connect failed. Resetting via Reset pin and trying again.
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 13us
InitTarget() start
Unknown SDA AP Id detected: 0xFFFFFFFF
InitTarget() end - Took 13.5ms
Connect failed. Resetting via Reset pin and trying again.
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 13us
InitTarget() start
Unknown SDA AP Id detected: 0xFFFFFFFF
InitTarget() end - Took 13.0ms
Cannot connect to target.
Second attempt: connect first
- Run jlink.exe
- connect
- r0
- erase
Result: error about missing RAMcode
Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. <Default>: S32K344
Type '?' for selection dialog
Device>
Please specify target interface:
J) JTAG (Default)
S) SWD
T) cJTAG
TIF>j
Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect
JTAGConf>
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>
Device "S32K344" selected.
Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 101us
InitTarget() start
Unknown SDA AP Id detected: 0xFFFFFFFF
InitTarget() end - Took 17.1ms
Connect failed. Resetting via Reset pin and trying again.
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 156us
InitTarget() start
Unknown SDA AP Id detected: 0xFFFFFFFF
InitTarget() end - Took 15.1ms
Cannot connect to target.
J-Link>r0
J-Link>erase
Target connection not established yet but required for command.
Device "S32K344" selected.
Connecting to target via JTAG
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 12us
InitTarget() start
SDA_AP detected
Checking if debug access is already enabled...
Debug access is not enabled yet. Performing enable debug access sequence...
Debug access enabled
Checking if HSE firmware is installed...
HSE firmware detected (SWAP disabled)
Lock step mode enabled
InitTarget() end - Took 91.1ms
TotalIRLen = 8, IRPrint = 0x0001
JTAG chain detection found 1 devices:
#0 Id: 0x0996001D, IRLen: 04, JTAG-DP
Found 1 device in JTAG chain, IRPost/DRPost != 0. Reset IRPost/DRPost to 0.
DPv0 detected
AP map detection skipped. Manually configured AP map found.
AP[0]: MEM-AP (IDR: Not set)
AP[1]: APB-AP (IDR: Not set)
AP[2]: MEM-AP (IDR: Not set)
AP[3]: MEM-AP (IDR: Not set)
AP[4]: AHB-AP (IDR: Not set)
AP[5]: AHB-AP (IDR: Not set)
AP[6]: MEM-AP (IDR: Not set)
AP[7]: MEM-AP (IDR: Not set)
AP[4]: Skipped ROMBASE read. CoreBaseAddr manually set by user
AP[4]: Core found
CPUID register: 0x411FC272. Implementer code: 0x41 (ARM)
Cache: No cache
Found Cortex-M7 r1p2, Big endian.
FPUnit: 8 code (BP) slots and 0 literal slots
ROM table scan skipped. CoreBaseAddr manually set by user: 0x40250400
SetupTarget() start
Initializing ECC RAM...
RAMCodeAddr: 0x20000000
RAMInitAddr: 0x20000010
RAMInitSize: 0x00007FF0
InitPattern: 0xDEADBEEF
CPU could not be halted
Timeout while initializing ECC RAM
CPU could not be halted
Initializing ECC RAM...
RAMCodeAddr: 0x20000000
RAMInitAddr: 0x20400000
RAMInitSize: 0x00004000
InitPattern: 0xDEADBEEF
CPU could not be halted
Timeout while initializing ECC RAM
CPU could not be halted
SetupTarget() end - Took 1.14s
****** Error: Cannot read register 0 (R0) while CPU is running
Cannot read register 1 (R1) while CPU is running
Cannot read register 2 (R2) while CPU is running
Cannot read register 15 (R15) while CPU is running
Memory zones:
Zone: "Default" Description: Default access mode
Cortex-M7 identified.
No address range specified, 'Erase Chip' will be executed
'erase': Performing implicit reset & halt of MCU.
ResetTarget() start
-- Identifying target device...
-- JTAG selected. Identifying JTAG Chain...
TotalIRLen = 8, IRPrint = 0x0001
JTAG chain detection found 1 devices:
#0 Id: 0x0996001D, IRLen: 04, JTAG-DP
Found 1 device in JTAG chain, IRPost/DRPost != 0. Reset IRPost/DRPost to 0.
-- JTAG Chain Identified. Connecting to DAP TAP...
-- Successfully connected to selected DAP TAP.
SDA_AP detected
Checking if core is already enabled...
Core already enabled
ResetTarget() end - Took 156ms
Erasing device...
****** Error: No matching RAMCode found
Failed to prepare for programming.
Failed to download RAMCode!
ERROR: Erase returned with error code -1.
The reset seems to be working, I just still can't talk to the uC.
I managed to find a sequence of commands that worked. I don't have exactly the sequence, but it's something like:
r0
erase 0 0 noreset
connect noreset
erase
The connect is successful after the erase 0 0 noreset, but the erase 0 0 noreset fails and does not prevent the application from running. I tried various reset, r0, r1 commands before this. Eventually I just stumbled onto a sequence that managed to erase it.
Update: After reviewing the DIO example I had been referencing again, it seems I overlooked the 'UnTouchedPortPins' section, and the MSCRn values for the port pins appear to match those for the debug port. I guess I'm now disabling those pins on reset?
I vaguely remember running into a similar thing in ProcessorExpert with a Kinetis micro a few years ago, but I don't remember what I had to do to recover from this state.