MicroPython_K210_LoBo icon indicating copy to clipboard operation
MicroPython_K210_LoBo copied to clipboard

WiFi "Error setting baudrate"

Open CorruptName opened this issue 6 years ago • 50 comments

After successfully flashing the provided firmware, When I try to connect with this error. Sipeed Dock M1W with ESP8285

>>> import network
>>> wifi = network.wifi
>>> wifi.reset()
>>> wifi.debug(True)
True
>>> wifi.reset()
>>> import _thread, network, time, machine, socket, gc, os
>>> wifi.start(tx=7, rx=6, ssid="SSID", password="PASS", baudrate=921600, wait=True)
M (10359821780) [WIFI]: Initialize WiFi UART
M (10359825780) [WIFI]: UART #0: initialize uart hardware
M (10359856677) [WIFI]: UART #0: initialized, tx=7, rx=6, bdr=921641
M (10359882693) [WIFI]: WiFi TASK STARTED
M (10359985755) [ATCMD]: Check and set device baudrate
W (10360626108) [ATCMD]: Trying at 115200 bd
W (10361316499) [ATCMD]: Trying at 230400 bd
W (10362006892) [ATCMD]: Trying at 460800 bd
W (10362697281) [ATCMD]: Trying at 1000000 bd
W (10363387678) [ATCMD]: Trying at 2000000 bd
E (10364076089) [ATCMD]: Error setting baudrate
M (10364080371) [WIFI]: UART #0 deinitialized
M (10364085209) [WIFI]: WiFi TASK TERMINATED
False

And here is log from flash:

./flash.sh -t 1MB -m dout

==========================
Flashing ESP8266 firmware:
--------------------------
  Flash type: 1MB
  Flash mode: dout
   Partition: 0
     Address: 0x001000
    Firmware: '../upgrade/esp8285_AT_1_2.bin'
 Erase Flash: 'yes'
================================================

esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting........_____....._____.
Detecting chip type... ESP8266
Chip is ESP8285
Features: WiFi, Embedded Flash
Crystal is 40MHz
MAC: 60:01:94:f0:8e:09
Uploading stub...
Running stub...
Stub running...
Erasing flash (this may take a while)...
Chip erase completed successfully in 0.5s
Staying in bootloader.

esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._
Detecting chip type... ESP8266
Chip is ESP8285
Features: WiFi, Embedded Flash
Crystal is 40MHz
MAC: 60:01:94:f0:8e:09
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Compressed 128 bytes to 75...
Wrote 128 bytes (75 compressed) at 0x000fc000 in 0.0 seconds (effective 51.4 kbit/s)...
Hash of data verified.
Flash params set to 0x0320
Compressed 4080 bytes to 2696...
Wrote 4080 bytes (2696 compressed) at 0x00000000 in 0.4 seconds (effective 74.2 kbit/s)...
Hash of data verified.
Compressed 1684 bytes to 1206...
Wrote 1684 bytes (1206 compressed) at 0x0007b000 in 0.2 seconds (effective 67.4 kbit/s)...
Hash of data verified.
Compressed 435876 bytes to 313593...
Wrote 435876 bytes (313593 compressed) at 0x00001000 in 50.4 seconds (effective 69.2 kbit/s)...
Hash of data verified.

Leaving...
Staying in bootloader.

Finished.

On a side note, The instructions should probably be updated or the flash.sh script fixed.. The instructions state that we should: Execute `./flash.sh -eo -t 1MB -m DOUT` to erase the existing firmware But when we get to: Execute `./flash.sh -t 1MB -m DOUT` to flash the new firmware This also causes erase first. That makes 2 erases before write. Also, During the second command, we are given a very brief window to reboot device while holding esp8285 boot pin to ground. This can be very tricky. I think that "flash.sh" should be fixed to not perform erase during write action.

Also, All of the steps in the instructions are "#1" lol.

Oh yea, And: ./flash.sh -eo -t 1MB -m DOUT should be replaced with: ./flash.sh -eo -t 1MB -m dout Since it will fail with capitals.

CorruptName avatar Dec 19 '19 21:12 CorruptName

Okay, So now I'm about to give up.. Got no wifi connection at all. Tried to flash back to ESP8285's Original Firmware, from: http://dl.sipeed.com/MAIX/factory_firmware/esp8266/WiFiSPIESP.ino.esp8285_40M_freq_1M_DOUT.bin and loaded Sipeed's Maix 5.0 Firmware so everything should be stock. Now When i try to connect to wifi, I get : Stopped Because: couldn't init nic esp8285 ,try again please Now i can't get wifi at all. What's wrong here?

CorruptName avatar Dec 20 '19 00:12 CorruptName

It looks the WiFi firmware flash was OK. It is strange that you can't get any response from ESP8285. I'll try to look into it. I'm using M1W for 10 months and newer had a problem.

I supose you have disconnected usb->uart adapter before testing. You can try to init with

wifi.start(tx=7, rx=6, ssid="SSID", password="PASS", baudrate=115200, wait=True)

ESP8285 enable pin is connected to K210 io Pin #8 and pulled-up with 12K resistor. You must newer use Pin #8 while using WiFi. Yo can try to configure the Pin#8 as output and set it high before initializing WiFi (using machine.Pin).

ESP8285 must be initialized even with the original firmware, there should be responses to the commands...

At the moment I can't think of anything else, I'll report if I'll find something.

loboris avatar Dec 21 '19 10:12 loboris

Thanks for the comments about flashing process. I'll use them to update the instructions for the next update.

loboris avatar Dec 21 '19 10:12 loboris

I submitted a pull request for changes to Readme.md if you would like to look at it. I will try your suggestions.

CorruptName avatar Dec 21 '19 15:12 CorruptName

So this is what i get on the original firmware:

>>> fm.register(8, fm.fpioa.GPIOHS0, force=True)
1
>>> wifi_en=GPIO(GPIO.GPIOHS0, GPIO.OUT)
>>>
>>> fm.register(board_info.WIFI_RX, fm.fpioa.UART2_TX, force=True)
1
>>> fm.register(board_info.WIFI_TX, fm.fpioa.UART2_RX, force=True)
1
>>> uart = UART(UART.UART2,115200, timeout=1000, read_buf_len=4096)
>>>
>>> wifi_en.value(1)
>>> nic = network.ESP8285(uart)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: couldn't init nic esp8285 ,try again please

I will have to load yours again to see what happens. I'm just confused why if i set everything back to factory it still does not work? I loaded the ESP8285 FW from the link above. 8(

CorruptName avatar Dec 21 '19 16:12 CorruptName

"I'm just confused why if i set everything back to factory it still does not work?" Was it ever working?

loboris avatar Dec 21 '19 16:12 loboris

"I'm just confused why if i set everything back to factory it still does not work?" Was it ever working?

Yes. Definitely.

CorruptName avatar Dec 21 '19 16:12 CorruptName

now i'm back on your firmware, wifi and k210:

 __  __              _____  __   __  _____   __     __
|  \/  |     /\     |_   _| \ \ / / |  __ \  \ \   / /
| \  / |    /  \      | |    \ V /  | |__) |  \ \_/ /
| |\/| |   / /\ \     | |     > <   |  ___/    \   /
| |  | |  / ____ \   _| |_   / . \  | |         | |
|_|  |_| /_/    \_\ |_____| /_/ \_\ |_|         |_|
------------------------------------------------------

MaixPy-FreeRTOS by LoBo v1.11.11
--------------------------------
MicroPython 1.11.11 (1abe503-dirty) built on 2019-12-19; Sipeed_board with Kendryte-K210
Type "help()" for more information.
>>> from machine import Pin
>>> import network
>>>
>>> wifi_en = Pin(8, Pin.OUT)
>>> wifi_en.value(1)
>>> wifi.start(tx=7, rx=6, ssid="SSID", password="PASS", baudrate=115200, wait=True)
M (239179352) [WIFI]: Initialize WiFi UART
M (239183180) [WIFI]: UART #0: initialize uart hardware
M (239213350) [WIFI]: UART #0: initialized, tx=7, rx=6, bdr=115205
M (239238364) [WIFI]: WiFi TASK STARTED
M (239341419) [ATCMD]: Check and set device baudrate
W (239981778) [ATCMD]: Trying at 230400 bd
W (240671162) [ATCMD]: Trying at 460800 bd
W (241360551) [ATCMD]: Trying at 921600 bd
W (242049936) [ATCMD]: Trying at 1000000 bd
W (242739325) [ATCMD]: Trying at 2000000 bd
E (243428705) [ATCMD]: Error setting baudrate
M (243432812) [WIFI]: UART #0 deinitialized
M (243437477) [WIFI]: WiFi TASK TERMINATED
False

CorruptName avatar Dec 21 '19 16:12 CorruptName

You think the flash may have destroyed the ESP8285?

CorruptName avatar Dec 21 '19 17:12 CorruptName

It is impossible to destroy ESP8285 by flashing! But it is possible it was not flashed correctly. You can try some other flashing method.

You can try to attach usb->uart adapter (Rx) to esp8285 Tx (K210 Rx) without connecting adapter's Tx, to see if there is any communicattion, there should be. I think ESP8285 prints some messages after reset (at 115200 bd).

loboris avatar Dec 21 '19 17:12 loboris

I know it is no longer labeled "DanDock" like the one from the wifi flash readme.md picture. Instead it says "Maix Dock". From our previous problems, it seems they have used slower flash, what else did they change? (rhetorical)

CorruptName avatar Dec 21 '19 17:12 CorruptName

It is impossible to destroy ESP8285 by flashing! But it is possible it was not flashed correctly. You can try some other flashing method.

You can try to attach usb->uart adapter (Rx) to esp8285 Tx (K210 Rx) without connecting adapter's Tx, to see if there is any communicattion, there should be. I think ESP8285 prints some messages after reset (at 115200 bd).

I did try this, I'll do it again and post results.

CorruptName avatar Dec 21 '19 17:12 CorruptName

ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x40108000, len 3056, room 16
tail 0
chksum 0xd7
load 0x3fffb000, len 992, room 8
tail 8
chksum 0xd7
csum 0xd7▒"xn▒▒9▒9▒9▒▒9▒9▒▒9▒   H~▒▒V$5u▒▒▒I▒ŨR@+       ▒[▒9▒▒9▒9▒▒9▒9▒9▒▒!▒▒xZr%r)Q*!▒̙▒b▒c▒▒$v▒▒▒▒-▒▒F▒ޛ
                         "▒▒▒jq+ͫQ▒▒▒ը▒▒٨vJa▒U▒▒-!1▒▒▒▒r▒zY▒▒▒Y▒v▒       ▒r@▒y(1▒1ƭ8▒ "@j▒l

Does that mean anything to you? LOL

CorruptName avatar Dec 21 '19 17:12 CorruptName

BTW, I tried flashing back to original fw using "flash_download_tools_v3.6.8" from espressif. Didn't seem to make any difference so i went back to esptool. Should I try this to flash your FW?

CorruptName avatar Dec 21 '19 17:12 CorruptName

It also prints this when i go from LOW to HIGH on pin 8 (wifi_en):

ets Jan  8 2013,rst cause:1, boot mode:(3,7)

load 0x40108000, len 3056, room 16
tail 0
chksum 0xd7
load 0x3fffb000, len 992, room 8
tail 8
chksum 0xd7
csum 0xd7▒x▒9▒9▒9▒▒9▒9▒9▒▒9▒    H~▒▒V$5u▒▒▒I▒ըR@+       ▒[˹▒9▒9▒9▒▒9▒9▒▒9c▒!▒hxZ%r+Q*!▒̙▒b▒c▒▒▒▒vm▒▒q-▒▒▒▒ޛ
                         "▒▒▒jq+ͫ▒▒▒▒ը▒m▒(vJa▒▒U▒▒-!▒1▒▒r▒z٨▒▒Y(v▒      ▒r@p▒(1▒1▒-8▒ "▒j▒▒

CorruptName avatar Dec 21 '19 17:12 CorruptName

Okay, so i watched while it does "Check and set device baudrate" and I get unknown chars. I have no idea what baud it is trying to use. I have tried many possible baud rates and nothing seems to be correct. LMK what you think.

CorruptName avatar Dec 21 '19 17:12 CorruptName

With my firmware flashed, you should get the following messages after esp8285 reset (pin8_lo -> pin8_hi):

����
==============================
LoBo ESP8266 Bootloader v1.2.0
==============================
   Flash map: 2, 1MB (512+512)
  Flash mode: DOUT, [ESP8285]
Reset reason: POWER_ON

Loading configured firmware (0)
  Address: 001000
Starting firmware 0, map 2 from 001000...


ready
AT

OK
ATE0

OK
+TCPCOMMANDS:1

OK
+CWMODE:1

OK
No AP

OK
No AP

OK
WIFI DISCONNECT
+CWJAP:3

FAIL

The massages after Starting firmware 0, map 2 from 001000... will be wisible only if ESP8285 baud rate was set to 11520 (after that message ESP8285 switches to the stored AT-command baud rate).

The baud rates tried by wifi driver are 115200, 230400, 460800, 921600, 1000000, 2000000

Before starting wifi you can connect usb->uart TX line to ESP8285 and execute AT commands directly from some terminal emulator (minicom, putty)

MicroPython

>>> wifi_en.value(0)
>>> wifi_en.value(1)

terminal:

����
==============================
LoBo ESP8266 Bootloader v1.2.0
==============================
   Flash map: 2, 1MB (512+512)
  Flash mode: DOUT, [ESP8285]
Reset reason: POWER_ON

Loading configured firmware (0)
  Address: 001000
Starting firmware 0, map 2 from 001000...


ready
WIFI DISCONNECT
at

OK
at+GMR
AT version:1.7.0.0(Apr 16 2019 15:31:04)
SDK version:3.1.0-dev(3b41fcf)
Compile time: Jun 30 2019 14:56:44
ESP8266_AT_LoBo v1.3.1
OK

Remember that at commands must be terminated with \r\n, you can use ctrl+m, ctrl+j if the terminal emulator doesn't emit both on return key.

If you don't get the response try to change terminal emulator baud rate until you get it.

loboris avatar Dec 21 '19 19:12 loboris

����

LoBo ESP8266 Bootloader v1.2.0

Flash map: 2, 1MB (512+512) Flash mode: DOUT, [ESP8285] Reset reason: POWER_ON

Loading configured firmware (0) Address: 001000 Starting firmware 0, map 2 from 001000...

ready WIFI DISCONNECT at

OK at+GMR AT version:1.7.0.0(Apr 16 2019 15:31:04) SDK version:3.1.0-dev(3b41fcf) Compile time: Jun 30 2019 14:56:44 ESP8266_AT_LoBo v1.3.1 OK

Yea, I'm not getting anything like that at 115200. I get what I posted. I just reflashed your firmware again too. Seems to be going perfectly. I have tried to communicate at many different baud rates, including the ones listed with no success. Even tried using Arduino IDE serial monitor since i know it can send both LF + CR. When i send "AT" at 115200, i get a response of "!".

CorruptName avatar Dec 21 '19 19:12 CorruptName

This is what i get when booting or when toggle wifi_en.value 0 > 1

14:33:55.651 ->  ets Jan  8 2013,rst cause:1, boot mode:(3,6)
14:33:55.651 -> 
14:33:55.651 -> load 0x40108000, len 3056, room 16 
14:33:55.651 -> tail 0
14:33:55.651 -> chksum 0xd7
14:33:55.651 -> load 0x3fffb000, len 992, room 8 
14:33:55.651 -> tail 8
14:33:55.651 -> chksum 0xd7
14:33:55.651 -> csum 0xd7⸮x⸮⸮9⸮9⸮⸮9⸮9⸮9⸮⸮9⸮	H~⸮⸮V$5u⸮⸮⸮⸮I⸮ըR@+	⸮[˹⸮9⸮9⸮9⸮⸮9⸮9⸮⸮c⸮!⸮hxZr⸮⸮QJ`J⸮%"⸮⸮
%r+Q*!⸮̙⸮b⸮c⸮⸮⸮⸮vm⸮⸮q-⸮⸮⸮⸮ޛ
14:33:55.685 -> "⸮⸮Ijq+ͫ⸮⸮⸮⸮ը⸮m⸮(vJa⸮⸮U⸮⸮-!⸮1⸮⸮r⸮zY⸮⸮⸮٨v⸮	⸮r@⸮y(1⸮1֭8⸮ "@j⸮⸮ 

CorruptName avatar Dec 21 '19 19:12 CorruptName

I just ordered a new board, maybe i can read the flash from it and flash this one back to stock? IDK.

CorruptName avatar Dec 21 '19 19:12 CorruptName

Hey, i just realized something.. The "ESP DOWNLOAD TOOL" reports that the ESP8285 has:

flash vendor:
51h : N/A
flash devID:
4014h
QUAD;8Mbit
crystal:
40 Mhz

Could this be the issue? 8mbit flash instead of 1mbit? Also, I got new Board today so i will try to read the flash from that and flash it to "broken" board in order to recover.

CorruptName avatar Dec 22 '19 21:12 CorruptName

ESP8285 has 1MB Flash 8Mbit === 1Mbyte, it's ok

loboris avatar Dec 22 '19 21:12 loboris

i feel stupid, just realized that. Somehow i just did esptool read_flash for to 0x800000 tho lol.

CorruptName avatar Dec 22 '19 22:12 CorruptName

Okay, it works again on stock firmware. Just successfully read flash from the new board and wrote it to the old one. Now WiFi works again.

MicroPython v0.5.0 on 2019-11-29; Sipeed_M1 with kendryte-k210
Type "help()" for more information.
>>> import network
>>> from machine import UART
>>> from Maix import GPIO
>>>
>>> fm.register(8, fm.fpioa.GPIOHS0, force=True)
1
>>> wifi_en=GPIO(GPIO.GPIOHS0, GPIO.OUT)
>>> fm.register(board_info.WIFI_RX, fm.fpioa.UART2_TX, force=True)
1
>>> fm.register(board_info.WIFI_TX, fm.fpioa.UART2_RX, force=True)
1
>>> uart = UART(UART.UART2,115200,timeout=1000, read_buf_len=4096)
>>> wifi_en.value(1)
>>> nic = network.ESP8285(uart)
>>> nic.connect("_ssid_", "_password_")
>>> nic.ifconfig()
('192.168.1.122', '255.255.255.0', '192.168.1.1', '0', '0', 'MAC', '_ssid_')

CorruptName avatar Dec 22 '19 22:12 CorruptName

So to recap, I don't think it's something wrong with your frimware, since the frimware posted by Sipeed doesn't work either. I'm going to post this firmware I just read here in case anyone else needs to flash back to stock and finds there is no working firmware available. Google Drive

CorruptName avatar Dec 22 '19 22:12 CorruptName

So now I'm back to stock and wifi works again. I tried flashing the esp8285 with your firmware again and had the same problem. Your firmware simply does not work with my board. When I try to use stock esp8285 firmware with your K210 firmware, I get this message. Any Suggestions? Any ideas to make your firmware work with esp8285?

M (27406130) [WIFI]: Initialize WiFi UART
M (27409871) [WIFI]: UART #0: initialize uart hardware
M (27439922) [WIFI]: UART #0: initialized, tx=7, rx=6, bdr=115205
M (27464936) [WIFI]: WiFi TASK STARTED
M (27567998) [ATCMD]: Check and set device baudrate
M (27584015) [ATCMD]: Device communicating at 115200 bd
M (27588974) [WIFI]: WiFi device initialization start
M (28104333) [ATCMD]: AT COMMAND: [AT\r\n] Expecting: [\r\nOK\r\n]
M (28112338) [ATCMD]: AT RESPONSE: match condition 1 at position 5 (2 ms, 0 byte(s), buf_start=0)
M (28130344) [ATCMD]: AT COMMAND: [ATE0\r\n] Expecting: [\r\nOK\r\n]
M (28138349) [ATCMD]: AT RESPONSE: match condition 1 at position 7 (2 ms, 0 byte(s), buf_start=0)
M (28156355) [ATCMD]: AT COMMAND: [AT+TCPCLOSE?\r\n] Expecting: [\r\nOK\r\n]
W (28265411) [ATCMD]: AT COMMAND: TIMEOUT (100 ms, 9)
M (28379481) [ATCMD]: AT COMMAND: [AT+TCPCLOSE?\r\n] Expecting: [\r\nOK\r\n]
W (28488534) [ATCMD]: AT COMMAND: TIMEOUT (100 ms, 9)
E (28592597) [WIFI]: Firmware supporting TCP commands must be used
M (28598526) [WIFI]: UART #0 deinitialized
M (28603106) [WIFI]: WiFi TASK TERMINATED

CorruptName avatar Dec 24 '19 18:12 CorruptName

It looks there is some issue with WiFi firmware provided in this repository's firmware/wifi/upgrade/ directory. Could you, please, try to flash the firmware from ESP8266_AT_LoBo. Just clone the repository, change the working directory to at_lobo inside the cloned directory and flash. The flash procedure (and flash script) is the same.

If the WiFi task is not started after the first init (WiFi TASK TERMINATED), just try again with the correct wifi credentials (after the first try some default configuration values are saved).

loboris avatar Dec 26 '19 13:12 loboris

It looks there is some issue with WiFi firmware provided in this repository's firmware/wifi/upgrade/ directory. Could you, please, try to flash the firmware from ESP8266_AT_LoBo. Just clone the repository, change the working directory to at_lobo inside the cloned directory and flash. The flash procedure (and flash script) is the same.

If the WiFi task is not started after the first init (WiFi TASK TERMINATED), just try again with the correct wifi credentials (after the first try some default configuration values are saved).

I'm about to try. I don't have high hopes though since the firmware from sipeed didn't work either, i doubt if it's a problem with both firmwares. More likely (to me) that there was a change in hardware that requires a different firmware which is causing the issue.

CorruptName avatar Dec 26 '19 14:12 CorruptName

I'm quite sure it will work as I've tested it today on a new M1W module, not previously flashed...

loboris avatar Dec 26 '19 14:12 loboris

>>> import network
>>> wifi = network.wifi
>>> wifi.debug(True)
True
>>> wifi.start(tx=7,rx=6,ssid=_ssid_,password=_pw_,wait=True)
M (185704869) [WIFI]: Initialize WiFi UART
M (185708696) [WIFI]: UART #0: initialize uart hardware
M (185738755) [WIFI]: UART #0: initialized, tx=7, rx=6, bdr=115205
M (185763769) [WIFI]: WiFi TASK STARTED
M (185866825) [ATCMD]: Check and set device baudrate
W (186507184) [ATCMD]: Trying at 230400 bd
W (187196572) [ATCMD]: Trying at 460800 bd
W (187885969) [ATCMD]: Trying at 921600 bd
W (188575360) [ATCMD]: Trying at 1000000 bd
W (189264750) [ATCMD]: Trying at 2000000 bd
E (189954141) [ATCMD]: Error setting baudrate
M (189958248) [WIFI]: UART #0 deinitialized
M (189962915) [WIFI]: WiFi TASK TERMINATED
False
>>> wifi.start(tx=7,rx=6,ssid=_ssid_,password=_pw_,wait=True)
M (202239698) [WIFI]: Initialize WiFi UART
M (202243524) [WIFI]: UART #0: initialize uart hardware
M (202273696) [WIFI]: UART #0: initialized, tx=7, rx=6, bdr=115205
M (202298711) [WIFI]: WiFi TASK STARTED
M (202401767) [ATCMD]: Check and set device baudrate
W (203042162) [ATCMD]: Trying at 230400 bd
W (203731583) [ATCMD]: Trying at 460800 bd
W (204420965) [ATCMD]: Trying at 921600 bd
W (205110362) [ATCMD]: Trying at 1000000 bd
W (205799772) [ATCMD]: Trying at 2000000 bd
E (206489176) [ATCMD]: Error setting baudrate
M (206493283) [WIFI]: UART #0 deinitialized
M (206497950) [WIFI]: WiFi TASK TERMINATED
False
>>>

CorruptName avatar Dec 26 '19 14:12 CorruptName