Hi,
We are running into a very curious problem when we try to build (espidf-arduino-blink) on two different boards.
Here is the code in Blink.cpp:
/* Blink Example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <driver/gpio.h>
#include "sdkconfig.h"
#include <Arduino.h>
#include <WiFi.h>
// /* Can run 'make menuconfig' to choose the GPIO to blink,
// or you can edit the following line and set a number here.
// */
// #define BLINK_GPIO (gpio_num_t)CONFIG_BLINK_GPIO
// #ifndef LED_BUILTIN
// #define LED_BUILTIN 4
// #endif
// void blink_task(void *pvParameter)
// {
// /* Configure the IOMUX register for pad BLINK_GPIO (some pads are
// muxed to GPIO on reset already, but some default to other
// functions and need to be switched to GPIO. Consult the
// Technical Reference for a list of pads and their default
// functions.)
// */
// gpio_pad_select_gpio(BLINK_GPIO);
// /* Set the GPIO as a push/pull output */
// gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
// while(1) {
// /* Blink off (output low) */
// gpio_set_level(BLINK_GPIO, 0);
// vTaskDelay(1000 / portTICK_PERIOD_MS);
// /* Blink on (output high) */
// gpio_set_level(BLINK_GPIO, 1);
// vTaskDelay(1000 / portTICK_PERIOD_MS);
// }
// }
// #if !CONFIG_AUTOSTART_ARDUINO
// void arduinoTask(void *pvParameter) {
// pinMode(LED_BUILTIN, OUTPUT);
// while(1) {
// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
// delay(1000);
// }
// }
// extern "C" void app_main()
// {
// // initialize arduino library before we start the tasks
// initArduino();
// xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
// xTaskCreate(&arduinoTask, "arduino_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
// }
// #else
// void setup() {
// Serial.begin(115200);
// xTaskCreate(&blink_task, "blink_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
// pinMode(LED_BUILTIN, OUTPUT);
// }
// void loop() {
// digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
// Serial.println("Hello!");
// delay(1000);
// }
// #endif
void wifiScan() {
// WiFi.scanNetworks will return the number of networks found
int n = WiFi.scanNetworks();
Serial.println("scan done");
if (n == 0) {
Serial.println("no networks found");
} else {
Serial.print(n);
Serial.println(" networks found");
for (int i = 0; i < n; ++i) {
// Print SSID and RSSI for each network found
Serial.print(i + 1);
Serial.print(": ");
Serial.print(WiFi.SSID(i));
Serial.print(" (");
Serial.print(WiFi.RSSI(i));
Serial.print(")");
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
delay(10);
}
}
Serial.println("");
}
#if !CONFIG_AUTOSTART_ARDUINO
void arduinoTask(void *pvParameter) {
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.begin(115200);
delay(100);
while(1) {
wifiScan();
// Wait a bit before scanning again
delay(5000);
}
}
extern "C" void app_main()
{
// initialize arduino library before we start the tasks
initArduino();
xTaskCreate(&arduinoTask, "arduino_task", configMINIMAL_STACK_SIZE, NULL, 5, NULL);
}
#else
void setup() {
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.begin(115200);
delay(100);
}
void loop() {
wifiScan();
// Wait a bit before scanning again
delay(5000);
}
#endif
The first platformio.ini config works without any issue:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env]
platform = espressif32
framework = arduino, espidf
build_flags =
-D CONFIG_BLINK_GPIO=2
monitor_speed = 115200
[env:esp32-s3-devkitc-1]
board = esp32-s3-devkitc-1
board_build.flash_mode = dio
The following one however does not work and generates an error :
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter, extra scripting
; Upload options: custom port, speed and extra flags
; Library options: dependencies, extra library storages
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env]
platform = espressif32
framework = arduino, espidf
build_flags =
-D CONFIG_BLINK_GPIO=2
monitor_speed = 115200
[env:adafruit_feather_esp32s3]
board = adafruit_feather_esp32s3
board_build.flash_mode = dio
The error is :
Building in release mode
Compiling .pio\build\adafruit_feather_esp32s3\src\Blink.o
Archiving .pio\build\adafruit_feather_esp32s3\esp-idf\asio\libasio.a
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\bootloader_random_esp32s3.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\bootloader_utility.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\esp_image_format.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\flash_encrypt.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\secure_boot.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\flash_partitions.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\flash_qio_mode.o
Compiling .pio\build\adafruit_feather_esp32s3\bootloader_support\src\bootloader_flash_config_esp32s3.o
src/Blink.cpp: In function 'void wifiScan()':
src/Blink.cpp:82:5: error: 'Serial' was not declared in this scope
Serial.println("scan done");
^~~~~~
src/Blink.cpp:82:5: note: suggested alternative: 'Serial2'
Serial.println("scan done");
^~~~~~
Serial2
src/Blink.cpp: In function 'void setup()':
src/Blink.cpp:131:5: error: 'Serial' was not declared in this scope
Serial.begin(115200);
^~~~~~
src/Blink.cpp:131:5: note: suggested alternative: 'Serial2'
Serial.begin(115200);
^~~~~~
Serial2
*** [.pio\build\adafruit_feather_esp32s3\src\Blink.o] Error 1
Can anyone help us with this issue please?