Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By wb8wka
#68095 I posted this up in GitHub but thought some might have some thoughts as well or if I'm just calling something wrong


===

Summary

RF Calibration cannot be turned off after 2.0.0 in wake from deepSleep causing current spike and longer boot

Hardware
Hardware: Wemos D1 mini and ESP-12S, 470uf cap between Vcc and Ground
Core Version: 2.0.0 (works - No RF Calibration current spike), 2.3.0 (Not working, current spike)
Test equipment: Rigol Scope, 1ohm current shunt, "fuzz" is because I didn't do calibration on scope but traces are accurate.

Description

Using identical code function ESP.deepSleep(6000000, WAKE_NO_RFCAL); in 2.0.0 ESP can wakeup without large current spike from RF_CAL, however after 2.0.0 RF_CAL executes causing large current spike and longer run time. Please see attached current traces. Correct data is sent in both instances, only different is current spike, which appears to be RF_CAL executing.

Sketch sends simple beacon using wifi_send_pkt_freedom. GPIO16 connected to reset.

WAKE_RF_DISABLED does behave as expected in both 2.0.0 and 2.3.0

Also

Code: Select all    system_deep_sleep_set_option(2);  // Option 2 is WAKE_NO_RFCAL
    //system_deep_sleep(6000000);
    system_deep_sleep_instant(6000000);  //  Trims 98ms off go to sleep


has same characteristics in that it cannot turn off RF_CAL

Settings in IDE

Module: WeMos D1 Mini & ESP-12S
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Mode: qio
Upload Using: SERIAL


Images

061517_1Ohm_100mvDiv.png

Version 2.0.0 without RF_CAL current spike at head

060917_1Ohm_100mvDiv.png

Version 2.3.0 with RF_CAL current spike at head



Sketch


Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
extern "C" {
  #include "user_interface.h"
// (Commented out code below for 2.0.0 to expose send_pkt_freedom, not needed in 2,3.0
//  typedef void (*freedom_outside_cb_t)(uint8 status);
//  int wifi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb);
//  void wifi_unregister_send_pkt_freedom_cb(void);
//  int wifi_send_pkt_freedom(uint8 *buf, int len, bool sys_seq);
  void system_deep_sleep_instant(uint32 time_in_us);
}


byte channel;
byte RandomMac = 1;
byte SequenceLSB = 0;
byte SequenceMSB = 0;
                 

// Packet I am sending
uint8_t packet[128] = { ......   68 bytes,,,,  };      // Obscured for example                                         


void setup() {
  delay(2);   // in this group was all 50
  wifi_set_opmode(STATION_MODE);
  delay(2);
  wifi_promiscuous_enable(1);     // need
  delay(2);
  system_phy_set_max_tpw(20);    //the maximum value of RF Tx Power, unit : 0.25dBm, range [0, 82] 19dBm = 76, 10dBm = 40, 14 dBm = 56
  delay(2);
}



void loop() {


    wifi_set_channel(1);
    delay(2);     // Delay in MS, was 20
    wifi_send_pkt_freedom(packet, 68, 0);
    //Increment fragment
    //Set fragment
    packet[22] = (SequenceLSB + 1);
    delay(10);     // Delay in MS
    wifi_send_pkt_freedom(packet, 68, 0);
    delay(10);     // Delay in MS
    SequenceLSB = (SequenceLSB & 0xF0);
    packet[22] = SequenceLSB;

    wifi_set_channel(6);
    delay(2);     // Delay in MS
    wifi_send_pkt_freedom(packet, 68, 0);
    delay(10);     // Delay in MS
    //Increment fragment
    //Set fragment
    packet[22] = (SequenceLSB + 1);
    wifi_send_pkt_freedom(packet, 68, 0);
    delay(10);     // Delay in MS
    SequenceLSB = (SequenceLSB & 0xF0);
    packet[22] = SequenceLSB;


    wifi_set_channel(11);
    delay(2);     // Delay in MS
    wifi_send_pkt_freedom(packet, 68, 0);
    delay(10);     // Delay in MS
    //Increment fragment
    packet[22] = (SequenceLSB + 1);
    wifi_send_pkt_freedom(packet, 68, 0);
    delay(2);
   
/// ESP.deepSleep(microseconds, mode) will put the chip into deep sleep. mode is one of WAKE_RF_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED.

    ESP.deepSleep(6000000, WAKE_NO_RFCAL); // Sleep for 6 seconds,


    //system_deep_sleep_set_option(2);
    //system_deep_sleep(6000000);
    //system_deep_sleep_instant(6000000);
 
}

You do not have the required permissions to view the files attached to this post.
User avatar
By schufti
#68149 I think, with the detailed analysis that you provided (owning/using scope, knowing what to expect from "wake_rf_nocal") about 99% of the casual forum members are baffled.
The other 1% that could cope just see the results and trust in your abilities, most likely they allready saw your posting on github.
BUT: as the same problem occurs with the direct system functions, I think your issue should better be posted to the espressiv esp8266_nonos_sdk repo and maybe in their forum (to directly alert the responsible persons).