Arm Mbed OS support forum

Cannot debug STM32L4 build

Hi

I’m building using mbed cli and it builds ok. I can deploy using OpenOCD but with no RTX5 RTOS support, it won’t debug. If I try and debug using pyOCD it throws an exception. I have opened a report there and it has been assigned as a bug, but the question is why is the mbed build producing an ELF file that is unusable by pyOCD?

My development path to date has been:

Build in Mbed CLI and debug using VSCode/OpenOCD. This failed because no RTOS support.

Switched to Mbed Studio expecting it to ‘just work’, but it builds but won’t deploy via pyOCD.

Switched back to Mbed CLI with VSCode/pyOCD but fails to deploy too due to errors below. I’ve moved back to Mbed CLI because I couldn’t get GCC builds working with Mbed Studio (here) and I needed to switch to GCC because the pyOCD owner suggested it produces more complete ELF file headers. But now I’m building with GCC, that still doesn’t work.

GDB says there is an overlapping region - is this is the issue and if so, what is overlapping in the following?


arm-mbed.elf:     file format elf32-littlearm

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000d688  08000000  08000000  000000c0  2**6
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .ARM.exidx    00000008  0800d688  0800d688  0000d748  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data         00000a10  200001c0  0800d690  0000d750  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  3 .bss          000027e0  20000bd0  0800e0a0  0000e160  2**3
                  ALLOC
  4 .heap         0009c850  200033b0  200033b0  0000e160  2**0
                  CONTENTS
  5 .ARM.attributes 0000002e  00000000  00000000  000aa9b0  2**0
                  CONTENTS, READONLY
  6 .comment      0000004c  00000000  00000000  000aa9de  2**0
                  CONTENTS, READONLY
  7 .debug_info   000fd1a7  00000000  00000000  000aaa2a  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
  8 .debug_abbrev 0001a8d4  00000000  00000000  001a7bd1  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
  9 .debug_aranges 000035e0  00000000  00000000  001c24a8  2**3
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 10 .debug_line   0003bbd5  00000000  00000000  001c5a88  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 11 .debug_str    00030f13  00000000  00000000  0020165d  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 12 .debug_ranges 00006e58  00000000  00000000  00232570  2**3
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 13 .debug_frame  0000a250  00000000  00000000  002393c8  2**2
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 14 .debug_loc    00033183  00000000  00000000  00243618  2**0
                  CONTENTS, READONLY, DEBUGGING, OCTETS
 15 .stabstr      00000076  00000000  00000000  0027679b  2**0
                  CONTENTS, READONLY, DEBUGGING

arm-mbed.elf:     file format elf32-littlearm

Program Header:
0x70000001 off    0x0000d748 vaddr 0x0800d688 paddr 0x0800d688 align 2**2
         filesz 0x00000008 memsz 0x00000008 flags r--
    LOAD off    0x000000c0 vaddr 0x08000000 paddr 0x08000000 align 2**6
         filesz 0x0000d690 memsz 0x0000d690 flags r-x
    LOAD off    0x0000d750 vaddr 0x200001c0 paddr 0x0800d690 align 2**3
         filesz 0x00000a10 memsz 0x000031f0 flags rw-
private flags = 5000200: [Version5 EABI] [soft-float ABI]
0000000449: GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"log","content":"warning: Overlapping regions in memory map: ignoring\n"}]}
0000000449: warning: Overlapping regions in memory map: ignoring
0000000544: GDB -> App: {"outOfBandRecord":[{"isStream":true,"type":"console","content":"0x0800c74c in ?? ()\n"}]}
>>> gdbserver start
>>> 0457795:ERROR:gdbserver:Unhandled exception in handle_message: individual memory accesses must not cross memory region boundaries
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 549, in handle_message
    reply = handler(msg[msgStart:])
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 1023, in handle_query
    resp = self.handle_query_xml(b'threads', int(data[0], 16), int(data[1].split(b'#')[0], 16))
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 1210, in handle_query_xml
    xml = self.get_threads_xml()
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 1300, in get_threads_xml
    if not self.is_threading_enabled():
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\gdbserver\gdbserver.py", line 1320, in is_threading_enabled
    return (self.thread_provider is not None) and self.thread_provider.is_enabled \
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\rtos\rtx5.py", line 408, in is_enabled
    return self.get_kernel_state() != 0 and not self._target.in_thread_mode_on_main_stack()
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\rtos\rtx5.py", line 446, in get_kernel_state
    return self._target_context.read8(self._os_rtx_info + RTX5ThreadProvider.KERNEL_STATE_OFFSET)
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\core\memory_interface.py", line 64, in read8
    return self.read_memory(addr, 8, now)
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\debug\cache.py", line 516, in read_memory
    return self._memcache.read_memory(addr, transfer_size, now)
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\debug\cache.py", line 422, in read_memory
    data = self.read_memory_block8(addr, 1)[0]
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\debug\cache.py", line 442, in read_memory_block8
    if not self._check_regions(addr, size):
  File "C:\Users\User\AppData\Local\Mbed Studio\mbed-studio-tools\python\lib\site-packages\pyocd\debug\cache.py", line 414, in _check_regions
    raise MemoryAccessError("individual memory accesses must not cross memory region boundaries")
pyocd.debug.cache.MemoryAccessError: individual memory accesses must not cross memory region boundaries

The addresses appear to be sequential blocks. Totally stuck in that code builds, even runs, but cannot debug.

Many thanks!