SSL troubles with Metro M4 + Airlift shield

For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

I have a Metro M4 board with an Airlift shield stacked on top, and my goal is to POST some simple data to an API endpoint on a web app I deployed to Netlify.

I installed Adafruit's WiFiNINA library as described in the docs. When I use the WiFININA > WiFiWebClient sketch and try to just do a plain GET request just to test my endpoint's URL, I get a 301 response that points to the HTTPS URL for the endpoint. When I try to use the WiFiSSLClient sketch to connect instead, the sketch just hangs until eventually timing out and moving on.

After doing some reading, it sounds like I need to upload the SSL certificate for Netlify to the board somehow, but I spent a couple hours trying to do that this morning and got super lost. I can't upload the FirmwareUpdater sketch from the custom Adafruit library because of some build errors (missing SerialNina, NINA_GPIO0, NINA_RESETN). That led me to this thread where the author tried using WiFiNINA_Generic, so I tried that. After following the complex installation instructions, I tried uploading the FirmwareUpdater board and it "bricked" my M4. Luckily double-tapping the board's reset button made it so I could upload a different sketch to undo that. Eventually I got rid of that WiFiNINA_Generic library and reverted back to the Adafruit WiFiNINA library and replicated each of the original issues to verify it was working OK.

Am I correct that I need to install an SSL cert on the board to access my Netlify endpoint? If so, how exactly would I do that with the Metro M4 and Airlift shield? If not, what might be going on here and how can I troubleshoot?

Note: the hostname of the endpoint in all the samples below has been changed to my-app.netlify.app just for safety. I have verified with Postman that it is working as expected.

Relevant code from the WiFiWebClient sketch:

Code: Select all

Serial.println("\nStarting connection to server...");
if (client.connect("my-app.netlify.app", 80)) {
  client.println("GET /api/swipe HTTP/1.1");
  client.println("Host: my-app.netlify.app");
  client.println("Connection: close");
  client.println();
}
Response from server:

Code: Select all

Starting connection to server...
HTTP/1.1 301 Moved Permanently
Location: https://my-app.netlify.app/api/swipe
Server: Netlify
X-Nf-Request-Id: 01GMR89XZS2NXFC33PQVTH6T0K
Date: Tue, 20 Dec 2022 17:11:38 GMT
Content-Length: 65
Content-Type: text/plain; charset=utf-8
So then I switched to the WiFiSSLClient sketch and updated it accordingly, hoping that it'll make the HTTPS connection. Here's the relevant code from that:

Code: Select all

Serial.println("\nStarting connection to server...");
if (client.connect("my-app.netlify.app", 443)) {
  client.println("GET /api/swipe HTTP/1.1");
  client.println("Host: my-app.netlify.app");
  client.println("Connection: close");
  client.println();
}
But this time all I get is the "starting connecting" message until eventually the server disconnects.

Code: Select all

Starting connection to server...

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by mikeysklar »


User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

I do not. I assumed it was the latest since I bought it just a couple weeks ago. I just uploaded the sketch WiFiNINA > Tools > CheckFirmwareVersion and this is what was printed to my serial monitor:

Code: Select all

Firmware version installed: 1.2.2
Latest firmware version available : 1.2.1

Check result: PASSED
Out of curiosity I followed the instructions in the first link to upload the Metro_M4_WiFi_ESP32_Passthru.UF2 bootloader to my M4 board. After that I tried to use the ESPTool web app to connect to my board, but the tool keeps telling me to do a "hard reset". I've tried pressing the reset button the M4 before, during, and after hitting the Connect button but keep getting the same message (attached). Any ideas?
Attachments
download.png
download.png (40.91 KiB) Viewed 311 times

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by mikeysklar »

1.7.4 is the latest nina-fw from Adafruit. You can see the releases here:

https://github.com/adafruit/nina-fw/releases

What OS / browser are you using for the Adafruit Web Serial ESPTool? I did see a weird issue where it failed with the screen you are seeing, but 10 minutes later started working.

User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

Got it! Which bootloader should I use? I'm using a Metro M4 with an Airlift shield stacked on top. Should I be following these instructions for an external Airlift setup? https://learn.adafruit.com/upgrading-es ... ut-3124207

I'm on Win10 + Chrome 108. Once I sort out this bootloader stuff I'll try again and be sure to wait a while.

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by mikeysklar »

The current bootloader for the Metro M4 is v3.14.0

https://github.com/adafruit/uf2-samdx1/ ... 3.14.0.uf2

Yes, I believe the "external" airlift instructions are the correct ones for your shield setup. I know it is confusing with Metro built-in Airlift and Shield option.

User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

I might be misunderstanding this, but it seems like there are alternative "passthru" bootloaders (UF2 files?) provided throughout the instructions page, and I need to install one of those first (after soldering three jumpers on the Airlift shield)? I'd share a link to the section I'm talking about, but it looks like there are duplicate IDs that are breaking anchor links for the "Upload Passthrough Code" headings. Start at this heading, then scroll down to its Upload Passthrough Code subheading: https://learn.adafruit.com/upgrading-es ... ng-3124196

My guess is that I should install the "Feather M0/M4 Passthrough UF2" bootloader/UF2, but I definitely want to confirm before messing with it haha. The red alert box doesn't mention the Airlift shield, but the section it says should be used for "different hardware" feels like less of a fit.

(Side note, this page could use a little TLC to correct the invalid heading hierarchy and duplicate IDs! There are lots of similar, but crucially different subsections too, so I wonder if breaking the content up into multiple subpages would help folks out in the future?)

User avatar
mikeysklar
 
Posts: 13936
Joined: Mon Aug 01, 2016 8:10 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by mikeysklar »

These instructions really don't say which way to go with the Metro M4 + Shield. I'll ask the guide author for guidance.

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by brubell »

Could you please take a photo of the BACK of your AirLift shield and attach it to this thread?

User avatar
claytercek
 
Posts: 1
Joined: Tue Jan 03, 2023 2:23 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by claytercek »

Hey folks! I'm working with @jasonwebb on this. Attached are images of the front and back of one of the airlift shields we're working with.
Attachments
front of board
front of board
IMG_5201.jpg (970.95 KiB) Viewed 247 times
back of board
back of board
IMG_5200.jpg (355.48 KiB) Viewed 247 times

User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

@brubell just following up on this! Based on the images that @claytercek provided above, what bootloader should we upload to the M4 board in order to run the passthrough sketch for upgrading the AirLift firmware?

In addition the bootloader change, it looks like we'll also need to solder three SMD jumpers on the AirLift boards before attempting to upgrade the AirLift firmware. But from the provided image (attached), I'm not 100% sure which three jumpers to solder. Maybe the ones on pins 4, 5, and 6 (SD, RST, and G0)?
Attachments
wireless_airliftshield.png
wireless_airliftshield.png (568.43 KiB) Viewed 234 times

User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

I tried a couple more things to see if I could make any headway on this, but no luck so far.
  1. I've uploaded both the Feather M0/M4 Passthrough UF2 and Metro_M4_WiFi_ESP32_Passthru.UF2, then tried the following for each.
  2. I uploaded the passthru Arduino sketch provided in the "Upgrading an external board" section.
  3. I soldered the jumpers on pins 4, 5, and 6 of the Airlift shield.
  4. I then noticed that the guide specifically names the pins ESP32_ResetN, ESP32 GPIO0, RXI, and TXO, which seem to correspond with pins 5, 6, 1, and 0 on the Airlift shield. So I tried soldering the jumpers on those to see what would happen.
Each time I received the same error as above in the ESPTool app.

User avatar
brubell
Learn User Page
 
Posts: 2010
Joined: Fri Jul 17, 2015 10:33 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by brubell »

Ok, you've tried a bunch of things and I'm not sure what the board currently looks like.

Could you post a picture of the BACK of your AirLift shield again?

Also paste the passthru arduino sketch you uploaded in step 2. Have you tried re-uploading this sketch since soldering the jumpers?

User avatar
jasonwebb
 
Posts: 111
Joined: Sat Sep 10, 2011 2:15 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by jasonwebb »

Currently I have the jumpers on pins 0,1,5,6 soldered (photo attached). Before this I had pins 0,1,6 soldered. Earlier I had no jumpers soldered.

Each time I changed the jumpers, I tried both the Feather M0/M4 Passthrough UF2 bootloader and the Metro_M4_WiFi_ESP32_Passthru.UF2 bootloader and the following Arduino sketch (found here):

Code: Select all

// SPDX-FileCopyrightText: 2018 Arduino SA 
//
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
  SerialNINAPassthrough - Use esptool to flash the ESP32 module
  For use with PyPortal, Metro M4 WiFi...

  Copyright (c) 2018 Arduino SA. All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or BANNED FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#include <Adafruit_NeoPixel.h>

unsigned long baud = 115200;

#if defined(ADAFRUIT_FEATHER_M4_EXPRESS) || \
  defined(ADAFRUIT_FEATHER_M0_EXPRESS) || \
  defined(ARDUINO_AVR_FEATHER32U4) || \
  defined(ARDUINO_NRF52840_FEATHER) || \
  defined(ADAFRUIT_ITSYBITSY_M0) || \
  defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) || \
  defined(ARDUINO_AVR_ITSYBITSY32U4_3V) || \
  defined(ARDUINO_NRF52_ITSYBITSY) || \
  defined(ARDUINO_PYGAMER_M4_EXPRESS)
  // Configure the pins used for the ESP32 connection
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS    13   // Chip select pin
  #define ESP32_RESETN  12   // Reset pin
  #define SPIWIFI_ACK   11   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   10
  #define NEOPIXEL_PIN   8
#elif defined(ARDUINO_AVR_FEATHER328P)
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS     4   // Chip select pin
  #define ESP32_RESETN   3   // Reset pin
  #define SPIWIFI_ACK    2   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   -1
  #define NEOPIXEL_PIN   8
#elif defined(TEENSYDUINO)
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS     5   // Chip select pin
  #define ESP32_RESETN   6   // Reset pin
  #define SPIWIFI_ACK    9   // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   -1
  #define NEOPIXEL_PIN   8
#elif defined(ARDUINO_NRF52832_FEATHER )
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI  // The SPI port
  #define SPIWIFI_SS    16  // Chip select pin
  #define ESP32_RESETN  15  // Reset pin
  #define SPIWIFI_ACK    7  // a.k.a BUSY or READY pin
  #define ESP32_GPIO0   -1
  #define NEOPIXEL_PIN   8
#elif !defined(SPIWIFI_SS)  // if the wifi definition isnt in the board variant
  // Don't change the names of these #define's! they match the variant ones
  #define SerialESP32   Serial1
  #define SPIWIFI       SPI
  #define SPIWIFI_SS    10   // Chip select pin
  #define SPIWIFI_ACK    7   // a.k.a BUSY or READY pin
  #define ESP32_RESETN   5   // Reset pin
  #define ESP32_GPIO0   -1   // Not connected
  #define NEOPIXEL_PIN   8
#endif

#if defined(ADAFRUIT_PYPORTAL)
  #define PIN_NEOPIXEL   2
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
  #define PIN_NEOPIXEL   40
#endif

Adafruit_NeoPixel pixel = Adafruit_NeoPixel(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(baud);
  pixel.begin();
  pixel.setPixelColor(0, 10, 10, 10); pixel.show();

  while (!Serial);
  pixel.setPixelColor(0, 50, 50, 50); pixel.show();

  delay(100);
  SerialESP32.begin(baud);

  pinMode(SPIWIFI_SS, OUTPUT);
  pinMode(ESP32_GPIO0, OUTPUT);
  pinMode(ESP32_RESETN, OUTPUT);
  
  // manually put the ESP32 in upload mode
  digitalWrite(ESP32_GPIO0, LOW);

  digitalWrite(ESP32_RESETN, LOW);
  delay(100);
  digitalWrite(ESP32_RESETN, HIGH);
  pixel.setPixelColor(0, 20, 20, 0); pixel.show();
  delay(100);
}

void loop() {
  while (Serial.available()) {
    pixel.setPixelColor(0, 10, 0, 0); pixel.show();
    SerialESP32.write(Serial.read());
  }

  while (SerialESP32.available()) {
    pixel.setPixelColor(0, 0, 0, 10); pixel.show();
    Serial.write(SerialESP32.read());
  }
}
To verify your last question, I just uploaded the sketch above to my Metro M4 with the AirLift shield attached, and am still getting the error from above in the ESPTool.
Attachments
airlift-back.jpg
airlift-back.jpg (895.29 KiB) Viewed 175 times

User avatar
siddacious
 
Posts: 407
Joined: Fri Apr 21, 2017 3:09 pm

Re: SSL troubles with Metro M4 + Airlift shield

Post by siddacious »

Hey Brent, it's been a bit!

As it happensI tried this last night and got the same error in the web esptool. The only thing I'm trying to do at this point is use the UART passthrough sketch to connect to the esp32 with esptool.

I connected the GPIO00 and TX/RX jumpers (reset appears to be connected already) and got the same error. Additionally I tried using the command line esptool as well with no success.

Can you try reproducing the issue?

Locked
Please be positive and constructive with your questions and comments.

Return to “Wireless: WiFi and Bluetooth”