0

I am working with the Songhe Mega2560 + WiFi R3 Mega2560 + ESP8266 4MB Memory integrated circuit for a project involving connecting to a WiFi signal and reading the RSSI value.

Below is a basic sketch that I uploaded to the Mega2560 to communicate to the ESP8266 through Serial3 to test the firmware:

#include "WiFiEsp.h"

// Emulate Serial3 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL3
#include "SoftwareSerial.h"
SoftwareSerial Serial3(6, 7); // RX, TX
#endif

void setup() {
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial3.begin(115200);
  // initialize ESP module
  WiFi.init(&Serial3);

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue
    while (true);
  }

  // Print WiFi MAC address
  printMacAddress();
}

void loop() {
  // do nothing
}

I flashed different versions of espressif's AT firmware but the serial monitor keeps showing this:

22:28:07.009 -> [WiFiEsp] Initializing ESP module
22:28:08.023 -> [WiFiEsp] >>> TIMEOUT >>>
22:28:10.026 -> [WiFiEsp] >>> TIMEOUT >>>
22:28:12.022 -> [WiFiEsp] >>> TIMEOUT >>>
22:28:14.023 -> [WiFiEsp] >>> TIMEOUT >>>
22:28:16.020 -> [WiFiEsp] >>> TIMEOUT >>>
22:28:17.006 -> [WiFiEsp] Cannot initialize ESP module
22:28:23.017 -> [WiFiEsp] >>> TIMEOUT >>>
22:28:23.017 -> [WiFiEsp] No tag found
22:28:23.017 -> WiFi shield not present

I am not sure if it is a firmware issue so I have tried multiple versions of AT firmware. The baud rate I have set is 115200. I have been looking at many other sources online, but I cannot seem to initialize WiFiEsp's WiFi module and I would really appreciate some help on this matter.

I have been following these steps for flashing and testing.

  1. Toggle DIP switches 5,6,7 to ON and all else OFF and RXD/TXD to RXD0

  2. Connect USB cable from port COM3 (on my computer) to integrated PCB with Mega2560 + ESP8266 WiFi

  3. Use esptool.py to flash firmware to the ESP8266

    • The latest, released firmware for ESP8266 is the "ESP8266-IDF-AT_V2.2.1.0.zip" downloadable at espressif.com

    • I download the factory_xxx.bin to address 0 since I read that it indicates all hardware configurations for the ESP module. Below is the command I ran:

      esptool.py --chip auto --port COM3 --baud 115200 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_size 4MB 0x0 factory_WROOM-02.bin

  4. Disconnect USB cable

  5. Toggle DIP switches 1,2,3,4 to ON and all else OFF and RXD/TXD to RXD3

  6. Connect USB cable and upload sketch with Arduino IDE and read serial monitor

This is the procedure I have been trying to debug. If anymore information is required for better help, please let me know and I will try my best to provide.

The screenshot below is the command I run which successfully flashes (I think):

C:\Users\[MY NAME]\Downloads\ESP8266_NONOS_SDK-3.0.5\ESP8266_NONOS_SDK-3.0.5\bin>esptool.py write_flash --flash_mode dout --flash_size 4MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin
esptool.py v4.4
Found 1 serial ports
Serial port COM3
Connecting....
Detecting chip type... Unsupported detection protocol, switching and trying again...
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: a4:e5:7c:b6:77:c0
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash will be erased from 0x00000000 to 0x00000fff...
Flash will be erased from 0x00001000 to 0x00065fff...
Flash will be erased from 0x001fb000 to 0x001fbfff...
Flash will be erased from 0x001fc000 to 0x001fcfff...
Flash will be erased from 0x000fe000 to 0x000fefff...
Flash will be erased from 0x001fe000 to 0x001fefff...
Flash params set to 0x0360
Compressed 4080 bytes to 2936...
Wrote 4080 bytes (2936 compressed) at 0x00000000 in 0.4 seconds (effective 92.5 kbit/s)...
Hash of data verified.
Compressed 413556 bytes to 296987...
Wrote 413556 bytes (296987 compressed) at 0x00001000 in 26.2 seconds (effective 126.1 kbit/s)...
Hash of data verified.
Compressed 4096 bytes to 26...
Wrote 4096 bytes (26 compressed) at 0x001fb000 in 0.1 seconds (effective 373.3 kbit/s)...
Hash of data verified.
Compressed 128 bytes to 75...
Wrote 128 bytes (75 compressed) at 0x001fc000 in 0.1 seconds (effective 11.8 kbit/s)...
Hash of data verified.
Compressed 4096 bytes to 26...
Wrote 4096 bytes (26 compressed) at 0x000fe000 in 0.1 seconds (effective 365.1 kbit/s)...
Hash of data verified.
Compressed 4096 bytes to 26...
Wrote 4096 bytes (26 compressed) at 0x001fe000 in 0.1 seconds (effective 357.1 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...

After this, I test it with Arduino's SerialPassThrough sketch replacing Serial1 with Serial3 and I get no response from running the command: AT. I would appreciate any help on how to resolve this and where I could possibly be going wrong. Thanks!

Jarhatz
  • 1
  • 1
  • the WiFiEsp library doesn't work with AT 2. use AT 1.7.5 from SDK 3.0.5. https://github.com/espressif/ESP8266_NONOS_SDK/releases – Juraj Dec 22 '22 at 10:23
  • switch to esp8266 and make sure the firmware is working and returning OK to test command "AT". – Juraj Dec 22 '22 at 10:25
  • Looking at **ESP8266_NONOS_SDK-3.0.5**, I notice that the flash download addresses use _eagle.flash.bin_ and _eagle.irom0text.bin_ which are not included in the bin. I am using their [ESP8266-SDK_Getting Started Guide.](https://www.espressif.com/sites/default/files/documentation/2a-esp8266-sdk_getting_started_guide_en.pdf) – Jarhatz Dec 22 '22 at 21:08
  • I tried flashing it without the _eagle.flash.bin_ and _eagle.irom0text.bin_ files and I am still not getting OK from AT commands using your SerialPassThrough sketch with a baudrate of 115200. – Jarhatz Dec 22 '22 at 21:24
  • https://github.com/JAndrassy/WiFiEspAT#at-17-1 – Juraj Dec 23 '22 at 07:43
  • @Juraj this is the integrated circuit I am using: [Chip](https://www.amazon.com/SongHe-Mega2560-ATmega2560-ESP8266-Compatible/dp/B07THDDFSJ/ref=sr_1_2?crid=3Q7WAQJDQFIBS&keywords=songhe+mega2560+%2B+Wifi+R3+esp8266&qid=1672112851&sprefix=songhe+mega2560+%2B+wifi+r3+esp8266%2Caps%2C132&sr=8-2) I believe I correctly flashed the **ESP8266_NONOS_SDK-3.0.5** firmware but I never get any OK response on my serial monitor when I try writing AT (NL&CR). I keep getting no response. I am using the --flash-size 4MB-c1 option I am certain is right. I am not sure if my flash map partitioning is correct. – Jarhatz Dec 27 '22 at 03:48
  • Yes. I read and followed the instructions from the link you sent. I did not use eagle.irom0text.bin and eagle.flash.bin in the firmware installation. The esptooly.py command that I ran with flash partitions can be seen at the bottom of the post. – Jarhatz Dec 27 '22 at 07:38
  • I ran the command with switches 5,6,7 to ON: ```esptool.py --port COM3 --baud 115200 write_flash --flash_size 2MB-c1 0x0 boot_v1.7.bin 0x01000 at/1024+1024/user1.2048.new.5.bin 0x1fb000 blank.bin 0x1fc000 esp_init_data_default_v08.bin 0xfe000 blank.bin 0x1fe000 blank.bin``` Then, I set switches 5,6 to ON and opened a serial connection through PuTTY with baudrate of 74880 which resulted in this message: ```ets Jan 8 2013,rst cause:2, boot mode:(1,7)``` I looked into this ESP output and it may be a power constraint. I am just flashing the chip from my laptop using a USB serial cable. – Jarhatz Dec 27 '22 at 17:33
  • you have 7 still ON ("boot mode 1") it should be "boot mode:(3, 7)" – Juraj Dec 27 '22 at 18:16
  • Just to clarify, when I flashed it with 5,6,7 ON, I got "bootmode: (1,7)". When I flashed it with 5,6 ON, I got "bootmode: (1,6)" For both of these attempts, I cannot type any commands and hit ENTER with CL+NR. There is no input or output shown. By the way, the firmware I am flashing is the same command as provided in your link from earlier. – Jarhatz Dec 27 '22 at 18:46
  • you need boot mode 3 for the firmware to start – Juraj Dec 27 '22 at 19:58
  • I set DIP switch 7 to OFF. Only 5 and 6 are ON. I flashed the firmware with those settings. But it still says "bootmode: (1,7)." How do I change it to boot mode 3? Sorry if these are dumb questions, getting this ESP to work on this integrated circuit has been troubling me for weeks. – Jarhatz Dec 27 '22 at 21:26
  • does it still show mode 1 if you disconnect the board from USB and then connect it back? – Juraj Dec 28 '22 at 05:55
  • Yes, it does. I disconnect the board from the USB and reconnect it and I see: `ets Jan 8 2013,rst cause:2, boot mode:(1,7)` – Jarhatz Dec 28 '22 at 06:27

0 Answers0