finally its working with JLinkGDBServer

This commit is contained in:
Robin Müller 2021-12-09 21:00:22 +01:00
parent b47ce37955
commit 1c16e903fd
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
6 changed files with 29 additions and 13 deletions

5
.vscode/launch.json vendored
View File

@ -9,9 +9,8 @@
"request": "launch", "request": "launch",
"name": "Debug LED Blinky", "name": "Debug LED Blinky",
// The user should start the J-Link server themselves for now. This is because the // The user should start the J-Link server themselves for now. This is because the
// ROM protection and the watchdog should be disabled after a reset, which requires // Cortex-Debug will issue a reset command, which is problematic even with
// the execution of a dedicated script. I have not found a way to make this work // a valid JLinkScript file
// with the jlinkscriptfile in the jlink folder
"servertype": "external", "servertype": "external",
"gdbTarget": "localhost:2331", "gdbTarget": "localhost:2331",
"gdbPath": "/usr/bin/gdb-multiarch", "gdbPath": "/usr/bin/gdb-multiarch",

View File

@ -1,3 +1,5 @@
#!/bin/bash #!/bin/bash
# Start the JLinkGDBServer while also specifying the JLinkScript file. The JLinkScript is necessary
# to disable ROM protection to allow flashing
JLinkGDBServer -select USB -device Cortex-M4 -endian little -if SWD -speed 2000 \ JLinkGDBServer -select USB -device Cortex-M4 -endian little -if SWD -speed 2000 \
-LocalhostOnly -vd -LocalhostOnly -vd -jlinkscriptfile ./jlink/JLinkSettings.JLinkScript

View File

@ -14,6 +14,21 @@ Purpose : J-Link target setup file for VORAGO VA416xx
---------------------------END-OF-HEADER------------------------------ ---------------------------END-OF-HEADER------------------------------
*/ */
int DisableRomProt(void) {
JLINK_SYS_Report("VA416XX: Disabling ROM protection");
return JLINK_MEM_WriteU32(0x40010010, 0x1); // ROM_PROT = 0x1
}
int DisableWatchdog(void) {
JLINK_MEM_WriteU32(0x400210C0, 0x1ACCE551); // WDOGLOCK = 0x1ACCE551
JLINK_MEM_WriteU32(0x40021008, 0x0); // WDOGCONTROL = 0x0 (diable)
}
int SetupTarget (void) {
JLINK_SYS_Report("SetupTarget()");
return DisableRomProt(); // ROM_PROT = 0x1
}
/********************************************************************* /*********************************************************************
* *
* AfterResetTarget * AfterResetTarget
@ -21,9 +36,8 @@ Purpose : J-Link target setup file for VORAGO VA416xx
int AfterResetTarget (void) { int AfterResetTarget (void) {
JLINK_SYS_Report("AfterResetTarget()"); JLINK_SYS_Report("AfterResetTarget()");
// disable watchdog and unlock code RAM for write // disable watchdog and unlock code RAM for write
JLINK_MEM_WriteU32(0x400210C0, 0x1ACCE551); // WDOGLOCK = 0x1ACCE551 DisableWatchdog();
JLINK_MEM_WriteU32(0x40021008, 0x0); // WDOGCONTROL = 0x0 (diable) return DisableRomProt(); // ROM_PROT = 0x1
return JLINK_MEM_WriteU32(0x40010010, 0x1); // ROM_PROT = 0x1
} }
/********************************************************************* /*********************************************************************
@ -32,7 +46,7 @@ int AfterResetTarget (void) {
*/ */
int BeforeTargetDownload (void) { int BeforeTargetDownload (void) {
JLINK_SYS_Report("BeforeTargetDownload()"); JLINK_SYS_Report("BeforeTargetDownload()");
return JLINK_MEM_WriteU32(0x40010010, 0x1); // ROM_PROT = 0x1 return DisableRomProt(); // ROM_PROT = 0x1
} }
/********************************************************************* /*********************************************************************
@ -41,7 +55,7 @@ int BeforeTargetDownload (void) {
*/ */
int AfterTargetDownload (void) { int AfterTargetDownload (void) {
JLINK_SYS_Report("AfterTargetDownload()"); JLINK_SYS_Report("AfterTargetDownload()");
return JLINK_MEM_WriteU32(0x40010010, 0x0); // ROM_PROT = 0x0 return DisableRomProt(); // ROM_PROT = 0x0
} }
/********************************************************************* /*********************************************************************
@ -50,7 +64,7 @@ int AfterTargetDownload (void) {
*/ */
int HandleBeforeFlashProg(void) { int HandleBeforeFlashProg(void) {
JLINK_SYS_Report("HandleBeforeFlashProg()"); JLINK_SYS_Report("HandleBeforeFlashProg()");
return JLINK_MEM_WriteU32(0x40010010, 0x1); // ROM_PROT = 0x1 return DisableRomProt(); // ROM_PROT = 0x1
} }
/********************************************************************* /*********************************************************************
@ -59,5 +73,5 @@ int HandleBeforeFlashProg(void) {
*/ */
int HandleAfterFlashProg(void) { int HandleAfterFlashProg(void) {
JLINK_SYS_Report("HandleAfterFlashProg()"); JLINK_SYS_Report("HandleAfterFlashProg()");
return JLINK_MEM_WriteU32(0x40010010, 0x0); // ROM_PROT = 0x0 return DisableRomProt(); // ROM_PROT = 0x0
} }

View File

@ -1,2 +0,0 @@
#!/bin/bash
gdb-multiarch -q --batch -ex 'source prep-flash.gdb'

3
scripts/prep-flash.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
# Alternative way to unlock the ROM protection of the VA416XX to allow flashing
gdb-multiarch -q --batch -ex 'source prep-flash.gdb'