So yes that works and it successfuly flashes the board.
Tests don’t run though and hangs forever:
> Executing task: C:\Users\tornt\.platformio\penv\Scripts\platformio.exe test <
Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items
Processing * in 5gnbiot environment
--------------------------------------------------------------------------------------------------------------------------------------------------Building...
Uploading...
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
Boards where the USB serial is implemented by the target chip and is thus is “unstable” in the sense that after flashing it ejects the USB serial device and gets connected after a time needs special care. The first one is while(!Serial){} as the first line in setup() to prevent anything being sent before the serial monitor is opened, second, a delay per point 3 in Redirecting... and before attempting to open the serial monitor, see Teensy 4.1 Unit Testing Issue - #5 by maxgerhardt for the technique.
But on a more basic level, did you test that Serial outputs something in the main firmware before trying to test? Pin mappings might be different.
It looks like its SerialUSB instead, so this works in main:
#define Serial SerialUSB
void setup() {
Serial.begin(115200);
while(!Serial);
Serial.println("setup");
}
But adding that #define Serial SerialUSB in test_main.cpp doesn’t fix the tests to run. And adding those delays in extra_script.py and the start of the test_main.cpp setup don’t help either.
Then the board can’t be treated as a pin-compatible Arduino Zero and the issue needs to be resolved by actually using their modified arduino core + variant. I’ll have a look at it.
Yes it doesn’t seem quite compatible - this is another sketch that works when running in the Arduino IDE but doesn’t work from main in PlatformIO - in the Arduino IDE it does power on the cellular modem which then after a moment outputs RDY on the serial port and then will respond to AT commands, but from PlatformIO no RDY and no response:
Yes that works and blinky outputs text and flashes the LEDs, and the more complicated sketch can talk to the modem and get GPS output.
Great, thank you!
I still can’t get Unity tests to work though and they just hang. It feels like maybe there is just somewhere else I need to configure serial to be SerialUSB. Any ideas?
Turns out if I add test_transport = custom to platformio.ini and then have a unittest_transport.h as below in the test directory then it all works. So great (though it would be nicer if it didn’t need the custom transport).
That’s because PlatformIO, with no test_transport explicitly set, defaults to using Serial as the unit testing serial ,not SerialUSB – sadly this is non-configurable and everything else needs the custom transport protocol. That could actually be improved by letting the user specify the serial object…
That breaks things for me and the build fails with lots of errors:
c:/users/tornt/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\tornt\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\libunity.a(unity.c.obj):/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/unity/unity/src/unity.c:56: multiple definition of UnityStrErrFloat’; .pio\build\ql-uecc\libe4e\libUnity.a(unity.c.o):C:\CQ\quarklink-client/.pio/libdeps/ql-uecc/Unity/src/unity.c:61: first defined here`
Now hunting aorund for how to go back to the non-dev version of platformio…