WDT reset on pwm_init

snapdan
Posts: 4
Joined: Sun Jan 24, 2016 9:24 am

WDT reset on pwm_init

Postby snapdan » Sun Jan 24, 2016 9:36 am

I'm able to get pwm working with the following code:

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"

void show_mac (void) {
    unsigned char mac[6];
    // wifi_get_macaddr ( STATION_IF, mac );
    // os_printf ( "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
    // mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
}
 
void user_init() {

    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

    // show_mac ();

}


However, if I un-comment just line 7 so it's like so:

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"

void show_mac (void) {
    unsigned char mac[6];
    wifi_get_macaddr ( STATION_IF, mac );
    // os_printf ( "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
    // mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
}
 
void user_init() {

    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

    // show_mac ();

}


It crashes:

ets Jan 8 2013,rst cause:4, boot mode:(1,0)

wdt reset


Which is especially strange since I'm still not even calling the show_mac() function!

I'm using the pfalcon/open-sdk and toolchain, which uses the v1.4.0 sdk. Here's the makefile I'm using:

Code: Select all

# Makefile for older versions (<1.0) of Espressif "AT" firmware
CC = xtensa-lx106-elf-gcc
CFLAGS = -I. -mlongcalls
LDLIBS = -nostdlib -Wl,--start-group -lmain -lupgrade -lnet80211 -lwpa -llwip -lpp -lphy -Wl,--end-group -lcirom -lgcc -lpwm
LDFLAGS = -Teagle.app.v6.ld

malarm-0x00000.bin: malarm
   esptool.py elf2image $^

malarm: malarm.o
   $(CC) $(LDFLAGS) $^ -o $@ $(LDLIBS)

malarm.o: malarm.c

flash: malarm-0x00000.bin
   esptool.py write_flash 0 malarm-0x00000.bin 0x40000 malarm-0x40000.bin

connect:
   picocom -b 115200 --omap crcrlf /dev/ttyUSB0


Any thoughts or ideas? Thanks.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: WDT reset on pwm_init

Postby ESP_Faye » Mon Jan 25, 2016 5:00 pm

Hi,

If you want to download firmware into Flash, it is : MTDO:0,GPIO0:0,GPIO2:1.
If you want to run the firmware, it is : MTDO:0,GPIO0:1,GPIO2:1.

It seems your GPIO0 is still in low-level, so the ESP8266 could not run the firmware.

If your problem is still unsolved, please feel free to let us know.

snapdan
Posts: 4
Joined: Sun Jan 24, 2016 9:24 am

Re: WDT reset on pwm_init

Postby snapdan » Tue Jan 26, 2016 9:38 am

Espressif_Faye wrote:Hi,

If you want to download firmware into Flash, it is : MTDO:0,GPIO0:0,GPIO2:1.
If you want to run the firmware, it is : MTDO:0,GPIO0:1,GPIO2:1.

It seems your GPIO0 is still in low-level, so the ESP8266 could not run the firmware.

If your problem is still unsolved, please feel free to let us know.


Ah, thank you but that's not the problem. Sorry - I should have been clearer with the debug output. With this code

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"

void show_mac (void) {
    unsigned char mac[6];
    // wifi_get_macaddr ( STATION_IF, mac );
    // os_printf ( "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
    // mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
}
 
void user_init() {

    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

    // show_mac ();

}


the pwm works (I have it connected to a piezo and it's making a tone) and I get the expected output

r��`rlmode : sta(18:fe:34:9f:da:75) + softAP(1a:fe:34:9f:da:75)
add if0
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
f r0, scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 1
cnt

connected with MuseumWorst, channel 5
dhcp client start...
ip:192.168.1.81,mask:255.255.255.0,gw:192.168.1.254


When I un-comment line 7 - which is never even used:

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"

void show_mac (void) {
    unsigned char mac[6];
    wifi_get_macaddr ( STATION_IF, mac );
    // os_printf ( "MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
    // mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] );
}
 
void user_init() {

    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

    // show_mac ();

}


I get constant wdt resets and it never seems to make it through pwm_init (the piezo is silent) :

b��`rlmode : sta(18:fe:34:9f:da:75) + softAP(1a:fe:34:9f:da:75)
add if0
add if1
dhcp server start:(ip:192.
ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 27360, room 16
tail 0
chksum 0x5d
load 0x3ffe8000, len 904, room 8
tail 0
chksum 0x9d
load 0x3ffe8388, len 244, room 8
tail 12
chksum 0xbf
csum 0xbf
rlmode : sta(18:fe:34:9f:da:75) + softAP(1a:fe:34:9f:da:75)
add if0
add if1
dhcp server start:(ip:192.
ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 27360, room 16
tail 0
chksum 0x5d
load 0x3ffe8000, len 904, room 8
tail 0
chksum 0x9d
load 0x3ffe8388, len 244, room 8
tail 12
chksum 0xbf
csum 0xbf
rlmode : sta(18:fe:34:9f:da:75) + softAP(1a:fe:34:9f:da:75)
add if0
add if1
dhcp server start:(ip:192.


Even just trying to add any more debug messages with os_printf causes the resets as well.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: WDT reset on pwm_init

Postby ESP_Faye » Thu Jan 28, 2016 12:10 pm

Hi,

I tested your code, it works fine, no WDT reset.

Did you download a wrong bin file ? It seems that your log is not corresponding to your test code.
In your log, the ESP8266 connects to a router, but there is no this part in your test code.

snapdan
Posts: 4
Joined: Sun Jan 24, 2016 9:24 am

Re: WDT reset on pwm_init

Postby snapdan » Sun Jan 31, 2016 3:23 am

Espressif_Faye wrote:Hi,

I tested your code, it works fine, no WDT reset.

Did you download a wrong bin file ? It seems that your log is not corresponding to your test code.
In your log, the ESP8266 connects to a router, but there is no this part in your test code.


Thanks for checking. It was connecting to a router because it was stored in flash. I cleared that with system_restore() and changed the code but it still resets when it gets to the pwm_init.

This code:

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
 
void user_init() {

    // wifi_set_opmode_current(STATION_MODE);
    wifi_set_opmode_current(SOFTAP_MODE);
    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

}


Gets this output:

�lrl�mode : softAP(1a:fe:34:9f:da:75)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)

ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 27336, room 16
tail 8
chksum 0x9f
load 0x3ffe8000, len 904, room 0
tail 8
chksum 0x5f
load 0x3ffe8388, len 244, room 0
tail 4
chksum 0x7d
csum 0x7d
rl�mode : softAP(1a:fe:34:9f:da:75)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)

ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 27336, room 16
tail 8
chksum 0x9f
load 0x3ffe8000, len 904, room 0
tail 8
chksum 0x5f
load 0x3ffe8388, len 244, room 0
tail 4
chksum 0x7d
csum 0x7d
rl�mode : softAP(1a:fe:34:9f:da:75)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)


This code:

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
 
void user_init() {

    wifi_set_opmode_current(STATION_MODE);
    // wifi_set_opmode_current(SOFTAP_MODE);
    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

}


Gets this output:

�l�lrl�mode : sta(18:fe:34:9f:da:75)
add if0

ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 27336, room 16
tail 8
chksum 0x9c
load 0x3ffe8000, len 904, room 0
tail 8
chksum 0x5c
load 0x3ffe8388, len 244, room 0
tail 4
chksum 0x7e
csum 0x7e
rl�mode : sta(18:fe:34:9f:da:75)
add if0

ets Jan 8 2013,rst cause:4, boot mode:(3,0)

wdt reset
load 0x40100000, len 27336, room 16
tail 8
chksum 0x9c
load 0x3ffe8000, len 904, room 0
tail 8
chksum 0x5c
load 0x3ffe8388, len 244, room 0
tail 4
chksum 0x7e
csum 0x7e
rl�mode : sta(18:fe:34:9f:da:75)
add if0


This code works and I get the expected tone from the piezo:

Code: Select all

#include "ets_sys.h"
#include "osapi.h"
#include "user_interface.h"
 
void user_init() {

    // wifi_set_opmode_current(STATION_MODE);
    // wifi_set_opmode_current(SOFTAP_MODE);
    uart_div_modify(0, UART_CLK_FREQ / 115200);
    gpio_init();

    uint32_t io_info[1][3] = {   
                          {PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13,13},
                          };

    uint32_t duty[1] = {500};
    pwm_init(1000, duty,1,io_info);
    pwm_start();

}


Output:

r��`rlmode : softAP(1a:fe:34:9f:da:75)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: WDT reset on pwm_init

Postby ESP_Faye » Tue Feb 02, 2016 11:51 am

Hi,

Here is our entire test project, sorry that we could not duplicate your problem.
user_main.c is the source code you provided.
\esp_iot_sdk_test\bin are our bin files after compiling the test code, please download and have a try.
Attachments
esp_iot_sdk_test.zip
(2.87 MiB) Downloaded 645 times

snapdan
Posts: 4
Joined: Sun Jan 24, 2016 9:24 am

Re: WDT reset on pwm_init

Postby snapdan » Mon Feb 15, 2016 2:12 am

Thank you, I finally got around to testing this and it works as expected. Does this mean something is wrong with my toolchain?

anszom
Posts: 1
Joined: Sat Apr 23, 2016 12:20 am

Re: WDT reset on pwm_init

Postby anszom » Sat Apr 23, 2016 4:30 pm

This is a SDK bug. See here for details: http://www.esp8266.com/viewtopic.php?f= ... =48#p46002

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: WDT reset on pwm_init

Postby ESP_Faye » Tue May 31, 2016 9:34 am

Hi,

Sorry that we can not reproduce your problem.

Here is our test code, please have a try and feel free to let us know, if your problem is still unsolved.

Thanks for your interest in ESP8266 !
Attachments
app_dbg_wdt_For_ESP8266_NONOS_SDK_V1.4.0_201605.zip
(72.15 KiB) Downloaded 581 times

Who is online

Users browsing this forum: No registered users and 2 guests