square / pylink

Python Library for device debugging/programming via J-Link
https://pylink.readthedocs.io/en/latest/
Other
334 stars 125 forks source link

CORESIGHT_AddAP doesn't execute #189

Open engrnader opened 6 months ago

engrnader commented 6 months ago

Hi, i'm executing a the commands below to connect to Cortex-M55 however I was not successful: response_1 = jlink.exec_command('CORESIGHT_AddAP = Index=4 Type=AHB-AP Addr=0x00300000') response_2 = jlink.exec_command('CORESIGHT_SetIndexAHBAPToUse = 4')

It seems that the second command works fine but not the first command. I wrote a jlink script and ran it from keil following the same exact procedure and I was able to connect to the device. I'm trying to override AP[4] address to 0x00300000.

image

Can someone help me implementing this using pylink?

hkpeprah commented 6 months ago

Could you try to use the coresight_* functions instead? https://pylink.readthedocs.io/en/latest/pylink.html#pylink.jlink.JLink.coresight_configure

engrnader commented 6 months ago

If I use the coresight functions instead I would have to define the ir_pre and post and dr_pre and post. I don't know those parameters.

How would you do it given the code I provided before?

hkpeprah commented 6 months ago

AFAIK, you can omit those parameters (they're optional). What have you tried?

engrnader commented 6 months ago

Then how can I specify the ROM table address? Jlink by default assumes the ROM table is at address 0x0.

I tried coresight_configure() with no parameters and it didn't work.

Here is what I have tried per your recommendations: image

I gotten the same error. image

Now, the issue here is that there are multiple cores within the JTAG chain and I want to select a specific core within the JTAG chain shown in the code snippet above. When executing the commands mentioned before, it don't select the core specified.

Perhaps i'm using coresight_configure() wrong.

hkpeprah commented 5 months ago

If there are multiple cores on the JTAG chain, then you unfortunately have to use the arguments: https://pylink.readthedocs.io/en/latest/pylink.html#pylink.jlink.JLink.coresight_configure

I personally haven't used an ARM device with multiple cores on a single scan chain, so I can't tell you what the arguments you would pass for each of those would be. Sorry to say. I would look up a reference manual for your part to see if it specifies anything about that. I'm guessing the core_idx is related to the device index on the scan chain.

engrnader commented 5 months ago

@hkpeprah thank you for your response. I will look into this more.