Compile/upload issues with NANO 33 BLE (works with 33IOT)

Hello everyone,

First of all, I’m using Arduino IDE 1.8.12 and ArduinoBLE v1.1.2

I started coding my first BLE app using the 33 IOT and Arduino IDE to read datas from the inbuilt accelerometer from a smartphone app or a second board (I coded another program fr a “central” device). I have no issue with the 33IOT.

The thing is, for consumption, cost and efficiency reasons I want to use the 33BLE board which is supposed to work fine with ArduinoBLE lib + LSM (accelerometer) lib. This is where the problem starts:

-Compiling is really (really) slow: 5 to 10 min for a simple code (even for the BatteryMonitor example code)

#include <ArduinoBLE.h>
#include <Arduino_LSM9DS1.h>

int accelX=1;
int accelY=1;
int accelXUp=1;
float x, y, z;
bool benneLevee=true;

BLEService customService("1101");
BLEUnsignedIntCharacteristic customXChar("2101", BLERead | BLENotify);
//BLEUnsignedIntCharacteristic customYChar("2102", BLERead | BLENotify);
//BLEBoolCharacteristic customBenneLevee("2013", BLERead | BLENotify);

void setup() {
IMU.begin();
Serial.begin(9600); 

pinMode(LED_BUILTIN, OUTPUT);

if (!BLE.begin()) {
Serial.println("BLE failed to Initiate");
delay(500);
while (1);
}

BLE.setLocalName("ZenBenne");
BLE.setAdvertisedService(customService);
customService.addCharacteristic(customXChar);
  

BLE.addService(customService);

customXChar.writeValue(accelX);
//customYChar.writeValue(accelY);
//customBenneLevee.writeValue(benneLevee);

BLE.advertise();

Serial.println("Bluetooth device is now active, waiting for connections...");
}


void loop() {

BLEDevice central = BLE.central();

if (central) {
Serial.print("Connected to central: ");
Serial.println(central.address());
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("end if");

while (central.connected()) {
//delay(200);
Serial.println("while");

read_Accel();
//read_benneLevee();

if(abs(accelX-accelXUp)>5){

  
customXChar.writeValue(accelX);
Serial.println("------------------------------------------- UPDATE");
//customYChar.writeValue(accelY);
//customBenneLevee.writeValue(benneLevee);
accelXUp=accelX;

}



Serial.println("At Main Function");
Serial.println("");
Serial.print("Accel X: ");
Serial.print(accelX);


//Serial.println(benneLevee);
//if(benneLevee){
//  Serial.println(" ! BENNE LEVEE ! ");
//}
}
}




digitalWrite(LED_BUILTIN, LOW);
Serial.print("Disconnected from central: ");
Serial.println(central.address());
}

void read_Accel() {

if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);
accelX = (1+x)*100;
//accelY = (1+y)*100;

}
}

/*void read_benneLevee (){

if(accelX>10){

benneLevee=true;
}

else{

  benneLevee=false;

}
}*/

-Uploading to the board (when it works) takes around 10min

-I have these warning messages while compiling (I don’t have them with the 33IOT)

C:\Users\kylli\Documents\Arduino\libraries\ArduinoBLE\src\utility\GAP.cpp: In member function 'void GAPClass::setManufacturerData(uint16_t, const uint8_t*, int)':

C:\Users\kylli\Documents\Arduino\libraries\ArduinoBLE\src\utility\GAP.cpp:59:57: warning: variable length array 'tmpManufacturerData' is used [-Wvla]

   uint8_t tmpManufacturerData[manufacturerDataLength + 2];

                                                         ^

C:\Users\kylli\Documents\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp: In member function 'bool ATTClass::handleNotify(uint16_t, const uint8_t*, int)':

C:\Users\kylli\Documents\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp:522:39: warning: variable length array 'notification' is used [-Wvla]

     uint8_t notification[_peers[i].mtu];

                                       ^

C:\Users\kylli\Documents\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp: In member function 'bool ATTClass::handleInd(uint16_t, const uint8_t*, int)':

C:\Users\kylli\Documents\Arduino\libraries\ArduinoBLE\src\utility\ATT.cpp:552:37: warning: variable length array 'indication' is used [-Wvla]

     uint8_t indication[_peers[i].mtu];

                                     ^

^ I had to cut some because of message length limit

I guess there is an issue with the ArduinoBLE lib and the 33BLE board.

Of course, I installed the 33BLE package and selected it in the Tool menu.

I already tried to clean install the IDE, delete and reinstall the libraries, make it works on another computer: nothing is working

Please tell me if you have any clue about that…

Kyllian

[EDIT]
-The IDE sometimes crashes when I try to open the serial monitor for the NANO BLE COM port
-Compiling with 33IOT selected in Tool Menu works fine. When I change to NANO BLE it doesn’t work anymore (no board plugged for both cases)

Kyllarrior:
-Compiling is really (really) slow: 5 to 10 min for a simple code (even for the BatteryMonitor example code)

Compiling will be slower than you might like for the Nano 33 BLE because MbedOS is big, but it should definitely not take 5 to 10 minutes. A common cause of slow compilation is your antivirus software doing an on-access scan. The Arduino IDE creates a ton of short processes during the compilation, so if each of these has to wait to be scanned before running, it slows things way down.

Try TEMPORARILY disabling your antivirus for a single compilation to see if you notice that it makes it significantly faster, then turn the antivirus back on. If the compilation is faster with the antivirus off you will need to adjust the settings of your antivirus to whitelist the appropriate file, folder, or process so it doesn't interfere with compilation.

Note that the Arduino IDE does caching during compilation, so subsequent compilations will be faster than the first one. So make sure to not let that throw off your results when you are comparing compilation time.

Kyllarrior:
-Uploading to the board (when it works) takes around 10min

The Arduino IDE always compiles the sketch before uploading. When you say uploading takes around 10 minutes, do you mean the time for compilation and uploading combined, or just the uploading process alone?

Hello pert, thank you for your reply

I've tried turning off my antivirus (I'm using Windows Defender please don't shame me haha) and weirdly I'm not sure about the effect on my issue. Compiling time can is now pretty random (for the same code, same board) and sometimes crashes the IDE (I often have to delete the Java process to close it). Good thing is in good cases it takes less than 1min. Same goes for uploading: between 15s and crash.

I still have the warnings while compiling.

I'd like to have a more stable and faster use of IDE because I'm spending too much time on this issue.

In short, antivirus made it slightly better but it sometimes is still too long (especially the first compile after I re-open the IDE)

PS: As I read if the main help thread I have these COM ports switching thing and I need to switch the port to check the Serial Monitor after an upload. I know it should be normal but can it be a reason for my issues ?

Thanks again,

Kyllian

Kyllarrior:
sometimes crashes the IDE

Strange. I haven’t seen reports of that. To investigate this, you can start the Arduino IDE by running arduino_debug.exe from the command line:

  • Start File Explorer (AKA Windows Explorer).
  • Open the Arduino IDE’s installation folder (usually C:\Program Files (x86)\Arduino)
  • In the folder listing of the Arduino IDE installation folder, hold the Shift key while clicking the right hand button on the mouse.
  • Click “Open PowerShell window here” (or “Open command window here” if using Windows 7). PowerShell (or cmd if using Windows 7) will now open with the current directory set to the Arduino IDE installation folder.
  • Type ./arduino_debug
  • Press Enter. Debug output should now be printed to the PowerShell window as the Arduino IDE starts (or fails to start).
  • Wait for the Arduino IDE to finish starting, or failing to start.
  • Switch back to the PowerShell window if the Arduino IDE window took the focus.
  • Right click on the title bar of the PowerShell window.
  • Click Edit > Select All. This will select all the text in the PowerShell window.
  • Press Ctrl + c. This will copy the contents of the PowerShell window to the clipboard.
  • In this Arduino forum thread, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum’s code tags markup to your reply, making it easier for us to read.
  • Press Ctrl + V. This will paste the output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Click the “Post” button.

Hopefully that will give us some information we can use to help you with the problem.

Kyllarrior:
I still have the warnings while compiling.

I think it’s probably nothing to worry about. It is interesting that we get that warning when compiling for Nano 33 BLE, but not when compiling for the SAMD boards. I messed around a little trying to find what causes this different behavior, but I didn’t find it.

Kyllarrior:
I’d like to have a more stable and faster use of IDE because I’m spending too much time on this issue.

An alternative would be to use the Arduino Web Editor:
https://create.arduino.cc/editor

Kyllarrior:
PS: As I read if the main help thread I have these COM ports switching thing and I need to switch the port to check the Serial Monitor after an upload. I know it should be normal but can it be a reason for my issues ?

It’s quite annoying, but I don’t believe it’s related to the slow compilation or the IDE crashes.

Do you have a CREATE account ?
If so could you try a compile and upload from that as Per suggests
Just tried your sketch here and it has no problems. for either the BLE or IOT

Also just tried 1.8.12 and initial compile was approx 3.5 minutes and a subsequent compile was clearly quicker< 1 minute due to the advanced cache used by the IDE for the BLE.
That would indicate a local error (which is what you are seeing).

I am running windows 7 x64 pro here btw as a full blown ADMINISTRATOR.
Have you made any changes to your OS in terms of services running or registry ?

Any issues with the COM port can often be addressed by uploading the BLINK or BARE MINIMUM examples. (quickly double tap the RESET button to put it in BOOTLOADER MODE.
This will often clear any errant features / issues caused by a previous sketch.

Currently also using core 1.1.4 for the BLE so you may want to update and see if that helps.
And 1.8.3 for the IOT

Bob.

PS. The BLE does have some slowness caused by two factors.
First is that it is MBED which means a lot of extra work is involved for the IDE
Second is that it is still a relatively new board in the grand scheme of things and as time (not too much hopefully) progresses they usually combine or streamline some options with newer cores.

I dont see any errors or warnings at all here with the sketch BTW

Per is especially good at spotting IDE errors so please do as he asks for the debug log.

Bob.

Hello. It has been 3 or 4 months since my Arduino IDE started to compile extremely slowly. I am now trying to compile on a bluepill with Arduino Core STM32 and it is simply impossible to use, since it takes more than 10 minutes /compilation.

Here is the zip file of the log as suggested (more than 9000 characters). Thanks:

Log_Starting_Arduino_1.8.12.zip (7.86 KB)