{"id":1615,"date":"2015-10-10T19:03:43","date_gmt":"2015-10-11T02:03:43","guid":{"rendered":"http:\/\/www.hhhh.org\/joeboy\/blog\/?p=1615"},"modified":"2015-10-12T03:44:11","modified_gmt":"2015-10-12T10:44:11","slug":"esp8266-error-dont-use-rtc-mem-data","status":"publish","type":"post","link":"https:\/\/www.hhhh.org\/joeboy\/blog\/?p=1615","title":{"rendered":"Esp8266 error: \u201cdon&#8217;t use rtc mem data\u201d"},"content":{"rendered":"<p>Update: Turns out my problems, while repeatable, were likely to do my libraries being set in a non-homogeneous state. It appears that an auto partially rolled back the SDK version being used, which was weird. A full make clean, and rebuild fixed the problem I was having. Still the reset problem is fairly common with the ESPs and Espressif SDK. This guy summed it up the <A href=\"http:\/\/internetofhomethings.com\/homethings\/?p=396\">ESP Reset Problem<\/a> really well. <\/p>\n<p>So this error was a beast to find \u2013 and I saw some others online were having the same problem &#8211; so I figured I should post about it someplace Google could find it. <\/p>\n<p>I\u2019m using the espressif development tools, which are getting better, but remain only sparsely documented. My problem started after a change in my code started the ESP crashing on power up. The crash presented, or so I thought, like a flash write error contaminating the boot loader. <\/p>\n<p>I was getting this error about messing with RTC memory: <\/p>\n<p>\u201c<br \/>\nr<br \/>\n ets Jan  8 2013,rst cause:2, boot mode:(3,6)<\/p>\n<p>load 0x40100000, len 29920, room 16<br \/>\ntail 0<br \/>\nchksum 0x07<br \/>\nload 0x3ffe8000, len 924, room 8<br \/>\ntail 4<br \/>\nchksum 0xbf<br \/>\nload 0x3ffe83a0, len 4528, room 4<br \/>\ntail 12<br \/>\nchksum 0xde<br \/>\ncsum 0xde<br \/>\ndon&#8217;t use rtc mem data<br \/>\n\u201c<\/p>\n<p>Well, it turns out the problem was my starting to use the init_done_callback code when I upgraded SDK versions. I jumped from a 1.x SDK to a 1.4. The init_done_callback code was added into the SDK somewhere in that range. The call works fine, and I had been using it for a while in my code when I ran into problems merging the timer code. It is not in the documentation anywhere yet, but you apparently can&#8217;t mess with the os timers within the init_done_callback function. <\/p>\n<p>Since it looks like init_done_callback is how you launch code after all the underlying espressif code has finished I\u2019m thinking this is a bug. For now I\u2019m going to change to launching my timers before setting the callback, and use a flag to wait until espressif init\u2019s done. <\/p>\n<p>Here\u2019s a cut down version of the code triggering the problem:<\/p>\n<p>void ICACHE_FLASH_ATTR user_init(void){<br \/>\n  user_gpio_init();<br \/>\n  user_uart_init();<\/p>\n<p>\/\/ Problem killing the timer is here! I should handle timers outside callback.<br \/>\n  system_init_done_cb(init_done_callback);<br \/>\n}<\/p>\n<p>void init_done_callback(void)<br \/>\n{<br \/>\n\/\/ Callback launches fine &#8211; but its the setting of os_timers that triggers<br \/>\n\/\/ the crash \/ messing with timer memory error.<br \/>\n  start_keepalive_timer(KEEPALIVE_INTERVAL_SECS);<br \/>\n}<\/p>\n<p>void ICACHE_FLASH_ATTR start_keepalive_timer(int interval)<br \/>\n{<br \/>\n#ifdef DBG_KEEPALIVE<br \/>\n    os_timer_disarm( &#038;dbg_keepalive_timer);<br \/>\n    os_timer_setfn(  &#038;dbg_keepalive_timer,<br \/>\n                     (os_timer_func_t *)dbg_keepalive_timerfunc,<br \/>\n                     NULL);<br \/>\n    os_timer_arm(&#038;dbg_keepalive_timer, (1000 * interval), 1);<br \/>\n#endif<br \/>\n}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: Turns out my problems, while repeatable, were likely to do my libraries being set in a non-homogeneous state. It appears that an auto partially rolled back the SDK version being used, which was weird. A full make clean, and rebuild fixed the problem I was having. Still the reset problem is fairly common with [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[68],"tags":[],"class_list":["post-1615","post","type-post","status-publish","format-standard","hentry","category-esp8266"],"_links":{"self":[{"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1615"}],"version-history":[{"count":6,"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1615\/revisions"}],"predecessor-version":[{"id":1624,"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1615\/revisions\/1624"}],"wp:attachment":[{"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hhhh.org\/joeboy\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}