Solved! Go to Solution.
Hello Diego,
thank you for your comment.
I have found a solution, but it is not in the reset scripts.
As far as I understand the reset scripts are called after the flash download is finished. But this is not what I needed.
Just to state the problem again. what I need is that the reset line is activated before the debug connection is established.
I want to use the Linkserver as a standalone tool to program boards. So I am running it from a batch file in a command line window.
But your post made me look at the preconnect scripts.
In the command line you can call the linkserver.exe with a .json configuration file. This configuration file determines which scripts are called. In all the examples I have looked at there was no preconnect script.
The schema file "LinkServer_XXXX\devices\devices.schema.json" shows how to add the script into the configuration file.
However the documentation on this is not very clear.
For reference here is the modified configuration file:
{
"copyright": "Copyright 2023 NXP",
"license": "SPDX-License-Identifier: BSD-3-Clause",
"version": "1.0.0",
"vendor": "NXP",
"devices": [
{
"board": "TWR-K22F120M",
"device": {
"name": "MK22FN512xxx12",
"family": "K2x",
"memory": [
{
"location": "0x00000000",
"size": "0x00080000",
"type": "Flash",
"flash-driver": "FTFA_2K.cfx"
},
{
"location": "0x20000000",
"size": "0x00010000",
"type": "RAM"
},
{
"location": "0x1fff0000",
"size": "0x00010000",
"type": "RAM"
}
],
"cores": [
{
"type": "cm4",
"name": "cm4"
}
]
},
"debug": {
"protocol": "swd",
"swo": true,
"preconnect-script": "preconnect_HOLD_RESET.scp",
"connect-script": "kinetisconnect.scp",
"masserase-script": "kinetismasserase.scp"
}
}
]
}
Here is the preconnect script that i wrote:
1 Print "Preonnect Script"
10 REM check for debug probes
20 PROBELIST
30 REM open connection to debug probe
40 PROBEOPENBYINDEX a%
50 REM set the reset line
60 WIREHOLDRESET a% 0
Missing fact: the preconnect scripts have to be located in the folder "Linkserver_XXXX\binaries\ToolScripts\". If they are in the "Scripts"-Folder they are not found. Also there is no error message that the script is not found.
Also the print statement in the .scp file is not showing up in the command line output.
Now, everytime I run linkserver.exe with this configuration, I can connect to the microcontroller without a problem.
Hi @m_p
Thank you for reaching out!
I think that we could test using a custom reset script. By looking the MCUXpresso IDE documentation, we can see that there are some ways to handle how debugger manages reset, appart from connect.
You could try these options but there is the option for reset script.
This is further described here:
I did not find a Kinetis reset script, on particular, but in the linksersver there are some reset scripts for other MCUs, they may help as referece , example path is C:\nxp\LinkServer_1.5.30\binaries\Scripts
Please let me know if this helps, or any other related question you may have.
Diego
Hello Diego,
thank you for your comment.
I have found a solution, but it is not in the reset scripts.
As far as I understand the reset scripts are called after the flash download is finished. But this is not what I needed.
Just to state the problem again. what I need is that the reset line is activated before the debug connection is established.
I want to use the Linkserver as a standalone tool to program boards. So I am running it from a batch file in a command line window.
But your post made me look at the preconnect scripts.
In the command line you can call the linkserver.exe with a .json configuration file. This configuration file determines which scripts are called. In all the examples I have looked at there was no preconnect script.
The schema file "LinkServer_XXXX\devices\devices.schema.json" shows how to add the script into the configuration file.
However the documentation on this is not very clear.
For reference here is the modified configuration file:
{
"copyright": "Copyright 2023 NXP",
"license": "SPDX-License-Identifier: BSD-3-Clause",
"version": "1.0.0",
"vendor": "NXP",
"devices": [
{
"board": "TWR-K22F120M",
"device": {
"name": "MK22FN512xxx12",
"family": "K2x",
"memory": [
{
"location": "0x00000000",
"size": "0x00080000",
"type": "Flash",
"flash-driver": "FTFA_2K.cfx"
},
{
"location": "0x20000000",
"size": "0x00010000",
"type": "RAM"
},
{
"location": "0x1fff0000",
"size": "0x00010000",
"type": "RAM"
}
],
"cores": [
{
"type": "cm4",
"name": "cm4"
}
]
},
"debug": {
"protocol": "swd",
"swo": true,
"preconnect-script": "preconnect_HOLD_RESET.scp",
"connect-script": "kinetisconnect.scp",
"masserase-script": "kinetismasserase.scp"
}
}
]
}
Here is the preconnect script that i wrote:
1 Print "Preonnect Script"
10 REM check for debug probes
20 PROBELIST
30 REM open connection to debug probe
40 PROBEOPENBYINDEX a%
50 REM set the reset line
60 WIREHOLDRESET a% 0
Missing fact: the preconnect scripts have to be located in the folder "Linkserver_XXXX\binaries\ToolScripts\". If they are in the "Scripts"-Folder they are not found. Also there is no error message that the script is not found.
Also the print statement in the .scp file is not showing up in the command line output.
Now, everytime I run linkserver.exe with this configuration, I can connect to the microcontroller without a problem.
Hi @m_p
Thank you very much, I am glad that you shared the solution you have found, it may help other users too ! My apologies, yes, it makes more sense to use preconnect script as it prepares the MCU for initial debug.
Diego