vsCode - it seems I'm getting stuck in an infinite loop

Continuing from vsCode cant start debugger

Situation is that upon running device initialization code it enters an infinite loop. Rolf Requests:

The Cy_SysLib_ProcessingFault is a known error as our stack has several registers and SFLASH protected. Are you able to provide the full call stack and where it exactly goes into the fault?

This should be what you requested. Not sure how to tell “where it exactly goes into the fault”

The same info pulled directly from gdb:

> bt
#0  Cy_SysLib_ProcessingFault () at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_syslib.c:489
#1  0x10001690 in Cy_SysLib_FaultHandler (faultStackAddr=<optimized out>) at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_syslib.c:461
#2  0x10000992 in UsageFault_Handler () at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/devices/bsp/COMPONENT_MTB/startup/TOOLCHAIN_GCC_ARM/startup_psoc6_02_cm4.S:496
#3  <signal handler called>
#4  0x10001bb2 in ?? ()
#5  0x100015e8 in Cy_SysLib_AssertFailed (file=file@entry=0x10001c40 "/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_ipc_pipe.c", line=line@entry=0x1de) at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_syslib.c:182
#6  0x10001270 in Cy_IPC_Pipe_ExecCallback (endpoint=0x10001d04) at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_ipc_pipe.c:478
#7  0x26fad1f8 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

This might be where it fails:

Could it be a simple usage error here? I cloned the hello-world repo, and from there only typed a set of lorawan keys in LoRaWAN_keys.h. I set .OTAA_10x.DevEui and .OTAA_10x.AppKey

The module in question is a Onethinx core v18.02 on the “official” development board

This looks very weird. It seems the code is not being executed well (mismatch with compiler, programmed code)?

Are you sure the code is compiled correctly and is programmed okay?

Is the correct compiler chosen?

Lets have a look.

Clean Reconfigure:

[driver] Removing /home/mogul/Onethings_vsCode/VSCodeHelloWorld/build/CMakeCache.txt
[driver] Removing /home/mogul/Onethings_vsCode/VSCodeHelloWorld/build/CMakeFiles
[cms-client] Configuring using the "Unix Makefiles" CMake generator
[cmake] ------ "Project VSCodeHelloWorld" ------
[cmake] The C compiler identification is GNU 9.2.1
[cmake] The CXX compiler identification is GNU 9.2.1
[cmake] Check for working C compiler: /pack/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc
[cmake] Check for working C compiler: /pack/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc -- works
[cmake] Detecting C compiler ABI info
[cmake] Detecting C compiler ABI info - done
[cmake] Detecting C compile features
[cmake] Detecting C compile features - done
[cmake] Check for working CXX compiler: /pack/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-g++
[cmake] Check for working CXX compiler: /pack/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-g++ -- works
[cmake] Detecting CXX compiler ABI info
[cmake] Detecting CXX compiler ABI info - done
[cmake] Detecting CXX compile features
[cmake] Detecting CXX compile features - done
[cmake] The ASM compiler identification is GNU
[cmake] Found assembler: /pack/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/bin/arm-none-eabi-gcc
[cmake] Chip variant: CY8C6347BZI_BLD53
[cmake] /home/mogul/Onethings_vsCode/VSCodeHelloWorld
[cmake] /home/mogul/Onethings_vsCode/VSCodeHelloWorld/design/GeneratedSource/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/cmsis/include/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/devices/bsp/COMPONENT_MBED/startup/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/devices/bsp/COMPONENT_MTB/startup/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/devices/include/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/devices/include/ip/home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/include/home/mogul/Onethings_vsCode/VSCodeHelloWorld/source/home/mogul/Onethings_vsCode/VSCodeHelloWorld/source/OnethinxCore
[cmake] /home/mogul/Onethings_vsCode/VSCodeHelloWorld/source/OnethinxCore/OnethinxCore01.c/home/mogul/Onethings_vsCode/VSCodeHelloWorld/source/main.c
[cmake] /home/mogul/Onethings_vsCode/VSCodeHelloWorld/design/GeneratedSource/cycfg.c/home/mogul/Onethings_vsCode/VSCodeHelloWorld/design/GeneratedSource/cycfg_clocks.c/home/mogul/Onethings_vsCode/VSCodeHelloWorld/design/GeneratedSource/cycfg_pins.c/home/mogul/Onethings_vsCode/VSCodeHelloWorld/design/GeneratedSource/cycfg_routing.c/home/mogul/Onethings_vsCode/VSCodeHelloWorld/design/GeneratedSource/cycfg_system.c
[cmake] Configuring done
[cmake] CMake Deprecation Warning:
[cmake]   The 'cmake-server(7)' is deprecated.  Please port clients to use the
[cmake]   'cmake-file-api(7)' instead.
[cmake] Generating done

Clean Rebuild:

[build] Starting build
[proc] Executing command: /pack/cmake-3.16.2-Linux-x86_64/bin/cmake --build /home/mogul/Onethings_vsCode/VSCodeHelloWorld/build --config customDebug --target all -- -j 6
[build] Scanning dependencies of target VSCodeHelloWorld.elf
[build] [  1%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/source/main.c.obj
[build] [  2%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/source/OnethinxCore/OnethinxCore01.c.obj
[build] [  3%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/design/GeneratedSource/cycfg_pins.c.obj
[build] [  4%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/design/GeneratedSource/cycfg_routing.c.obj
[build] [  5%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/design/GeneratedSource/cycfg.c.obj
[build] [  6%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/design/GeneratedSource/cycfg_clocks.c.obj
[build] [  8%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/design/GeneratedSource/cycfg_system.c.obj
[build] [  9%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/devices/bsp/COMPONENT_MTB/startup/system_psoc6_cm4.c.obj
[build] [ 10%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_ble_clk.c.obj
[build] [ 11%] Building ASM object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/devices/bsp/COMPONENT_MTB/startup/TOOLCHAIN_GCC_ARM/startup_psoc6_02_cm4.S.obj
[build] [ 12%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_canfd.c.obj
[build] [ 13%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_aes_v1.c.obj
[build] [ 15%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto.c.obj
[build] [ 16%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_aes_v2.c.obj
[build] [ 17%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_cmac_v1.c.obj
[build] [ 18%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_cmac_v2.c.obj
[build] [ 19%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_crc_v1.c.obj
[build] [ 20%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_crc_v2.c.obj
[build] [ 22%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_des_v1.c.obj
[build] [ 23%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_des_v2.c.obj
[build] [ 24%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_ecc_domain_params.c.obj
[build] [ 25%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_ecc_ecdsa.c.obj
[build] [ 26%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_ecc_key_gen.c.obj
[build] [ 27%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_ecc_nist_p.c.obj
[build] [ 29%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_hmac_v1.c.obj
[build] [ 30%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_hmac_v2.c.obj
[build] [ 31%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_hw.c.obj
[build] [ 32%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_hw_v1.c.obj
[build] [ 33%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_mem_v1.c.obj
[build] [ 34%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_mem_v2.c.obj
[build] [ 36%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_prng_v1.c.obj
[build] [ 37%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_prng_v2.c.obj
[build] [ 38%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_rsa.c.obj
[build] [ 39%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_sha_v1.c.obj
[build] [ 40%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_sha_v2.c.obj
[build] [ 41%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_trng_v1.c.obj
[build] [ 43%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_trng_v2.c.obj
[build] [ 44%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_core_vu.c.obj
[build] [ 45%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_csd.c.obj
[build] [ 46%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_crypto_server.c.obj
[build] [ 47%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_ctb.c.obj
[build] [ 48%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_ctdac.c.obj
[build] [ 50%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_device.c.obj
[build] [ 51%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_dma.c.obj
[build] [ 52%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_dmac.c.obj
[build] [ 53%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_efuse.c.obj
[build] [ 54%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_flash.c.obj
[build] [ 55%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_gpio.c.obj
[build] [ 56%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_i2s.c.obj
[build] [ 58%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_ipc_drv.c.obj
[build] [ 59%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_ipc_pipe.c.obj
[build] [ 60%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_ipc_sema.c.obj
[build] [ 61%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_lpcomp.c.obj
[build] [ 62%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_lvd.c.obj
[build] [ 63%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_mcwdt.c.obj
[build] [ 65%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_pdm_pcm.c.obj
[build] [ 66%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_profile.c.obj
[build] [ 67%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_prot.c.obj
[build] [ 68%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_rtc.c.obj
[build] [ 69%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_sar.c.obj
[build] [ 70%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_scb_common.c.obj
[build] [ 72%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_scb_ezi2c.c.obj
[build] [ 73%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_scb_i2c.c.obj
[build] [ 74%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_scb_spi.c.obj
[build] [ 75%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_scb_uart.c.obj
[build] [ 76%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_sd_host.c.obj
[build] [ 77%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_seglcd.c.obj
[build] [ 79%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_smartio.c.obj
[build] [ 80%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_smif.c.obj
[build] [ 81%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_smif_memslot.c.obj
[build] [ 82%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_sysanalog.c.obj
[build] [ 83%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_sysclk.c.obj
[build] [ 84%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_sysint.c.obj
[build] [ 86%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_syslib.c.obj
[build] [ 87%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_syspm.c.obj
[build] [ 88%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_systick.c.obj
[build] [ 89%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_tcpwm_counter.c.obj
[build] [ 90%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_tcpwm_pwm.c.obj
[build] [ 91%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_tcpwm_quaddec.c.obj
[build] [ 93%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_trigmux.c.obj
[build] [ 94%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_usbfs_dev_drv.c.obj
[build] [ 95%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_usbfs_dev_drv_io.c.obj
[build] [ 96%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_usbfs_dev_drv_io_dma.c.obj
[build] [ 97%] Building C object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/cy_wdt.c.obj
[build] [ 98%] Building ASM object CMakeFiles/VSCodeHelloWorld.elf.dir/psoc6pdl/drivers/source/TOOLCHAIN_GCC_ARM/cy_syslib_gcc.S.obj
[build] [100%] Linking C executable VSCodeHelloWorld.elf
[build] [100%] Built target VSCodeHelloWorld.elf
[build] Scanning dependencies of target VSCodeHelloWorld
[build] No ELF section .cychecksum found, creating one
[build] Application checksum calculated and stored in ELF section .cychecksum
[build] No ELF section .cymeta found, creating one
[build] Checksum calculated and stored in ELF section .cymeta
[build] ------- Memory usage -------
[build]    -------------------------------------------------- 
[build]   | Section Name         |  Address      |  Size     | 
[build]    -------------------------------------------------- 
[build]   | .text                |  0x10000000   |  7404     | 
[build]   | .copy.table          |  0x10001cec   |  24       | 
[build]   | .zero.table          |  0x10001d04   |  8        | 
[build]   | .data                |  0x080002e0   |  1520     | 
[build]   | .cy_sharedmem        |  0x080008d0   |  12       | 
[build]   | .noinit              |  0x080008e0   |  148      | 
[build]   | .bss                 |  0x08000974   |  800      | 
[build]    -------------------------------------------------- 
[build]   Total Internal Flash (Available)          917504   0xe0000 
[build]   Total Internal Flash (Utilized)           8968     0x02308 
[build]   Total Internal SRAM (Available)           229376   0x38000 
[build]   Total Internal SRAM (Utilized)            2480     0x009b0
[build] [100%] Built target VSCodeHelloWorld
[build] Build finished with exit code 0

Debug Console:

Please check OUTPUT tab (Adapter Output) for output from /home/mogul/Onethings_vsCode/VSCodeHelloWorld/tools_2.0/linux/openocd/bin/openocd
Launching server: "/home/mogul/Onethings_vsCode/VSCodeHelloWorld/tools_2.0/linux/openocd/bin/openocd" "-c" "gdb_port 50000" "-s" "/home/mogul/Onethings_vsCode/VSCodeHelloWorld/tools_2.0/linux/openocd/scripts" "-c" "set PROGRAMMER kitprog3" "-c" "set ENABLE_ACQUIRE 0" "-c" "set ENABLE_CM0 0" "-f" "/home/mogul/Onethings_vsCode/VSCodeHelloWorld/config/scripts/openocd.tcl"
Launching GDB: "arm-none-eabi-gdb" "-q" "--interpreter=mi2"
Reading symbols from /home/mogul/Onethings_vsCode/VSCodeHelloWorld/build/VSCodeHelloWorld.elf...
Cy_SysLib_ProcessingFault () at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_syslib.c:489
489	        while(1) {}
Not implemented stop reason (assuming exception): undefined
SWD DPIDR 0x6ba02477
Failed to read memory at 0x16002008
mem2array: Read @ 0x16002004, w=4, cnt=1, failed
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000f00 msp: 0x08047800
Output radix now set to decimal 16, hex 10, octal 20.
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x41000003 pc: 0x100015f4 msp: 0x0803efb0
psoc6.cpu.cm4: bkpt @0x10000905, issuing SYSRESETREQ
psoc6.cpu.cm4: external reset detected
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x10000904 msp: 0x0803f000
Note: automatically using hardware breakpoints for read-only addresses.

And when I Pause the debugger it adds to the debug console

 received signal SIGINT, Interrupt.
Cy_SysLib_ProcessingFault () at /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/source/cy_syslib.c:489
489	        while(1) {}

As mentioned earlier, I have seen the processor being able to execute code. I hacked in a few lines of C code to compute a Fibonacci sequence. Simply dropped the code before it does the fatal integrity check.

I was able to single step through the code an see the numbers in the debugger.
Of course, all this could have been executing on the host system, but it looked quite genuine.

Are you able to change ‘runtomain’ to false in launch.json and step manually to see if you see some strange things. Your call-stack reveals ‘Unknown Source’ which tells that it executes on memory locations that aren’t corresponding the code you compiled.

"runToMain": true

Oh, this turned out to be a long journey single-stepping and setting breakpoints through library assembly code.

Here goes the summary, hope it tell you something:

  1. Line 450 in startup_psoc6_02_cm4.S does a bl __libc_init_array
  2. then it enters something that seems to have been dissembled. vsCode has named it __libc_init_array.cdasm
  3. three instructions down it jumps again
adr hex code
0x10001704: 70 40 eors r0, r6
0x10001706: 2d e9 6c 60 stmdb sp!, {r2, r3, r5, r6, sp, lr}
0x1000170a: 9f e5 b.n 0x1000124c <Cy_IPC_Pipe_ExecCallback+56>
  1. Back in C-land in the file cy_ipc_pipe.c in the function Cy_IPC_Pipe_ExecCallback
  2. Here the structure endpoint gets CY_ASSERT_L1 analyzed and the key callbackArray is checked against NULL, which it unfortunately is.

HA! found something! (but it was nothing, read update at the bottom of this post)
While compiling, I didn’t notice the (2) at the PROBLEMS tab:

Notice the filename cy_ipc_pipe, the exact module that triggers the error.

So question is now where do I add an include path for this project?

CMakeLists.txt which appears to be what Clean Reconfigure executes, do indeed find, and add, the directory /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/include which is where cy_ipc_pipe.h resides.

But then again. I’m not sure here, might just be vsCode editor help misinterpreting things. Two observations:

  • if I, just for fun, comment the #include "cy_ipc_pipe.h" line in cy_ipc_pipe.c, the problems immediately goes up to 14, so at least something good is coming from the file vsCode claims it cannot read
  • catching the actual compiler commands run - be fast with ps and grep - reveals that the needed -I directive pointing to /home/mogul/Onethings_vsCode/VSCodeHelloWorld/psoc6pdl/drivers/include indeed is there

A quick restart of vsCode cleared whatever had confused the intillisense - or what is was - now I am back to “0 problems” but still stuck in the tight loop.

I just tried to look into this. It still puzzles me :exploding_head:

It seems something is wrong with building the project. Can you delete the contents of the build folder and try again?

This is my disassembly of __libc_init_array which runs fine for me.

0x10001644: 70 b5           	push	{r4, r5, r6, lr}
0x10001646: 0d 4e           	ldr	r6, [pc, #52]	; (0x1000167c <__libc_init_array+56>)
0x10001648: 0d 4d           	ldr	r5, [pc, #52]	; (0x10001680 <__libc_init_array+60>)
0x1000164a: 76 1b           	subs	r6, r6, r5
0x1000164c: b6 10           	asrs	r6, r6, #2
0x1000164e: 06 d0           	beq.n	0x1000165e <__libc_init_array+26>
0x10001650: 00 24           	movs	r4, #0
0x10001652: 01 34           	adds	r4, #1
0x10001654: 55 f8 04 3b     	ldr.w	r3, [r5], #4
0x10001658: 98 47           	blx	r3
0x1000165a: a6 42           	cmp	r6, r4
0x1000165c: f9 d1           	bne.n	0x10001652 <__libc_init_array+14>
0x1000165e: 09 4e           	ldr	r6, [pc, #36]	; (0x10001684 <__libc_init_array+64>)
0x10001660: 09 4d           	ldr	r5, [pc, #36]	; (0x10001688 <__libc_init_array+68>)
0x10001662: 76 1b           	subs	r6, r6, r5
0x10001664: 00 f0 f4 f8     	bl	0x10001850 <_init>
0x10001668: b6 10           	asrs	r6, r6, #2
0x1000166a: 06 d0           	beq.n	0x1000167a <__libc_init_array+54>
0x1000166c: 00 24           	movs	r4, #0
0x1000166e: 01 34           	adds	r4, #1
0x10001670: 55 f8 04 3b     	ldr.w	r3, [r5], #4
0x10001674: 98 47           	blx	r3
0x10001676: a6 42           	cmp	r6, r4
0x10001678: f9 d1           	bne.n	0x1000166e <__libc_init_array+42>
0x1000167a: 70 bd           	pop	{r4, r5, r6, pc}
0x1000167c: a4 07           	lsls	r4, r4, #30
0x1000167e: 00 08           	lsrs	r0, r0, #32
0x10001680: a4 07           	lsls	r4, r4, #30
0x10001682: 00 08           	lsrs	r0, r0, #32
0x10001684: ac 07           	lsls	r4, r5, #30
0x10001686: 00 08           	lsrs	r0, r0, #32
0x10001688: a4 07           	lsls	r4, r4, #30
0x1000168a: 00 08           	lsrs	r0, r0, #32

Tried that (to delete the build folder) and it didn’t help the slightest.

Where do you run your vsCode? (linux, windows, mac) Perhaps I should try to do “exactly” as you do. I’m home on holiday leave, so I have a broad selection of machinery available to me.

Also, it could be something stupid I am missing. after all this is my first adventure with vsCode.

Getting VS Code up and running is sometimes troublesome (as we see right now). Once it’s set up well, it runs very smooth.

I tried on all platforms (yesterday on Ubuntu) and it all works fine. Do you prefer Linux?

I can try to debug ‘your’ build and vice versa.

jup, linux is my main platform. Will try on a different machine tomorrow, fresh install and everything. Both outcomes (works/works not) will teach us something.

Please tell me which versions of relevant software packages you are using. (on your ubuntu setup)


I tried the latest Ubuntu, downloaded VS Code and installed the extensions.
apt get CMake and put the latest GNU ARM compiler in a folder in usr/bin/

Added this folder to path (using ~.profile) and that’s about it.

Let me know when you like to try.

ok, just before hitting the sheets I tried one simple experiment. I scratched VSCodeHelloWorld and tried over with a fresh clone.

Reconfigure and build seems to run fine as always, but then when I hit “Launch CM4 (KitProg)”


Please check OUTPUT tab (Adapter Output) for output from /home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/tools_2.0/linux/openocd/bin/openocd
Launching server: "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/tools_2.0/linux/openocd/bin/openocd" "-c" "gdb_port 50000" "-s" "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/tools_2.0/linux/openocd/scripts" "-c" "set PROGRAMMER kitprog3" "-c" "set ENABLE_ACQUIRE 0" "-c" "set ENABLE_CM0 0" "-f" "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/config/scripts/openocd.tcl"
Launching GDB: "arm-none-eabi-gdb" "-q" "--interpreter=mi2"
Reading symbols from /home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/build/VSCodeHelloWorld-take2.elf...
__libc_init_array () at /tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/misc/init.c:35
35	/tmp/dgboter/bbs/rhev-vm10--rhe6x86_64/buildbot/rhe6x86_64--arm-none-eabi/build/src/newlib-cygwin/newlib/libc/misc/init.c: No such file or directory.
Not implemented stop reason (assuming exception): undefined
SWD DPIDR 0x6ba02477
Failed to read memory at 0x16002008
mem2array: Read @ 0x16002004, w=4, cnt=1, failed
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000f00 msp: 0x08047800
Output radix now set to decimal 16, hex 10, octal 20.
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x41000003 pc: 0x100015f4 msp: 0x0803efb0
psoc6.cpu.cm4: bkpt @0x10000905, issuing SYSRESETREQ
psoc6.cpu.cm4: external reset detected
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x10000904 msp: 0x0803f000
Note: automatically using hardware breakpoints for read-only addresses.

Two points of interests:

  • __libc_init_array - remarkably close to where I have traced it down to lock up
  • I dont have anything named /tmp/dgboter on my disk.

Googling dgboter leads to some issues with cmake. So I retried with the one from ubuntu, which resulted in a slightly different output:

Please check OUTPUT tab (Adapter Output) for output from /home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/tools_2.0/linux/openocd/bin/openocd
Launching server: "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/tools_2.0/linux/openocd/bin/openocd" "-c" "gdb_port 50000" "-s" "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/tools_2.0/linux/openocd/scripts" "-c" "set PROGRAMMER kitprog3" "-c" "set ENABLE_ACQUIRE 0" "-c" "set ENABLE_CM0 0" "-f" "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/config/scripts/openocd.tcl"
Launching GDB: "arm-none-eabi-gdb" "-q" "--interpreter=mi2"
Reading symbols from /home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/build/VSCodeHelloWorld-take2.elf...
Cy_SysLib_ProcessingFault () at /home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/psoc6pdl/drivers/source/cy_syslib.c:489
489	        while(1) {}
Not implemented stop reason (assuming exception): undefined
SWD DPIDR 0x6ba02477
Failed to read memory at 0x16002008
mem2array: Read @ 0x16002004, w=4, cnt=1, failed
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000f00 msp: 0x08047800
Output radix now set to decimal 16, hex 10, octal 20.
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x41000003 pc: 0x100015f4 msp: 0x0803efb0
psoc6.cpu.cm4: bkpt @0x10000905, issuing SYSRESETREQ
psoc6.cpu.cm4: external reset detected
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x10000904 msp: 0x0803f000
Note: automatically using hardware breakpoints for read-only addresses.

Oh well, it encourages me to look further in…


Open On-Chip Debugger 0.10.0+dev- (2019-09-10-18:37)
Licensed under GNU GPL v2
For bug reports, read
adapter speed: 1500 kHz
Warn : Transport "swd" was already selected
adapter speed: 1000 kHz
cortex_m reset_config sysresetreq
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 1.2.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : VTarget = 4.831 V
Info : clock speed 1000 kHz
Info : SWD DPIDR 0x6ba02477
Info : psoc6.cpu.cm4: hardware has 6 breakpoints, 4 watchpoints
** Silicon: 0xE207, Family: 0x100, Rev.: 0x23 (B2)
** Detected Device: CY8C6347BZI-BLD53
** Detected Main Flash size, kb: 1024
Info : SWD DPIDR 0x6ba02477
Error: Failed to read memory at 0x16002008
Error: mem2array: Read @ 0x16002004, w=4, cnt=1, failed
Error: Invalid FlashBoot: High version word of Flash Boot is zero
** Chip Protection: SECURE
Info : Listening on port 50000 for gdb connections
Info : accepting 'gdb' connection on tcp/50000
undefined debug reason 8 - target needs reset
Warn : No RTOS could be auto-detected!
Info : SWD DPIDR 0x6ba02477
Error: Failed to read memory at 0x16002008
Error: mem2array: Read @ 0x16002004, w=4, cnt=1, failed
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000f00 msp: 0x08047800
Info : Padding image section 0 at 0x10002330 with 208 bytes (bank write end alignment)

[  5%] [#                               ] [ Erasing     ]
[ 11%] [###                             ] [ Erasing     ]
[ 16%] [#####                           ] [ Erasing     ]
[ 22%] [#######                         ] [ Erasing     ]
[ 27%] [########                        ] [ Erasing     ]
[ 33%] [##########                      ] [ Erasing     ]
[ 38%] [############                    ] [ Erasing     ]
[ 44%] [##############                  ] [ Erasing     ]
[ 50%] [################                ] [ Erasing     ]
[ 55%] [#################               ] [ Erasing     ]
[ 61%] [###################             ] [ Erasing     ]
[ 66%] [#####################           ] [ Erasing     ]
[ 72%] [#######################         ] [ Erasing     ]
[ 77%] [########################        ] [ Erasing     ]
[ 83%] [##########################      ] [ Erasing     ]
[ 88%] [############################    ] [ Erasing     ]
[ 94%] [##############################  ] [ Erasing     ]
[100%] [################################] [ Erasing     ]
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (1010). Workaround: increase "set remotetimeout" in GDB

[100%] [################################] [ Programming ]
Info : SWD DPIDR 0x6ba02477
Error: Failed to read memory at 0x16002008
Error: mem2array: Read @ 0x16002004, w=4, cnt=1, failed
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000f00 msp: 0x08047800
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x41000003 pc: 0x100015f4 msp: 0x0803efb0
Info : psoc6.cpu.cm4: bkpt @0x10000905, issuing SYSRESETREQ
Info : psoc6.cpu.cm4: external reset detected
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x10000904 msp: 0x0803f000

Quite a few memory access errors.

@Rolf do you find anything of interest in the blobs above?


The launch looks good.

To me it looks like the source isn’t built by the correct compiler. It seems some wrong paths are included somewhere. dgboter doesn’t tell me anything too.

Can you post the contents of build/compile_commands.json?


It look like a collection of sections. Probably one for each file going through the compiler. I have taken one of them and split up the crazy long line for us to better see and understand:

     -g3 -mthumb     
     -D CY8C6347BZI_BLD53
     -o CMakeFiles/VSCodeHelloWorld-take2.elf.dir/psoc6pdl/drivers/source/cy_usbfs_dev_drv_io.c.obj   
     -c /home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/psoc6pdl/drivers/source/cy_usbfs_dev_drv_io.c",
  "file": "/home/mogul/Onethings_vsCode/VSCodeHelloWorld-take2/psoc6pdl/drivers/source/cy_usbfs_dev_drv_io.c"

I tried to put the whole file here, but forum complains that the text body limit got exceeded. And attachments are apparently only for images. I created a dropbox link for it: https://www.dropbox.com/s/mit4zjm64s4dyn2/compile_commands.json?dl=0

  1. I tried to hack CMakeCache.txt to set CMAKE_VERBOSE_MAKEFILE:BOOL=TRUE I did this after the Clean Reconfigure run.
  2. Next I did clean and build
  3. Now the build process has turned very verbose.
  4. I had a look at the link stage. I expected to see a -L statement pointing somewhere down here /pack/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi/lib/gcc/arm-none-eabi/9.2.1
  5. but no. all I saw was the ones below (which is the same as found in ./CMakeFiles/VSCodeHelloWorld-take2.elf.dir/link.txt) which after some line break-up looks like:


-o VSCodeHelloWorld-take2.elf

Next I had a look at ./VSCodeHelloWorld-take2.readelf which looks like:

There are 25 section headers, starting at offset 0x15c118:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        10000000 010000 001d14 00  AX  0   0  8
  [ 2] .copy.table       PROGBITS        10001d14 011d14 000018 00  WA  0   0  1
  [ 3] .zero.table       PROGBITS        10001d2c 011d2c 000008 00  WA  0   0  1
  [ 4] .ramVectors       PROGBITS        08000000 0208e0 0002e0 00      0   0  8
  [ 5] .data             PROGBITS        080002e0 0202e0 0005f0 00 WAX  0   0  8
  [ 6] .cy_sharedmem     PROGBITS        080008d0 0208d0 00000c 00  WA  0   0  4
  [ 7] .noinit           NOBITS          080008e0 0208e0 000094 00  WA  0   0  8
  [ 8] .bss              NOBITS          08000974 0208e0 000320 00  WA  0   0  4
  [ 9] .heap             PROGBITS        08000c98 020bc0 000400 00      0   0  8
  [10] .stack_dummy      PROGBITS        08000c98 020fc0 001000 00      0   0  8
  [11] .ARM.attributes   ARM_ATTRIBUTES  00000000 021fc0 000030 00      0   0  1
  [12] .comment          PROGBITS        00000000 021ff0 00005a 01  MS  0   0  1
  [13] .debug_info       PROGBITS        00000000 02204a 0273f0 00      0   0  1
  [14] .debug_abbrev     PROGBITS        00000000 04943a 0032b2 00      0   0  1
  [15] .debug_loc        PROGBITS        00000000 04c6ec 005f66 00      0   0  1
  [16] .debug_aranges    PROGBITS        00000000 052658 000630 00      0   0  8
  [17] .debug_ranges     PROGBITS        00000000 052c88 000950 00      0   0  1
  [18] .debug_macro      PROGBITS        00000000 0535d8 023ad0 00      0   0  1
  [19] .debug_line       PROGBITS        00000000 0770a8 00db83 00      0   0  1
  [20] .debug_str        PROGBITS        00000000 084c2b 0d1c84 01  MS  0   0  1
  [21] .debug_frame      PROGBITS        00000000 1568b0 000ec0 00      0   0  4
  [22] .symtab           SYMTAB          00000000 157770 0023d0 10     23 274  4
  [23] .strtab           STRTAB          00000000 159b40 0024d1 00      0   0  1
  [24] .shstrtab         STRTAB          00000000 15c011 000105 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  y (purecode), p (processor specific)

Elf file type is EXEC (Executable file)
Entry point 0x10000905
There are 3 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x010000 0x10000000 0x10000000 0x01d34 0x01d34 RWE 0x10000
  LOAD           0x0202e0 0x080002e0 0x10001d34 0x005fc 0x005fc RWE 0x10000
  LOAD           0x0208e0 0x080008e0 0x10002338 0x00000 0x003b4 RW  0x10000

 Section to Segment mapping:
  Segment Sections...
   00     .text .copy.table .zero.table 
   01     .data .cy_sharedmem 
   02     .noinit .bss 

@Rolf whats in yours?

HA! Fantastic progress!! Messages are ticking in :sunglasses:

How did I do?

  1. Discovered that the official onethinx helloworld repository contained output from a build process.
  2. I inspected the VSCodeHelloWorld.map
  3. It revealed that it was compiled with a 8.2.1 tool chain
  4. I downloaded, installed and compiled with a similar
  5. Success!

So for now gcc-arm-none-eabi-8-2019-q3-update works better than gcc-arm-9.2-2019.12-x86_64-arm-none-eabi. At least for me.

Good catch!!!

A search on gcc-arm-9.2-2019.12-x86_64-arm-none-eabi brought me to the ARM-Cortex-A family page, which indeed isn’t the correct compiler for the the Onethinx Core (which uses Cortex-M family).

The gcc-arm-none-eabi-8-2019-q3-update is for Cortex-M so that version is correct. The latest can be found here.

It’s funny that it seems to run well initially and eventually runs into a fault.

Thanks for your great persistence and thorough look into this :ok_hand:

I will update the documentation to emphasize the user to select the correct compiler (I always used the RM version just by sheer luck :laughing: )