I am running Ubuntu 22, Visual Studio and my target device is a ‘mkr wifi 1010’.
I have written a simple Unity test that passes in native mode.
However, when I try run the test on the target device it fails with the following message.
TimeoutError: Could not automatically find serial port for the `Arduino MKR WiFi 1010` board based on the declared HWIDs=['2341:8054', '2341:0054']
TimeoutError: Could not automatically find serial port based on the known UART bridges
Error: Please specify `upload_port` for environment or use global `--upload-port` option.
For some development platforms it can be a USB flash drive (i.e. /media/<user>/<device name>)
*** [upload] Explicit exit, status 1
Uploading stage has failed, see errors above. Use `pio test -vvv` option to enable verbose output
I can see from the that the code has been uploaded to the device successfully
My platformio settings are
For these dev boards that don’t have a permanent-on USB-to-UART chip on them, you have to give PlatformIO a little bit of delay before it tries to find the serial port.
Testing…
If you don’t see any output for the first 10 secs, please reset board (press reset button)
[Errno 2] could not open port /dev/ttyACM0: [Errno 2] No such file or directory: ‘/dev/ttyACM0’
I have noticed that after this the board is ‘stuck’ and I have to give it a hard reset (double click of the reset button to get the LED to slow flash) before I can program it again. Is there a fault in the Unity firmware?
I don’t think there is a problem with my tests because:
I can get it to work if I target a ‘nano every’
If I run the test on a ‘mkr wifi 1010’ and wait for it to fail and then open a serial port and press reset I can see the output to a successful test run
The example ‘calculator’ project also has similar issues. Generally the device does not hang but at lest one of the two test cases will fail randomly.
It looks its a problem with the device disconnecting from the port when it swaps from upload to serial port mode.
Unsurprising, because that board has a permant-on SAMD21 as the USB-to-UART (and SWD) converter and you program the actual ATMega4809 sitting behind that; but with a mrk wifi 1010, you program the SAMD21 chip directly. The SAMD21 is running your firmware and hosting the USB stack / serial port at the same time.
And that is happening even though you put the “sleep(5)” in the after_upload?
Consistent with “the project doesn’t have the delay after upload script”