PlatformIO Community

undefinedError: Processing LPC1769 DEBUG (platform: https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip; board: nxp_lpc1769; framework: arduino)

Started getting this error when clicking PIO Debug. Used to work fine just a few days ago.
The compile phase completes successfully, but when the DEBUG window opens the error occurs and it erases the contents that the compiler put in the .pio\build\LPC1769 DEBUG folder. Then of course a following error about not finding “idedata.json” occurs since the compiled output folder was erased.

Odd thing is that other projects compile and debug just fine.

I don’t know where to start in fixing this. What does undefinedError: mean and how can I find out what caused it?

The full output is:

undefinedError: Processing LPC1769 DEBUG (platform: https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip; board: nxp_lpc1769; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/nxplpc-arduino-lpc176x/nxp_lpc1769.html
PLATFORM: NXP Arduino LPC176x (0.1.3) > NXP LPC1769
HARDWARE: LPC1769 120MHz, 31.97KB RAM, 464KB Flash
DEBUG: Current (custom) On-board (cmsis-dap) External (blackmagic, jlink)
PACKAGES:
 - framework-arduino-lpc176x 0.2.9
 - toolchain-gccarmnoneeabi 1.90301.200702 (9.3.1)
Converting Marlin.ino
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ strict
Found 2 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <U8glib-HAL> 0.4.5
Building in debug mode
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Users\\tony\\Documents\\CNC\\MAINBOARD\\MKS-SGEN\\Marlin-2.0.8-052521-SGEN\\.pio\\build/LPC1769 DEBUG/debug\\idedata.json':
  File "C:\Users\tony\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 230:
    with open(
========================== [FAILED] Took 1.33 seconds ==========================

Environment    Status    Duration
-------------  --------  ------------
LPC1769 DEBUG  FAILED    00:00:01.335
==================== 1 failed, 0 succeeded in 00:00:01.335 ====================

The error is thrown within the core. Please open an issue at https://github.com/platformio/platformio-core/issues with your project.

max,
I believe that FileNotFoundError is normal when the entire .pio\build\DEBUG folder was erased prior to getting to the point of looking for that idedata.json file. It can’t find the file because the earlier undefinedError: Processing LPC1769 DEBUG … nuked the .pio\build\DEBUG folder.

The problem is this initial undefinedError: but I can’t find any clues as to what is causing it in the first place.

I’m very sure debugging fails because the FileNotFoundError is seen as critical → abort before that. If it worked in a previous core version, you have found a regression, that should be reported.

You can also cross-verify that it’s the core version by deliberately downgrading your core. In a CLI you can use pip install "platformio==5.1.1" (or any other version from platformio · PyPI) to downgrade. Make sure auto-update is turned off in the PlatformIO VSCode extension settings.

Hello Max,

I did some more investigating into this issue and here’s what I found interesting:

There is a an extra script “pre:buildroot/share/PlatformIO/scripts/common-cxxflags.py” in this Marlin project, and inside there’s a test to decide whether to append “/debug” to the ‘BUILD_DIR’ (see below)

#common-cxxflags.py
#Convenience script to apply customizations to CPP flags

Import(“env”)
env.Append(CXXFLAGS=[
“-Wno-register”
#"-Wno-incompatible-pointer-types",
#"-Wno-unused-const-variable",
#"-Wno-maybe-uninitialized",
#"-Wno-sign-compare"
])

#Add CPU frequency as a compile time constant instead of a runtime variable
def add_cpu_freq():
if ‘BOARD_F_CPU’ in env:
env[‘BUILD_FLAGS’].append(’-DBOARD_F_CPU=’ + env[‘BOARD_F_CPU’])

#Useful for JTAG debugging
#It will separate release and debug build folders.
#It useful to keep two live versions: a debug version for debugging and another for
#release, for flashing when upload is not done automatically by jlink/stlink.
#Without this, PIO needs to recompile everything twice for any small change.

if env.GetBuildType() == “debug” and env.get(‘UPLOAD_PROTOCOL’) not in [‘jlink’, ‘stlink’]:
env[‘BUILD_DIR’] = ‘$PROJECT_BUILD_DIR/$PIOENV/debug’

#On some platform, F_CPU is a runtime variable. Since it’s used to convert from ns
#to CPU cycles, this adds overhead preventing small delay (in the order of less than
#30 cycles) to be generated correctly. By using a compile time constant instead
#the compiler will perform the computation and this overhead will be avoided
add_cpu_freq()

It checks if doing a debug build, but not if UPLOAD is jlink or stlink and appends “/debug” to the ‘BUILD_DIR’.

Now what I found is with these two lines present,

if env.GetBuildType() == “debug” and env.get(‘UPLOAD_PROTOCOL’) not in [‘jlink’, ‘stlink’]:
env[‘BUILD_DIR’] = ‘$PROJECT_BUILD_DIR/$PIOENV/debug’

then the .json files in the .vscode folder do not automatically update when the project is unloaded/re-loaded. This doesn’t seem right, and then launch.json won’t know about the changed build directory to find files it needs.
If I prevent the second line with the re-define of BUILD_DIR, then the .json files in the .vscode folder do automatically update when the project is unloaded/re-loaded!

Since my Marlin project uses debug_tool=custom and upload_protocol=custom, I thought to add ‘custom’ to the if statement expression like this:

if env.GetBuildType() == “debug” and env.get(‘UPLOAD_PROTOCOL’) not in [‘jlink’, ‘stlink’, ‘custom’]:
env[‘BUILD_DIR’] = ‘$PROJECT_BUILD_DIR/$PIOENV/debug’

That prevented the adding of “/debug” to the BUILD_DIR and guess what? Everything ran perfectly fine.

I looked at older versions of Marlin back to 2.0.7 (October 2020) and they didn’t have this code to add “/debug” to BUILD_DIR.

So I’m concluding that this addition to “PlatformIO/scripts/common-cxxflags.py” is causing the undefinedError problem when trying to use debugging.

I’m not sure which of the two things I identified are the cause of PIO_DEBUG failure

  1. Is it due to .json files in the .vscode folder not updating properly when project loads?
  2. Or due to the adding of “/debug” to BUILD_DIR, which also causes #1 to happen?

-Tony

You should file a bug in Marlin to have them fix this. It’s their script after all.

Max,

I went and filed this as a bug on Marlin github.
Thanks for your help.

Tony