-->
Page 1 of 1

Trying to read esp8266 boot messages results in garbage

PostPosted: Tue Jan 16, 2018 12:38 pm
by lpares12
Hi,

I recently bought and ESP-01 to start with ESP8266 development, but can't make it run anything. So after reading the SDK I wanted to make sure that my connections and everything were properly set.

I've been trying to read the messages that the ESP8266 prints to UART0 on boot, as explained in page 172 of http://espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf. The problem is that I can't manage to read them, I only get garbage messages in the putty console.

My schematic is the following:
Image

Whenever I want to flash I connect the pin IO0 to ground and whenever I want to run the code I connect it to VCC. And also note that the MB102 is powered by a USB cable directly from my computer.

In theory whenever you boot the ESP-01 you should get some messages through console. So before booting I open a serial connection in putty with /dev/ttyUSB0 and baud rate 76800 (although I've tried several with no luck!). Then, I boot the ESP-01 and get some garbage in the serial console, but nothing readable.

For building the toolchain in Unix I followed this tutorial https://primalcortex.wordpress.com/2015/01/09/esp8266-setting-up-native-sdks-on-linux-and-exploring-some-applications/

And I tried to execute the blinky example https://github.com/esp8266/source-code-examples/tree/master/blinky (I had to change the Makefile to set ESPTOOL variable to my correct path).

After building it I flashed it by executing
Code: Select allsudo make flash
, which outputs:
user@pc:/opt/Espressif/ESP8266_SDK/blinky$ sudo make flash
/opt/Espressif/esptool-py/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 firmware/0x00000.bin 0x40000 firmware/0x40000.bin
esptool.py v2.3-dev
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Compressed 30784 bytes to 21342...
Wrote 30784 bytes (21342 compressed) at 0x00000000 in 1.9 seconds (effective 129.4 kbit/s)...
Hash of data verified.
Compressed 137476 bytes to 103602...
Wrote 137476 bytes (103602 compressed) at 0x00040000 in 9.2 seconds (effective 119.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting...


So everything looks fine, to run it I pull IO0 up and reboot the ESP-01. Again I receive a garbage boot message and the firmware doesn't execute correctly since the LED isn't blinking. The main reason I was trying to read the boot message was to make sure that everything was correctly working, but it looks like something is failing.

Does anyone have any idea what I could be doing wrong?

Thanks!

Re: Trying to read esp8266 boot messages results in garbage

PostPosted: Wed Jan 17, 2018 7:14 am
by lpares12
I finally managed to read the boot message! To solve it I stopped using putty and started using python serial.tools.miniterm which does something different than putty and fixed my problem. So I run:

[url]python -m serial.tools.miniterm /dev/ttyUSB0 76800[/url]

Now I'm getting this output when running my firmware:

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

load 0x3ffe8000, len 2636, room 16
tail 12
chksum 0xef
ho 0 tail 12 room 4
load 0x00000000, len 0, room 12
tail 0
chksum 0xef
load 0x00000000, len 0, room 4
tail 0
chksum 0xef
csum 0xef
csum err
ets_main.c


Why am I getting a checksum error if I read in the documentation pdf http://espressif.com/sites/default/files/documentation/2c-esp8266_non_os_sdk_api_reference_en.pdf that if chksum == csum the flash was read successfully?

My code is the following:

Code: Select all#include "ets_sys.h"
#include "osapi.h"
#include "gpio.h"
#include "os_type.h"
#include "user_config.h"

#define user_procTaskPrio        0
#define user_procTaskQueueLen    1
os_event_t    user_procTaskQueue[user_procTaskQueueLen];
static void user_procTask(os_event_t *events);

LOCAL os_timer_t blink_timer;
LOCAL uint8_t led_state=0;

LOCAL void ICACHE_FLASH_ATTR blink_cb(void *arg)
{
    led_state = !led_state;
    GPIO_OUTPUT_SET(2, led_state);
}

//Do nothing function
static void ICACHE_FLASH_ATTR
user_procTask(os_event_t *events)
{
    os_delay_us(10);
}

//Init function
void ICACHE_FLASH_ATTR
user_init()
{
    // Initialize the GPIO subsystem.
    gpio_init();

    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);

    os_timer_disarm(&blink_timer);
    os_timer_setfn(&blink_timer, (os_timer_func_t *)blink_cb, (void *)0);
    os_timer_arm(&blink_timer, 1000, 1);
   
    //Start os task
    system_os_task(user_procTask, user_procTaskPrio,user_procTaskQueue, user_procTaskQueueLen);
}

Re: Trying to read esp8266 boot messages results in garbage

PostPosted: Thu Jan 18, 2018 11:21 am
by lpares12
After more days than I wish to admit I was able to upload my code to the ESP-01 ESP8266.

For anyone having the same problem I had about the csum err I'd recommend you try all the different combinations in configuration when flashing the ESP8266. The configuration that worked for me was the following:

Code: Select allesptool.py --port /dev/ttyUSB0 write_flash -fm dout -ff 40m -fs 1MB 0x00000 firmware/0x00000.bin 0x40000 firmware/0x40000.bin


I was trying to use flash mode dout as a lot of forums said, but this wasn't enough for me, I also needed to set the flash frequency to 40MHz and the flash size to 1MB.

Hope this post helps fellow programmers.