Bug with code compilied in platformio/VScode but works fine with platformio/atom

I don’t yet know if this is a code issue or platformio issue.

The bug is that the microcontroller (teensy4.0) hangs at line 180 here:

recval = SPI.transfer((test_read.opcode >> 8) & 0xFF);

This is external library but I can clone it and edit if necessary. The bug occurs when compiling in platformio/VSCode but there are no problems when compiling with platformio in (the now depreciated) atom IDE.

The VSCode bug has been confirmed with several linux machines, one machine is running both atom and VSCode and can compile successfully on atom but not VSCode.

All machines are using platformio version: Core: 6.1.7 Home 3.4.4
VSCode V 1.71.0
atom V1.60.0

Thanks,
Woody

Same issue with this library, compiles but doesn’t run correctly on VSCode,

I just haven’t identified which file/line yet:

That’s extremely strange considering the PlatformIO core is doing the compilation, not the IDE, and when they both have the same core and packages, they should producee the same result.

Can you see in the compilation logs for both IDEs that it’s using the same Teensy platform verison? It should be among the first 20 lines of the “Build” log.

That is interesting, there are some differences in the versions here…

Here’s the first few lines for VSCode:

Processing teensy40 (platform: teensy; board: teensy40; framework: arduino)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.18.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-arduinoteensy @ 1.158.0 (1.58) 
 - tool-teensy @ 1.158.0 (1.58) 
 - toolchain-gccarmnoneeabi-teensy @ 1.110301.0 (11.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ deep, Compatibility ~ soft
Found 106 compatible libraries
Scanning dependencies...

And here’s the first few lines for atom:

Processing teensy40 (platform: teensy; board: teensy40; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.15.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
 - framework-arduinoteensy @ 1.156.0 (1.56)
 - tool-teensy @ 1.155.0 (1.55)
 - toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ deep, Compatibility ~ soft
Found 105 compatible libraries
Scanning dependencies...

Alright, so if that version works, let’s just cut it short and change the platformio.ini from using

platform = teensy

to

platform = teensy@4.15.0

Maybe 4.16.0 and 4.17.0 work too? See releases.

The main difference between them is the version of the used Arduino-Teensy core. The core might have a regression or an incompatibility with your sketch with at least v1.58.

The compiler version also took a massive leap from 5.4.1 to 11.3.1 between these platform versions, maybe the used C++ standard version with it, so there’s a lot to watch out for.

Thank you, that really looked like it should have worked, but it hasn’t. This is the output after using

platform = teensy@4.15.0

which does differ slightly from the old one:

Processing teensy40 (platform: teensy@4.15.0; board: teensy40; framework: arduino)
--------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/teensy/teensy40.html
PLATFORM: Teensy (4.15.0) > Teensy 4.0
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 1.94MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES: 
 - framework-arduinoteensy @ 1.156.0 (1.56) 
 - tool-teensy @ 1.158.0 (1.58) 
 - toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ deep, Compatibility ~ soft
Found 106 compatible libraries
Scanning dependencies...

However there is now another problem. On the machine which had both VSCode and atom running, I tried compiling the project using VSCode for the first time today. Now the same bug is occurring when compiled by atom too, it seems to have transferred over by compiling once in VSCode. I’ve restarted, done a clean and even redownloaded the project and still not working in atom.

I’ve tried all teensy versions from 4.12 to 4.17 with no change

The package versions haven’t changed on atom, so I’m wondering is there is actually something else going on. I’m going to try reinstalling all the libraries on atom next and see if that helps

So this is still non-working, while

Was working? Well then, let’s downgrade tool-teensy too just to be sure. Can you additionally add

platform_packages =
   tool-teensy@1.155.0

to the platformio.ini and retry?

So this didn’t work fix it, however there is an incompatibility of this version with the version of linux on the newer machine, not sure if this is helpful information…

Resolving teensy40 dependencies...
Tool Manager: Installing platformio/tool-teensy @ 1.155.0
Error: Could not find the package with 'platformio/tool-teensy @ 1.155.0' requirements for your system 'linux_x86_64'

the versions of linux I’m using are, “new” machine, just VSCode:

NAME="Ubuntu"
VERSION="20.04.4 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.4 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Old machine, atom and VSCode installed:

NAME="Linux Mint"
VERSION="20.1 (Ulyssa)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 20.1"
VERSION_ID="20.1"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=ulyssa
UBUNTU_CODENAME=focal

Update,

I tried to get the same code working on arduino after the original platformio install broke, and that also failed at the same point. For now I’m going to call this a coding issue and not a platformio issue.

Still a big mystery as to how it was ever working on the older machine, but I think there’s bigger issues I need to dive into first.

Thanks for all the help anyway,
Woody

Fixed…

It was a coding issue, the above library was initialised without an SPI.begin() line which meant that the SPI failed to run, doh! The main confusion is how was it working completely fine on the older machine for years. I suspect the real bug was that is was ever working at all.

Thanks for all the assistance,
W

1 Like