LinkServer automation with python

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

LinkServer automation with python

Jump to solution
1,420 Views
mimlo
Contributor IV

Hello,
I'm using LinkServer v24.9.75 to automate flashing operations for the custom board that I have.
The microcontroller on this board is IMXRT1176 and it is connected to external hyperflash memory via Hyperbus..

I know there are 2 tools that can be used for flashing:
 - LinkServer
 - crt_emu_cm_redlink

The second one is used by the LinkServer for low-level operations if I'm not mistaken.

The problem I have is that LinkServer seems to have some dependencies built in that require me to put json config files and flash-loader.cfx files to the location where LinkServer is installed. This is not good for me, I would like to have a possibility to pass an argument with path to the config file to it directly from python.

Take a look here:

 

LinkServer.exe flash C:\Embedded\Target\customBoard\src\NewBoard\MIMXRT1170.json:NewBoard load C:\Embedded\Target\customBoard\src\NewBoard\Debug\example.axf

ERRMSG: Exception: Device query can have at most 2 parts (3 found): ['C', '\Embedded\Target\customBoard\src\NewBoard\MIMXRT1176.json', 'NewBoard']

 

 
The above method does not work. If I skip the path to config file and I use the new one I added within path  ...\LinkServer_24.9.75\devices then it works without a problem.
It is not ideal because it requires me to have this dependency in python scrript that configuration is places in the LinkServer device directory, as well as to flash directory for my custom flash-loader.cfx image.

Linkerver flash help says:

 

Usage: LinkServer.exe flash [OPTIONS] DEVICE COMMAND [ARGS]...

  Flash operations

  DEVICE can be:
  - <DEVICE_NAME>:<BOARD> pair, same as `devices --filter` parameter
  - device configuration file with extension `.json`.
          Use `config` command for generating such a file from an existing device

 

From the above description it seems I'm not using the device configuration file properly or I misunderstand the meaning of this help text.

My question is, can I get rid of these dependencies from LinkServer perspective or should I rely purely on crt_emu_cm_redlink for flash related operations?
For crt_emu_cm_redlink I know I can pass parameters with path to it and it works well.

In the end I just want to run one of the 2 as subprocess and pass parameters to it so it can do the flashing part.

0 Kudos
Reply
1 Solution
685 Views
ErichStyger
Specialist I

Hi @mimlo and @EdwinHz ,

this is an older discussion, but I think it is important to clarify two things (for anyone looking for a similar thing too).

1) I do *not* recommend using crt_emu_cm_redlink. This is more of an internal tool working in the background and should not be called directly. Instead, the LinkServer should be used. Sure, you can use it, but it is not recommended.

2) You can use LinkServer instead, and you can directly specif the JSON file. As already noted, the syntax is

DEVICE can be:
  - <DEVICE_NAME>:<BOARD> pair, same as `devices --filter` parameter
  - device configuration file with extension `.json`.
          Use `config` command for generating such a file from an existing device

The point I want to stress is that it is either <DEVICE_NAME>:<BOARD> *or* the path to the JSON file.

Using 

LinkServer.exe flash C:\Embedded\Target\customBoard\src\NewBoard\MIMXRT1170.json:NewBoard load C:\Embedded\Target\customBoard\src\NewBoard\Debug\example.axf

mixes up the JSON file with the <BOARD>.

So use the following

LinkServer.exe flash C:\Embedded\Target\customBoard\src\NewBoard\MIMXRT1170.json load C:\Embedded\Target\customBoard\src\NewBoard\Debug\example.axf

and it should work fine.

 

I hope this helps,

Erich

View solution in original post

5 Replies
686 Views
ErichStyger
Specialist I

Hi @mimlo and @EdwinHz ,

this is an older discussion, but I think it is important to clarify two things (for anyone looking for a similar thing too).

1) I do *not* recommend using crt_emu_cm_redlink. This is more of an internal tool working in the background and should not be called directly. Instead, the LinkServer should be used. Sure, you can use it, but it is not recommended.

2) You can use LinkServer instead, and you can directly specif the JSON file. As already noted, the syntax is

DEVICE can be:
  - <DEVICE_NAME>:<BOARD> pair, same as `devices --filter` parameter
  - device configuration file with extension `.json`.
          Use `config` command for generating such a file from an existing device

The point I want to stress is that it is either <DEVICE_NAME>:<BOARD> *or* the path to the JSON file.

Using 

LinkServer.exe flash C:\Embedded\Target\customBoard\src\NewBoard\MIMXRT1170.json:NewBoard load C:\Embedded\Target\customBoard\src\NewBoard\Debug\example.axf

mixes up the JSON file with the <BOARD>.

So use the following

LinkServer.exe flash C:\Embedded\Target\customBoard\src\NewBoard\MIMXRT1170.json load C:\Embedded\Target\customBoard\src\NewBoard\Debug\example.axf

and it should work fine.

 

I hope this helps,

Erich

674 Views
mimlo
Contributor IV

Hi @ErichStyger,
Your point is valid and pretty much point on. At the time of writing this post, I was not fully aware of the capabilities of the LinkServer but I'm up to speed now (at least from the flashing standpoint).

Just in case anyone else stumbles upon this post, take a note that in order to use the

<DEVICE_NAME>:<BOARD>

command notation, you need to have your device_name.json file (like MIMXRT1170.json present in the device folder where LinkServer performs a search (For my LinkServer version it's under .LinkServer_25.3.31\devices).

I decided to go with LinkServer and adopt the device.json file dependency, as it is nearly identical type of dependency that SEGGER JLink requires when there is custom device to be handled (for JLink, it's a device.xml file that is required).
Additionally, one extremely cool thing that I can add to the above is the LinkServer's feature that performs .json file validation in terms of syntax. If you mess it up, it informs you that a given field at a given line is not valid. Very very cool feature that JLink evidently lacks for their .xml device files

Best regards,
Michael

0 Kudos
Reply
669 Views
ErichStyger
Specialist I

HI @mimlo ,

Indeed, JSON imho is much more modern format with better possibilities than XML (which is older too).

 

Erich

0 Kudos
Reply
664 Views
mimlo
Contributor IV
json is not my personal favorite as it is quite painful to read (because of many constructs like [], {}, and etc.). However .xml is is way much worse imho

My personal preference is yml and toml.
Both are quite modern looking, easy to read, and lightweight to parse by different engines/modules.
0 Kudos
Reply
1,376 Views
EdwinHz
NXP TechSupport
NXP TechSupport

Hi @mimlo,

I'm afraid that these dependencies for LinkServer are not removable, as this is how LinkServer was designed. Please use crt_emu_cm_redlink instead to pass the path as a parameter sucessfully.

BR,
Edwin.

0 Kudos
Reply