How do I use my own flashing script in MCUXpresso

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I use my own flashing script in MCUXpresso

799 Views
RogerDavisWork
Contributor II

We have some projects that use the MCUXpresso IDE for building, flashing, and debugging.

One of our projects requires multiple steps to flash the target because it uses both internal and external flash parts.  We have a flashing script that works for us from a command line interface using JLink commands and would like to port it into the MCUXpresso setup so that we can call it to flash the target when we want to debug.

I have tried multiple things to get it to recognize my script but I am doing it wrong somehow.  First, I cannot seem to replace the script.jlink file that is in the project because it just gets overwritten with the default values.  I also tried editing the debug configuration and having the path to my flashing script in the Script field in the JLink Debugger tab, but that generates errors as if it is looking for some other kind of file than my flashing script.

Please advise me as to how to get MCUXpresso to use my script and execute it such that the JLink commands will flash my target in the debug startup sequence.  Thank you.

Labels (1)
0 Kudos
5 Replies

707 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello, in order to get more details, is the script the same one that you use successfully on J-link commander? or did you make modifications to add on the J-Link debugger tab? Could you share both if possible?

Best regards,
Pavel

 

0 Kudos

695 Views
RogerDavisWork
Contributor II

I found a partial workaround by adding the flashing batch file that uses the jlink script as a post-build step. I have two versions of jlink scripts. The first flashes both internal and external flash parts. The second one only flashes the external part.
The reason that I have two scripts is an attempt to see what I can get to work by flashing both or just the external in the post-build step.

The ideal situation is to be able to flash both flashes myself in post-build, and just have the debugger load symbols and run (by *unchecking* the "Load Image" box on the "Startup" tab). But this does not work. When it runs, the code goes into the weeds every time when I do this.

So instead, I flash either one or both flashes in post-build and then allow the debug configuration to re-flash the internal one again (by *checking* the "Load Image" box on the "Startup" tab). This appears to work for some unknown reason.

Interestingly, I can flash both flashes using the same batch and jlink files on a command line and run the device, so I am fairly confident that there is nothing wrong with the flash script. Although after flashing it, I then perform a reset.

Here is the version for flashing both internal and external flashes. The one that only does the external one is identical without the first loadbin. The way that the external flashing works is that we load the image into upper RAM and a flashing utility into lower RAM and let it run.

The batch file sets up this config:

set JLINK_ARGS=-ExitOnError 1 -device MK81FN256XXX15 -if JTAG -speed 4000 -jtagconf "-1,-1" -autoconnect 1
set JLINK_COMMAND_SCRIPT=-CommanderScript %SCRIPT_PATH%
%JLINK_PATH%\JLink %JLINK_ARGS% %JLINK_COMMAND_SCRIPT%

The jlink script is this:


RSetType 3
r

loadbin C:\xxx\internal_firmware_image.bin, 0x0000

loadbin C:\xxx\external_firmware_image.bin, 0x20000000
loadbin C:\yyy\tools\qspi_192K.bin, 0x1FFF0000
wreg msp, 0x20030000
wreg psp, 0x20030000
setpc 0x1fff0400
halt
exit

I should note that in post-build, before running the flashing batch file, we run another batch file that calls a python script to process the axf/elf file into two binary files, and it is these files that get flashed into the two flash parts.

0 Kudos

504 Views
ErichStyger
Senior Contributor V

If you want to program multiple binary files, you can do this directly in the debugger/gdb commands/settings, e.g. see

https://mcuoneclipse.com/2022/11/01/loading-multiple-binary-files-with-gdb/

Additionally, if you want to do low level stuff, you can do this with the J-Link Script files: https://wiki.segger.com/J-Link_script_files

The script can be passed in the MCUXpresso IDE here:

ErichStyger_0-1701533543887.png

 

I hope this helps,

Erich

0 Kudos

771 Views
Pavel_Hernandez
NXP TechSupport
NXP TechSupport

Hello @RogerDavisWork 

Could you tell us what is your part number?

Best regards

0 Kudos

716 Views
RogerDavisWork
Contributor II

MK81FN256

0 Kudos