T 4.1 FlexCan and Native Ethernet crash

alex-arc

Active member
I am trying to send data to the Can bus over ethernet
things run fine for a while and the it craches
and I get this message from the Debug/print.h

Code:
need to switch to alternate clock during reconfigure of ARM PLL

USB PLL is running, so we can use 120 MHz

Freq: 12 MHz * 66 / 4 / 1

ARM PLL=80002064

ARM PLL needs reconfigure

ARM PLL=80002042

New Frequency: ARM=198000000, IPG=99000000

Decreasing voltage to 1150 mV

vh Alex
 
Where is the file Debug/print.h from? Maybe I’m missing something, but I don’t see that file in either NativeEthernet or in the Teensy cores (there’s a debug/printf.h file in teensy4, however).

There’s a second Ethernet stack you can use to rule out the stack vs. your own code: QNEthernet. If it fails with that too, it likely means something’s amiss in your code (or the CAN library?).
 
Ah debug/print.h is in the core and I have not seen that stuff printed out since beta testing phase and has since been turned off from what I remember.

First what version of the IDE and Teensyduino are you using?

In addition, in the latest version of Teensyduino for Teens 4.1 a crash report is available that you can include in your sketches by inserting these lines after Serial.begin(xxxx):
Code:
  if (CrashReport) {
    Serial.print(CrashReport);
  }
 
Yes it is the debug print from ..\cores\teensy4\debug\printf.h

I have tried both NativeEthernet and QNEthernet. QNEthernet works a bit longer than NativeEthernet.

i am on platformio with teensy 4.14.0

CrashReport:

Code:
CrashReport:

  A problem occurred at (system time) 16:19:17

  Code was executing from address 0x1950

  CFSR: 82

	(DACCVIOL) Data Access Violation

	(MMARVALID) Accessed Address: 0x0 (nullptr)
	  Check code at 0x1950 - very likely a bug!
	  Run "addr2line -e mysketch.ino.elf 0x1950" for filename & line number.

  Temperature inside the chip was 49.29 °C
  Startup CPU clock speed is 600MHz
  Reboot was caused by auto reboot after fault or bad interrupt detected

trying to get addr2line to work right now
 
I got addr2line to work. I had to add build_flags = -g to platform.ini (look here for more info https://forum.pjrc.com/threads/67998-Using-CrashReport-on-Mac-OS?p=291308&viewfull=1#post291308)

it points to .platformio\packages\framework-arduinoteensy\libraries\FlexCAN_T4/FlexCAN_T4.h:37

Code:
#if !defined(_FLEXCAN_T4_H_)
#define _FLEXCAN_T4_H_

#include "Arduino.h"
#include "circular_buffer.h"
#include "imxrt_flexcan.h"

*******************************************  LINE 37 Below
typedef struct CAN_message_t {
  uint32_t id = 0;          // can identifier
  uint16_t timestamp = 0;   // FlexCAN time when message arrived
  uint8_t idhit = 0; // filter that id came from
  struct {
    bool extended = 0; // identifier is extended (29-bit)
    bool remote = 0;  // remote transmission request packet type
    bool overrun = 0; // message overrun
    bool
 
I think it is solved now.


this line seems to have be the problem
Code:
CAN_message_t *send_buf = new CAN_message_t[frame_num];

I did try to wrap it in __disable_irq() __enable_irq() because maybe the memory allocation was being interupted by an ethernet event, but that did not work


I then changed it out for this
Code:
CAN_message_t send_buf[frame_num];
and now it works fine

but still strange that it only crashes when the ethernet lib is also in use
 
Can you clarify where you've made these changes? Was this line in your code, or in the FlexCAN library?

I've had this same issue but didn't have time to investigate myself, and this appears to be the only thread I can find on this issue.
 
Back
Top