Skip to content

Commit 150d7c2

Browse files
[nrf fromlist] boards: nordic: replace custom JLink reset scheme
Upstream PR #: 82976 The secure domain firmware ADAC interface has again been changed for SDFW v9.0 with ADAC v3, which no longer supports non-essential domain resets which the custom JLink reset scheme for nrf54h20dk/nrf54h20/cpuapp, nrf54h20dk/nrf54h20/cpurad, nrf9280pdk/nrf9280/cpuapp and nrf9280pdk/nrf9280/cpurad relied on. All resets done through the ADAC interface now do a global reset instead, which as of now "kills" the JLink session. This commit updates the JLink scripts for these boards to provide at least some way to debug the app/radio cores from the start of execution. It is likely no longer possible to implement a clean reset through the JLink scripts, and support for handling the global reset will need to be added to the tools instead. However, it is still possible to debug from the start of execution by resetting the device over ADAC first and then running "west attach". Signed-off-by: Jonathan Nilsen <[email protected]>
1 parent 8601a4e commit 150d7c2

File tree

4 files changed

+4
-192
lines changed

4 files changed

+4
-192
lines changed

boards/nordic/nrf54h20dk/support/nrf54h20_cpuapp.JLinkScript

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ __constant U32 _DHCSR_DBGKEY = (0xA05F << 16);
1111
__constant U32 _DHCSR_C_DEBUGEN = (1 << 0);
1212
__constant U32 _DHCSR_C_HALT = (1 << 1);
1313

14-
// Debug Exception and Monitor Control Register
15-
__constant U32 _DEMCR_ADDR = 0xE000EDFC;
16-
__constant U32 _DEMCR_VC_CORERESET = (1 << 0);
17-
__constant U32 _DEMCR_TRCENA = (1 << 24);
18-
1914
// CPU wait enable register
2015
__constant U32 _CPUCONF_CPUWAIT_OFFSET = 0x50C;
2116

@@ -154,7 +149,7 @@ int _DoAdacTransaction(int checkReplyStatus)
154149
return 0;
155150
}
156151

157-
int ResetTarget(void)
152+
int SetupTarget(void)
158153
{
159154
int err;
160155
U32 adacMajorVersion;
@@ -192,33 +187,6 @@ int ResetTarget(void)
192187
JLINK_SYS_Report1("ADAC major version: ", adacMajorVersion);
193188

194189
if (adacMajorVersion >= 2) {
195-
// There is a very small chance that this command fails if the domain reset itself
196-
// at the exact same time the command was issued. Therefore we retry a few times.
197-
i = 0;
198-
while (i < 3) {
199-
// Reset non-essential domains
200-
_adacTx[0] = 0xA30A0000; // Command RESET
201-
_adacTx[1] = 0x00000004; // Data length 4 bytes
202-
_adacTx[2] = 0x00000000; // (reserved)
203-
err = _DoAdacTransaction(1);
204-
if (err >= 0) {
205-
break;
206-
} else if (err != _ERR_REPLY) {
207-
return -1;
208-
}
209-
210-
i = i + 1;
211-
}
212-
213-
// Start the core in halted mode
214-
_adacTx[0] = 0xA3090000; // Command START
215-
_adacTx[1] = 0x00000004; // Data length 4 bytes
216-
_adacTx[2] = 0x01000000 | (_PROCESSOR_ID << 16); // Own processor, Flags HALT
217-
err = _DoAdacTransaction(1);
218-
if (err < 0) {
219-
return -1;
220-
}
221-
222190
// Start other cores normally (will fail silently if no firmware is present)
223191
i = 0;
224192
while (i < _NUM_OTHER_PROCESSORS) {
@@ -233,28 +201,13 @@ int ResetTarget(void)
233201

234202
i = i + 1;
235203
}
236-
} else {
237-
// Reset single domain via legacy implementation
238-
_adacTx[0] = 0xA3030000; // Command RESET
239-
_adacTx[1] = 0x00000004; // Data length 4 bytes
240-
_adacTx[2] = 0x01000000 | (_DOMAIN_ID << 16); // Own domain, Mode HALT
241-
err = _DoAdacTransaction(1);
242-
if (err < 0) {
243-
return -1;
244-
}
245204
}
246205

247206
// Halt the CPU
248207
JLINK_MEM_WriteU32(_DHCSR_ADDR, (_DHCSR_DBGKEY | _DHCSR_C_HALT | _DHCSR_C_DEBUGEN));
249208

250-
// Set vector catch on reset (to halt the CPU immediately after reset)
251-
JLINK_MEM_WriteU32(_DEMCR_ADDR, (_DEMCR_VC_CORERESET | _DEMCR_TRCENA));
252-
253209
// Disable CPU wait
254210
JLINK_MEM_WriteU32(_CPUCONF_ADDR + _CPUCONF_CPUWAIT_OFFSET, 0);
255211

256-
// Clear vector catch stuff
257-
JLINK_MEM_WriteU32(_DEMCR_ADDR, _DEMCR_TRCENA);
258-
259212
return 0;
260213
}

boards/nordic/nrf54h20dk/support/nrf54h20_cpurad.JLinkScript

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ __constant U32 _DHCSR_DBGKEY = (0xA05F << 16);
1111
__constant U32 _DHCSR_C_DEBUGEN = (1 << 0);
1212
__constant U32 _DHCSR_C_HALT = (1 << 1);
1313

14-
// Debug Exception and Monitor Control Register
15-
__constant U32 _DEMCR_ADDR = 0xE000EDFC;
16-
__constant U32 _DEMCR_VC_CORERESET = (1 << 0);
17-
__constant U32 _DEMCR_TRCENA = (1 << 24);
18-
1914
// CPU wait enable register
2015
__constant U32 _CPUCONF_CPUWAIT_OFFSET = 0x50C;
2116

@@ -162,7 +157,7 @@ int ConfigTargetSettings(void)
162157
return 0;
163158
}
164159

165-
int ResetTarget(void)
160+
int SetupTarget(void)
166161
{
167162
int err;
168163
U32 adacMajorVersion;
@@ -200,33 +195,6 @@ int ResetTarget(void)
200195
JLINK_SYS_Report1("ADAC major version: ", adacMajorVersion);
201196

202197
if (adacMajorVersion >= 2) {
203-
// There is a very small chance that this command fails if the domain reset itself
204-
// at the exact same time the command was issued. Therefore we retry a few times.
205-
i = 0;
206-
while (i < 3) {
207-
// Reset non-essential domains
208-
_adacTx[0] = 0xA30A0000; // Command RESET
209-
_adacTx[1] = 0x00000004; // Data length 4 bytes
210-
_adacTx[2] = 0x00000000; // (reserved)
211-
err = _DoAdacTransaction(1);
212-
if (err >= 0) {
213-
break;
214-
} else if (err != _ERR_REPLY) {
215-
return -1;
216-
}
217-
218-
i = i + 1;
219-
}
220-
221-
// Start the core in halted mode
222-
_adacTx[0] = 0xA3090000; // Command START
223-
_adacTx[1] = 0x00000004; // Data length 4 bytes
224-
_adacTx[2] = 0x01000000 | (_PROCESSOR_ID << 16); // Own processor, Flags HALT
225-
err = _DoAdacTransaction(1);
226-
if (err < 0) {
227-
return -1;
228-
}
229-
230198
// Start other cores normally (will fail silently if no firmware is present)
231199
i = 0;
232200
while (i < _NUM_OTHER_PROCESSORS) {
@@ -241,28 +209,13 @@ int ResetTarget(void)
241209

242210
i = i + 1;
243211
}
244-
} else {
245-
// Reset single domain via legacy implementation
246-
_adacTx[0] = 0xA3030000; // Command RESET
247-
_adacTx[1] = 0x00000004; // Data length 4 bytes
248-
_adacTx[2] = 0x01000000 | (_DOMAIN_ID << 16); // Own domain, Mode HALT
249-
err = _DoAdacTransaction(1);
250-
if (err < 0) {
251-
return -1;
252-
}
253212
}
254213

255214
// Halt the CPU
256215
JLINK_MEM_WriteU32(_DHCSR_ADDR, (_DHCSR_DBGKEY | _DHCSR_C_HALT | _DHCSR_C_DEBUGEN));
257216

258-
// Set vector catch on reset (to halt the CPU immediately after reset)
259-
JLINK_MEM_WriteU32(_DEMCR_ADDR, (_DEMCR_VC_CORERESET | _DEMCR_TRCENA));
260-
261217
// Disable CPU wait
262218
JLINK_MEM_WriteU32(_CPUCONF_ADDR + _CPUCONF_CPUWAIT_OFFSET, 0);
263219

264-
// Clear vector catch stuff
265-
JLINK_MEM_WriteU32(_DEMCR_ADDR, _DEMCR_TRCENA);
266-
267220
return 0;
268221
}

boards/nordic/nrf9280pdk/support/nrf9280_cpuapp.JLinkScript

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ __constant U32 _DHCSR_DBGKEY = (0xA05F << 16);
1111
__constant U32 _DHCSR_C_DEBUGEN = (1 << 0);
1212
__constant U32 _DHCSR_C_HALT = (1 << 1);
1313

14-
// Debug Exception and Monitor Control Register
15-
__constant U32 _DEMCR_ADDR = 0xE000EDFC;
16-
__constant U32 _DEMCR_VC_CORERESET = (1 << 0);
17-
__constant U32 _DEMCR_TRCENA = (1 << 24);
18-
1914
// CPU wait enable register
2015
__constant U32 _CPUCONF_CPUWAIT_OFFSET = 0x50C;
2116

@@ -154,7 +149,7 @@ int _DoAdacTransaction(int checkReplyStatus)
154149
return 0;
155150
}
156151

157-
int ResetTarget(void)
152+
int SetupTarget(void)
158153
{
159154
int err;
160155
U32 adacMajorVersion;
@@ -192,33 +187,6 @@ int ResetTarget(void)
192187
JLINK_SYS_Report1("ADAC major version: ", adacMajorVersion);
193188

194189
if (adacMajorVersion >= 2) {
195-
// There is a very small chance that this command fails if the domain reset itself
196-
// at the exact same time the command was issued. Therefore we retry a few times.
197-
i = 0;
198-
while (i < 3) {
199-
// Reset non-essential domains
200-
_adacTx[0] = 0xA30A0000; // Command RESET
201-
_adacTx[1] = 0x00000004; // Data length 4 bytes
202-
_adacTx[2] = 0x00000000; // (reserved)
203-
err = _DoAdacTransaction(1);
204-
if (err >= 0) {
205-
break;
206-
} else if (err != _ERR_REPLY) {
207-
return -1;
208-
}
209-
210-
i = i + 1;
211-
}
212-
213-
// Start the core in halted mode
214-
_adacTx[0] = 0xA3090000; // Command START
215-
_adacTx[1] = 0x00000004; // Data length 4 bytes
216-
_adacTx[2] = 0x01000000 | (_PROCESSOR_ID << 16); // Own processor, Flags HALT
217-
err = _DoAdacTransaction(1);
218-
if (err < 0) {
219-
return -1;
220-
}
221-
222190
// Start other cores normally (will fail silently if no firmware is present)
223191
i = 0;
224192
while (i < _NUM_OTHER_PROCESSORS) {
@@ -233,28 +201,13 @@ int ResetTarget(void)
233201

234202
i = i + 1;
235203
}
236-
} else {
237-
// Reset single domain via legacy implementation
238-
_adacTx[0] = 0xA3030000; // Command RESET
239-
_adacTx[1] = 0x00000004; // Data length 4 bytes
240-
_adacTx[2] = 0x01000000 | (_DOMAIN_ID << 16); // Own domain, Mode HALT
241-
err = _DoAdacTransaction(1);
242-
if (err < 0) {
243-
return -1;
244-
}
245204
}
246205

247206
// Halt the CPU
248207
JLINK_MEM_WriteU32(_DHCSR_ADDR, (_DHCSR_DBGKEY | _DHCSR_C_HALT | _DHCSR_C_DEBUGEN));
249208

250-
// Set vector catch on reset (to halt the CPU immediately after reset)
251-
JLINK_MEM_WriteU32(_DEMCR_ADDR, (_DEMCR_VC_CORERESET | _DEMCR_TRCENA));
252-
253209
// Disable CPU wait
254210
JLINK_MEM_WriteU32(_CPUCONF_ADDR + _CPUCONF_CPUWAIT_OFFSET, 0);
255211

256-
// Clear vector catch stuff
257-
JLINK_MEM_WriteU32(_DEMCR_ADDR, _DEMCR_TRCENA);
258-
259212
return 0;
260213
}

boards/nordic/nrf9280pdk/support/nrf9280_cpurad.JLinkScript

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ __constant U32 _DHCSR_DBGKEY = (0xA05F << 16);
1111
__constant U32 _DHCSR_C_DEBUGEN = (1 << 0);
1212
__constant U32 _DHCSR_C_HALT = (1 << 1);
1313

14-
// Debug Exception and Monitor Control Register
15-
__constant U32 _DEMCR_ADDR = 0xE000EDFC;
16-
__constant U32 _DEMCR_VC_CORERESET = (1 << 0);
17-
__constant U32 _DEMCR_TRCENA = (1 << 24);
18-
1914
// CPU wait enable register
2015
__constant U32 _CPUCONF_CPUWAIT_OFFSET = 0x50C;
2116

@@ -162,7 +157,7 @@ int ConfigTargetSettings(void)
162157
return 0;
163158
}
164159

165-
int ResetTarget(void)
160+
int SetupTarget(void)
166161
{
167162
int err;
168163
U32 adacMajorVersion;
@@ -200,33 +195,6 @@ int ResetTarget(void)
200195
JLINK_SYS_Report1("ADAC major version: ", adacMajorVersion);
201196

202197
if (adacMajorVersion >= 2) {
203-
// There is a very small chance that this command fails if the domain reset itself
204-
// at the exact same time the command was issued. Therefore we retry a few times.
205-
i = 0;
206-
while (i < 3) {
207-
// Reset non-essential domains
208-
_adacTx[0] = 0xA30A0000; // Command RESET
209-
_adacTx[1] = 0x00000004; // Data length 4 bytes
210-
_adacTx[2] = 0x00000000; // (reserved)
211-
err = _DoAdacTransaction(1);
212-
if (err >= 0) {
213-
break;
214-
} else if (err != _ERR_REPLY) {
215-
return -1;
216-
}
217-
218-
i = i + 1;
219-
}
220-
221-
// Start the core in halted mode
222-
_adacTx[0] = 0xA3090000; // Command START
223-
_adacTx[1] = 0x00000004; // Data length 4 bytes
224-
_adacTx[2] = 0x01000000 | (_PROCESSOR_ID << 16); // Own processor, Flags HALT
225-
err = _DoAdacTransaction(1);
226-
if (err < 0) {
227-
return -1;
228-
}
229-
230198
// Start other cores normally (will fail silently if no firmware is present)
231199
i = 0;
232200
while (i < _NUM_OTHER_PROCESSORS) {
@@ -241,28 +209,13 @@ int ResetTarget(void)
241209

242210
i = i + 1;
243211
}
244-
} else {
245-
// Reset single domain via legacy implementation
246-
_adacTx[0] = 0xA3030000; // Command RESET
247-
_adacTx[1] = 0x00000004; // Data length 4 bytes
248-
_adacTx[2] = 0x01000000 | (_DOMAIN_ID << 16); // Own domain, Mode HALT
249-
err = _DoAdacTransaction(1);
250-
if (err < 0) {
251-
return -1;
252-
}
253212
}
254213

255214
// Halt the CPU
256215
JLINK_MEM_WriteU32(_DHCSR_ADDR, (_DHCSR_DBGKEY | _DHCSR_C_HALT | _DHCSR_C_DEBUGEN));
257216

258-
// Set vector catch on reset (to halt the CPU immediately after reset)
259-
JLINK_MEM_WriteU32(_DEMCR_ADDR, (_DEMCR_VC_CORERESET | _DEMCR_TRCENA));
260-
261217
// Disable CPU wait
262218
JLINK_MEM_WriteU32(_CPUCONF_ADDR + _CPUCONF_CPUWAIT_OFFSET, 0);
263219

264-
// Clear vector catch stuff
265-
JLINK_MEM_WriteU32(_DEMCR_ADDR, _DEMCR_TRCENA);
266-
267220
return 0;
268221
}

0 commit comments

Comments
 (0)