khoih-prog / WiFiManager_NINA_Lite

Light-Weight WiFi/Credentials Manager for AVR Mega, Teensy, SAM DUE, SAMD, STM32, etc. boards running U-Blox WiFiNINA modules/shields. Powerful-yet-simple-to-use feature to enable adding dynamic custom parameters. Now using WiFiMulti_Generic library
MIT License
34 stars 10 forks source link

Adafruit Matrix Portal M4 - hangs on initialization #13

Closed wayned1014 closed 3 years ago

wayned1014 commented 3 years ago

Code hangs when executing the "WiFiManager_NINA = new WiFiManager_NINA_Lite();" command.

Using: Arduino IDE 1.8.13 Board: Adafruit Matrix Portal M4 (SAMD51)

I am using the example file "SAMD_WiFiNINA" with only the modification below to see where the problem is:

  Serial.print(F("\nStarting SAMD_WiFiNINA on ")); Serial.println(BOARD_TYPE);
  Serial.println(WIFIMANAGER_NINA_LITE_VERSION);
  Serial.println("Before NINA = new");
  WiFiManager_NINA = new WiFiManager_NINA_Lite();
  Serial.println("After NINA = new");

The output on the serial monitor is:

14:51:03.592 -> 
14:51:03.592 -> Starting SAMD_WiFiNINA on SAMD51J19A
14:51:03.592 -> WiFiManager_NINA_Lite v1.4.0
14:51:03.592 -> Before NINA = new

Hope this is all the information needed. Please let me know if you need any more information.

Thanks, Wayne

khoih-prog commented 3 years ago

Hi,

Thanks for using the library.

As you notice, when you compile the example, the following informative warnings display

In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:243:8: warning: #warning You have to modify pin usage according to actual connection for SAMD [-Wcpp]
  243 |       #warning You have to modify pin usage according to actual connection for SAMD
      |        ^~~~~~~
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:248: warning: "NINA_GPIO0" redefined
  248 |       #define NINA_GPIO0  (26u)                             //26
      | 
In file included from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/delay.h:24,
                 from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/Arduino.h:80,
                 from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:53:
/home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/variants/matrixportal_m4/variant.h:127: note: this is the location of the previous definition
  127 | #define NINA_GPIO0      ESP32_GPIO0
      | 
In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:249: warning: "NINA_RESETN" redefined
  249 |       #define NINA_RESETN (27u)
      | 
In file included from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/delay.h:24,
                 from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/Arduino.h:80,
                 from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:53:
/home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/variants/matrixportal_m4/variant.h:128: note: this is the location of the previous definition
  128 | #define NINA_RESETN     ESP32_RESETN
      | 
In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:250: warning: "NINA_ACK" redefined
  250 |       #define NINA_ACK    (28u)
      | 
In file included from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/delay.h:24,
                 from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/Arduino.h:80,
                 from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:53:
/home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/variants/matrixportal_m4/variant.h:129: note: this is the location of the previous definition
  129 | #define NINA_ACK        SPIWIFI_ACK
      | 
In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:252: warning: "SPIWIFI_SS" redefined
  252 |       #define SPIWIFI_SS       24   //PIN_SPI1_SS            //24
      | 
In file included from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/delay.h:24,
                 from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/Arduino.h:80,
                 from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:53:
/home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/variants/matrixportal_m4/variant.h:124: note: this is the location of the previous definition
  124 | #define SPIWIFI_SS      33
      | 
In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:253: warning: "SPIWIFI_ACK" redefined
  253 |       #define SPIWIFI_ACK      28   //NINA_ACK               //28
      | 
In file included from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/delay.h:24,
                 from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/Arduino.h:80,
                 from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:53:
/home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/variants/matrixportal_m4/variant.h:125: note: this is the location of the previous definition
  125 | #define SPIWIFI_ACK     31
      | 
In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:254: warning: "SPIWIFI_RESET" redefined
  254 |       #define SPIWIFI_RESET    27   //NINA_RESETN            //27
      | 
In file included from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/delay.h:24,
                 from /home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/cores/arduino/Arduino.h:80,
                 from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:53:
/home/kh/.arduino15/packages/adafruit/hardware/samd/1.7.3/variants/matrixportal_m4/variant.h:126: note: this is the location of the previous definition
  126 | #define SPIWIFI_RESET   ESP32_RESETN
      | 
Sketch uses 70816 bytes (13%) of program storage space. Maximum is 507904 bytes.

So you have to modify the WiFiNINA_Pinout_Generic.h#L238-L257 as follows:

    #elif ( defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) || defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) )

      #warning ADAFRUIT_METRO_M4_AIRLIFT_LITE or ADAFRUIT_PYBADGE_AIRLIFT_M4 are OK to use

    #elif ( defined(ADAFRUIT_MATRIXPORTAL_M4_EXPRESS)  )  

      #warning You have to modify pin usage according to actual connection for SAMD51 ADAFRUIT_MATRIXPORTAL_M4_EXPRESS
      // To define pin out for WiFiNINA here

      //#define PINS_COUNT           (60u)
      //NINA     
      #define NINA_GPIO0      ESP32_GPIO0
      #define NINA_RESETN     ESP32_RESETN
      #define NINA_ACK        SPIWIFI_ACK

      #define SPIWIFI_SS      33
      #define SPIWIFI_ACK     31
      #define SPIWIFI_RESET   ESP32_RESETN

    #else
      #warning You have to modify pin usage according to actual connection for SAMD
      // To define pin out for WiFiNINA here

      //#define PINS_COUNT           (60u)
      //NINA
      #define NINA_GPIO0  (26u)                             //26
      #define NINA_RESETN (27u)
      #define NINA_ACK    (28u)

      #define SPIWIFI_SS       24   //PIN_SPI1_SS            //24
      #define SPIWIFI_ACK      28   //NINA_ACK               //28 
      #define SPIWIFI_RESET    27   //NINA_RESETN            //27

    #endif
  #endif     

The compile result will be as follows if you've done correctly


In file included from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:105:4: warning: #warning Using WIFININA_Generic Library [-Wcpp]
  105 |   #warning Using WIFININA_Generic Library
      |    ^~~~~~~
In file included from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:108,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:244:8: warning: #warning You have to modify pin usage according to actual connection for SAMD51 ADAFRUIT_MATRIXPORTAL_M4_EXPRESS [-Wcpp]
  244 |       #warning You have to modify pin usage according to actual connection for SAMD51 ADAFRUIT_MATRIXPORTAL_M4_EXPRESS
      |        ^~~~~~~
In file included from /home/kh/Arduino/libraries/WiFiManager_NINA_Lite-1.4.0/src/WiFiManager_NINA_Lite_SAMD.h:51,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:179,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/libraries/WiFiWebServer-1.2.0/src/WiFiWebServer.h:54:4: warning: #warning Use SAMD architecture from WiFiWebServer [-Wcpp]
   54 |   #warning Use SAMD architecture from WiFiWebServer
      |    ^~~~~~~
In file included from /home/kh/Arduino/libraries/WiFiManager_NINA_Lite-1.4.0/src/WiFiManager_NINA_Lite_SAMD.h:51,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:179,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/libraries/WiFiWebServer-1.2.0/src/WiFiWebServer.h:109:4: warning: #warning Use WiFiNINA from WiFiWebServer [-Wcpp]
  109 |   #warning Use WiFiNINA from WiFiWebServer
      |    ^~~~~~~
In file included from /home/kh/Arduino/libraries/WiFiManager_NINA_Lite-1.4.0/src/WiFiManager_NINA_Lite_SAMD.h:51,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:179,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/libraries/WiFiWebServer-1.2.0/src/WiFiWebServer.h:136:4: warning: #warning SENDCONTENT_P_BUFFER_SZ using default 4 Kbytes [-Wcpp]
  136 |   #warning SENDCONTENT_P_BUFFER_SZ using default 4 Kbytes
      |    ^~~~~~~
In file included from /home/kh/Arduino/libraries/WiFiManager_NINA_Lite-1.4.0/src/WiFiManager_NINA_Lite_SAMD.h:108,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:179,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/libraries/DoubleResetDetector_Generic-1.4.0/src/DoubleResetDetector_Generic.h:79:4: warning: #warning Use SAMD and FlashStorage [-Wcpp]
   79 |   #warning Use SAMD and FlashStorage
      |    ^~~~~~~
In file included from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/defines.h:179,
                 from /home/kh/Arduino/khoih-prog_working/WiFiManager_NINA_Lite_GitHub/examples/SAMD_WiFiNINA/SAMD_WiFiNINA.ino:33:
/home/kh/Arduino/libraries/WiFiManager_NINA_Lite-1.4.0/src/WiFiManager_NINA_Lite_SAMD.h:135:4: warning: #warning Using Dynamic Parameters [-Wcpp]
  135 |   #warning Using Dynamic Parameters
      |    ^~~~~~~
In file included from /home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/utility/spi_drv.cpp:60:
/home/kh/Arduino/libraries/WiFiNINA_Generic-1.8.12/src/WiFiNINA_Pinout_Generic.h:244:8: warning: #warning You have to modify pin usage according to actual connection for SAMD51 ADAFRUIT_MATRIXPORTAL_M4_EXPRESS [-Wcpp]
  244 |       #warning You have to modify pin usage according to actual connection for SAMD51 ADAFRUIT_MATRIXPORTAL_M4_EXPRESS
      |        ^~~~~~~
Sketch uses 70816 bytes (13%) of program storage space. Maximum is 507904 bytes.

Try if there is any more issue. If not, try using a simple WiFiNINA example from WiFiNINA_Generic library before moving forward to more complex examples.

khoih-prog commented 3 years ago

You can use this just-updated WiFiNINA_Pinout_Generic.h to overwrite the old file to test.

khoih-prog commented 3 years ago

The WiFiNINA_Generic Releases v1.8.13 has just been released to add support to ADAFRUIT_MATRIXPORTAL_M4_EXPRESS

Please update it to save you time from modifying the files yourself, then test and report the result, no matter OK or not.

Thanks,


Releases v1.8.13

  1. Sync with Arduino WiFiNINA Library v1.8.13.

    • Update latest available nina-fw to v1.4.8
  2. Add support to SAMD51 ADAFRUIT_MATRIXPORTAL_M4_EXPRESS

wayned1014 commented 3 years ago

The modification to the pinout file did the trick.

Thanks, Wayne