Sming icon indicating copy to clipboard operation
Sming copied to clipboard

Servo sample wdt reset

Open kmihaylov opened this issue 5 years ago • 9 comments

Hello. I'm trying to use the Servo driver, but I'm getting wdt reset. I tried flashinit with no luck. The only change in the Basic_Servo example I made is to put SPI_SIZE ?= 4M in Makefile-user.mk

I'm using the develop branch, commit cc7af2263e41e24c12c047878c95f13489d5c81c I'll be glad if someone tries to build the example in order to confirm whether the issue is dedicated to my build environment or not.

Thank you!

$ make flash
(!) Spiffs support disabled. Remove 'DISABLE_SPIFFS' make argument to enable spiffs.
Killing Terminal to free /dev/ttyUSB0
/opt/Sming/Sming/Makefile-rboot.mk:638: recipe for target 'flash' failed
make: [flash] Killed (ignored)
/opt/esp-open-sdk/esptool/esptool.py -p /dev/ttyUSB0 -b 115200 write_flash -ff 40m -fm qio -fs 32m 0x00000 out/firmware/rboot.bin 0x02000 out/firmware/rom0.bin
WARNING: Flash size arguments in megabits like '32m' are deprecated.
Please use the equivalent size '4MB'.
Megabit arguments may be removed in a future release.
esptool.py v2.6-beta1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: 60:01:94:15:ad:f4
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Flash params set to 0x0040
Compressed 2032 bytes to 1429...
Wrote 2032 bytes (1429 compressed) at 0x00000000 in 0.1 seconds (effective 124.0 kbit/s)...
Hash of data verified.
Compressed 228592 bytes to 167314...
Wrote 228592 bytes (167314 compressed) at 0x00002000 in 14.8 seconds (effective 123.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
python -m serial.tools.miniterm /dev/ttyUSB0 115200 
--- Miniterm on /dev/ttyUSB0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
{l␀dܞ|␀�l�|␂␌␄␌�␌$�␄b|��␂�p␂�r�"�␜p␌��on�␀$oN���␌"pp��#$`␂r$s$␀l���␂�#␂�o␄␌␄�␄l�␌c|��␂�p␃�{�#�␌#�p␡�o�lon���␌#␜p��l{l{lp�o�␐␃␄␌���l␄␌␄␌␄␌c␄o�|␃d�␜�␄�p␄�|~�o�␂l��␀$`␃�2␒oo␌d`␃␎␃or�ےn␄␌␒�p{lp�n�␐␃␄␄{�ܜ�␃␄␌␌␄c␄n�|␃���␌␄b��oN�␃␄␌$`␃�␛␒nol�$`␂␎␃or����␃␄␌b�� ␃␏r��n␌␄#�� ␂s$�#�noߌ�p|␄�|�␌db�␒np ␛"�2b�b��n␀�N�c�ncp~�N␎l␜�o�␃o���"␄␌␄�␌dlp#�� ␂␜�n�␂o$lo���␌␄␌l�dl␎d␜�o�␂n�␒ے�"␌␌␄��␄l$l␡{l�b�on�␀�l�␓oNn>␀� #�␃��o�␃N␎drl␌�Nn��|�܄�o�␂␌�b␏l��␂�2�n�{��o|�␌d␄ldl`␂��r�l��: 00
rf[113] : 00
rf[114] : 01

SDK ver: 2.0.0(5a875ba) compiled @ Aug  9 2016 15:12:27
phy ver: 1055, pp ver: 10.2

mode : softAP(62:01:94:15:ad:f4)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100

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

wdt reset
load 0x40100000, len 1344, room 16 
tail 0
chksum 0x9c
load 0x3ffe8000, len 660, room 8 
tail 12
chksum 0xbd
csum 0xbd

rBoot v1.4.2 - [email protected]
Flash Size:   32 Mbit
Flash Mode:   QIO
Flash Speed:  40 MHz
rBoot Option: Big flash

Booting rom 0.
��␂�␓�N�|␛r��o|�␌d␄ll$`␃��r�p���: 00
rf[113] : 00
rf[114] : 01

SDK ver: 2.0.0(5a875ba) compiled @ Aug  9 2016 15:12:27
phy ver: 1055, pp ver: 10.2

mode : softAP(62:01:94:15:ad:f4)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100

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

wdt reset
load 0x40100000, len 1344, room 16 
tail 0
chksum 0x9c
load 0x3ffe8000, len 660, room 8 
tail 12
chksum 0xbd
csum 0xbd

rBoot v1.4.2 - [email protected]
Flash Size:   32 Mbit
Flash Mode:   QIO
Flash Speed:  40 MHz
rBoot Option: Big flash

Booting rom 0.
��␂�␒�n�{��n|�␄l␌d$l ␂��r�l��: 00
rf[113] : 00
rf[114] : 01

SDK ver: 2.0.0(5a875ba) compiled @ Aug  9 2016 15:12:27
phy ver: 1055, pp ver: 10.2

mode : softAP(62:01:94:15:ad:f4)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100

kmihaylov avatar Dec 23 '18 20:12 kmihaylov

The sample does appear to be missing Serial.begin(SERIAL_BAUD_RATE); at the start of init(), but not convinced that would cause wdt resets...

mikee47 avatar Dec 23 '18 22:12 mikee47

I'll try it tomorrow despite that I have the SERIAL_BAUD_RATE option in my other project.

I'm seeing that the Servo driver uses HardwareTimer. Just tried Basic_HwPWM and it works. I set the frequency and period as per Servo's specs and I believe HwPWM can be a replacement option. I didn't test it with AP/Sta enabled, but I hope it works. Currently the duty cycle isn't precise much (I'm using the euqation provided in the nonos reference).

kmihaylov avatar Dec 23 '18 23:12 kmihaylov

Hey, experiencing the same issue while directly using HardwareTimer in nonmaskable mode (I need 5-bit 50bps uart for a project).

It looks like it broke somewhere between 0b646a584e9c44f71f45e5fc431145e355619107 (2018/08/28; not 100% sure, but it looks like it was the last time my magic uart code worked...) and current release.

Informatic avatar May 17 '19 11:05 Informatic

Have you tried running it under the debugger ?

make clean
make ENABLE_GDB=1

mikee47 avatar May 17 '19 11:05 mikee47

GNU gdb (crosstool-NG crosstool-ng-1.22.0-55-gecfc19a) 7.10
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=xtensa-lx106-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
add symbol table from file "out/build/bootrom.elf" at
        .text_addr = 0x40000000

Welcome to SMING!
Type 'c' (continue) to run application

Remote debugging using /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
gdbstub_init () at /home/informatic/Projects/Sming/Sming/gdb/gdbstub.cpp:914
914                     gdb_do_break();
(gdb) c
Continuing.
Init Basic Servo Sample

Program received signal SIGTRAP, Trace/breakpoint trap.
gdbstub_init () at /home/informatic/Projects/Sming/Sming/gdb/gdbstub.cpp:914
914                     gdb_do_break();
(gdb) bt
#0  gdbstub_init () at /home/informatic/Projects/Sming/Sming/gdb/gdbstub.cpp:914
#1  0x4020798a in gdb_init () at /home/informatic/Projects/Sming/Sming/appspecific/gdb/gdb_hooks.cpp:231
#2  0x40232571 in user_init () at appinit/user_main.cpp:37
#3  0x40206d61 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) c
Continuing.
Init Basic Servo Sample
^C
Program received signal SIGTRAP, Trace/breakpoint trap.
gdbstub_init () at /home/informatic/Projects/Sming/Sming/gdb/gdbstub.cpp:914
914                     gdb_do_break();
(gdb) bt
#0  gdbstub_init () at /home/informatic/Projects/Sming/Sming/gdb/gdbstub.cpp:914
#1  0x4020798a in gdb_init () at /home/informatic/Projects/Sming/Sming/appspecific/gdb/gdb_hooks.cpp:231
#2  0x40232571 in user_init () at appinit/user_main.cpp:37
#3  0x40206d61 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

Seems like nothing interesting, after wdt reset I just end up on initial breakpoint, doing Ctrl-c during hang does nothing (and then wdt kicks in as expected with the same result)

I'll try stepping into attach() and will report what I get... Otherwise, I'll just do a bisect between these versions.

Informatic avatar May 17 '19 11:05 Informatic

As (somewhat) expected, ESP halts after this line: https://github.com/SmingHub/Sming/blob/develop/Sming/Arch/Esp8266/Core/HardwareTimer.cpp#L117

I'll do the bisect... later today.

Informatic avatar May 17 '19 12:05 Informatic

I wonder if the problem is if the timer interval needs setting before enabling interrupts? If it's too short it will crash.

RTC_REG_WRITE(FRC1_LOAD_ADDRESS, usToTimerTicks(interval)); TM1_EDGE_INT_ENABLE(); ETS_FRC1_INTR_ENABLE(); ~~RTC_REG_WRITE(FRC1_LOAD_ADDRESS, usToTimerTicks(interval));~~

mikee47 avatar May 17 '19 12:05 mikee47

@kmihaylov @Informatic Did you guys make any progress on this? I'm currently revising the Servo library (#1870) so good opportunity to sort this out.

mikee47 avatar Oct 05 '19 12:10 mikee47

HwPWM did the job for me, therefore I didn't test with HardwareTimer. I can give it a try later today.

kmihaylov avatar Oct 07 '19 07:10 kmihaylov