Using Seeeduino XIAO BLE Sense can upload but not monitor

I’m using PIO in VS Code, and am targeting the Seeeduino XIAO BLE Sense platform. I’ve read through some related issues and PRs, specifically:

I’m new to the whole tool chain here (not an embedded dev) so it’s likely a configuration issue.

From within PIO I can upload to my target on /dev/ttyACM0, however once the upload happens the device disappears – I would post a screenshot, but I can only post one per message, so I’ll share that I see the device when I click on the extension “devices” (and see it on the OS, linux), and here is a shot of what looks like upload is working:

However, after this the device is gone from the OS and the devices link in the PIO extension doesn’t show any available ports. When I try to monitor I get asked for the port (and an empty list is given).

I will note that the device seems to work fine with the arduino ide 2, and that when I uploaded code via that route I could monitor it from within PIO.

Where should I be digging to try and understand why the device upload isn’t working correctly?

Well what is your src/main.cpp?

Apologies, I’m just using the default project main.cpp for an MWE:

#include <Arduino.h>

// put function declarations here:
int myFunction(int, int);

void setup() {
  // put your setup code here, to run once:
  int result = myFunction(2, 3);
}

void loop() {
  // put your main code here, to run repeatedly:
}

// put function definitions here:
int myFunction(int x, int y) {
  return x + y;
}

I did have a different one too that was my development code trying to use the IMU, but even this one above doesn’t seem to run.

The serial may not be autostarted. Use

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
}

void loop() {
}

instead.

I did this, but symptoms are the same. The board “unmounts” as a device after the upload, which seems to be the issue. I don’t know whether the code is running on the board or not, but the device shouldn’t need to be reset between uploads, right?

The device will reset to run the new firmware instead of the bootloader. So it will take some time until the port shows up.

Just to confirm, when you press “Upload” and only after that “Monitor”, instead of “Upload and monitor”, it also fails to find a serial port?

Right – I press upload, I wait awhile (several minutes), then hit monitor, but the device is no longer connected (no /dev/ttyACM0). Is there a configuration for uploading that I can verify works/doesn’t work? I don’t know much about the toolchain, apologies.

Weird how it finds /dev/ttyACM0 for the upload then. Or is that you manually putting the device into bootloader mode?

Do you get the same result when you use the other core instead, i.e. set

board = xiaoblesense_adafruit

in the platformio.ini?

No, I didn’t manually put it in. So when I reset the board it appears as a port file, and I can monitor it even:

So I think I must have messed up in the configuration of the device in PIO.

When I try that board (xiaoblesense_adafruit) I get an unknown board ID.

For my setup I followed the medium article that is used for this board – should I be trying to merge your PR into a copy of PIO and build it instead?

Thanks for all the help Max!

My PR superseeds the Medium article.

Upload this sketch instead

#include <Arduino.h>

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println("Hello from Xiao BLE Sense");
  delay(1000);
}

and reset the board after the upload as you did before. Does the serial monitor now output the exepcted data?

Ok, so, I must have messed up when copying from the medium article. I thought I needed to build your PR against the PIO source myself and then deploy it, but it’s way easier than that – just replacing my ini file to point to your URL and things are dynamically pulled down. Reload, and now things just work.

I’m not sure what I did wrong, but using the following platform.ini and reloading the project and things are good!


[platformio]
default_envs = xiaoblesense_arduinocore_mbed

[env]
platform = https://github.com/maxgerhardt/platform-nordicnrf52
framework = arduino

[env:xiaoblesense_arduinocore_mbed]
board = xiaoblesense

[env:xiaoblesense_adafruit_nrf52]
board = xiaoblesense_adafruit

[env:xiaoble_arduinocore_mbed]
board = xiaoble

[env:xiaoble_adafruit_nrf52]
board = xiaoble_adafruit

Thanks again for the help Max!