Posts by mastupristi
-
-
I’m working in a production setup (not a development/debug session), where each board must be prepared before its main flash image is programmed. Our process is (simulated with EVK):
- Connect to the MIMXRT1021-EVK via a Segger J-Link (SWD + SWO).
- Use J-Link Commander (JLink.exe / JLinkCommander) to load our custom firmware into RAM.
- Start execution immediately with the g command.
In this context I do not attach a debugger or IDE—everything runs “headless” via J-Link Commander scripts. What I’d like to do is have the running firmware emit simple status or log messages over the SWO pin (ITM port 0 → TPIU), so that our production test station can capture and display these messages without stopping the CPU.
My questions are:- Is it possible to enable and view SWO output purely from J-Link Commander, without starting a full debug session?
- If so, what is the exact sequence of J-Link Commander commands to
- configure the SWO pin protocol and baud rate,
- enable the ITM stimulus port,
- and capture the output in the console?
I’m already comfortable initializing SWO in firmware (DEMCR, TPIU, ITM regs, etc.), but I need to know the proper J-Link Commander commands to turn on the trace port and route its output to the stdout of J-Link Commander.
Any example scripts or pointers to the relevant manual sections would be greatly appreciated!
Thank you in advance,Max
-
Hello,
I read this: https://kb.segger.com/ConfigTargetSe…illegal_regions
and I tried this script:
Template_ExcludeIllegalRegions.JLinkScript
Then I try to attach to MIMXRT1021-EVK:
/opt/SEGGER/JLink/JLinkExe -if SWD -speed auto -device MIMXRT1021xxx5A -autoconnect 1 -JLinkScriptFile Template_ExcludeIllegalRegions.JLinkScript
I get this:
QuoteSEGGER J-Link Commander V8.30 (Compiled Apr 30 2025 12:10:43)DLL version V8.30, compiled Apr 30 2025 12:09:37
Connecting to J-Link via USB...O.K.
Firmware: J-Link V10 compiled Jan 30 2023 11:28:07
Hardware version: V10.10
J-Link uptime (since boot): N/A (Not supported by this model)
S/N: 260106436
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref=3.303V
Device "MIMXRT1021XXX5A" selected.Connecting to target via SWD
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 13us
Found SW-DP with ID 0x0BD11477
DPIDR: 0x0BD11477
CoreSight SoC-400 or earlier
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, ADDR: 0x00000000)
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)
Cache: L1 I/D-cache present
Found Cortex-M7 r1p1, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ E00FD000
[0][0]: E00FE000 CID B105100D PID 000BB4C8 ROM Table
ROMTbl[1] @ E00FE000
[1][0]: E00FF000 CID B105100D PID 000BB4C7 ROM Table
ROMTbl[2] @ E00FF000
[2][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7
[2][1]: E0001000 CID B105E00D PID 000BB002 DWT
[2][2]: E0002000 CID B105E00D PID 000BB00E FPB-M7
[2][3]: E0000000 CID B105E00D PID 000BB001 ITM
[1][1]: E0041000 CID B105900D PID 001BB975 ETM-M7
[1][2]: E0042000 CID B105900D PID 004BB906 CTI
[0][1]: E0040000 CID B105900D PID 000BB9A9 TPIU-M7
[0][2]: E0043000 CID B105F00D PID 001BB101 TSG
I-Cache L1: 16 KB, 256 Sets, 32 Bytes/Line, 2-Way
D-Cache L1: 16 KB, 128 Sets, 32 Bytes/Line, 4-Way****** Error: Failed to add region 0x60000000 - 0x600001FF because it overlaps with an existing region of type != normal, which cannot be replaced
Memory zones:
Zone: "Default" Description: Default access mode
Cortex-M7 identified.
I want to override the area 0x60000000-0x600001FF , I need to do this.I don't even know how memory regions are defined now (how can I print them?).
How can I solve it?
best regards
Max -
Hello everyone,
I’m using Segger J-Link v8.30 and an NXP RT1xxx MCU that boots from external QSPI-NOR flash mapped, for example, at 0x3000 0000. Although the NOR flash supports 4 KiB sector erases at the hardware level, J-Link Commander (and the GDB Server) currently always performs erases in 64 KiB blocks. When I write the FW into the flash I need to preserve 512 bytes at 0x3000 0400–0x3000 05FF, which contain data that must survive every download.
Key details:- Hardware sector erase size: 4 KiB
- J-Link software erase granularity: 64 KiB
- Regions to rewrite:
- 0x3000 0000–0x3000 03FF
- 0x3000 0600–0x300x xxxx
- Region to preserve: 0x3000 0400–0x3000 05FF
In development and debugging I use the GDB Server, but for simple production programming I rely on J-Link Commander.
How can I achieve this with J-Link software?
Thank you!
-
Hi,
Re-reading this old post I read about “SetFlashDLNoRMWThreshold”, so I said to myself, “Why not try this as well?”
I modified the script like this:
Codeint HandleBeforeFlashProg(void) { JLINK_ExecCommand("SetFlashDLNoRMWThreshold = 0x10000"); // was 0xffffffff return 0; }
And works!!!
Now you can help me answer the question, “Why does it work?”
regards
Max -
Hi,
we have a bit of a problem with FWs larger than 57344 bytes (0xe000 in hexadecimal), that run XIP from flash, and we connect to CM4.
We were also able to reproduce the problem with an example SDK (which I attach) on MCUXpresso IDE v11.10.0 [Build 3148] and running on EVKB, and JLink (tested 7.98h and .7.96o)In fact, the FW resides in flash at address 0x08002000 (but I have also tried having it reside at 0x08012000, with the same results)
The flash is correctly written in all cases. If the FW is smaller the JLink debugging session starts without problems. While with larger FWs it does not, and the Program-counter we find it at an address of 0x2020xxxx, where the JLink RAMCode should reside
but we didn't map anything there.To implement the FW “bloat” I used an array, not used by anyone in the code (so as not to alter it), but present in the executable thanks to a special KEEP() directive on the linking options:
If the id 39676 threshold is exceeded, the flash image exceeds 57344 bytes and what happens is that it doesn't get to the main because the PC stays somewhere in 0x2020xxxx
An interesting coincidence is that the FW, as mentioned resides at 0x08002000, and so exceeding the size 0xe000 means exceeding 0x08010000, an oddly round number. For these reasons, we tried to place at 0x08012000 but did not notice any change.
can you also try it and help us figure out where we are going wrong?
regards
Max
-
Hello,
I'm using JLink 7.98h, JLink Ultra+, and I'm trying to write QSPI flash of a RT1170-EVKB evaluation board.I can do this by connecting to CM7 core, but when I try to use CM4 I have some problems:
For example this is the JFlashExe screenshot:I can successfully connect to core but it fails to erase flash:
I attach jflash.log
Where am I wrong?
How to make it works?best regards
Max -
Hello,
I traced the process of writing a FW in flash using a logic state analyzer. I was able to observe some very questionable behaviors.The file is quite large, and even its decoding contains more than 3,000 commands. However, there are some peculiarities that I would like to discuss with you
Reads take place byte by byte
I was able to observe that the memory reads, in the initial comparison and in the final verification are done using the 0x6B command, but one byte at a time. In this way, reading 1kB takes 40960 clock cycles. Whereas on the other hand if I read the same kB in one transaction it would take 2086 clock cycles!!! That's a 95% reduction in time!!!!
Why do you read one byte at a time?QE bit is written and rewritten many times (for no reason at all)
In the track I took the QE bit is written and rewritten a total of 79 times. Very often between two consecutive writes (one 0 and the other 1 or vice versa) there are no other operations, making the write completely useless. Also Even if QE bit is 1 the "normal" commands still work, so there is no need to rewrite QE to 0 for the Page Program or Block Erase commands.At the end QE bit remains at 0
The rom bootloader requires the QE bit to be 1 in the flash. But the last write done leaves the QE bit at 0, so after a flash write the FW will still not be executable until we rewrite the QE bit to 1 using another FW (residing in RAM)
The value of dummy cycles is never read
The memory I'm using right now is an Infineon S25FL064L (ID 01 60 17). It has the setting of the number of dummy cycles in the config3 register. The command to read that data is 0x33. This command is never sent to the flash, so how does the FW know how many dummy cycles to add to the readings?The number of bytes of the address is not read.
The flash can use 3 or 4 bytes of address. setting is contained in the Config2 register, which can be read with the 0x15 command. But that command is never sent to the flash.64kB blocks are deleted
Deletions are made by 64kB blocks. Wouldn't it be more efficient to do it by 4kB sectors (supported by flashes with the 0x20 command)? This would have a finer grain at the cost of a little more time to erase, which is possible to recover by doing better readsI know that a FW is injected inside the micro that is used to perform the actual operations (FlaxSPI programming, reads, writes, etc.). Is it possible to get the source code of such FW?
Let me know if you want the trace (in sigrok format) and how you can share it
best regards
Max
-
hi,
I use RT1176 and i have to write flash (mapped to 0x30000000)
The FW is divided into two parts,- a first part called the boot header exactly 8K in size
- a second part which is the actual application and starts at offset 0x2000.
For each of the two parts I have an elf file.
How do I write both parts into the flash using a script?
I tried the following script:
Codedevice MIMXRT1176xxxA_M7 if SWD speed auto connect sleep 1 loadfile "FW/image/Ama_BootHdr.elf" sleep 1 loadfile "FW/image/Ama.elf" exit
But I get a timeout error when trying to write the second part:
Code
Display MoreSEGGER J-Link Commander V7.92n (Compiled Oct 31 2023 15:15:57) DLL version V7.92n, compiled Oct 31 2023 15:15:34 J-Link Command File read successfully. Processing script file... J-Link>device MIMXRT1176xxxA_M7 J-Link connection not established yet but required for command. Connecting to J-Link via USB...O.K. Firmware: J-Link Ultra V4 compiled Sep 22 2022 15:00:10 Hardware version: V4.00 J-Link uptime (since boot): N/A (Not supported by this model) S/N: 504400379 License(s): RDI, FlashBP, FlashDL, JFlash, GDB VTref=3.308V J-Link>if SWD Selecting SWD as current target interface. J-Link>speed auto Selecting auto as target interface speed J-Link>connect Device "MIMXRT1176XXXA_M7" selected. Connecting to target via SWD Found SW-DP with ID 0x6BA02477 DPIDR: 0x6BA02477 CoreSight SoC-400 or earlier Scanning AP map to find all available APs AP[3]: Stopped AP scan as end of AP map has been reached AP[0]: AHB-AP (IDR: 0x84770001) AP[1]: AHB-AP (IDR: 0x24770011) AP[2]: APB-AP (IDR: 0x54770002) Iterating through AP map to find AHB-AP to use AP[0]: Core found AP[0]: AHB-AP ROM base: 0xE00FD000 CPUID register: 0x411FC272. Implementer code: 0x41 (ARM) Cache: L1 I/D-cache present Found Cortex-M7 r1p2, Little endian. FPUnit: 8 code (BP) slots and 0 literal slots CoreSight components: ROMTbl[0] @ E00FD000 [0][0]: E00FE000 CID B105100D PID 000BB4C8 ROM Table ROMTbl[1] @ E00FE000 [1][0]: E00FF000 CID B105100D PID 000BB4C7 ROM Table ROMTbl[2] @ E00FF000 [2][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7 [2][1]: E0001000 CID B105E00D PID 000BB002 DWT [2][2]: E0002000 CID B105E00D PID 000BB00E FPB-M7 [2][3]: E0000000 CID B105E00D PID 000BB001 ITM [1][1]: E0041000 CID B105900D PID 001BB975 ETM-M7 [1][2]: E0042000 CID B105900D PID 004BB906 CTI [0][1]: E0043000 CID B105900D PID 001BB908 CSTF I-Cache L1: 32 KB, 512 Sets, 32 Bytes/Line, 2-Way D-Cache L1: 32 KB, 256 Sets, 32 Bytes/Line, 4-Way Memory zones: Zone: "Default" Description: Default access mode Cortex-M7 identified. J-Link>sleep 1 Sleep(1) J-Link>loadfile "FW/image/Ama_BootHdr.elf" 'loadfile': Performing implicit reset & halt of MCU. Reset: Halt core after reset via DEMCR.VC_CORERESET. Reset: Reset device via AIRCR.SYSRESETREQ. Core did not halt after reset, halting it manually. AfterResetTarget() start Valid application detected. Setting PC / SP manually. Booting from FlexSPI1. AfterResetTarget() end - Took 52.8ms Downloading file [FW/image/Ama_BootHdr.elf]... J-Link: Flash download: Bank 0 @ 0x30000000: 1 range affected (65536 bytes) J-Link: Flash download: Total: 1.457s (Prepare: 0.277s, Compare: 0.212s, Erase: 0.467s, Program: 0.000s, Verify: 0.499s, Restore: 0.000s) J-Link: Flash download: Program speed: 0 KB/s ****** Error: Verification failed @ address 0x30000000 Timeout while programming sector, RAMCode did not respond in time! Error while programming flash: Verify failed. J-Link>sleep 1 Sleep(1) J-Link>loadfile "FW/image/Ama.elf" 'loadfile': Performing implicit reset & halt of MCU. Reset: Halt core after reset via DEMCR.VC_CORERESET. Reset: Reset device via AIRCR.SYSRESETREQ. Reset: SYSRESETREQ has confused core. Found SW-DP with ID 0x6BA02477 DPIDR: 0x6BA02477 CoreSight SoC-400 or earlier AP map detection skipped. Manually configured AP map found. AP[0]: AHB-AP (IDR: Not set) AP[0]: Core found AP[0]: AHB-AP ROM base: 0xE00FD000 CPUID register: 0x411FC272. Implementer code: 0x41 (ARM) Cache: L1 I/D-cache present Found Cortex-M7 r1p2, Little endian. Reset: Using fallback: VECTRESET. Reset: Halt core after reset via DEMCR.VC_CORERESET. Reset: Reset device via AIRCR.VECTRESET. AfterResetTarget() start AfterResetTarget() end - Took 159ms Downloading file [FW/image/Ama.elf]... ****** Error: Timeout while get device description, RAMCode did not respond in time! SEGGER_OPEN_GetFlashInfo(): RAMCode never stops. failed to determine dynamic flash info. Error while determining flash info (Bank @ 0x30000000) Unspecified error -1 J-Link>exit Script processing completed.
in particular I notice that the affected ranges for the boot header is 64KB which corresponds to the largest erasable sector of my flash. In addition, I have a verification error.
I tried swapping the two files:
Codedevice MIMXRT1176xxxA_M7 if SWD speed auto connect sleep 1 loadfile "FW/image/Ama.elf" sleep 1 loadfile "FW/image/Ama_BootHdr.elf" exit
the behavior changes, I no longer have timeouts:Code
Display MoreSEGGER J-Link Commander V7.92n (Compiled Oct 31 2023 15:15:57) DLL version V7.92n, compiled Oct 31 2023 15:15:34 J-Link Command File read successfully. Processing script file... J-Link>device MIMXRT1176xxxA_M7 J-Link connection not established yet but required for command. Connecting to J-Link via USB...O.K. Firmware: J-Link Ultra V4 compiled Sep 22 2022 15:00:10 Hardware version: V4.00 J-Link uptime (since boot): N/A (Not supported by this model) S/N: 504400379 License(s): RDI, FlashBP, FlashDL, JFlash, GDB VTref=3.308V J-Link>if SWD Selecting SWD as current target interface. J-Link>speed auto Selecting auto as target interface speed J-Link>connect Device "MIMXRT1176XXXA_M7" selected. Connecting to target via SWD Found SW-DP with ID 0x6BA02477 DPIDR: 0x6BA02477 CoreSight SoC-400 or earlier Scanning AP map to find all available APs AP[3]: Stopped AP scan as end of AP map has been reached AP[0]: AHB-AP (IDR: 0x84770001) AP[1]: AHB-AP (IDR: 0x24770011) AP[2]: APB-AP (IDR: 0x54770002) Iterating through AP map to find AHB-AP to use AP[0]: Core found AP[0]: AHB-AP ROM base: 0xE00FD000 CPUID register: 0x411FC272. Implementer code: 0x41 (ARM) Cache: L1 I/D-cache present Found Cortex-M7 r1p2, Little endian. FPUnit: 8 code (BP) slots and 0 literal slots CoreSight components: ROMTbl[0] @ E00FD000 [0][0]: E00FE000 CID B105100D PID 000BB4C8 ROM Table ROMTbl[1] @ E00FE000 [1][0]: E00FF000 CID B105100D PID 000BB4C7 ROM Table ROMTbl[2] @ E00FF000 [2][0]: E000E000 CID B105E00D PID 000BB00C SCS-M7 [2][1]: E0001000 CID B105E00D PID 000BB002 DWT [2][2]: E0002000 CID B105E00D PID 000BB00E FPB-M7 [2][3]: E0000000 CID B105E00D PID 000BB001 ITM [1][1]: E0041000 CID B105900D PID 001BB975 ETM-M7 [1][2]: E0042000 CID B105900D PID 004BB906 CTI [0][1]: E0043000 CID B105900D PID 001BB908 CSTF I-Cache L1: 32 KB, 512 Sets, 32 Bytes/Line, 2-Way D-Cache L1: 32 KB, 256 Sets, 32 Bytes/Line, 4-Way Memory zones: Zone: "Default" Description: Default access mode Cortex-M7 identified. J-Link>sleep 1 Sleep(1) J-Link>loadfile "FW/image/Ama.elf" 'loadfile': Performing implicit reset & halt of MCU. Reset: Halt core after reset via DEMCR.VC_CORERESET. Reset: Reset device via AIRCR.SYSRESETREQ. Core did not halt after reset, halting it manually. AfterResetTarget() start Valid application detected. Setting PC / SP manually. Booting from FlexSPI1. AfterResetTarget() end - Took 53.1ms Downloading file [FW/image/Ama.elf]... J-Link: Flash download: Bank 0 @ 0x30000000: 1 range affected (262144 bytes) J-Link: Flash download: Total: 6.568s (Prepare: 0.326s, Compare: 1.632s, Erase: 1.835s, Program: 2.173s, Verify: 0.402s, Restore: 0.196s) J-Link: Flash download: Program speed: 117 KB/s ****** Error: Verification failed @ address 0x30000000 Error while programming flash: Verify failed. J-Link>sleep 1 Sleep(1) J-Link>loadfile "FW/image/Ama_BootHdr.elf" 'loadfile': Performing implicit reset & halt of MCU. Reset: Halt core after reset via DEMCR.VC_CORERESET. Reset: Reset device via AIRCR.SYSRESETREQ. Core did not halt after reset, halting it manually. AfterResetTarget() start Valid application detected. Setting PC / SP manually. Booting from FlexSPI1. AfterResetTarget() end - Took 53.0ms Downloading file [FW/image/Ama_BootHdr.elf]... J-Link: Flash download: Bank 0 @ 0x30000000: 1 range affected (262144 bytes) J-Link: Flash download: Total: 6.592s (Prepare: 0.326s, Compare: 1.627s, Erase: 1.805s, Program: 2.234s, Verify: 0.402s, Restore: 0.195s) J-Link: Flash download: Program speed: 114 KB/s ****** Error: Verification failed @ address 0x30000000 Error while programming flash: Verify failed. J-Link>exit Script processing completed.
for both parts I have the address 0x30000000, which is incorrect for the application, and the affected range is 262144 for both. They also both fail verification.
so how should the script be for me to write the two parts, verifying both?
best regards
Max -
I would like to automate the writing of flash. The problem is that the file name to write changes from time to time depending on the version. Is there any way using a parametrized command or script file so that the filename to write becomes a parameter?
best regards
Max -
I work with RT1051 and I have a project contained and executed in RAM.
I wrote a command file to automate loading and execution:Code
Display Moreconnect sleep 10 r sleep 100 loadfile "image/executable.hex" sleep 10 setpc <ENTRYPOINT> sleep 100 g sleep 100 exit
Every version I make <ENTRYPOINT> can change, forcing me to introspect the produced binary.
To automate this aspect as well, how could I do it?
For example, is it possible to pass parameters from JLink command line to CommandScript? Or is it possible to declare variables inside the script that I would populate by reading the content of a specific memory location (the address of the ResetISR inside the vectors)? Or are there other methods I haven't considered like JlinkScripts?
best regards
Max -
Is the source code of i.MXRT1050_QSPI flashloader available?
I would need to see how the pins, clocks, and MPU are configured.
I hope and believe there is nothing to keep hidden since the hidden part is distributed as a pre-compiled library (SEGGER_OFL_Lib_CortexM_LE.a). I'm just talking about startup code and the various functions to populate as explained in the wiki page https://wiki.segger.com/Open_Flashloaderbest regards
Max -
I have a board that mounts RT1051 and QSPI. How do I select that type of memory, since I believe HyperFlash is selected by default?
best reagards
Max -
I'm having trouble with an RT1061. I am attaching the log file.
The J-Link works since I can write and debug FW in RAM. Flash works since my FW in ram can read and write flash correctly. Also J-Link can read the content of the flash. The power supply is stable and the clock is working.
The error is:Code: failure.log
Display MoreT43725740 020:214.509 JLINK_EraseChip() T43725740 020:215.337 CPU_ReadMem(4 bytes @ 0xE000ED90) T43725740 020:216.138 CPU_ReadMem(4 bytes @ 0xE000ED94) T43725740 020:216.834 -- -------------------------------------- T43725740 020:216.946 -- Start of determining flash info (Bank @ 0x60000000) T43725740 020:216.987 -- Calculating RAM usage T43725740 020:217.050 -- RAM usage = 40492 Bytes T43725740 020:217.086 -- Preserving CPU registers T43725740 020:217.154 -- Preparing memory T43725740 020:217.209 -- Preparing target T43725740 020:217.242 -- Preserving target RAM temporarily used for programming T43725740 020:470.765 -- Downloading RAMCode T43725740 020:581.442 -- Preparing RAMCode T43725740 020:590.992 ***** Error: T43725740 020:591.109 Failed to prepare RAMCode using RAM T43725740 020:591.147 -- Error while determining flash info (Bank @ 0x60000000) T43725740 020:591.184 ***** Error: T43725740 020:591.217 Error while determining flash info (Bank @ 0x60000000) T43725740 020:591.249 -- End of determining flash info T43725740 020:593.180 - 378.727ms returns -1
What are the reasons why it can fail like this?
-
I am able to build a firmware that resides in QSPI and that is loaded into ITCM from the ROM bootloader at startup.
What happens, for example on the EVKB, is that J-Link correctly writes the FW in QSPI flash then sets the program counter at the entry point.
Unfortunately, in this way, what is being executed is not the firmware just written, but the one that was running before writing, because the RAM is not touched by J-Link. It should be the ROM bootloader that populates the RAM.I would like to have J-Link, once the FW is written in QSPI, trigger the ROM bootloader. I'm trying to write a script without success.
How can I do that?best regards
Max -
We have a custom board project equipped with two i.MX RT1051.
We would like to use the JTAG connection, instead of the SWD, in order to link the two MCUs, as shown here
https://en.wikipedia.org/wiki/JTAG#Dais…G_(IEEE_1149.1)
[Blocked Image: https://upload.wikimedia.org/wikipedia/commons/c/c9/Jtag_chain.svg]
so we can only use one program/debug connector.
The preliminary step for us is to make the JTAG connection work on EVKB (taking care to pull up the JTAG_MOD signal). However, the connection is not established.We wonder where we're wrong. Is there any special command or parameter for J-Link? We wonder if the RT105x supports JTAG for programming and debugging or just boundary scan.
best regards
Max -
-
maybe I didn't explain myself well: I am perfectly aware of the manual and of the existence of the described procedure.
I wondered if J-Link would offer any shortcuts to do this, given the criticality: they are one time programmable, and an error could compromise the chip irreversibly.
Moreover, the programming of the QSPI also involves an algorithm of several steps. However, this is provided by J-Link as functionality.In any case, I understand that Segger has not addressed with the issue leaving it entirely to the users, right?
best regards
Max -
Using J-link I can connect and debug my i.MX RT1051.
I need to program the OTP eFuses to make my board boot from QSPI (I cannot use boot pins)Which J-Link commands I need?
best regards
Max -