0

Trouble loading Arduino code on Grand Central M4
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Trouble loading Arduino code on Grand Central M4

by quarkz2 on Fri Jun 14, 2019 5:43 pm

2thru6.JPG
2thru6.JPG (954.24 KiB) Viewed 261 times
I do know if this is in the same vein as "0/2 on Getting Either of the Grand Centrals to Work".

Over time I purchased six Grand Central Boards. After building hardware, I just got started on porting my old code that ran on 3 UNOs to the Grand Central.
But first I tried the circuitpython tutorial out on 1 board.
When I tried going back to Arduino I followed the tutorial. I have the IDE setup so it has the Grand Central SAMD51 listed and selected under the board manager.
I have downloaded the Win7 drivers.
I did the double click to put the boards into GCM4BOOT, then drug the update-bootloader-grandcentral_m4-v3.3.0-adafruit.10.uf2 file onto the GCM4BOOT drive.
In Windows 7, looking at the device manager, I see two new COM ports Adafruit GCM4 Express UF2 bootloader (com 36) and Adafruit GCM4 Express UF2 web USB dummy (com 37).
In the IDE only com36 is selectable, so I select com36 and upload the blink sketch to the M4.
In the error window of the IDE I get:

Code: Select all | TOGGLE FULL SIZE
Sketch uses 13064 bytes (1%) of program storage space. Maximum is 1032192 bytes.
Device       : ATSAMD51x20
Version      : v1.1 [Arduino:XYZ] Apr 14 2019 22:38:13
Address      : 0x0
Pages        : 2048
Page Size    : 512 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 32
Locked       : none
Security     : false
BOD          : false
BOR          : true
Write 13336 bytes to flash (27 pages)

[                              ] 0% (0/27 pages)
[========                      ] 29% (8/27 pages)
[=================             ] 59% (16/27 pages)
[==========================    ] 88% (24/27 pages)
[==============================] 100% (27/27 pages)
Done in 0.156 seconds
Verify 13336 bytes of flash

[=                             ] 3% (1/27 pages)
[==                            ] 7% (2/27 pages)
[===                           ] 11% (3/27 pages)
[====                          ] 14% (4/27 pages)
[=====                         ] 18% (5/27 pages)
[======                        ] 22% (6/27 pages)
[=======                       ] 25% (7/27 pages)
[========                      ] 29% (8/27 pages)
[==========                    ] 33% (9/27 pages)
[===========                   ] 37% (10/27 pages)
[============                  ] 40% (11/27 pages)
[=============                 ] 44% (12/27 pages)
[==============                ] 48% (13/27 pages)
[===============               ] 51% (14/27 pages)
[================              ] 55% (15/27 pages)
[=================             ] 59% (16/27 pages)
[==================            ] 62% (17/27 pages)
[====================          ] 66% (18/27 pages)
[=====================         ] 70% (19/27 pages)
[======================        ] 74% (20/27 pages)
[=======================       ] 77% (21/27 pages)
[========================      ] 81% (22/27 pages)
[=========================     ] 85% (23/27 pages)
[==========================    ] 88% (24/27 pages)
[===========================   ] 92% (25/27 pages)
[============================  ] 96% (26/27 pages)
[==============================] 100% (27/27 pages)
Verify successful
Done in 0.092 seconds


In the device manager COM36 and 37 Disappear, then in the IDE error window, the following is added.

Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload.

Pressing the reset button has no affect, it doesn't seem to cut power to the green POWER LED or the now green neopixle.
The Red RX LED fades up and down.

I tried the same Arduino IDE setup for the other GCM4 boards, some took the blink sketch and It would revert to 1 com port, different from the two GCM4BOOT COM ports.

But then when I went to load another sketch I am testing, the sketch would seem to upload, then after a second or two that new com port would disappear from the device manager, and then generate the same 'board could not be found' error in the IDE error window.

Code: Select all | TOGGLE FULL SIZE
Sketch uses 28548 bytes (2%) of program storage space. Maximum is 1032192 bytes.
Device       : ATSAMD51x20
Version      : v1.1 [Arduino:XYZ] Dec 30 2018 21:24:00
Address      : 0x0
Pages        : 2048
Page Size    : 512 bytes
Total Size   : 1024KB
Planes       : 1
Lock Regions : 32
Locked       : none
Security     : false
BOD          : false
BOR          : true
Write 29860 bytes to flash (59 pages)

[                              ] 0% (0/59 pages)
[====                          ] 13% (8/59 pages)
[========                      ] 27% (16/59 pages)
[============                  ] 40% (24/59 pages)
[================              ] 54% (32/59 pages)
[====================          ] 67% (40/59 pages)
[========================      ] 81% (48/59 pages)
[============================  ] 94% (56/59 pages)
[==============================] 100% (59/59 pages)
Done in 0.356 seconds
Verify 29860 bytes of flash

[=                             ] 3% (2/59 pages)
[=                             ] 5% (3/59 pages)
[==                            ] 6% (4/59 pages)
[==                            ] 8% (5/59 pages)
[===                           ] 10% (6/59 pages)
[===                           ] 11% (7/59 pages)
[====                          ] 13% (8/59 pages)
[====                          ] 15% (9/59 pages)
[=====                         ] 16% (10/59 pages)
[=====                         ] 18% (11/59 pages)
[======                        ] 20% (12/59 pages)
[======                        ] 22% (13/59 pages)
[=======                       ] 23% (14/59 pages)
[=======                       ] 25% (15/59 pages)
[========                      ] 27% (16/59 pages)
[========                      ] 28% (17/59 pages)
[=========                     ] 30% (18/59 pages)
[=========                     ] 32% (19/59 pages)
[==========                    ] 33% (20/59 pages)
[==========                    ] 35% (21/59 pages)
[===========                   ] 37% (22/59 pages)
[===========                   ] 38% (23/59 pages)
[============                  ] 40% (24/59 pages)
[============                  ] 42% (25/59 pages)
[=============                 ] 44% (26/59 pages)
[=============                 ] 45% (27/59 pages)
[==============                ] 47% (28/59 pages)
[==============                ] 49% (29/59 pages)
[===============               ] 50% (30/59 pages)
[===============               ] 52% (31/59 pages)
[================              ] 54% (32/59 pages)
[================              ] 55% (33/59 pages)
[=================             ] 57% (34/59 pages)
[=================             ] 59% (35/59 pages)
[==================            ] 61% (36/59 pages)
[==================            ] 62% (37/59 pages)
[===================           ] 64% (38/59 pages)
[===================           ] 66% (39/59 pages)
[====================          ] 67% (40/59 pages)
[====================          ] 69% (41/59 pages)
[=====================         ] 71% (42/59 pages)
[=====================         ] 72% (43/59 pages)
[======================        ] 74% (44/59 pages)
[======================        ] 76% (45/59 pages)
[=======================       ] 77% (46/59 pages)
[=======================       ] 79% (47/59 pages)
[========================      ] 81% (48/59 pages)
[========================      ] 83% (49/59 pages)
[=========================     ] 84% (50/59 pages)
[=========================     ] 86% (51/59 pages)
[==========================    ] 88% (52/59 pages)
[==========================    ] 89% (53/59 pages)
[===========================   ] 91% (54/59 pages)
[===========================   ] 93% (55/59 pages)
[============================  ] 94% (56/59 pages)
[============================  ] 96% (57/59 pages)
[============================= ] 98% (58/59 pages)
[==============================] 100% (59/59 pages)
Verify successful
Done in 0.217 seconds
Couldn't find a Board on the selected port. Check that you have the correct port selected.  If it is correct, try pressing the board's reset button after initiating the upload.
Attachments
board1.jpg
board1.jpg (958.67 KiB) Viewed 261 times

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by quarkz2 on Fri Jun 14, 2019 6:35 pm

Is the GCM4 programming USB port sharing GPIO pins 11, 14, 15, 18, 19, like the RX/TX pins, 0 & 1, did on the Uno boards?
Attachments
gcm4_usb.png
gcm4_usb.png (10.89 KiB) Viewed 256 times

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by adafruit_support_carter on Fri Jun 14, 2019 7:28 pm

It sounds like you have 6 total Grand Central boards? Can you clarify how many of those 6 are showing this issue.

adafruit_support_carter
 
Posts: 12991
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble loading Arduino code on Grand Central M4

by quarkz2 on Mon Jun 17, 2019 2:55 pm

Only 1 board has the upside down xtal osc.
The other 5 have the problem of losing the COM port, established by downloading the BLINK sketch after being in GCM4BOOT.

Here is the patch work code that I load after loading BLINK.
This code works on an UNO.
The code will finish loading, make a non-GCM4BOOT com port, then after a few seconds removes the new com port and say the board can not be found..


Code: Select all | TOGGLE FULL SIZE
//Updated: April 9, 2018 at 5:23 PM
//The BME280's I2C address is 0x77.

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1305.h>
#include <K30_I2C.h>

// Used for I2C
#define OLED_RESET 15 //pin A1
Adafruit_SSD1305 display(OLED_RESET);

int flowPin = A0;
int flow =0;
int flowIn =0;
int count =0;
int leftOver = 0;
int timeLeft = 0;

const unsigned long thirtyMinutes = 30 * 60 *1000UL;
static unsigned long lastSampleTime = 0 - thirtyMinutes;  // initialize such that a reading is due the first time through loop()

K30_I2C k30_i2c = K30_I2C(0x69);
int co2 = 0;
int rc  = 1;


//#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C

unsigned long delayTime;

void setup() {
  Serial.begin(9600);
  display.begin();
  Serial.println(F("BME280 test"));

  bool status;

  // default settings
  status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }

  Serial.println("-- Default Test --");
  delayTime = 1000;

  Serial.println();

  delay(100); // let sensor boot up
}


void loop() {
  rc = k30_i2c.readCO2(co2);
//  flowValue();
  printValues();
//  if (millis() - lastDiplayTime > sampleInterval

 
 
  displayValues();
}
 
//********************************************* OLED (SSD1305)PRINT **************************************************
void displayValues() {
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextWrap(false);
  display.setCursor(0, 0);

  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.println("         VLAD         ");
 
  display.setTextColor(WHITE);
  display.println(" ");
  display.print("Temp:");
  display.print(bme.readTemperature());
  display.println("C ");
  display.print("% RH:");
  display.println(bme.readHumidity());

  //display.print("Pres   : ");
  //display.print(bme.readPressure() / 100.0F);
  //display.println(" hPa");
 
  //display.print("Flow= ");
  //display.print(flowIn);
  //display.println(" sccm");

  if (rc == 0){
  display.print("CO2: ");
  display.print(co2);
  display.println(" ppm");
  } else{
    display.print("CO2 reading failed\n"); 
  }
  //display.println("\n");
  delay(3000); //time between readings = 3 second
 
 

  leftOver = ((thirtyMinutes - millis()) / 1000);
  if (leftOver <= 1000) { count=count+1;}
  display.print("Time Left : ");
  display.print(leftOver);
  display.println(" sec");

   display.print("Sample # ");
  display.println(count);

  display.display();
  display.clearDisplay();
 
 
  }

//********************************************* SERIAL PRINT **************************************************
void printValues() {
  rc = k30_i2c.readCO2(co2);
  if (rc == 0){
    Serial.println("Succesful reading");
    Serial.print("flow = "); Serial.print(flow); Serial.print("flowIn = "); Serial.print(flowIn); Serial.print("\tCO2 Concentration = "); Serial.print(co2); Serial.println(" ppm");
     
//    Serial.print("Humidity:    "); Serial.print(sensor.readHumidity(), 2);
//  Serial.print("\tTemperature: "); Serial.println(sensor.readTemperature(), 2);
 // Serial.print("Count- ");Serial.println(count);
   //  printValues();
 
  } else{
    Serial.print("Failure to read sensor\n"); 
  }
  Serial.println("\n");
  delay(3000); //time between readings

  //Serial.print("Temperature = ");Serial.print(bme.readTemperature());Serial.println(" *C");
  //Serial.print("Pressure = ");Serial.print(bme.readPressure() / 100.0F);Serial.println(" hPa");
//  Serial.print("Approx. Altitude = ");Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));Serial.println(" m");
  //Serial.print("Humidity = ");Serial.print(bme.readHumidity());Serial.println(" %");
 
  Serial.println();
  Serial.println(leftOver);

}


Thanks looking into this adafruit_support_carter.

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by adafruit_support_carter on Mon Jun 17, 2019 2:59 pm

The upside down xtal is definitely an issue. For the other boards, I'm not sure I follow what the issue is. Do they upload and run the blink example OK?
https://learn.adafruit.com/adafruit-gra ... blink-6-21

adafruit_support_carter
 
Posts: 12991
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble loading Arduino code on Grand Central M4

by quarkz2 on Mon Jun 17, 2019 3:35 pm

Yes, the other 5 boards will upload BLINK from the example in the Arduino IDE and run.

A new, different non-GCM4BOOT COM port will be established.


The problem is when I go to load the next sketch (after BLINK), now that the COM port has been established, the IDE error window says the sketch has loaded.

In the error widow the IDE displays:

Verify successful
Done in 0.217 seconds


Then within a couple of second of that message in the IDE error window, the GCM4 board will try to reboot.
Fail, remove the just established com port and send the error

Couldn't find a Board on the selected port. Check that you have the correct port selected. If it is correct, try pressing the board's reset button after initiating the upload."


Code: Select all | TOGGLE FULL SIZE
/*
  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/Blink
*/

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by adafruit_support_carter on Mon Jun 17, 2019 4:43 pm

What about two uploads of Blink in a row? Change the blink rate, upload the change, etc. Can you do that over and over OK?

adafruit_support_carter
 
Posts: 12991
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble loading Arduino code on Grand Central M4

by quarkz2 on Wed Jun 19, 2019 4:50 pm

Yes, I can load BLINK multiple times, changing the length of delay each time, and not have the COM port disapear.

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by adafruit_support_carter on Wed Jun 19, 2019 8:31 pm

It sounds like something specific to that other sketch then. Can you post the full code listing for it.

adafruit_support_carter
 
Posts: 12991
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble loading Arduino code on Grand Central M4

by quarkz2 on Wed Jun 19, 2019 9:21 pm

Thanks.

Code: Select all | TOGGLE FULL SIZE
//Updated: April 9, 2018 at 5:23 PM
//The BME280's I2C address is 0x77.

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Adafruit_SSD1305.h>
#include <K30_I2C.h>

// Used for I2C
#define OLED_RESET 15 //pin A1
Adafruit_SSD1305 display(OLED_RESET);

int flowPin = A0;
int flow =0;
int flowIn =0;
int count =0;
int leftOver = 0;
int timeLeft = 0;

const unsigned long thirtyMinutes = 30 * 60 *1000UL;
static unsigned long lastSampleTime = 0 - thirtyMinutes;  // initialize such that a reading is due the first time through loop()

K30_I2C k30_i2c = K30_I2C(0x69);
int co2 = 0;
int rc  = 1;


//#define SEALEVELPRESSURE_HPA (1013.25)

Adafruit_BME280 bme; // I2C

unsigned long delayTime;

void setup() {
  Serial.begin(9600);
  display.begin();
  Serial.println(F("BME280 test"));

  bool status;

  // default settings
  status = bme.begin();
  if (!status) {
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }

  Serial.println("-- Default Test --");
  delayTime = 1000;

  Serial.println();

  delay(100); // let sensor boot up
}


void loop() {
  rc = k30_i2c.readCO2(co2);
//  flowValue();
  printValues();
//  if (millis() - lastDiplayTime > sampleInterval

 
 
  displayValues();
}
 
//********************************************* OLED (SSD1305)PRINT **************************************************
void displayValues() {
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextWrap(false);
  display.setCursor(0, 0);

  display.setTextColor(BLACK, WHITE); // 'inverted' text
  display.println("         VLAD         ");
 
  display.setTextColor(WHITE);
  display.println(" ");
  display.print("Temp:");
  display.print(bme.readTemperature());
  display.println("C ");
  display.print("% RH:");
  display.println(bme.readHumidity());

  //display.print("Pres   : ");
  //display.print(bme.readPressure() / 100.0F);
  //display.println(" hPa");
 
  //display.print("Flow= ");
  //display.print(flowIn);
  //display.println(" sccm");

  if (rc == 0){
  display.print("CO2: ");
  display.print(co2);
  display.println(" ppm");
  } else{
    display.print("CO2 reading failed\n");
  }
  //display.println("\n");
  delay(3000); //time between readings = 3 second
 
 

  leftOver = ((thirtyMinutes - millis()) / 1000);
  if (leftOver <= 1000) { count=count+1;}
  display.print("Time Left : ");
  display.print(leftOver);
  display.println(" sec");

   display.print("Sample # ");
  display.println(count);

  display.display();
  display.clearDisplay();
 
 
  }

//********************************************* SERIAL PRINT **************************************************
void printValues() {
  rc = k30_i2c.readCO2(co2);
  if (rc == 0){
    Serial.println("Succesful reading");
    Serial.print("flow = "); Serial.print(flow); Serial.print("flowIn = "); Serial.print(flowIn); Serial.print("\tCO2 Concentration = "); Serial.print(co2); Serial.println(" ppm");
     
//    Serial.print("Humidity:    "); Serial.print(sensor.readHumidity(), 2);
//  Serial.print("\tTemperature: "); Serial.println(sensor.readTemperature(), 2);
 // Serial.print("Count- ");Serial.println(count);
   //  printValues();
 
  } else{
    Serial.print("Failure to read sensor\n");
  }
  Serial.println("\n");
  delay(3000); //time between readings

  //Serial.print("Temperature = ");Serial.print(bme.readTemperature());Serial.println(" *C");
  //Serial.print("Pressure = ");Serial.print(bme.readPressure() / 100.0F);Serial.println(" hPa");
//  Serial.print("Approx. Altitude = ");Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));Serial.println(" m");
  //Serial.print("Humidity = ");Serial.print(bme.readHumidity());Serial.println(" %");
 
  Serial.println();
  Serial.println(leftOver);

}

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by adafruit_support_carter on Thu Jun 20, 2019 4:00 pm

Nothing super obvious. But there can possibly be user code running that interferes with the software reset when uploading a new sketch. If you can get it to reliably upload by going into bootloader each time, then that may be what you'll have to do for your project.

adafruit_support_carter
 
Posts: 12991
Joined: Tue Nov 29, 2016 2:45 pm

Re: Trouble loading Arduino code on Grand Central M4

by quarkz2 on Thu Jun 20, 2019 4:17 pm

Thanks for looking at it. Did you get it to recreate the problem, causing your GCM4 to drop the usb COM port?

In my GCM4 version, I think I will be trying to control the OLED via the hardwired, not software, SPI header on the board.

With the GCs M4 chip is the usb port on its own set of pins, isolating it from any of the multi-use GPIO pins, or the I2C & SPI ports?

Also can I get an RMA for the 1st board that has the xtal osc soldered on upside down?

Thanks for doing a thankless job 'adafruit_support_carter'.

quarkz2
 
Posts: 7
Joined: Fri Aug 18, 2017 4:44 pm

Re: Trouble loading Arduino code on Grand Central M4

by adafruit_support_carter on Thu Jun 20, 2019 4:27 pm

Did you get it to recreate the problem, causing your GCM4 to drop the usb COM port?

I don't have that K30_I2C.h library, so couldn't test fully. But I've seen this general behavior before on other M0/M4 boards where the USB is hosted by the main chip.

With the GCs M4 chip is the usb port on its own set of pins, isolating it from any of the multi-use GPIO pins, or the I2C & SPI ports?

Yep. You can check schematic here.
https://learn.adafruit.com/adafruit-gra ... atics-35-2

Also can I get an RMA for the 1st board that has the xtal osc soldered on upside down?

Totes. And if you're up for it, you could probably get it working with some light solder work and flipping the crystal back over. But it shouldn't have arrived like that, so on us to replace.

Send an email to support@adafruit.com with a link to this thread and they can send you a replacement Grand Central M4.

adafruit_support_carter
 
Posts: 12991
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.


cron