{"action":"created","issue":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/3408","repository_url":"https://api.github.com/repos/esp8266/Arduino","labels_url":"https://api.github.com/repos/esp8266/Arduino/issues/3408/labels{/name}","comments_url":"https://api.github.com/repos/esp8266/Arduino/issues/3408/comments","events_url":"https://api.github.com/repos/esp8266/Arduino/issues/3408/events","html_url":"https://github.com/esp8266/Arduino/issues/3408","id":241499953,"node_id":"MDU6SXNzdWUyNDE0OTk5NTM=","number":3408,"title":"ESP.deepSleep(xxxx, WAKE_NO_RFCAL) not working since 2.0.0","user":{"login":"wb8wka","id":6334083,"node_id":"MDQ6VXNlcjYzMzQwODM=","avatar_url":"https://avatars1.githubusercontent.com/u/6334083?v=4","gravatar_id":"","url":"https://api.github.com/users/wb8wka","html_url":"https://github.com/wb8wka","followers_url":"https://api.github.com/users/wb8wka/followers","following_url":"https://api.github.com/users/wb8wka/following{/other_user}","gists_url":"https://api.github.com/users/wb8wka/gists{/gist_id}","starred_url":"https://api.github.com/users/wb8wka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wb8wka/subscriptions","organizations_url":"https://api.github.com/users/wb8wka/orgs","repos_url":"https://api.github.com/users/wb8wka/repos","events_url":"https://api.github.com/users/wb8wka/events{/privacy}","received_events_url":"https://api.github.com/users/wb8wka/received_events","type":"User","site_admin":false},"labels":[{"id":194072129,"node_id":"MDU6TGFiZWwxOTQwNzIxMjk=","url":"https://api.github.com/repos/esp8266/Arduino/labels/component:%20core","name":"component: core","color":"fad8c7","default":false},{"id":210716775,"node_id":"MDU6TGFiZWwyMTA3MTY3NzU=","url":"https://api.github.com/repos/esp8266/Arduino/labels/staged-for-release","name":"staged-for-release","color":"5319e7","default":false},{"id":192608391,"node_id":"MDU6TGFiZWwxOTI2MDgzOTE=","url":"https://api.github.com/repos/esp8266/Arduino/labels/type:%20bug","name":"type: bug","color":"fc2929","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/esp8266/Arduino/milestones/8","html_url":"https://github.com/esp8266/Arduino/milestone/8","labels_url":"https://api.github.com/repos/esp8266/Arduino/milestones/8/labels","id":1894520,"node_id":"MDk6TWlsZXN0b25lMTg5NDUyMA==","number":8,"title":"2.5.0","description":"","creator":{"login":"igrr","id":4349050,"node_id":"MDQ6VXNlcjQzNDkwNTA=","avatar_url":"https://avatars2.githubusercontent.com/u/4349050?v=4","gravatar_id":"","url":"https://api.github.com/users/igrr","html_url":"https://github.com/igrr","followers_url":"https://api.github.com/users/igrr/followers","following_url":"https://api.github.com/users/igrr/following{/other_user}","gists_url":"https://api.github.com/users/igrr/gists{/gist_id}","starred_url":"https://api.github.com/users/igrr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/igrr/subscriptions","organizations_url":"https://api.github.com/users/igrr/orgs","repos_url":"https://api.github.com/users/igrr/repos","events_url":"https://api.github.com/users/igrr/events{/privacy}","received_events_url":"https://api.github.com/users/igrr/received_events","type":"User","site_admin":false},"open_issues":87,"closed_issues":59,"state":"open","created_at":"2016-07-20T16:16:06Z","updated_at":"2018-08-19T07:41:45Z","due_on":"2018-12-01T08:00:00Z","closed_at":null},"comments":77,"created_at":"2017-07-09T04:39:10Z","updated_at":"2018-08-20T22:00:51Z","closed_at":null,"author_association":"NONE","body":"\r\n\r\n### Summary\r\n\r\nRF Calibration cannot be turned off after 2.0.0 in wake from deepSleep  causing current spike and longer boot\r\n\r\n#### Hardware\r\nHardware:\t\t\tWemos D1 mini and ESP-12S, 470uf cap between Vcc and Ground\r\nCore Version:      \t2.0.0  (works -  No RF Calibration current spike), 2.3.0  (Not working, current spike)\r\nTest equipment: Rigol Scope, 1ohm current shunt, \"fuzz\" is because I didn't do calibration on scope but traces are accurate. \r\n\r\n### Description\r\n\r\nUsing 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. \r\n\r\nSketch sends simple beacon using wifi_send_pkt_freedom. GPIO16 connected to reset.  \r\n\r\nWAKE_RF_DISABLED does behave as expected in both 2.0.0 and 2.3.0\r\n\r\nAlso \r\n\r\n    system_deep_sleep_set_option(2);  // Option 2 is WAKE_NO_RFCAL\r\n    //system_deep_sleep(6000000);\r\n    system_deep_sleep_instant(6000000);  //  Trims 98ms off go to sleep\r\n\r\nhas same characteristics in that it cannot turn off RF_CAL \r\n\r\n### Settings in IDE\r\n\r\nModule:  \t\t\tWeMos D1 Mini & ESP-12S\r\nFlash Size: \t\t4MB\r\nCPU Frequency:\t\t80Mhz\r\nFlash Mode:\t\t\tqio\r\nUpload Using:\t\tSERIAL\r\n\r\n\r\n### Images\r\n\r\n![061517_1ohm_100mvdiv](https://user-images.githubusercontent.com/6334083/27991244-71872e98-643e-11e7-8919-b6abe641115b.png)\r\n### Version 2.0.0 without RF_CAL current spike at head\r\n\r\n\r\n\r\n![060917_1ohm_100mvdiv](https://user-images.githubusercontent.com/6334083/27991231-05b1adb0-643e-11e7-910d-a4e612e977bd.png)\r\n### Version 2.3.0 with RF_CAL current spike at head\r\n\r\n\r\n\r\n### Sketch\r\n\r\n```\r\n\r\n#include <ESP8266WiFi.h>\r\n#include <WiFiClient.h> \r\nextern \"C\" {\r\n  #include \"user_interface.h\"\r\n// (Commented out code below for 2.0.0 to expose send_pkt_freedom, not needed in 2,3.0\r\n//  typedef void (*freedom_outside_cb_t)(uint8 status);\r\n//  int wifi_register_send_pkt_freedom_cb(freedom_outside_cb_t cb);\r\n//  void wifi_unregister_send_pkt_freedom_cb(void);\r\n//  int wifi_send_pkt_freedom(uint8 *buf, int len, bool sys_seq);\r\n  void system_deep_sleep_instant(uint32 time_in_us);\r\n}\r\n\r\n\r\nbyte channel;\r\nbyte RandomMac = 1; \r\nbyte SequenceLSB = 0;\r\nbyte SequenceMSB = 0;\r\n                 \r\n\r\n// Packet I am sending\r\nuint8_t packet[128] = { ......   68 bytes,,,,  };      // Obscured for example                                          \r\n\r\n\r\nvoid setup() {\r\n  delay(2);   // in this group was all 50\r\n  wifi_set_opmode(STATION_MODE);\r\n  delay(2);\r\n  wifi_promiscuous_enable(1);     // need\r\n  delay(2);\r\n  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\r\n  delay(2);\r\n}\r\n\r\n\r\n\r\nvoid loop() {\r\n\r\n\r\n    wifi_set_channel(1);\r\n    delay(2);     // Delay in MS, was 20\r\n    wifi_send_pkt_freedom(packet, 68, 0);\r\n    //Increment fragment\r\n    //Set fragment\r\n    packet[22] = (SequenceLSB + 1);\r\n    delay(10);     // Delay in MS\r\n    wifi_send_pkt_freedom(packet, 68, 0);\r\n    delay(10);     // Delay in MS\r\n    SequenceLSB = (SequenceLSB & 0xF0);\r\n    packet[22] = SequenceLSB;\r\n\r\n    wifi_set_channel(6); \r\n    delay(2);     // Delay in MS\r\n    wifi_send_pkt_freedom(packet, 68, 0);\r\n    delay(10);     // Delay in MS\r\n    //Increment fragment\r\n    //Set fragment\r\n    packet[22] = (SequenceLSB + 1);\r\n    wifi_send_pkt_freedom(packet, 68, 0);\r\n    delay(10);     // Delay in MS\r\n    SequenceLSB = (SequenceLSB & 0xF0); \r\n    packet[22] = SequenceLSB;\r\n\r\n\r\n    wifi_set_channel(11); \r\n    delay(2);     // Delay in MS\r\n    wifi_send_pkt_freedom(packet, 68, 0);\r\n    delay(10);     // Delay in MS\r\n    //Increment fragment\r\n    packet[22] = (SequenceLSB + 1);\r\n    wifi_send_pkt_freedom(packet, 68, 0);\r\n    delay(2);\r\n   \r\n/// 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.\r\n\r\n    ESP.deepSleep(6000000, WAKE_NO_RFCAL); // Sleep for 6 seconds,\r\n\r\n\r\n    //system_deep_sleep_set_option(2);\r\n    //system_deep_sleep(6000000);\r\n    //system_deep_sleep_instant(6000000);\r\n \r\n}\r\n\r\n\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/esp8266/Arduino/issues/comments/414477566","html_url":"https://github.com/esp8266/Arduino/issues/3408#issuecomment-414477566","issue_url":"https://api.github.com/repos/esp8266/Arduino/issues/3408","id":414477566,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNDQ3NzU2Ng==","user":{"login":"torntrousers","id":12925578,"node_id":"MDQ6VXNlcjEyOTI1NTc4","avatar_url":"https://avatars0.githubusercontent.com/u/12925578?v=4","gravatar_id":"","url":"https://api.github.com/users/torntrousers","html_url":"https://github.com/torntrousers","followers_url":"https://api.github.com/users/torntrousers/followers","following_url":"https://api.github.com/users/torntrousers/following{/other_user}","gists_url":"https://api.github.com/users/torntrousers/gists{/gist_id}","starred_url":"https://api.github.com/users/torntrousers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/torntrousers/subscriptions","organizations_url":"https://api.github.com/users/torntrousers/orgs","repos_url":"https://api.github.com/users/torntrousers/repos","events_url":"https://api.github.com/users/torntrousers/events{/privacy}","received_events_url":"https://api.github.com/users/torntrousers/received_events","type":"User","site_admin":false},"created_at":"2018-08-20T22:00:51Z","updated_at":"2018-08-20T22:00:51Z","author_association":"CONTRIBUTOR","body":"It seems difficult to work this out with out any doc on what the rtc reg 24 and 30 are supposed to be for.\r\nAdding this to an sketch:\r\n```\r\nRF_PRE_INIT() {\r\n    volatile uint32_t* rtc_reg = (volatile uint32_t*) 0x60001000;\r\n    rtc_reg[24] &= 0xFFFF;\r\n}\r\n``` \r\nAppears to get RF_CAL  to run again. But both rtc_reg[24] and rtc_reg[30] are xFFFFFFFF on wake up no matter what sleep mode was used to put the ESP to deepSleep.  \r\n"}}
{"actor":{"display_login":"torntrousers"}}