matteocrippa / leafminer

A FOSS bitcoin miner for ESP8266 and ESP32
MIT License
70 stars 12 forks source link

ESP32 with 4MB of FLASH cannot run LeafMiner #30

Open PSLLSP opened 5 months ago

PSLLSP commented 5 months ago

LeafMiner v 0.0.13

Module with ESP32-WROOM-32 has USB-C with HL-340 UART, 4MB of FLASH, 30 pins, 2 buttons, 2 LEDs. It can run NerdMiner_V2 (ESP32-devkit v 1.6.3) but LeafMiner doesn't run on this board.

$ esptool.py flash_id
esptool.py v4.6.2
Found 1 serial ports
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
WARNING: Detected crystal freq 41.01MHz is quite different to normalized freq 40MHz. Unsupported crystal in use?
Crystal is 40MHz
MAC: 08:d1:f9:01:23:45
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

Flashed with LeafMiner 0.0.13:

# esptool.py  --baud 115200 write_flash -e 0 /dev/null # full chip ERASE
esptool.py --baud 115200 write_flash 0x0000 bootloader_esp32.bin
esptool.py --baud 115200 write_flash 0x8000 partitions_esp32.bin
esptool.py --baud 115200 write_flash 0x10000 firmware_esp32.bin

LeafMiner doesn't run:

$ miniterm /dev/ttyUSB0 115200
--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
invalid header: 0x04202040
invalid header: 0x04202040
invalid header: 0x04202040
invalid header: 0x04202040
invalid header: 0x04202040
invalid header: 0x04202040
invalid header: 0x04202040
invalid header: 0x04202040
ets Jul 29 2019 12:21:46

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
...
matteocrippa commented 5 months ago

Same here, I think there's something wrong in the cli flasher. I was testing using platformio on EP32, ESP32-S2 and ESP32-S3 and I never hit this issue, alternative can be an issue with the CI, but I don't think so

PSLLSP commented 5 months ago

I modified offset of bootloader from 0x0000 to 0x1000 and I see some progress. I was able to connect to WiFi LEAFMINER and configure the miner at http://192.168.4.1 but miner after reset cannot connect to my WiFi AP. NerdMiner was running on this module few minutes ago and it was working fine so I believe that WiFi configuration is correct and HW is not defective...

# esptool.py  --baud 115200 write_flash -e 0 /dev/null # full chip ERASE
esptool.py --baud 115200 write_flash 0x1000 bootloader_esp32.bin
esptool.py --baud 115200 write_flash 0x8000 partitions_esp32.bin
esptool.py --baud 115200 write_flash 0x10000 firmware_esp32.bin

This is what I see in the console, it looks like client cannot connect to WiFi...

$ miniterm /dev/ttyACM0 115200
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46

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:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
E (265) psram: PSRAM ID read error: 0xffffffff
[I] Main: LeafMiner - v.0.0.13 - (C: 2)
[I] Main: ESP32 - Disable WDT
[I] Storage: Setup: OK
[I] Blink: Setup
[I] Blink: Blinking 5 times
[I] AutoUpdate: Connecting to LuckyAP...

This is different ESP32 module than last time, so I add output from flash_id. This module is in format "WeMos D1", it has micro USB, reset button, two LED, UART is CH9102X.

$ esptool.py flash_id
esptool.py v4.6.2
Found 1 serial ports
Serial port /dev/ttyACM0
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP32
Chip is ESP32-D0WD-V3 (revision v3.1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: 08:d1:f9:01:23:56
Uploading stub...
Running stub...
Stub running...
Manufacturer: 5e
Device: 4016
Detected flash size: 4MB
Hard resetting via RTS pin...

Module is mining now! I am not sure what was wrong. I erased the flash, then flashed it and configured again and it is mining now. LED was configured to blink but it doesn't blink, it shines in blue. NerdMiner can blink this LED...

matteocrippa commented 4 months ago

@PSLLSP so it's mining, but not blinking? So we need to figure out what's the GPIO for the led, for sure it's not 2

matteocrippa commented 4 months ago

Btw checkin the verbose log of Platfomio, it flashes it in this way:

esptool.py --chip esp32 --port "/dev/cu.Bluetooth-Incoming-Port" --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 bootloader.bin 0x8000 partitions.bin 0xe000 .platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin 0x10000 .pio/build/esp32/firmware.bin
PSLLSP commented 4 months ago

It is interesting that PlatformIO flashes some file to address 0xe000 (0xe000 .platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin) but that file boot_app0.bin is not included in release files... NerdMiner has 4 files in release folder and 0xe000_boot_app0.bin is in the list...

matteocrippa commented 4 months ago

I added that file to the CI script, let's see if helps. An extra plan would be to prepare a web flasher, but I have not that time right now

PSLLSP commented 4 months ago

I see that version 0.0.15 was released and I see new files in release. I am curious about files 0xe000_boot_esp8266.bin and 0xe000_boot_geekmagic-smalltv.bin. I assume those should not be there. Please, verify in log file from PlatformIO...

Webflasher is great help for new users but I do not think it is priority at this point. LeafMiner is not ready for "mass production". I used NerdMiner and it works but there was no development for several months and even simple issue with pool password was not fixed so I was looking for an alternative. I have found LeafMiner. I still see it is not ready, so I have not replaced any NerdMiner with LeafMiner and I cannot recommend anyone to switch. That is why I think that webflasher is not priority. Even webflasher for NerdMiner is not without issues, some boards just cannot be flashed with their webflasher. esptool can flash all my boards...