Pioinit Undefined command: "loop" - Error when starting debug

I get this error from PIO right after compilation when trying to run in debug mode:

ResetHandler () at C:\Users\Markus\.platformio\packages\framework-arduinoteensy\cores\teensy3\mk20dx128.c:767
767		while (dest < &_edata) *dest++ = *src++;
Not implemented stop reason (assuming exception): undefined
.pioinit:14: Error in sourced command file:
Undefined command: "loop".  Try "help".

Any ideas how to fix? Thanks in advance!

Could you provide platformio.ini?

Sure! Thank you!

platformio.ini

[env:teensy32]
platform = teensy
board = teensy31
framework = arduino

upload_protocol = jlink

debug_tool = custom
debug_port = :2331
debug_init_break = loop
debug_init cmds =
  target remote $DEBUG_PORT
  file "$PROG_PATH"
  load "$PROG_PATH"
  $INIT_BREAK
  monitor reset
  monitor halt

debug_server =
  JLinkGDBServerCL.exe
  -singlerun
  -if
  SWD
  -select
  USB
  -port
  2331
  -device
  MK20DX256xxx7

extra_scripts = extra_script.py

extra_script.py

Import("env")

UPLOAD_JLINK_CONF = env.subst("$BUILD_DIR/upload.jlink")

def _generate_aux(*args, **kwargs):
    with open(UPLOAD_JLINK_CONF, "w") as fp:
        fp.write("""
h
r
h
loadfile %s
r
q        
        """ % env.subst("$BUILD_DIR/firmware.hex").replace("\\", "/"))

env.AddPreAction(
    "upload",
     env.VerboseAction(_generate_aux, "Creating auxiliary files"))

env.Replace(
    UPLOADHEXCMD=
    'JLink -device MK66FX1M0xxx18 -speed 4000 -if swd -autoconnect 1 -CommanderScript %s' % UPLOAD_JLINK_CONF
)

Please check documentation for debug_init_break option. What does mean “loop”? Which type of breakpoint would you like to set? Temporary? Hardware? For example, temporary breakpoint for “loop” has the next GDB syntax: tb loop.

1 Like

This works! Sorry I should have RTFM. Not sure how the wrong dubug_init_break command got into my platformio.ini in the first place. Thank you!