Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify JLinkScript file #188

Closed
gw826943555 opened this issue Dec 21, 2023 · 9 comments
Closed

Specify JLinkScript file #188

gw826943555 opened this issue Dec 21, 2023 · 9 comments

Comments

@gw826943555
Copy link

gw826943555 commented Dec 21, 2023

Hi,

I am now trying to connect a dual-core cortex-r5. We use -JLinkScriptFile command to specify the JLinkScript file and connect the core I'd like to connect.
JLink.exe -JLinkScriptFile xxx_path\R5_ConnectCore0.JLinkScript
JLink.exe -JLinkScriptFile xxx_path\R5_ConnectCore1.JLinkScript
It works fine.

My question is whether pylink support this feature.

Thanks!

@hkpeprah
Copy link
Contributor

PyLink does not support the scripts. The scripts are essentially commands / function calls. You will need to translate your scripts into the appropriate function calls.

@gtowers-dukosi
Copy link
Contributor

gtowers-dukosi commented Aug 9, 2024

@hkpeprah -JLinkScriptFile does not specify a sequence of command function calls. You're getting confused with the -CommanderScript option.

JLinkScriptFile is a C-like syntax that allows you to customise internal actions, most notably what happens on a device reset to allow for hardware-specific requirements that cannot be easily dealt with through the standard J-Link API.
See https://wiki.segger.com/J-Link_script_files for more details.

I agree that supporting JLinkScriptFiles would be a really useful feature add for the module, as their lack limits what can be done with the module.

EDIT: after thinking about it a bit further, I guess the script files are probably parsed by jlink.exe rather than the DLL itself, so maybe there is a way to implement equivalent actions directly using pylink.

@hkpeprah
Copy link
Contributor

hkpeprah commented Aug 9, 2024

My mistake. Thanks for the correct @gtowers-dukosi. From reading over that link, it seems like if you put the script in the same folder as the DLL as Default.JLinkScript, then it should just run it. I think it should be possible we can automate this process, and take a script file in the .open() command as an optional parameter, then copy it to the path with the DLL. Do you think that would work for your use case?

@gtowers-dukosi
Copy link
Contributor

The DLL is normally somewhere in "C:\Program Files (x86)", which on most machines needs admin privileges for an application to write to, so that's probably not going to work - but I like your thinking. Thanks for reading up, I'd missed that section on the page - very interesting to know that it's parsed by the .dll rather than the .exe. That suggests there must be another way to somehow specify a custom filepath directly to the DLL.

@hkpeprah
Copy link
Contributor

hkpeprah commented Aug 9, 2024

By default, we copy the library file to a separate temporary folder (unless you specify otherwise). So we should be able to write the Default script into that folder, and delete it when we clean-up the temporary library file as well.

@gtowers-dukosi
Copy link
Contributor

Sounds like it might just work then! I think it would meet my requirements in any case.
Thanks again

@gtowers-dukosi
Copy link
Contributor

I found a better solution! This does exactly what I need:
jlink.exec_command("scriptfile = C:\\path\\to\\myJlinkScript.JLinkScript")

Technically no pylink upfates even needed for pylink, but since it's not at all obvious I think a pylink wrapper function for that command would be a nice feature.

@hkpeprah
Copy link
Contributor

Nice! That is much simpler. If you want to submit a patch for the new function, I can accept it. Something like set_script()?

@hkpeprah
Copy link
Contributor

hkpeprah commented Sep 4, 2024

This is now available via set_script_file() in v1.3.0 thanks to @gtowers-dukosi!

@hkpeprah hkpeprah closed this as completed Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants