AUniter icon indicating copy to clipboard operation
AUniter copied to clipboard

ESP8266

Open sskorupski opened this issue 1 year ago • 2 comments

Hi, I'm trying to begin with AUniter, however after doing the setup, I have some strange behavior.

Actual behavior

When I test an ESP8266 device, I get a compilation failed message

Expected behavior

The compilation does not fails

Reproduction step:

Files hierarchy:

    • esp8266
    • espe8266.ino
      • src
      • DeviceInfo.h
      • tests
        • DeviceInfo
        • DeviceInfo.ino

The file content for DeviceInfo.h

class DeviceInfo {
  public:
    char* getChipId() {
      if (strlen(chipIdStr) <= 0){
        uint32_t chipId = ESP.getChipId();
        sprintf(chipIdStr, "%08X", chipId);
      }
      return chipIdStr;
    }

    char* getMacAddress() {
      if (strlen(macAddressStr) <= 0){
        uint8_t mac[6];
        WiFi.macAddress(mac);
        sprintf(macAddressStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
      }
      return macAddressStr;
    }

  private:
    char chipIdStr[9]; // Tableau de caractères pour stocker le chip ID (8 caractères + le caractère de fin de chaîne '\0')
    char macAddressStr[18]; // Tableau de caractères pour stocker l'adresse MAC (17 caractères + le caractère de fin de chaîne '\0')
};

The file content of DeviceInfo.ino:

#line 2 "DeviceInfo.ino"

#include <AUnit.h>
#include "DeviceInfo.h"

using namespace aunit;
DeviceInfo deviceInfo;

void setup() {
  Serial.begin(115200);
  while(!Serial);
}

void loop() {
    TestRunner::run();
}

test(getTheChipId) {
    assertEqual(deviceInfo.getChipId(), "hello");
}

When I run the following command au --cli test esp8266:USB0 DeviceInfo.ino I get the following output:

Reading config: /home/sskorupski/.auniter.ini
Using CLI: AUNITER_ARDUINO_CLI=/home/sskorupski/bin/arduino-cli
-------- Processing file 'DeviceInfo.ino'
Enabling flock on serial port /dev/ttyUSB0
$ /home/sskorupski/bin/arduino-cli  compile --upload  --fqbn esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M1M,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,FlashErase=none,UploadSpeed=921600 --port /dev/ttyUSB0 --warnings all --build-property 'compiler.cpp.extra_flags=-D AUNITER -DAUNITER_ESP8266 -DAUNITER_SSID="MyWiFi" -DAUNITER_PASSWORD="mypassword" ' DeviceInfo.ino
Error during build: Invalid FQBN: getting build properties for board esp8266:esp8266:nodemcuv2: invalid option 'UploadSpeed'
FAILED compile: esp8266 /dev/ttyUSB0 DeviceInfo.ino
FAILED test: esp8266: run_arduino.sh failed on DeviceInfo.ino

I get slight differences if I try again, the FQBN option error can be one of LwIPVariant, CpuFrequency, Debug, FlashSize

Additional informations

  • arduino-cli version: arduino-cli Version: 0.33.0 Commit: ca60d4b4 Date: 2023-05-29T15:18:18Z
  • arduino-ide version: 2.1.0

sskorupski avatar Jun 18 '23 17:06 sskorupski

I assume that you are using the latest version of AUniter, and you copied the sample.auniter.ini into your own .auniter.ini file.

The problem is probably caused by fact that the ESP8266 Core changed the format of their fqbn at some point, and sample.auniter.ini was never updated with the new version. So instead of the configuration currently in sample.auniter.ini:

nodemcuv2 = esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M1M,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,FlashErase=none,UploadSpeed=921600

you probably need to use something like this which seems to be in my $HOME/.auniter.ini:

nodemcuv2 = esp8266:esp8266:nodemcuv2:xtal=80,vt=flash,exception=disabled,ssl=all,eesz=4M2M,led=2,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600

Each new version of the ESP8266 core keeps changing this fqbn parameter, and I can never remember what all those options mean.

In the future, the way to debug this is to fire up the Arduino IDE (I use 1.8.19, I can't use 2.0 but it probably works similarly), use the drop-down menus to configure the board that you are using, go to the Preferences menu and enable the verbose mode, then look at the debugging output for a flag that has the --fqbn. The flag will be buried deep inside the debugging output, like this:

/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/arduino-builder -dump-prefs -logger=machine -hardware /home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/hardware -hardware /home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages -tools /home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/tools-builder -tools /home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/hardware/tools/avr -tools /home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages -built-in-libraries /home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/libraries -libraries /home/brian/src/arduino/libraries -fqbn=esp8266:esp8266:generic:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=3232,non32xfer=fast,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=40,FlashMode=dout,eesz=1M64,led=2,sdk=nonosdk_190703,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200 -ide-version=10819 -build-path /tmp/arduino_build_80305 -warnings=all -build-cache /tmp/arduino_cache_743210 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.xtensa-lx106-elf-gcc.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.xtensa-lx106-elf-gcc-3.0.4-gcc10.3-1757bed.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/xtensa-lx106-elf-gcc/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mkspiffs- 3.0.4-gcc10.3-1757bed.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/mkspiffs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.mklittlefs-3.0.4-gcc10.3-1757bed.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/mklittlefs/3.0.4-gcc10.3-1757bed -prefs=runtime.tools.python3.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/python3/3.7.2-post1 -prefs=runtime.tools.python3-3.7.2-post1.path=/home/brian/Downloads/arduino/ArduinoIDE/arduino-1.8.19/portable/packages/esp8266/tools/python3/3.7.2-post1 -verbose /home/brian/src/AUnit/tests/CompareTest/CompareTest.ino

Copy the value of that --fqbn into your .auniter.ini file.

You can do a similar thing with the Arduino CLI, but I can never remember what string is supposed to go into that -b flag, since that's the thing that we are looking for in the first place. I guess arduino-cli board listall is supposed to help.

bxparks avatar Jun 18 '23 20:06 bxparks

I updated the sample.auniter.ini to the latest that in my personal copy. And while I was touching it, I added a bunch of other boards.

bxparks avatar Jun 18 '23 21:06 bxparks