Hi,
I am having problems connecting to my target with J-LINK after the flexRAM has been remapped.
Everything works fine and I have no problems with J-LINK connecting if I don't remap the flexRAM, or the 1st time I program the image with the remapped flexRAM. But after that, I cannot connect and I have to erase the flash via the serial download mode.
My suspicion is that the J-LINK is being upset by the new flexRAM settings. The flexRAM settings that work OK with the J-LINK are DTCM=128k, ITCM=128k and OCRAM=768k total (256k flexRAM). But if I change this to DTCM=512k, ITCM=0 and OCRAM=512k total (0k flexRAM) then that's when I see the connection problems.
The application with the modified flexRAM settings works just fine, the only problem is the J-LINK not connecting.
How do you use a J-LINK with the above modified flexRAM settings?
If you were using a linkserver CMSIS-DAP programmer, then you would use a different connect script and I tried this on the NXP EVK and that all seems to work OK. But I cannot try this on our own target hardware because we just have a JTAG header on that PCB.
Any thoughts please?
thanks!
There is no reason why you can't use CMSIS-DAP with a JTAG Header - it uses the same pins (in fact it normally boots in JTAG mode and CMSIS-DAP switches to SWD).
thanks @converse
yes, I know that - but we don't have any, we just have a J-LINK. Hence my reference to the NXP EVK (which has CMSIS DAP on the PCB)
My original question remains - how do you use a J-LINK with a target that has zero ITCM memory allocated? I have since proved that if you allocate even a small amount (32kb) of the flexRAM to ITCM then the J-LINK works fine.
Edit - I forgot to add, when the J-LINK fails to connect the log says the following:
****** Error: Failed to prepare RAMCode using RAM
Error while determining flash info (Bank @ 0x60000000)
Could not start CPU core. (ErrorCode: -1)
Unspecified error -1
Script processing completed.
Unable to perform operation!
Command failed with exit code 1
Hi @nickwallis ,
In each example project in SDK, there is a xxxx_sdram_init.jlinkscript. You can modify this jlinkscript and let IDE run it. In the script you can restore FlexRAM so that jlink can download RAMcode.
Regards,
Jing
thanks @jingpan
I modified the script as below and added it to the JLINK launch configuration, unfortunately this is still not working for me. Does it look OK to you? Did I do something wrong or miss some other step?
void InitTarget(void)
{
flexRAM_Init();
}
void flexRAM_Init(void)
{
MEM_WriteU32(0x400A0000,4); // TCM_CTRL
MEM_WriteU32(0x400AC040,0x00200007); // GPR16
MEM_WriteU32(0x400AC044,0xaaaaaabb); // GPR17, DTCM = 14 banks, ITCM = 2 banks
MEM_WriteU32(0x400AC038,0x00a70000); // GPR14, DTCM = 512kB, ITCM = 64kB
}
Hi,
You can refer to this case. I think your problem also can be resolved by jlink script.
https://community.nxp.com/t5/MCUXpresso-IDE/Flexram-in-rt1010-with-0KB-ITCM/m-p/1080487#M5873
Regards,
Jing
hi @jingpan
that works for a debug session, but not for when I just want to erase/program the flash
Is the script only used when you invoke a debug session? (it seems that way)
How do I do a similar thing for flash erase/program? Thanks!
Hi,
In GUI flash tool, there is Preview command option. Select this option to be presented with a preview programming command to be issued and a script that can perform this action independently of the IDE.
Please try to add script here.
Regards,
Jing
thanks @jingpan
I tried your suggestion and unfortunately it gives the same error message, see below. Did I miss something or make a mistake somewhere?
script.jlink contents:
ExitOnError 1
r
h
w4 0x400AC040,0x00200007
w4 0x400AC044,0xaaaaaabb
w4 0x400AC038,0x00a70000
loadfile "C:\mcuxpresso_ws_11p4\XXXXX\Debug\XXXXX.hex" 0x60000000
qc
qc
output :
C:\mcuxpresso_ws_11p4\XXXXX>prog.cmd
C:\mcuxpresso_ws_11p4\XXXXX>set MCUX_WORKSPACE_LOC=C:/mcuxpresso_ws_11p4
C:\mcuxpresso_ws_11p4\XXXXX>set MCUX_JLINK=C:/Program Files (x86)/SEGGER/JLink/
C:\mcuxpresso_ws_11p4\XXXXX>"C:/Program Files (x86)/SEGGER/JLink/JLink.exe" -if SWD -speed auto -commanderscript "C:/mcuxpresso_ws_11p4/XXXXX/script.jlink" -device MIMXRT1062xxx6A -SelectEmuBySN 59102795
SEGGER J-Link Commander V7.50 (Compiled Jul 1 2021 17:38:54)
DLL version V7.50, compiled Jul 1 2021 17:37:28
J-Link Command File read successfully.
Processing script file...
J-Link Commander will now exit on Error
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link V9 compiled May 7 2021 16:26:12
Hardware version: V9.10
S/N: 59102795
License(s): GDB
VTref=3.232V
Target connection not established yet but required for command.
Device "MIMXRT1062XXX6A" selected.
Connecting to target via SWD
InitTarget() start
InitTarget()
_TargetHalt: CPU halted
InitTarget() end
Found SW-DP with ID 0x0BD11477
DPIDR: 0x0BD11477
Scanning AP map to find all available APs
AP[1]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x04770041)
Iterating through AP map to find AHB-AP to use
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FD000
CPUID register: 0x411FC271. Implementer code: 0x41 (ARM)
Found Cortex-M7 r1p1, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ E00FD000
ROMTbl[0][0]: E00FE000, CID: B105100D, PID: 000BB4C8 ROM Table
ROMTbl[1] @ E00FE000
ROMTbl[1][0]: E00FF000, CID: B105100D, PID: 000BB4C7 ROM Table
ROMTbl[2] @ E00FF000
ROMTbl[2][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS-M7
ROMTbl[2][1]: E0001000, CID: B105E00D, PID: 000BB002 DWT
ROMTbl[2][2]: E0002000, CID: B105E00D, PID: 000BB00E FPB-M7
ROMTbl[2][3]: E0000000, CID: B105E00D, PID: 000BB001 ITM
ROMTbl[1][1]: E0041000, CID: B105900D, PID: 001BB975 ETM-M7
ROMTbl[1][2]: E0042000, CID: B105900D, PID: 004BB906 CTI
ROMTbl[0][1]: E0040000, CID: B105900D, PID: 000BB9A9 TPIU-M7
ROMTbl[0][2]: E0043000, CID: B105F00D, PID: 001BB101 TSG
Cache: Separate I- and D-cache.
I-Cache L1: 32 KiB, 512 Sets, 32 Bytes/Line, 2-Way
D-Cache L1: 32 KiB, 256 Sets, 32 Bytes/Line, 4-Way
Cortex-M7 identified.
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
ResetTarget() start
ResetTarget() end
PC = 60002308, CycleCnt = 00000000
R0 = 60002309, R1 = 20203AB8, R2 = 0003E75D, R3 = 000090F0
R4 = 60002309, R5 = 20203A70, R6 = 3ECDE544, R7 = 000000F0
R8 = 00200300, R9 = 00000000, R10= 00000000, R11= 400F8000
R12= 000001FE
SP(R13)= 20200F70, MSP= 20200F70, PSP= 00000000, R14(LR) = 00215329
XPSR = 81000000: APSR = Nzcvq, EPSR = 01000000, IPSR = 000 (NoException)
CFBP = 00000000, CONTROL = 00, FAULTMASK = 00, BASEPRI = 00, PRIMASK = 00
FPS0 = 00000000, FPS1 = 00000000, FPS2 = 00000000, FPS3 = 00000000
FPS4 = 00000000, FPS5 = 00000000, FPS6 = 00000000, FPS7 = 00000000
FPS8 = 00000000, FPS9 = 00000000, FPS10= 00000000, FPS11= 00000000
FPS12= 00000000, FPS13= 00000000, FPS14= 00000000, FPS15= FFFFFFFF
FPS16= 00000000, FPS17= 00000000, FPS18= 00000000, FPS19= 00000000
FPS20= 00000000, FPS21= 00000000, FPS22= 00000000, FPS23= 00000000
FPS24= 00000000, FPS25= 00000000, FPS26= 00000000, FPS27= 00000000
FPS28= 00000000, FPS29= 00000000, FPS30= 00000000, FPS31= FFFFFFFF
FPSCR= 00000000
Writing 00200007 -> 400AC040
Writing AAAAAABB -> 400AC044
Writing 00A70000 -> 400AC038
Downloading file [C:\mcuxpresso_ws_11p4\XXXXX\Debug\XXXXX.hex]...
****** Error: Failed to prepare RAMCode using RAM
Error while determining flash info (Bank @ 0x60000000)
Unspecified error -1
Script processing completed.
C:\mcuxpresso_ws_11p4\XXXXX>
Hi,
Please try
w4 0x400AC044,0x55AFFA55
w4 0x400AC040,0x00200007
If that's not enough, you can include all my jlinkscript in it.
Regards,
Jing
thanks @jingpan I tried that but still the same unfortunately
I also tried just using J-Link commander and typing the commands in manually, one by one, also with the same result.
This feels like we are missing an important step somewhere - but what?
Hi,
I tried on my board, it can work.
w4 0x400AC044,0x55AFFA55
w4 0x400AC040,0x00200007
w4 0x400AC038,0x00990000
Don't forget set 0x400AC038. If you set 0x400AC038 to other value, for example 0x000a0000 or 0x00a00000, downloading would fail. That means set these register here is really useful.
Regards,
Jing
thanks @jingpan, but that connect script is not for a J-LINK.
I already shared with you the J-LINK script that I am using but it is not working for me, do you know why?
Hi,
my attachment is jlinkscript. Please take a try.
My apologies @jingpan I saw the link but not the attachment.
I'll give that a try.