How to make redlinkserv work in the command line?

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

How to make redlinkserv work in the command line?

Jump to solution
7,412 Views
laszlomonda
Contributor IV

Hi there,

I'd like to use my LPC-Link 2 probe on the command line to program my boards and I cannot make it work this way.

First up, I launch "boot_link2" which works:

laci@spark /usr/local/mcuxpressoide-10.0.0_344/ide/bin $ ./boot_link2
/usr/local/mcuxpressoide-10.0.0_344/ide/bin/dfu_boot -s ./boot_link2 -n LPC-Link2 -v 0x1fc9:0x000c -i /usr/local/mcuxpressoide-10.0.0_344/ide/bin/../bin/LPC432x_CMSIS_DAP_V5_182.bin.hdr
Looking for DFU devices with VID 1fc9 PID 000c ...
dfu-util -d 1fc9:000c -c 1 -i 0 -t 2048 -R -D /usr/local/mcuxpressoide-10.0.0_344/ide/bin/../bin/LPC432x_CMSIS_DAP_V5_182.bin.hdr
Booted LPC-Link2 (1fc9:000c) with /usr/local/mcuxpressoide-10.0.0_344/ide/bin/../bin/LPC432x_CMSIS_DAP_V5_182.bin.hdr

Second, I launch "redlinkserv --telnetport=3025,3050" which starts up, but doesn't output anything and doesn't return. It also doesn't make the upcoming "crt_emu_cm_redlink" command work, and it hangs forever.

Third, I launch "crt_emu_cm_redlink", which fails. I assume it's because redlinkserv failed.

laci@spark  $ /usr/local/mcuxpressoide/ide/bin/crt_emu_cm_redlink --flash-load-exec "/home/laci/download/uhk-left.bin" -g --debug 2 --vendor NXP -p MKL03Z32xxx4 --load-base=0 -ProbeHandle=1 -CoreIndex=0 --reset vectreset -x /home/laci/mcuxpresso/.mcuxpressoide_packages_support/MKL03Z32xxx4_support --flash-dir /home/laci/mcuxpresso/.mcuxpressoide_packages_support/MKL03Z32xxx4_support/Flash 

Ns: MCUXpresso RedlinkMulti Driver v10.0 (Mar 21 2017 01:36:19 - crt_emu_cm_redlink build 190)
Pc: ( 0) Reading remote configuration
Pc: ( 5) Remote configuration complete
Nc: Reconnected to existing redlink server (PID 4294967295)
Nc: Connecting to probe 1 core 0 (server PID unknown) gave 'Ee(38). Invalid probe index.'
Nc: Connecting to probe 1 core 0 (server PID unknown) gave 'Ee(38). Invalid probe index.'
Nc: Connecting to probe 1 core 0 (server PID unknown) gave 'Ee(38). Invalid probe index.'
Nc: Server OK but no connection to probe 1 core 0 (after 3 attempts) - Ee(38). Invalid probe index.
Ed:02: Failed on connect: Ee(38). Invalid probe index.
Et:31: No connection to debug probe
Pc: (100) Target Connection Failed

"crt_emu_cm_redlink" works after I start up the Link Server GUI Flash programmer utility of MCUXpresso IDE, but as I said, I'd like to use LPC-Link 2 purely from the command line, so it's not an option.

Waiting for your ultimate wisdom, guys.

- Laci

1 Solution
2,170 Views
ErichStyger
Senior Contributor V

You should have a look a the 'LinkServer' (see https://mcuoneclipse.com/2023/05/14/linkserver-for-microcontrollers/ NXP has released what was formerly under the 'RedLink' as a gdb server package. LinkServer works fine on my side as command line tool, as it is like other gdb server implementations.

I hope this helps,

Erich

View solution in original post

13 Replies
2,178 Views
derek_pbolt
Contributor I
I'm also running into this issue. I've tried the suggested:
  • Made sure that the port is open on the firewall.
  • Not using probehandle or coreindex
  • Initially did not start redlinkserv, but realized that if i did start it from the command line in another terminal, that the process was able to connect. This is confusing as a NXP user said that we should not need to manually start it with crt_emu_cm_redlink. So at this point I've been trying to use python to open a redlinkserv process in the background before running crt_emu_cm_redlink.
  • I see the mention of Scripts folder which I have, and it mentions a specific exe that needs to be in this directory but not what that exe is.
My command (with paths shortened):
{crt_emu_cm_redlink} --flash-load-exec {firmware_file} -p PN7640 --ConnectScript {connect_scp_path} --ResetScript {reset_scp_path} --flash-driver= -x {sdk_path} --flash-dir {flash_dir_path} --flash-hashing --load-base=0x218000

My Error:
Ns: MCUXpresso IDE RedlinkMulti Driver v11.7 (Mar 22 2023 09:52:55 - crt_emu_cm_redlink.exe build 13)
Wc(03). No cache support.
Nc: Found chip XML file in C:\Users\Developer\AppData\Roaming\Python\Python311\site-packages\eol\workspace\sdk\PN7640.xml
Ns: redlink server client - failed to connect to new server localhost port 3490
Nc: Could not connect to link server - status 255
Nc: Failed to connect a LinkServer process.
Ed:02: Failed on connect: Ee(D0). Could not connect to server
Et:31: No connection to chip's debug port

My intent is to package up all the things needed to run this into a python package so that it's easy for our partners to install our firmware installation tool.
0 Kudos
2,171 Views
ErichStyger
Senior Contributor V

You should have a look a the 'LinkServer' (see https://mcuoneclipse.com/2023/05/14/linkserver-for-microcontrollers/ NXP has released what was formerly under the 'RedLink' as a gdb server package. LinkServer works fine on my side as command line tool, as it is like other gdb server implementations.

I hope this helps,

Erich

5,681 Views
satbir7
Contributor III

Hello All,

This is  old thread, someone must have  a solution by now....

I am in the  same situation...

If I start the redlinkserver from the IDE by  clicking the Red Link, then I can flash my MCU from CMD using crt_emu_cm_redlink. 

If the server is not running  then it fails with the  following  error:

Ns: redlink server client - failed to connect to new server localhost port 3490
Nc: Could not connect to link server - status 255
Nc: Failed to connect a LinkServer process.
Ed:02: Failed on connect: Ee(D0). Could not connect to server
Et:31: No connection to chip's debug port

One thing that is different  here is  the  port number, when the server is started from IDE it  connects to port 3025.

How can I make this  work ?

 

Thanks,

Satbir

 

0 Kudos
5,677 Views
converse
Senior Contributor V

What is your command line that is failing?

have you checked firewall?

0 Kudos
5,673 Views
satbir7
Contributor III

Thanks for the quick reply!!

Here is my cmd 

crt_emu_cm_redlink -pMKE02Z64xxx4 -ConnectScript ke0xconnect.scp --flash-driver= -x --flash-dir -x -vendor=NXP -flash-load "code.axf"

Ns: MCUXpresso IDE RedlinkMulti Driver v11.2 (Sep 22 2020 13:23:35 - crt_emu_cm_redlink build 19)
Wc(03). No cache support.
Nc: Found part description in XML file MKE02Z4_internal.xml
Ns: redlink server client - failed to connect to new server localhost port 3490
Nc: Could not connect to link server - status 255
Nc: Failed to connect a LinkServer process.
Ed:02: Failed on connect: Ee(D0). Could not connect to server
Et:31: No connection to chip's debug port

 

Nothing pops up in firewall, asking for access.

And it works if I first start the Link Server from IDE.

Thanks,

Satbir

 

0 Kudos
5,637 Views
satbir7
Contributor III

Hi @converse ,

I was having issues with RedlinkServer crashing, but I figured it out today.

redlinkserve.exe was crashing, because I didn't  have  the  Scripts folder with the  .exe file.

Once I moved the  Scripts folder, it started working as expected.

Now, I have  a working standalone GUI which can Unsecure/Flash the MKE02Z MCU with LPC-Link2.

Thanks for the reply!!

I have  another question though!

Ns: MCUXpresso IDE RedlinkMulti Driver v11.2 (Sep 22 2020 13:23:35 - crt_emu_cm_redlink.exe build 19)
Wc(03). No cache support.
Nc: Found part description in XML file MKE02Z4_internal.xml
Nc: Restarted LinkServer process (PID 51348).
Wc: ============= SCRIPT: ke0xconnect.scp =============
Wc: KE0X Connect Script
Wc: Probe Handle 1 Open
Wc: DpID = 0BC11477
Wc: Assert NRESET
Wc: Reset pin state: 00
Wc: Power up Debug
Wc: APID = 0x04770031
Wc: MDM-AP APID: 0x001C0020
Wc: Release NRESET
Wc: Reset pin state: 01
Wc: MDM-AP System Reset/Hold Reset/Debug Request
Wc: MDM-AP Control: 0x00000008
Wc: MDM-AP Status (Flash Ready) : 0x00000007
Wc: Part is secured
Wc: Mass Erase Required
Wc: ============= END SCRIPT ==========================


Nc: Probe Firmware: LPC-LINK2 CMSIS-DAP V5.361 (NXP Semiconductors)
Nc: Serial Number: BSEWGYEQ
Nc: VID:PID: 1FC9:0090
Nc: USB Path: \\?\hid#vid_1fc9&pid_0090&mi_00#7&f75d0ea&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}
Nc: Using memory from core 0 after searching for a good core
Ns: redlink server client - failed to receive response (to op 62) from server after 2000ms - Unknown error (rc 138)
Nc: connection failed - EE(47): Debug Mailbox Request Failed... Retrying
Nc: probe 1 TAP 0 gives zero TAP ID - is probe connected to a target?
Ns: redlink server client - warning - 28 bytes of unexpected data from the server
Nc: Using memory from core 0 after searching for a good core
Ns: redlink server client - failed to receive response (to op 62) from server after 2000ms - Unknown error (rc 138)
Ed:02: Failed on connect: EE(47): Debug Mailbox Request Failed.
Et: Probe(0): Connected&Reset. Was: NotConnected. DpID: 00000000. CpuID: 00000000. Info: <None>
Nc: Last stub error 0: OK
Nc: Last sticky error: 0x0 AIndex: 0
Nc: Debug bus selected: MemAp 0
Nc: DAP Speed test unexecuted or failed
Nc: Debug protocol: SWD. RTCK: Disabled. Vector catch: Disabled.
Ns: redlink server client - warning - 28 bytes of unexpected data from the server
Nc: error closing down debug session - Nn(05). Wire ACK Fault in DAP access

 

Is there anyway to just run the Script with crt_emu_cm_redlink.exe, such that only the "italicized" portion of the above log is observed?

Can the crt_emu_cm_redlink.exe exit after running the Script?

Thanks,

Satbir

0 Kudos
6,044 Views
lpcxpresso_supp
NXP Employee
NXP Employee

The error you are seeing is indistinguishable from that seen if there was no connection to a board/MCU.

Therefore I think it is time to take a big step back and establish exactly what is working ...

You are debugging using an LPC-Link2 debug probe and trying to connect to a board containing a KL03 MCU?

Is this a development board e.g. a Kinetis Freedom board or a user designed board?

How is the board being powered?

Are you able to debug this board from the IDE? If so, please can you paste the debug log for a successful debug session into this thread.

To find the debug log please go to the IDE  Console -> From the Drop Down -> Debug messages

Yours,

MCUXpresso Support

0 Kudos
6,044 Views
jimmypedersen
Contributor I

Hi

Sorry to hi-jack this thread but my problem is related to the one above.

I'm writing a script to download the same firmware to three CPUs at the same time (to speed up production) using LPC-link 2's. Problem is that I can't get the script to work when using -ProbeHandle=n. If I run the script without the -ProbeHandle the CPU connected to the first LPC-Link 2 gets programmed three times. How do I get this to work?

Kind regards

Jimmy

Ps. If i run redlinkserv.exe --commandline and there do a probelist I see all the probes, indexed 1, 2 & 3. They are all running LPC-Link-II CMSIS-DAP firmware (And strangely enough have the same serial: A000000001).

The probes both works fine from MCUXpresso

They are programmed with the  LPC-Link-II CMSIS-DAP firmware and set in the NON-DFU mode with the JP1 jumper in place (So if I understand it correctly no bootloading should be needed)

0 Kudos
6,044 Views
converse
Senior Contributor V

This link describes how to use the command line flash tool

https://community.nxp.com/message/630785 

A couple of things to note:

- do not start redlinkserv. The tool automatically does this in the background

- if there is one probe connected to one mcu, do not use probehandle or coreindex

6,044 Views
laszlomonda
Contributor IV

Hi Con,

I appreciate your answer, and already read the resources you linked before, but they're overly general, and lack detail. Unlike Segger J-Link, LPC-Link2 looks very command line unfriendly, and I cannot make it work based on these documents.

If I don't call redlinkserv when using crt_emu_cm_redlink, then I get:

Nc: Connecting to probe 0 core 0 - Ee(D1). Redlink server process restart
Nc: Server OK but no connection to probe 0 core 0 (after 3 attempts) - Ee(36). Could not connect to core.
Ed:02: Failed on connect: Ee(36). Could not connect to core.
Et:31: No connection to debug probe
Pc: (100) Target Connection Failed

I tried to run crt_emu_cm_redlink without the ProbeHandle or CoreIndex arguments and nothing seemed to change.

Any further help is much appreciated.

- Laci

0 Kudos
6,044 Views
lpcxpresso_supp
NXP Employee
NXP Employee

Hi Laci

I tried to run crt_emu_cm_redlink without the ProbeHandle or CoreIndex arguments and nothing seemed to change.

A very good idea.

In the following:

Nc: Connecting to probe 0 core 0 - Ee(D1). Redlink server process restart
Nc: Server OK but no connection to probe 0 core 0 (after 3 attempts) - Ee(36). Could not connect to core.

we would expect a failure because zero is not a valid probe number.

Omitting both the --probehandle and the --coreindex options will normally work best if there is no instance of MCUXpresso IDE in use. 

The link server will be run for you if necessary.

It looks like you are trying to program the flash and are starting from the command line

/usr/local/mcuxpressoide/ide/bin/crt_emu_cm_redlink --flash-load-exec "/home/laci/download/uhk-left.bin" -g --debug 2 --vendor NXP -p MKL03Z32xxx4 --load-base=0 -ProbeHandle=1 -CoreIndex=0 --reset vectreset -x 

which you probably derived from the command used inside the IDE.  Here are some points that might help

  • --flash-load-exec "/home/laci/download/uhk-left.bin" will program the image into your device and then start it running using a reset.  The quotes around the file name are good practice but, unless the file name includes spaces or other strange characters, aren't strictly necessary.
    Did you want to execute the code as well as program it?  If you just needed to program the data use --flash-load instead of --flash-load-exec.
  • -g is used by the IDE to get the program to report information it uses for a progress meter, if you are using the command on the command line you don't need it.
  • --debug 2 sets a debug level that will dictate the amount of detail printed to the (standard error) output, there is nothing wrong with including it, but you don't need it.
  • --vendor NXP was useful in old versions of LPCXpresso IDE, but now there are no other options for --vendor and 'NXP' is the default anyway, so you don't really need it.
  • -p MKL03Z32xxx4 provides the name of your board or package and is absolutely necessary
  • --load-base 0 is required only because you are flashing a binary file (and binary files contain no internal detail of which target address they should be flashed to).
  • --probehandle 1 identifies the debug probe you are using - in particular it selects the 'first' to be found (the link server can deal with simultaneous connections to many).  If you omit this the first probe is located automatically, so you probably don't require this.
  • --coreindex 0 identifies the CPU on the board attached to the given probe that you wish to use (some boards have multiple cores).  Core 0 is the 'first' one located and is the default, so you probably don't require this either.
  • --reset vectreset chooses the type of reset you use in order to execute the image once it has been written to flash (only required because you have used --flash-load-exec rather than --flash-load). There are two main options 'vectreset' (or 'system') and 'sysresetreq' (or 'core'). The former causes the image to run by doing the kind of reset that causes the Boot ROM to re-execute.  The latter just resets the core that you are connected to (but perhaps not other parts of the system and not including any initialization that the Boot ROM might have provided for you) and then jumps to the address embedded in the fist word of the image you booted.
  • -x : this option should be followed by the name of a directory where XML information defining various details of the memory map, which memory areas are served by which flash drivers, and where peripherals can be found.  You might need this, particularly if you have updated details of flash location or where memory areas are in the IDE and you want to inherit that information.  The defaults should be OK if you haven't made such changes. -x on its own is incorrect - it is a bug in crt_emu_cm_redlink that it does not say so.

If you don't need -x and you would like only to program the flash you could try:

/usr/local/mcuxpressoide/ide/bin/crt_emu_cm_redlink --flash-load "/home/laci/download/uhk-left.bin" -p MKL03Z32xxx4 --load-base 0 

The existing information about using the tool from the command line is poor and we are thinking of updating it. 

Meanwhile I hope the above will help.

Note also that 

    /usr/local/mcuxpressoide/ide/bin/crt_emu_cm_redlink -h

will print out some limited, if cryptic, details of some of the other options.

Sincerely

LPCXpresso IDE Support

0 Kudos
6,044 Views
laszlomonda
Contributor IV

Dear LPCXpresso IDE Support,

Thank you for the detailed description. I appreciate it very much.

Based on your description, I tried to strip down my command as much as possible, but unfortunately I get almost the same error messages as before:

$ /usr/local/mcuxpressoide/ide/bin/crt_emu_cm_redlink --flash-load /home/laci/download/uhk-left.bin -p MKL03Z32xxx4 --load-base=0 -x /home/laci/mcuxpresso/.mcuxpressoide_packages_support/MKL03Z32xxx4_support
Ns: MCUXpresso RedlinkMulti Driver v10.0 (Jun 22 2017 23:34:07 - crt_emu_cm_redlink build 272)
Wc(03). No cache support.
Nc: Server OK but no connection to probe 0 core 0 (after 3 attempts) - Ee(36). Could not connect to core.
Ed:02: Failed on connect: Ee(36). Could not connect to core.
Et:31: No connection to chip's debug port
Nc: error closing down debug session - Em(02). MEM-AP is not selected.

Do you have any further ideas about this?

- Laci

0 Kudos
6,044 Views
mbomio
Contributor I

Hi,

We ran into a similar problem and found the solution. What worked for us was removing the "-ProbeHandle=1" parameter from the "crt_emu_cm_redlink" command, so that the probe is detected automatically.

I hope this helps :smileyhappy:

Best regards,

Enrique

0 Kudos