cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U5 - ICACHE with XIP from OCTOSPI - Breakpoints and General Setup

bluluiss
Associate II

After hours of struggling, I finally managed to get the I-CACHE working while using XIP from an external Macronix OCTOSPI Flash.
The key was enabling memory remapping and writing a proper linker script that used the I-CACHE remapped address space.

First, I want to highlight that—aside from AN5212 and the Reference Manual—a clear example is NOT provided.

I had to manually modify the linker script (which is not correctly generated by CubeMX), and after hours of frustrating debugging, I discovered that breakpoints set via STLink_GDBServer do not work by default.

This issue arises because the following memory definitions XML is hardcoded into the STLink GDB Server:

 

<?xml version="1.0"?>
<!DOCTYPE memory-map
PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
"http://sourceware.org/gdb/gdb-memory-map.dtd">
<memory-map>
<memory type="ram" start="0x0" length="0x8000000"/>
<memory type="flash" start="0x8000000" length="0x400000">
<property name="blocksize">0x2000</property>
</memory>
<memory type="ram" start="0x8400000" length="0x3c00000"/>
<memory type="flash" start="0xc000000" length="0x400000">
<property name="blocksize">0x2000</property>
</memory>
<memory type="ram" start="0xc400000" length="0x83c00000"/>
<memory type="flash" start="0x90000000" length="0x2000000">
<property name="blocksize">0x100</property>
</memory>
<memory type="ram" start="0x92000000" length="0x6dffffff"/>
</memory-map>

 

As a result, GDB refuses to set breakpoints in the I-CACHE remapped region (0x10000000 - 0x1FFFFFFF), which executes code but is not recognized as a flash memory region.

After even more time spent dealing with incomplete documentation, I finally managed to fix it by writing a custom GDB init script to properly configure the memory regions:

# Reset Target
monitor reset

# Delete crazy ST default RW region
delete mem 4

# Map RAM region as RW for variable watches
mem 0x20000000 0x27FFFFFF rw

# Map ICACHE region as RO for enabling breakpoints
mem 0x10000000 0x1FFFFFFF ro

Given these challenges, I would like to request a way to pass a custom XML memory region definition to STLink-GDBServer via a command-line parameter.

Is this feature planned?

I believe that most users assume they are utilizing the I-CACHE, but in reality, they do not perform memory remapping and, most importantly, do not modify the linker script accordingly.

Given this, please provide a clear example demonstrating how to properly use I-CACHE with XIP on external OSPI/HEXSPI flash memories, including the necessary memory remapping steps and linker script modifications.

 

0 REPLIES 0