I create bug report in Qt community.
It seems that you (or mine) have to update Linux Kernetl to get improved FlexCAN driver.
Unfortunately, I’m not able to build the Qt image based on Yocto layers from Qt because of build fails; Qt didn’t help me to build “Boot2Qt image for Apalis iMX8”.
@Vitaliy Something else you might want to try is essentially disabling DVFS (dynamic voltage and frequency scaling). Changing frequency can lead to delays leading to package drops. I think the performance govenor should essentially disable all scaling (as the SoC will run on maximum frequency at all times). Make sure you have a good cooling solution!
@Vitaliy during the tests with the Qt demo UI running, did you receive kernel messages on the serial console? If yes, those could be the culprit, as those cause considerable amount of latencies/jitter. Can you try with only emergency messages enabled?
I tried to reproduce the issue on my side.
I used the latest image.
Boot to Qt for Embedded Linux 3.0.2 b2qt-apalis-imx8 ttyLP1
root@b2qt-apalis-imx8:~# uname -a
Linux b2qt-apalis-imx8 4.14.159-0+git.fff496c2a1bd #1 SMP PREEMPT Tue Apr 14 17:50:14 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
I send with our USB CAN adapter RTR frames with the minimal specified inter frame spacing. Timing between frames is in 47.48 us confirmed by oscilloscope.
On the Apalis iMX8 the image is just booted, i.e. the Qt demo shows the available demos, the can0 NIC is up, no userspace application takes the CAN frames, so Socket CAN silently drops the frame on its highest layer. CAN setup with ‘ip link set can0 up type can bitrate 1000000’.
The can0 interface statistics shows all error counters at 0, i.e. no overruns in hardware, no dropped frames between driver and higher Socket CAN layers.
If I repeat the test, but take the frames to userspace with ‘candump > /dev/null’ the dropped counter counts up, maybe 10…50 frames per 1’000’000 frames received.
If I increase the candump’s priority and keeping the CPU’s clock at its highest frequency I do not see any dropped messages.
If I don’t send RTR frames as in the tests above, but actually send data frames with a 1 byte payload, I do not see any dropped frames without giving candump a higher priority or keeping the CPUs at their highest operating point.
What exact SW and HW version of things are you using?
Do you really have no user space application reading the received CAN frames?
What happens if you send CAN frames with a 1 byte payload instead of RTR frames?
Hi, @max.tx
Today I setup my Apalis Evaluation Board v1.0A with SOM Apalis iMX8QM 4GB WB v1.0B. I connect a FullHD monitor through a DVI connector. Also I attach standard USB mouse and keyboard.
From TEZI, I flash new boot2qt demo image to SOM, it is the same as you wrote:
root@b2qt-apalis-imx8:~# uname -a
Linux b2qt-apalis-imx8 4.14.159-0+git.fff496c2a1bd #1 SMP PREEMPT Tue Apr 14 17:50:14 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
Just after flashing, I connect to apalis using ssh terminal, connect CAN cable to other node (which generate CAN traffic), setup CAN by command ‘ip link set can0 up type can bitrate 1000000’. The length of the CAN cable from Apalis Evaluation Board to RM48USB (the other CAN node) is 2.8 m. Also I soldered the termination resistor 120 Ohm between CANH and CANL pins in the connector X32.
After that, I start to generate CAN traffic with SFF 0x565 and 0 bytes of the payload on RM48USB.
After that, I start Qt E-Bike demo, do something in that demo program.
After that, I stop to generate CAN traffic on RM48USB and check the number of generated packets from RM48USB MCU: 1’358’009.
After that, I check status of the CAN bus in Apalis:
RM48USB use SN65HVD232Q CAN transceiver. Apalis use ADUM1301+MCP2551. I suppose that it is all ok with hardware.
So, after short run of E-Bike demo, I’ve seen package lost without any userspace application working with CAN bus.
Is there something that I can do? I think that it is a good idea to move work with CAN bus to standalone Cortex-M4 core and use IPC to get the CAN data from one core to other.
Using your last command, I note that there are less errors.
After little stress-testing (using “ping -f” to flood on Ethernet and run Qt demo software), I send 5729317 packets and get only 5 errors:
Other statistics after 22 minutes of running standard Qt demo without my interruption.
For this run, I add command “echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor” before generating CAN traffic.
Thank you for the clue. In our case, we were having CAN FD frame overruns with imx8qxp with SCFW debug enabled. Fine with SCFW debug UART disabled. Changing scaling_governor to performance worked around that issue too, though disabling debug was the actual fix.