esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
294 stars 38 forks source link

Boot Loop - help understanding why #6159

Closed Fayrewood closed 3 months ago

Fayrewood commented 3 months ago

The problem

I am running a D1 Mini with JNSwanson's excellent CC1101 decoder, but my ESP32 gets stuck in a boot loop and I can't fathom out why. I have asked in that forum, but thought I may get a larger support group here. I have double checked all of the connections and continuity between the ESP32 and the CC1101.

The pin connections are below and I get the same error if I remove the CC1101 connections:

CC1101  NodeMCU
CSN D8(CS)
CSK(CLK)D5()
MISO    D6(MISO) + D2
MOSI    D7(MOSI)
GND GND
VCC 3.3V 

Is anyone able to decode the log output and point me in the right direction as to what is happening please?

Log at boot, after a boot loop:

[11:29:20] ets Jan  8 2013,rst cause:1, boot mode:(3,6)
[11:29:20]
[11:29:20]load 0x4010f000, len 3424, room 16 
[11:29:20]tail 0
[11:29:20]chksum 0x2e
[11:29:20]load 0x3fff20b8, len 40, room 8 
[11:29:20]tail 0
[11:29:20]chksum 0x2b
[11:29:20]csum 0x2b
[11:29:20]v00069fa0
[11:29:20]~ld

Decoder Information:

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

[11:50:09]Soft WDT reset
[11:50:09]
[11:50:09]Exception (4):
[11:50:09]epc1=0x40201049 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
[11:50:09]
[11:50:09]>>>stack>>>
[11:50:09]
[11:50:09]ctx: cont
[11:50:09]sp: 3ffffcd0 end: 3fffffd0 offset: 0160
[11:50:09]3ffffe30:  3ffffe50 33c134e0 3ffef92c 40201278  
[11:50:09]3ffffe40:  3ffe8f17 33c134e0 3ffef92c 402013e9  
[11:50:09]3ffffe50:  3ffe8f17 33c134e0 3ffef92c 40201579  
[11:50:09]3ffffe60:  00000000 3ffefad0 3ffef92c 4021230e  
[11:50:09]3ffffe70:  3fff12ec 0000000a 3ffef810 4021099d  
[11:50:09]3ffffe80:  00000006 00000006 3fff1b2c 40100b42  
[11:50:09]3ffffe90:  0000002c 00000014 00000005 3ffef810  
[11:50:09]3ffffea0:  3fff1794 00000020 3fff18dc 3ffef810  
[11:50:09]3ffffeb0:  3fff1794 3ffef938 3fffff64 4021418b  
[11:50:09]3ffffec0:  00000000 feefeffe feefeffe feefeffe  
[11:50:09]3ffffed0:  402274bc 00000000 7fc00000 00000000  
[11:50:09]3ffffee0:  3fff171c 3fff1720 3fff1720 00000000  
[11:50:09]3ffffef0:  3ffffef8 0000000d 78656c41 65646e61  
[11:50:09]3fffff00:  61334272 00000072 00000000 00000000  
[11:50:09]3fffff10:  00000000 00000000 00000000 00000000  
[11:50:09]3fffff20:  00000000 00000000 00000000 402274bc  
[11:50:09]3fffff30:  00000000 7fc00000 00000000 3fff170c  
[11:50:09]3fffff40:  3fff1710 3fff1710 40227484 00000000  
[11:50:09]3fffff50:  7fc00000 00000000 3fff111c 3fff113c  
[11:50:09]3fffff60:  3fff113c 3fff18dc 3fff18e0 3fff18e0  
[11:50:09]3fffff70:  00000000 3fffff84 00000001 feefeffe  
[11:50:09]3fffff80:  feefeffe 3fff18bc feefeffe feefeffe  
[11:50:09]3fffff90:  3fff1874 00000000 3fffff64 feefeffe  
[11:50:09]3fffffa0:  feefeffe feefeffe feefeffe 3ffefce0  
[11:50:09]3fffffb0:  3fffdad0 00000000 3ffefcb4 40222814  
[11:50:09]3fffffc0:  feefeffe feefeffe 3fffdab0 40100465  
[11:50:10]<<<stack<<<
[11:50:10]
--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Here's the relevant YAML for the device:

esphome:
  name: iboost32
  platform: ESP8266
  board: d1_mini
  includes:
    - iBoost.h
    - CC1101_RFx.h
  libraries:
    - SPI

sensor:
  - platform : custom
    lambda: |- 
      iBoost = new iBoostBuddy; // note: this is declared globally in iBoost.h
      App.register_component(iBoost);
      return {iBoost->heatingImport,iBoost->heatingPower,iBoost->heatingToday,iBoost->heatingYesterday,iBoost->heatingLast7,iBoost->heatingLast28,iBoost->heatingLastGT,iBoost->heatingBoostTime}; 

Which version of ESPHome has the issue?

2024.7.3

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP8266

Board

D1 Mini

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

Fayrewood commented 3 months ago

Is anyone able to help and take a look at the debug logs please? This is driving me nuts. I have tried several CC1101 modules and ESP32 D1 Mini boards and followed the wiring meticulously and checked continuity between the ESP and the CC1101.

I've enabled verbose logging and the ESP is happy up until it tries to run the reset radio in the iboost.h code, just after reporting "SPI OK":

void setup() override {
    // This will be called by App.setup()
    addressLQI = 255; // set received LQI to lowest value
    addressValid=false;
    SPI.begin();
    Serial.println("SPI OK");
    ESP_LOGW(TAG, "SPI OK");
    radio.reset();
    radio.begin(868.300e6); // Freq=433.2Mhz. Do not forget the "e6"
    radio.setMaxPktSize(61);
    radio.writeRegister(CC1101_FREQ2, 0x21); // 868.300MHz  (868300000 <<16)/26000000
    radio.writeRegister(CC1101_FREQ1, 0x65);
    radio.writeRegister(CC1101_FREQ0, 0x6a);
    radio.writeRegister(CC1101_FSCTRL1, 0x08); // fif=203.125kHz
    radio.writeRegister(CC1101_FSCTRL0, 0x00); // No offset
    radio.writeRegister(CC1101_MDMCFG4, 0x5B); // CHANBW_E = 1 CHANBW_M=1 BWchannel =325kHz   DRATE_E=11
    radio.writeRegister(CC1101_MDMCFG3, 0xF8); // DRATE_M=248 RDATA=99.975kBaud
    radio.writeRegister(CC1101_MDMCFG2, 0x03); // Disable digital DC blocking filter before demodulator enabled. MOD_FORMAT=000 (2-FSK) Manchester Coding disabled Combined sync-word qualifier mode = 30/32 sync word bits detected
    radio.writeRegister(CC1101_MDMCFG1, 0x22); // Forward error correction disabled 4 preamble bytes transmitted CHANSPC_E=2
    radio.writeRegister(CC1101_MDMCFG0, 0xF8); // CHANSPC_M=248 200kHz channel spacing
    radio.writeRegister(CC1101_CHANNR, 0x00); // The 8-bit unsigned channel number, which is multiplied by the channel spacing setting and added to the base frequency.
    radio.writeRegister(CC1101_DEVIATN, 0x47); // DEVIATION_E=4 DEVIATION_M=7 ±47.607 kHz deviation
    radio.writeRegister(CC1101_FREND1, 0xB6); // Adjusts RX RF device
    radio.writeRegister(CC1101_FREND0, 0x10); // Adjusts TX RF device
    radio.writeRegister(CC1101_MCSM0, 0x18); // Calibrates whngoing from IDLE to RX or TX (or FSTXON) PO_TIMEOUT 149-155uS Pin control disabled XOSC off in sleep mode
    //radio.writeRegister(CC1101_MCSM1, 0x00); // Channel clear = always Return to idle after packet reception Return to idle after transmission
    radio.writeRegister(CC1101_FOCCFG, 0x1D); // The frequency compensation loop gain to be used before a sync word is detected = 4K The frequency compensation loop gain to be used after a sync word is Detected = K/2 The saturation point for the frequency offset compensation algorithm = ±BWchannel /8
    radio.writeRegister(CC1101_BSCFG, 0x1C); // The clock recovery feedback loop integral gain to be used before a sync word is detected = KI The clock recovery feedback loop proportional gain to be used before a sync word is detected = 2KP The clock recovery feedback loop integral gain to be used after a sync word is Detected = KI/2 The clock recovery feedback loop proportional gain to be used after a sync word is detected = KP The saturation point for the data rate offset compensation algorithm = ±0 (No data rate offset compensation performed)
    radio.writeRegister(CC1101_AGCCTRL2, 0xC7); // The 3 highest DVGA gain settings can not be used. Maximum allowable LNA + LNA 2 gain relative to the maximum possible gain. Target value for the averaged amplitude from the digital channel filter = 42dB
    radio.writeRegister(CC1101_AGCCTRL1, 0x00); // LNA 2 gain is decreased to minimum before decreasing LNA gain Relative carrier sense threshold disabled Sets the absolute RSSI threshold for asserting carrier sense to MAGN_TARGET
    radio.writeRegister(CC1101_AGCCTRL0, 0xB2); // Sets the level of hysteresis on the magnitude deviation (internal AGC signal that determine gain changes) to Medium hysteresis, medium asymmetric dead zone, medium gain Sets the number of channel filter samples from a gain adjustment has been made until the AGC algorithm starts accumulating new samples to 32 samples AGC gain never frozen
    radio.writeRegister(CC1101_FSCAL3, 0xEA); // Detailed calibration
    radio.writeRegister(CC1101_FSCAL2, 0x2A); //
    radio.writeRegister(CC1101_FSCAL1, 0x00); //
    radio.writeRegister(CC1101_FSCAL0, 0x1F); //
    radio.writeRegister(CC1101_FSTEST, 0x59); // Test register
    radio.writeRegister(CC1101_TEST2, 0x81); // Values to be used from SmartRF software
    radio.writeRegister(CC1101_TEST1, 0x35); //
    radio.writeRegister(CC1101_TEST0, 0x09); //
    radio.writeRegister(CC1101_IOCFG2, 0x0B); // Active High Serial Clock
    radio.writeRegister(CC1101_IOCFG0, 0x46); // Analog temperature sensor disabled Active High Asserts when sync word has been sent / received, and de-asserts at the end of the packet
    radio.writeRegister(CC1101_PKTCTRL1, 0x04); // Sync word is always accepted Automatic flush of RX FIFO when CRC is not OK disabled Two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. No address checkof received packages.
    radio.writeRegister(CC1101_PKTCTRL0, 0x05); // Data whitening off Normal mode, use FIFOs for RX and TX CRC calculation in TX and CRC check in RX enabled Variable packet length mode. Packet length configured by the first byte after sync word
    radio.writeRegister(CC1101_ADDR, 0x00); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).

    static uint8_t paTable[] = {0xC6, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F};
    radio.writeBurstRegister(CC1101_PATABLE, paTable, sizeof(paTable));

    radio.strobe(CC1101_SIDLE); //
    radio.strobe(CC1101_SPWD); //

    Serial.println("Radio OK");
    radio.setRXstate(); // Set the current state to RX : listening for RF packets
    Serial.println("Radio RX OK");
    // LED setup. It is importand as we can use the module without serial terminal
    pinMode(LED_BUILTIN, OUTPUT);
    Serial.println("Setup Finished");
    ESP_LOGW(TAG, "Setup Finished");
  }
ssieb commented 3 months ago

You're using a custom component, so this is not the right place. Something in there is taking too long. You also shouldn't be using Serial. If you need more help, then come ask on the esphome discord server or one of the forums.