ESP32-DIV icon indicating copy to clipboard operation
ESP32-DIV copied to clipboard

**Design Flaws in ESP32DIV - Pin Conflicts Cause Module Initialization Failures & Stability Issues (with Solutions)**

Open silentfox2023 opened this issue 1 year ago • 7 comments

At present, there are problems in the ESP32DIV design. Since all pins of the CC1101 module and the second NRF24L01P module are shared, including the critical CE (GOD0) and CSN (the GOD2 pin is the CE pin of the first NRF24L01P module), pin conflicts have occurred. This causes the second NRF24L01P to fail to initialize and the CC1101 to operate unstably. According to the circuit principle, it is necessary to redesign the pins of the CC1101 or NRF24L01P to at least ensure that CE and CSN pins are not shared. Alternatively, a switch can be designed to ensure that the CC1101 module and the NRF24L01P module cannot be powered on simultaneously.

In addition, the same problem exists between the SD module and the third NRF24L01P module. The CS pin of the SD and the CSN pin of the NRF24L01P share GPIO5. Therefore, after inserting the SD card, the NRF24L01P may fail to initialize or operate unstably, although partial fixes may be possible through code.

it is recommended that everyone use this cautiously and suggest redesigning the circuit board to ensure usability and stability.

Hey, I also want to hear everyone's suggestions and usage experiences.

Image

silentfox2023 avatar Jun 04 '25 01:06 silentfox2023

I was assuming that it was probably something you can get around by de initialising the nrf, 1101 or the sd card when they aren't needed, im not sure, but yeah will definitely cause some issues...

zRCrackiiN avatar Jun 04 '25 16:06 zRCrackiiN

There are a total of 4 modules using SPI communication, and the SD module also uses SPI communication. How can conflicts be avoided? Currently, I haven't seen anyone do this before. The only idea I have is to distinguish them through different register addresses, but this is only logical. Physically, the Chip Select signals will be transmitted to the two modules simultaneously.

silentfox2023 avatar Jun 04 '25 16:06 silentfox2023

hi

Is there already a plan for a new design? when will it be available?

best regards

BrainScript2018 avatar Jun 23 '25 05:06 BrainScript2018

There are a total of 4 modules using SPI communication, and the SD module also uses SPI communication. How can conflicts be avoided? Currently, I haven't seen anyone do this before. The only idea I have is to distinguish them through different register addresses, but this is only logical. Physically, the Chip Select signals will be transmitted to the two modules simultaneously.

Do you think it's worth redesigning the PCB and including a switch maybe or does Cifer have a redesign on the way already? It's hard to reach him.

t1nkersec avatar Jun 25 '25 12:06 t1nkersec

Designing a separate switch is not as good as redesigning to connect other pins of the ESP32. It can be understood by looking at the circuit diagram. The ESP32 still has at least two idle pins, IO35 and IO39, which can respectively replace the CS pins of the SD module and the second NRF24L01P module. However, the problem is that both boards need to be redesigned and prototyped.

silentfox2023 avatar Jun 26 '25 01:06 silentfox2023

@silentfox2023 how can I reach out to you? Do you have discord?

feyz7 avatar Aug 17 '25 14:08 feyz7

Hey this is a repost from this morning that @dasbrotimofen had told me about! #89 @silentfox2023 @BrainScript2018 @t1nkersec @zRCrackiiN .. whats up Amigos!! I'll start this by telling everyone I'm sorry in advance for the long explanation !!! then again if you don't like don't read it LMFDO!!! 😈

those are both awesome questions and to be honest they both kicked my ass for a minute!! I never saw https://github.com/cifertech/ESP32-DIV/issues/35 as I haven't been on here that long. I put together the DIV a few weeks ago and a bunch of things were not working or had never been developed. So I dug in and found some workarounds that didn't require a new design. I did a bunch of research and came to a resolution that so far appears to be working for the pin 16 conflict and the TX/RX issue!!! I sent Cifer my firmware upgrades on the 2nd or the 3rd of this month, I dont know him but I thought I would help out, the next Monday the V1.5 was released, and I never heard from the dude... I even sent him an email first with the firmware! go figure

so for the TX / RX situation here is what I came up with! As far as I can tell the naming was backwards from the start! it appears they were named based off of a function that might not have been correct. as far as I could tell the C1101 module in async serial mode works opposite to there design intuition. the original design calls (mySwitch.enableTransmit(TX_PIN); // Passing 26 - WRONG!. also mySwitch.enableReceive(RX_PIN); // Passing 16 - wrong!.. the fix was swapping which pin gets passed to enableTransmit() vs enableReceive(). the example is ( mySwitch.enableTransmit(RX_PIN); // Passing 16 (GDO0) - correct! mySwitch.enableReceive(TX_PIN); // Passing 26 (GDO2) - correct! ) The CC1101 GDO pins are configurable via registers - GDO0 and GDO2 can be set to different functions depending on how the library initializes them.

The ESP32-DIV V1 board has two RF transceivers that must share limited GPIO pins: ALSO KEEP YOUR PECKER PINCHERS OFF OF THE PINS WHEN YOUR BOARD IS ACTIVE!! IT FUCKS EVERYTHING UP.. PUT SOME HOT GLUE OVER THE PINS SO YOU DONT CHASE YOUr TAIL LIKE MY GOOFY ASS DID!! THE BUG!!! 🪳 The original CiferTech firmware had no cleanup logic when switching between radio modes. When a user would exit the SubGHz Replay Attack menu and load the 2.4GHz Spectrum Analyzer, the NRF24 library would reconfigure pin 16 as an output and start toggling it to control the radio. But the RCSwitch interrupt was still attached from the previous SubGHz session. Every time the NRF24 library toggled pin 16, the RCSwitch interrupt handler fired. This happened thousands of times per second because the NRF24 constantly enables and disables itself during scanning operations. The interrupt handler was never designed to be called this rapidly or during unrelated operations. This caused multiple failures. The interrupt service routine was being called faster than it could complete, leading to stack overflow. The CPU would get stuck servicing interrupts and the watchdog timer would reset the device. The interrupt handler was writing to RCSwitch's internal buffers while those buffers were being used for completely different purposes, causing memory corruption. Race conditions between the two radio libraries caused random freezes that required a full power cycle to recover from.

THE FIX: 👍✅ at least the best I can do for now!! I created a cleanup function called cleanupSubGHz() that must be called before switching from any SubGHz mode to any 2.4GHz mode. This function does severalthings in a specific order.

1st, it checks if SubGHz receive mode is active by looking at a flag we added called subghz_receive_active. If the flag is true, it calls mySwitch.disableReceive() which internally detaches the interrupt from pin 16. This is the critical step that prevents the crash. Perfect>>> not entirely but it's better than it was, additionally @duggie162-cpu is correct you need to check your solder and ensure the connection is good!! My C1101 was actually defective !! 2nd, it checks if the RMT driver was initialized for brute force attacks. The ESP32's RMT peripheral also uses pin 16 for hardware-timed pulse generation during code transmission. If it was active, we uninstall the RMT driver to release that resource. 3rd, it puts the CC1101 into idle mode by calling setSidle(). This stops any ongoing RF activity and prevents interference with the NRF24. 4th, it releases the SPI bus by calling SPI.end(). Both radios share the same SPI pins for communication, so the CC1101 must fully release the bus before the NRF24 can use it. 5th, it sets the CC1101's chip select pin high to ensure the CC1101 ignores any SPI traffic meant for the NRF24.

Finally, it sets pin 16 and pin 26 to input mode. This puts them in a neutral state so the NRF24 library can safely reconfigure pin 16 as an output for CE control without any conflict.

I also added a state flag called subghz_receive_active that tracks whether the RCSwitch interrupt is currently attached. This flag gets set to true when we enable SubGHz receive mode and set to false when we disable it. The cleanup function checks this flag to avoid trying to detach an interrupt that was never attached, which could cause undefined behavior.

The Results: I HOPE!! SO FAR ITS WORKING OK FOR ME 😵‍💫

Before the fix, users experienced random crashes when navigating between SubGHz and 2.4GHz menus. The device would freeze or reset itself, and often required a full power cycle to recover. The 2.4GHz features simply wouldn't work if you had used any SubGHz feature earlier in the session. After the fix, radio mode transitions are completely clean. Users can freely switch between SubGHz replay attacks, 2.4GHz spectrum analysis, WiFi attacks, and back to SubGHz without any crashes or lockups. Both radios work independently and reliably.

IS IT STILL A LITTLE BUGGY?? MAYBE!! If you open the SUbGHZ menu and open the SubGHz Replay Attack menu - you should see a pre check on your screen showing C1101 active.. as it starts so scan it will clear that out. then when you switch to the 2.4Ghz menu and start any of these functions it should switch and clear !! P.S I also added another feature here as well.. if you use your dpad and go LEFT of 300 it will do a SCAN function of all frequencies... press again to exit..

JesseCHale avatar Jan 22 '26 14:01 JesseCHale