For some unknown reason a couple of vigotec offline controllers (VigoStick) from our VEVOR 3018 farm stopped working with a blank screen of death.
First thing was to try to reverse engineer the pins that had no name in the bottom of the controller, turns out these are the UART0 that can be used to upload sketches to the ESP32.
Then i followed the LCD pins to map out the GPIOs that controlled the SPI ST7735 1.8 inch screen that vigostick is using:
- TFT_CS 15, TFT_RST 2, TFT_DC 12, TFT_SCLK 13, TFT_MOSI 14
Installed Adafruit_ST7735 library in arduino IDE and used the inbuilt graphics text example modifying the following code to align with the pinouts
#else
// For the breakout board, you can use any 2 or 3 pins.
// These pins will also work for the 1.8" TFT shield.
#define TFT_CS 15
#define TFT_RST 2 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 12
#define TFT_SCLK 13
#define TFT_MOSI 14
...
// For ST7735-based displays, we will use this call
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
...
// (This one also works but with glitches on the edge of the screen)
// Use this initializer if using a 1.8" TFT screen:
// tft.initR(INITR_BLACKTAB); // Init ST7735S chip, black tab
// OR use this initializer if using a 1.8" TFT screen with offset such as WaveShare:
tft.initR(INITR_GREENTAB); // Init ST7735S chip, green tab
To upload the code there is a trick that one must do when the program tries to connect to the serial and that is to short the GPIO0 to ground to put the ESP32 in boot mode, in case of the ESP32-WROOM-32E it is the farthest pinst to the right of the chip like in the picture
Ok so the ESP is working and the LCD is fine... something else is messed up
A couple of websearches and found a video explaining how to use arduino idea to backup and restore a flash image on a esp32, a tool called esptool that is well documented. So next thing was to try copying the code from a working ESP and injecting it to the vigotec to see if it worked.
- https://community.blynk.cc/t/how-to-backup-restore-official-firmware-on-any-espressif-esp8266-esp32/34309
- https://www.youtube.com/watch?v=2GwzbBn7uRw
# IINSTALL ESPTOOL
pip install esptool
# RUN ESPTOOL
esptool.py
# Change COM3 to your own Port
## For 1M Flash:
python esptool.py -b 115200 --port COM3 read_flash 0x000000 0x100000 flash_1M.bin
python esptool.py -b 115200 --port COM3 write_flash --flash_freq 80m 0x000000 flash_1M.bin
## For 4M Flash:
python esptool.py -b 115200 --port COM3 read_flash 0x00000 0x400000 flash_4M.bin
python esptool.py -b 115200 --port COM3 write_flash --flash_freq 80m 0x000000 flash_4M.bin
that is all
## Erasing Flash
esptool.py -b 115200 --port COM7 erase_flash
you should get something like this for the 4M flash
## BACKING UP
C:\Users\Utilizador>esptool.py -b 115200 --port COM7 read_flash 0x00000 0x400000 vigostik_132_211123_flash_4M.bin
esptool.py v4.6
Serial port COM7
Connecting..........
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: e0:e2:e6:5a:1a:10
Uploading stub...
Running stub...
Stub running...
4194304 (100 %)
4194304 (100 %)
Read 4194304 bytes at 0x00000000 in 391.4 seconds (85.7 kbit/s)...
Hard resetting via RTS pin...
## UPLOADING
C:\Users\Utilizador>esptool.py -b 115200 --port COM7 write_flash --flash_freq 80m 0x000000 vigostik_132_211123_flash_4M.bin
esptool.py v4.6
Serial port COM7
Connecting.....................
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting......
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 34:ab:95:4a:a2:50
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x003fffff...
Compressed 4194304 bytes to 1351601...
Wrote 4194304 bytes (1351601 compressed) at 0x00000000 in 189.5 seconds (effective 177.1 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
The cloning worked for the graphic demo but when i cloned a working vigostick to the non working one the blank screen returned... What now? I opened the binary file that i had just backed up in HxD to see if the file was encripted and it does not seem so, since there is unencripted text showing including M and G commands
Turns out i had not power cycled the ESP properly, so the cloning works but now this error:
Fatal Error
VigoStick 1.32 211123
Run Error!
My next guess is that the eeprom, that holds the webfiles is corrupted or mismatched, maybe filesystem upload is missing or maybe i messed up the memory size on the backup ???
Ok so dropping the image into a wemos with a similar EPS32-WROOM-32E chip and having easy acess to the enable button mi managed to get this debug list on the arduino serial monitor...
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
Falling back to built-in command interpreter.
OK
>ets Jun 8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
VIGO-STKBAAN-n9EQQuh5bP
Connecting to VIGOTEC with 12345678... Disconnected
.. Disconnected
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
Local AP VIGO-STKBAAN started, 192.168.0.1
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
HTTP server started
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
Get start...
[E][WiFiGeneric.cpp:739] hostByName(): DNS Failed for www.vigotec.cn
Get failed.
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
VigoStick 1.32 Build:211123 Start
And shorting enable to ground on the vigostick board i got this debug
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
VIGO-STKBKBH-tgVwL:iKVA
Connecting to VIGOTEC with 12345678... Disconnected
.. Disconnected
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
Local AP VIGO-STKBKBH started, 192.168.0.1
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
HTTP server started
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][sd_diskio.cpp:775] sdcard_mount(): f_mount failed: (3) The physical drive cannot work
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
Get start...
[E][WiFiGeneric.cpp:739] hostByName(): DNS Failed for www.vigotec.cn
Get failed.
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
VigoStick 1.32 Build:211123 Start
So the error is most likely just the fact that there is no GRBL board since the ESP is creating the Access Point and the control page can be accessed via the IP/Password that the serial dump shows.
So most likely this is done and fixed. I should probably extract the 1.5v from the newer controller if the error is the board connections, since the newer version handles that error more greacefully allowing full controll of the standalone controller instead of showing a blocking error like this version does :)
... It was not. I am out of ideas for a couple of days
The backed up vigostick firmware for the ESP32 can be downloaded here:
- https://github.com/X3msnake/my-gists-files/blob/main/vigostik_132_211123_flash_4M.bin
- https://github.com/X3msnake/my-gists-files/blob/main/vigostik_150_220504_flash_4M.bin
This is the full boot cycle of a healthy VigoStick when connected to the GRBL board
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
[E][sd_diskio.cpp:123] sdSelectCard(): Select Failed
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
VIGO-STKPTTM-8QUR6h45FM
Connecting to VIGOTEC with 12345678... Disconnected
.. Disconnected
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
Local AP VIGO-STKPTTM started, 192.168.0.1
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
[E][Preferences.cpp:49] begin(): nvs_open failed: NOT_FOUND
Grbl 1.1f ['$' for help]
VIGOTEC.SDEM1.1.0.220328
VigoStick 1.5 Build:220504 Start
$0=8
$1=25
$2=0
$3=0
$4=0
$5=0
$6=0
$10=1
$11=0.010
$12=0.002
$13=0
$20=0
$21=0
$22=0
$23=0
$24=25.000
$25=500.000
$26=250
$27=1.000
$30=1000
$31=0
$32=0
$33=0
$100=800.000
$101=800.000
$102=800.000
$110=1000.000
$111=1000.000
$112=1000.000
$120=50.000
$121=50.000
$122=20.000
$130=200.000
$131=200.000
$132=200.000
<Idle|MPos:0.000,0.000,0.000|FS:0,0|WCO:0.000,0.000,0.000>
So seems the cloning is missing some thing, well these stick supposedly upgrade Over The Air (OTA) so i got inside the webpage, added the network credentials, it rebooted and then i was able to check for updates...
After issuing the upgrade command and being greeted with the Update message on the ESP screen i waited for it to "UPDRADE..." as seen in the picture :P
It rebooted and it was working... probably china also has my gues wifi password now :P I'll just make a honeypot full of wasps out of it, just in case...
Either way it is fixed and hopefully it will help someone in a near future Last but not least, popped up inside the VigoStick portal one last time to change back the wifi ID and password. I dont want these things connected to the web nor i want everyone that can boot a machine to read my guest wifi and password at the boot screen so i used that to send a subliminal message
- (https://github.com/BlackVS/ESP32-reversing) good list with tools to reverse engineer the ESP32
💬 ESP32 Flash Memory Overview
<!--🧔 User-->
I want to understand how an ESP32 works, namely the flash memory. Does it have internal memory or does it use the EEPROM to flash to?
<!--🤖 Assistant-->
The ESP32 has its own internal flash memory for storing program code and data. It typically ranges from 4MB to 16MB. The flash memory is non-volatile and is commonly used to store firmware or program code.
<!--🧔 User-->
So, does the ESP32 resemble an FPGA, not having internal memory and always loading from external memory? Or is it more like an ATmega328P that stores the runtime code inside its internal memory?
<!--🤖 Assistant-->
Apologies for the confusion. The ESP32 does have its own internal flash memory, unlike an FPGA. It resembles an ATmega328P in terms of storing the runtime code inside its internal memory. The ESP32 has both internal flash memory and internal RAM.
<!--🧔 User-->
When popping the cover on an ESP32 shield, we can see two components: the IC and an EEPROM. Is the EEPROM used for flashing?
<!--🤖 Assistant-->
I apologize for the confusion again. The ESP32 does not have a built-in EEPROM. The component you see is likely an external EEPROM module, which is optional and not part of the ESP32 itself. It can be used for additional storage.
<!--🧔 User-->
So, that extra memory is where one stores the SPIFFS file system, for example?
<!--🤖 Assistant-->
Yes, that's correct. If an external EEPROM or other non-volatile storage component is present, it can be used to store the SPIFFS file system. SPIFFS is a lightweight file system designed for small embedded systems like the ESP32.
<!--🧔 User-->
If I want to do a full backup including SPIFFS, is there a way?
<!--🤖 Assistant-->
Yes, if you want to perform a full backup that includes the SPIFFS (SPI Flash File System) data along with the firmware, you can use a combination of tools and techniques.
Here's a general approach to achieve a full backup:
Backup the firmware: Use the
esptool
to backup the firmware from the internal flash memory of the ESP32, as described earlier. This will capture the bootloader, partition table, and the user application code.Backup the SPIFFS data: To back up the SPIFFS data, you will need to access the SPIFFS partition directly. The specific steps may vary depending on the framework or SDK you are using for ESP32 development (e.g., Arduino, ESP-IDF). In general, you'll need to mount the SPIFFS partition and read the files from it. Here's a high-level outline of the process:
a. Identify the SPIFFS partition: Determine the partition used for SPIFFS storage. This information is typically defined in the partition table configuration.
b. Mount the SPIFFS partition: Mount the SPIFFS partition in your ESP32 code. This allows you to access the files stored in the SPIFFS.
c. Read and copy the SPIFFS files: Iterate through the files in the SPIFFS partition, read their contents, and save them to your backup location. You can use file system APIs provided by the framework or SDK you are using to access and copy the files.
By following these steps, you can create a backup that includes both the firmware (captured using
esptool
) and the SPIFFS data. This way, you'll have a complete snapshot of the ESP32's internal flash memory, including both the program code and the files stored in the SPIFFS file system.<!--🧔 User-->
Thanks. One last thing, is there a way to download and share this conversation in markdown format for use on GitHub?
<!--🤖 Assistant-->
Yes, you can download and share the full conversation in a markdown format to use on GitHub or any other platform that supports markdown. Here's how you can do it:
Scroll to the beginning of the conversation and make sure all the desired content is visible on your screen.
Select and copy the entire conversation by either right-clicking and selecting "Copy" or using the keyboard shortcut (Ctrl+C or Command+C).
Open a text editor or a markdown editor of your choice.
Paste the copied conversation into the text editor by either right-clicking and selecting "Paste" or using the keyboard shortcut (Ctrl+V or Command+V).
Save the file with a
.md
extension (e.g.,conversation.md
).Now you have the conversation saved in a markdown file. You can upload this file to GitHub or any other platform that supports markdown and use it to display the conversation with the desired layout.
In a markdown file, you can further enhance the formatting by adding section headers, bullet points, code blocks, or any other markdown syntax to structure and style the conversation content as needed.
Please note that the markdown representation of the conversation will not retain the interactive aspects of the conversation with the AI model. It will only capture the textual content of the conversation.
<!--🧔 User-->
Create a full transcription of our chat to markdown for use in github gist, each interaction should be in a comment box and start with a emoji of a bearded user and another of your choice for the the assistant add "---" when the actor changes
Do not transcribe past this prompt
End of conversation.