Linux kernel module to use ESP8089 / ESP8266 over SPI. Intended for use with Raspberry Pi Zero.
If using an ESP8089, no changes are required to be made to the chip. If using an ESP8266, the SPI flash must first be desoldered. This is the 8-pin SOIC component near the 32-pin QFN die. The ESP-201 variation works well for this. Alternatively, one can use an off-brand NodeMCU or WeMos D1 Mini, albeit a version that doesn't use the ESP-12.
Raspberry Pi | ESP8266 / ESP8089 | Function |
---|---|---|
BCM 13 | CHIP_EN | esp_reset_gpio |
BCM 16 | GPIO10 / SDIO_DATA_3 | esp_cs0_pin |
BCM 19 | GPIO7 / SDIO_DATA_0 | MISO |
BCM 20 | GPIO11 / SDIO_CMD | MOSI |
BCM 21 | GPIO6 / SDIO_CLK | SCLK |
BCM 26 | GPIO8 / SDIO_DATA_1 | esp_interrupt |
3.3V | GPIO15 / MTDO | boot select |
3.3V | GPIO0 | boot select |
GND | GPIO2 | boot select |
It may be advisable to add a resistor across each I/O pin (33 ~ 330 Ohm).
Start with a fresh install of Raspbian.
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
sudo apt-get -y install raspberrypi-kernel-headers gcc git make
mkdir ~/esp
cd ~/esp
git clone https://github.com/notabucketofspam/ESP8089-SPI.git
cd ESP8089-SPI
sudo make install
sudo su
echo "options esp8089-spi esp_reset_gpio=13 esp_cs0_pin=16 esp_interrupt=26" > /etc/modprobe.d/esp.conf
echo "esp8089_spi" >> /etc/modprobe.d/blacklist
echo "spi_bcm2835" >> /etc/modules
echo "spi_bcm2835aux" >> /etc/modules
echo "esp8089_spi" >> /etc/modules
echo "dtoverlay=spi1-1cs,cs0_pin=16,cs0_spidev=disabled" >> /boot/config.txt
reboot
The ESP8266 is basically just a rehashed ESP8089, which is a wireless chip commonly used in many Unix-based devices. The ESP8089 is designed to load its firmware over SPI / SDIO when the device in question boots, whereas the ESP8266 is intended to load firmware off of the integrated SPI flash component. The pins used for this operation, though, are exposed on most varieties of the chip. These pins can be therefore utilized to load any custom firmware onto an ESP8266; in fact, this is what the eagle_fw#.h files are. The SPI flash must first be removed to do this.
Upon boot of the host device, the ESP chip is power cycled using the CHIP_EN pin (held low) and subsequently set to load code over SPI via GPIO15 (held high). During this time, GPIO0 must be held high and GPIO2 must be held low to select the correct boot mode.
https://hackaday.io/project/8678-rpi-wifi
https://github.com/al177/esp8089
https://github.com/george-hopkins/esp8089-spi
https://www.espressif.com/sites/default/files/documentation/esp8266-technical_reference_en.pdf
http://gamma.spb.ru/images/pdf/esp8089_datasheet_en.pdf
https://www.terraelectronica.ru/pdf/show?pdf_file=%252Fds%252Fpdf%252FE%252FEspressif_FAQ_EN.pdf
https://www.signal.com.tr/pdf/cat/8n-esp8266_spi_reference_en_v1.0.pdf
https://www.espressif.com/sites/default/files/documentation/ESP8266_Pin_List_0.xls