memtool - jlink batch file

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User7457
Level 2
Level 2
First like received
Hi,
Does anyone have a simple batch file to use with Memtool in order to execute from command line?
I need to Erase - program - verify an xmc4500 without opening the graphical interface. I see that I have to use a batch file but I don't find info about its configuration ( ie whats the command syntax for loading the hex file, start download ...).
As I need a command line tool I tried also jlink. Everything works fine but first of all you have to open the jlink console, than from there you can send single commands.
Is there anyway of doing all in one step?

Thanks
Frank
0 Likes
23 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi frank,

Please see my reply below in red.

frankmag wrote:
Hi,
Does anyone have a simple batch file to use with Memtool in order to execute from command line?
Travis: Sorry there is no batch file to work with Memtool.

I need to Erase - program - verify an xmc4500 without opening the graphical interface. I see that I have to use a batch file but I don't find info about its configuration ( ie whats the command syntax for loading the hex file, start download ...).
Travis: I really don't understand what you are trying to do, these feature are already provided in the memtool and why do you need a batch file for?

As I need a command line tool I tried also jlink. Everything works fine but first of all you have to open the jlink console, than from there you can send single commands.
Is there anyway of doing all in one step?

Thanks
Frank
0 Likes
User7457
Level 2
Level 2
First like received
My goal is to call a single file from command line (ie Download.bat ) and have the micro programmed without any other manual insertion into a GUI.
If I call Memtool from command as follow:
memtool command.mtb
and inside command.mtb I put the commnd connect then memtool opens and automatically connct to the target.
What are the ather commands that I have to insert into command.mtb in order to load the hex file, start the program session and then close memtool?

Thanks
0 Likes
Not applicable
Hi Travis,

I have a similar requirement for the following reasons....

1) I need the end user to be able to perform the re-programming
2) The end user is not an electronics or software engineer and so the process has to be simple
3) The end user does not speak English and will not be able to operate the Memtool dialogs

I need the end user to simply run a command file. I imagine this would do the following....

a) Launch Memtool (possibly minimised)
b) Pass the batch commands to Memtool or point to another file containing the batch commands

Could you please advise if this or something similar is possible please.

Thank you very much
Aaron
0 Likes
Mike1
Employee
Employee
5 sign-ins First question asked 10 replies posted
The professional version of Memtool which is available from PLS (www.pls-mc.com) supports scripting.
0 Likes
lock attach
Attachments are accessible only for community members.
Not applicable
Thanks Mike, I will have a look at the professional version of Memtool.

I have received the Memtool batch command application note (see attached). It meets some of the requirements. So far I have not found a way to launch it silently and execute batch files so the end user doesn't have to speak English.



Best regards
Aaron
0 Likes
Marillion
Employee
Employee
5 sign-ins First solution authored First like given
Here is the solution for JLINK. It works for all XMC kits with on-board dedugger (JLINK):

1. Make sure "JLink.exe" and "JLinkARM.dll" is located in the same folder as the batch-file (see next step).

2. Create a batch-file (e.g. program.bat) with following content:
JLink.exe -CommanderScript testscript.jlink

3. Create the JLINK script file (name "testscript.jlink" with the required commands e.g.:
device XMC1100-T038F0064
loadbin testprogram_v1_0.bin,0x10001000
r
exit


This example is programing a binary file (testprogram_v1_0.bin) into the XMC1100. You get the binary file from DAVE, if you switch the "Output file format" to "binary" (Project>>Active Project Properties>>ARM-GCC Create Flash Image/Output)

This works fine. I used this method several thousand times.

Best Regards
Marillion
0 Likes
Not applicable
Hi Marillion,

Thank you very much for your fast reply. I will try this method on the next production batch of pcb's.

Best regards
Aaron
0 Likes
Not applicable
Hia, I have recently used the IMTMemtool.exe, via the command line interface, with a batch file to automate the reprogramming of a Tricore. Is there ant way to just erase the microprocessor as "erase" does not seem to be a valid batch command like "program" & "connect" are. Does anyone know if this is possible?

Thanks
0 Likes
Anoop
Employee
Employee
Does any one know if "Segger Jlink" dll's and executable is free to distribute or licensed one?
0 Likes
Not applicable
Hi, Anoop,
Segger Jlink DLL is not free to distribute.

Cheers
tys
0 Likes
Not applicable
Aaron Walsh wrote:
Thanks Mike, I will have a look at the professional version of Memtool.

I have received the Memtool batch command application note (see attached). It meets some of the requirements. So far I have not found a way to launch it silently and execute batch files so the end user doesn't have to speak English.



Best regards
Aaron

Example Batch File
The following example batch file connects the target system. Than it loads a starter software
(starter.hex), a firmware and a device specific serial number. The firmware is loaded twice. The second
time it is loaded using an offset of 0x40000. So the firmware image is programmed twice into the
FLASH memory device. Please note that after each open_file operation the loaded sections have to be
added to the FLASH Buffers before the next open_file operation can take place. Finally all loaded
sections are programmed into the FLASH memory device.
connect
open_file c:\Data\starter.hex
select_all_sections
add_selected_sections
open_file c:\Data\firmware.hex
select_all_sections
add_selected_sections
open_file c:\Data\firmware.hex , +40000h
select_all_sections
add_selected_sections
open_file c:\Data\sernum.hex
select_all_sections
add_selected_sections
program
disconnect
0 Likes
User13264
Level 1
Level 1
I was able to follow the instructions specified in the PDF that Aaron posted and get completely cli based opening, running, programming with, and closing of Infineon Memtool.

Create a file with the following contents:


connect
open_file C:\Must\Use\Full\Path\To\Hex\File.hex
select_all_sections
add_selected_sections
program
disconnect
exit


I experimentally found that the `exit` command is run by the batch script and can be used to close Memtool after the programming.

Memtool suggests using the `.mtb` file extension for this file but I've found that any extension works. As frankmag suggested, simply launch Memtool.exe with the filename of the "batch" file as the only argument and it will run those commands.

A couple caveats:
- You need to have Memtool previously configured for the correct processor / communication & bootloader method
- You must use an absolute path to the .hex files loaded for programming
- Memtool window still launches (not silent)

I'd love any thoughts on how to clean up these annoyances.

EDIT: Recent Explorations

I've been looking into how to use a script to automatically pick the correct target for memtool. So far, I've found two interesting things:

First, the folder in "My Documents", "Infineon/IMT 4.7". That folder's ini file can be updated to point to a new "target.cfg" to load automatically. It seems, if that folder doesn't exists, the tool does not re-create it. Maybe it was created by the installer?

Second, the registry keys found at "HKCU\SOFTWARE\Infineon\Memtool4\4.7\TargInfo" are used in the GUI to show target options.
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

You can also use JLink commander if you are using a Segger probe or an on-board debugger of our development kits:

C:\Program Files (x86)\SEGGER\JLink_V616a\JLink.exe -Device XMC4700-2048 -CommandFile CommandFile.jlink

and CommandFile.jlink file:

si 1
speed auto
r
h
loadfile .\Debug\POSIF_QD_XMC47.hex, 0x0c000000
r
q
0 Likes
User17508
Level 1
Level 1
Sorry to revive an old thread, but does anyone know how to reboot the target after programming?
0 Likes
Anonymous
Not applicable
dpastl wrote:
Sorry to revive an old thread, but does anyone know how to reboot the target after programming?

Same here.
I'm wiring a CI tool that compiles, flashes the compilation result and then should run the program and check some results via a COM device output.
0 Likes
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
Hello,

It's been a while but I am trying to a similar thing for XMC1400.
I need to change the BMI value and enable debugging but this takes so many steps from the graphical interface. I need to do this with one clickif it is possible.
But with this batch script methos I could only "Connect".
BMI changing steps are: HW Proctect - > Setuo - > Selectil proper BMI configuration - > OK - > Start - >.... Goes like this
This process is too complicated for a non-technical person.
Is there a way to do these all?
0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked
Hello Ipak,

Kindly see the response from Segger on this.

Forum link
The regular J-Link models are able to do this automatically.The OB on the Infineon XMC boards was specifically designed for the work with the DAVE IDE and does not support the necessary
features required to do this automatically.


Using ASC_BSL mode host program which can does this with the help of ROM APIs is one option to do this.

Best Regards,
Vasanth
0 Likes
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
Hi Vasanth,

This is the third post you are refering me the same example project :).
I'd like to kindly repeat that I am interested in doing this in XMC1400. Not XMC1300. Am I missing something? Are you missing something?

Bests,
İpek
0 Likes
User22611
Level 1
Level 1
Hi All,

I need to run the Infineon memtool using batch file in Windows without showing up the GUI. I am able to launch the memtool using cmd . But the next commands that are given in this post like "connect" or " open_file " is not working for me after running the memtool.I
I am trying to execute those commands directly in Windows Power shell or command prompt , but its throwing "command unrecognized error". Can you please let me know how to run these commands from batch file. Do we nned to launch any specific
command prompt from memtool installation folder to get these commands working?

Regards,
Aryan Kashyap
0 Likes
alen
Level 1
Level 1
First reply posted Welcome!

Hi,do you hava a solution for this?I am currently facing the same problem and look forward to your solution?

0 Likes
User22611
Level 1
Level 1
chrisbaggott wrote:
Hia, I have recently used the IMTMemtool.exe, via the command line interface, with a batch file to automate the reprogramming of a Tricore. Is there ant way to just erase the microprocessor as "erase" does not seem to be a valid batch command like "program" & "connect" are. Does anyone know if this is possible?

Thanks


Hi Chris,

Can you please share the steps of how you are able to do the reprogramming of a tricore using batch file. I am also trying to do the same but for me "connect" is not working.

Thanks in Advance!
0 Likes
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked
Hi,

The memtool is supported only on the windows platform as per release notes.
If the core is specific to tricore, can you ask in the related forum space ?

Best Regards,
Vasanth
0 Likes
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hi

For those who have interest on this matter, I find out that Infineon Memtool is a restricted version of another Memtool and it is possible to use script with this other memtool. But it is commercial .

(https://www.pls-mc.com/products/flash-programming-ude-memtool-flash-programmer/)

I was having some issues  when connecting to an XMC1400 which is in ASC BSL mode. I reach to this other Memtool's support. And ,you won't believe this, unlike Infineon's support, they answered!!!! 🙂 

Here is the answer :

"Your seen behavior is well known and not uncommon. This is a result of the XMC1400 architecture itself • Very Low power • No explicit Reset signal Therefore, in BSL mode the connection is unstable. Any spike on RX line after PowerUp disturbs the BSL.Since there is no Reset a Power ON needs to be done. But this is not easy as well since the XMC1400 is powered even if there is only one Pin high."

and for those who are looking for automation for changing BMI or flashing: 

"The Infineon Memtool is a product developed by PLS, but a bit trimmed .So Automation (controlling UDE via script or command line) is not included. Attached you can find our comparison sheet Infineon Memtool vs. UDE Memtool. For Automation the professional Version of UDE or UDE Memtool is required. And you’re right: I asked our Cortex experts, the BMI is indeed a part of the Flash but can’t be programmed via .elf or .hex file. For programming the BMI you need special UDE Memtool functions. Automating these is only included in the professional UDE/UDE Memtool versions. "

Dear Infineon people, I asked you about Memtool and BMI stuff multiple times from different forum posts. You neither give any useful information nor mention this commercial Memtool. And I think this is shame. 

Best regards,

İpek