<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi Michael,<br>
    <br>
    Correct, not a config issue.  I had assumed it was a race condition
    (first time I've seen it), but didn't realize it involved my code. 
    Yikes!<br>
    <br>
    This is the call-back into the OBD2ECU task when a CAN frame is
    received in the system.  Apparently everyone looking for a CAN frame
    gets called when a frame is received from any bus, and each process
    needs to filter out the ones they own.  So, somehow a CAN frame was
    seen to have been received before the system was fully initialized. 
    Perhaps something dropped into the hardware buffer after the chip
    was turned on, but not before the O/S had gotten everything situated
    for handling it.  I don't currently have anything connected to the
    OBDII CAN bus (CAN3) on my module, so this must have been a frame
    from the car itself on CAN 1.  CAN 2 is not used in my car.<br>
    <br>
    What precisely is "early" in the context of a boot crash?  That
    would put a bound on the size and location of the timing window.<br>
    <br>
    Greg<br>
    <br>
    <br>
    <div class="moz-cite-prefix">Michael Balzer wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:6a8db28c-03ba-2952-d802-d720e6dd2deb@expeedo.de">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      Greg,<br>
      <br>
      the backtrace says the crash happened here:<br>
      <br>
      <tt>0x4008f6de is in vTaskEnterCritical
(/Users/mark/esp/esp-idf/components/freertos/include/freertos/portmacro.h:283).<br>
        278     * Warning: From the ISA docs: in some (unspecified)
        cases, the s32c1i instruction may return the<br>
        279     * *bitwise inverse* of the old mem if the mem wasn't
        written. This doesn't seem to happen on the<br>
        280     * ESP32 (portMUX assertions would fail).<br>
        281     */<br>
        282    static inline void uxPortCompareSet(volatile uint32_t
        *addr, uint32_t compare, uint32_t *set) {<br>
        283        __asm__ __volatile__ (<br>
        284            "WSR         %2,SCOMPARE1 \n"<br>
        285            "S32C1I     %0, %1, 0     \n"<br>
        286            :"=r"(*set)<br>
        287            :"r"(addr), "r"(compare), "0"(*set)<br>
        0x4008eb10 is in xQueueGenericReceive
        (/Users/mark/esp/esp-idf/components/freertos/./queue.c:1455).<br>
        1450        statements within the function itself.  This is done
        in the interest<br>
        1451        of execution time efficiency. */<br>
        1452    <br>
        1453        for( ;; )<br>
        1454        {<br>
        1455            taskENTER_CRITICAL(&pxQueue->mux);<br>
        1456            {<br>
        1457                /* Is there data in the queue now?  To be
        running the calling task<br>
        1458                must be    the highest priority task wanting
        to access the queue. */<br>
        1459                if( pxQueue->uxMessagesWaiting > (
        UBaseType_t ) 0 )<br>
        <b>0x4011f3fd is in OBD2ECU_task(void*)
(/Users/mark/Documents/ovms/Open-Vehicle-Monitoring-System-3/vehicle/OVMS.V3/components/obd2ecu/src/obd2ecu.cpp:155).</b></tt><tt><br>
      </tt><tt>150      obd2ecu *me = (obd2ecu*)pvParameters;</tt><tt><br>
      </tt><tt>151    </tt><tt><br>
      </tt><tt>152      CAN_frame_t frame;</tt><tt><br>
      </tt><tt>153      while(1)</tt><tt><br>
      </tt><tt>154        {</tt><tt><br>
      </tt><b><tt>155        if (xQueueReceive(me->m_rxqueue,
          &frame, (portTickType)portMAX_DELAY)==pdTRUE)</tt></b><tt><br>
      </tt><tt>156          {</tt><tt><br>
      </tt><tt>157          // Only handle incoming frames on our CAN
        bus</tt><tt><br>
      </tt><tt>158          if (frame.origin == me->m_can)
        me->IncomingFrame(&frame);</tt><tt><br>
      </tt><tt>159          }</tt><tt><br>
      </tt><br>
      <br>
      So I assume that's the same bug I already reported in issue #103:<br>
      <br>
      <a class="moz-txt-link-freetext"
href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/issues/103"
        moz-do-not-send="true">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/issues/103</a><br>
      <br>
      …and as it now happened to you, I assume it's not configuration
      related. Can you verify my assumption?<br>
      <br>
      <blockquote type="cite">Looks like an init race condition, i.e.
        m_rxqueue used in undefined state.</blockquote>
      <br>
      Regards,<br>
      Michael<br>
      <br>
      <br>
      <br>
      <div class="moz-cite-prefix">Am 22.05.2018 um 19:24 schrieb Greg
        D.:<br>
      </div>
      <blockquote type="cite"
        cite="mid:45c73f38-dcea-9bac-7b5a-bedc8e08617d@gmail.com">
        <pre wrap="">Just noticed this on my production 3.1 module.  Was this an artifact of the 
upgrade from .005 to .006?

Last boot was 140983 second(s) ago
Time at boot: 2018-05-20 19:05:59 PDT
This is reset #17 since last power cycle
Detected boot reason: EarlyCrash (12/12)
Crash counters: 1 total, 1 early
Last crash: StoreProhibited exception on core 1
Registers:
PC : 0x4008f6de PS : 0x00060033 A0 : 0x8008eb13 A1 : 0x3ffd6150
A2 : 0xfefeff4e A3 : 0x0000abab A4 : 0xb33fffff A5 : 0x00000001
A6 : 0x00060020 A7 : 0x0000cdcd A8 : 0x0000abab A9 : 0x3ffd6150
A10 : 0x00000003 A11 : 0x00060023 A12 : 0x00060020 A13 : 0x3ffb4188
A14 : 0x000001e8 A15 : 0x00001800 SAR : 0x00000000 EXCCAUSE: 0x0000001d
EXCVADDR: 0xfefeff4e LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace:
0x4008f6de 0x4008eb10 0x4011f3fd 0x40174f95 0x400e73be 0x400e4699 0x40085149 
0x40128bc2 0x40128df7 0x401287b4 0x400ea22d 0x400eac7a 0x400ead09 0x400ead19 
0x402207d6 0x400e9ece 0x400e9f79 0x400e45f5 0x400e4604 0x400f5c09 0x400f035d
Version: 3.1.006/ota_0/main (build idf v3.1-dev-455-gf4905cdf May 20 2018 20:08:31)
--------------------------------------------------------------------------------
Running partition: ota_0
Boot partition: ota_0
Firmware: 3.1.006/ota_0/main (build idf v3.1-dev-455-gf4905cdf May 20 2018 20:08:31)
</pre>
        <!--'"--><br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com" moz-do-not-send="true">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" moz-do-not-send="true">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="160">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
OvmsDev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a>
<a class="moz-txt-link-freetext" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>