cancel
Showing results for 
Search instead for 
Did you mean: 

Using Jtag/SWD in Linux

info
Associate II

Custom PCB, STM32MP157C chip. Linux 5.7.10. Buildroot build. No issues - Linux boots to console prompt without trouble, no errors.

I can view device registers and all memory regions using Segger Jlink via SWD in both SPL and UBoot. Once Linux starts - I can only view memory from 0xC0000000 to 0xCFFFFFFF, i.e. the DRAM. Any attempt to read internal RAM or device registers via SWD fails with "cannot read memory". JLink connected to CPU 0 (A7). If connected to M4 all I get is 0x23000000 regardless of what address I try to read (but the M4 is still in reset so that may be the reason).

I am not certain if SWD read goes through A7 virtual memory mapping or not - but anybody know what needs to change so I can access internal RAM space and device registers from SWD once Linux is running ?

1 REPLY 1
PatrickF
ST Employee

Hi @info​ 

not sure, but I think you face multiple hurdles:

  • internal SYSRAM is usually assigned to secure SW (e.g. part of TF-A and OpTEE). If secure debug is not disabled in the HW (BSEC), you could probably tell your debugger to create secure accesses (worth to ask Segger for that)
  • Linux is trying as far as he can to stop peripheral bus clock when not needed (usual example is GPIOs AFMUX which are statically setup once), so most peripherals registers cannot be accesses until clock is re-enabled inside RCC

I'm not expert, but Linux debugging with JTAG/SWD is usually used only for driver development. Most Linux cases uses SW debugging.

See https://wiki.st.com/stm32mpu/wiki/Debugging_the_Linux_kernel_using_the_GDB

and https://wiki.st.com/stm32mpu/wiki/Linux_tracing,_monitoring_and_debugging

Regards.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.