Hello
As everyone CAN'er knows, good old CAN operates at up to 1MHz bit rate clock, one extended ID message is roughly 100 bit times long. That's up to 10k messages per second, which is a piece of cake to handle on 16bit S12 operating at much less than 25MHz bus clock. 10k msgs / sec is also piece of cake for bare metal Vybrid app. But unfortunately it is not a piece of cake for Linux and SocketCAN.
SocketCAN, VF61, 3.13 kernel, no user app working, 5-6 kmsgs / sec on CAN bus. Htop shows ~30% CPU usage... Start one app, which just selects and waits for CAN socket and pulls messages from SocketCAN - CPU usage rises to ~70%... And I would like to have few similar CAN apps operating simultaneously...
Thanks for ideas.
Edward
Solved! Go to Solution.
Hello Edward and karinavalencia,
We are not able to reproduce the processor consumption on a Tower VF610 evaluation kit.
We have configured and brought up the FlexCAN device, and see .3% CPU consumption at most in Busybox top; running htop, CPU consumption rises to 2%. But we are not seeing any other processor consumption at idle with just the device enabled and configured. Transmitting over CAN also does not show any changes in CPU consumption.
Are you able to provide a test application case which shows this behavior?
Thank you,
Timesys Support
kef2 can you provide the information requested?
Hi
Thanks for trying to help solving issue.
Looks like something has changed, perhaps in RFS from my last LinuxLink builds. Previously CPU usage was high like 30% with no CAN app running (kernel only). Starting CAN app (kernel+app) CPU usage was rising to 60% or more depending on message rate. Now with no CAN app running, I see no CPU load, but starting CAN app I see the same 60% for kernel+app. I see high CPU loads only using FlexCAN driver. Using external USB-CAN dongle I see no load, just a couple of % for kernel+app and much higher message rates.
I'll try reproducing issue in new smaller application, also try to figure what's changed that kernel god better and seems not loading alone CPU.
Update1: See attached trycan project. It just waits for can messages using select() and displays message rate. The same problem, high CPU load.
Update2: Well. Finally I found what caused high CPU load with ~6kmsgs/s when CAN app is not running. It was a missing gpio-keys status="disabled" is dts file. (See attached *.dts) Now CPU load is around zero with lots of messages and CAN app (trycan) not running. But question remains, why I see high CPU load when CAN application is running.
Again, what I have.
- untouched kernel image from last LinuxLink build, modified *.dts file as attached.
- ~5800 messages / sec on CAN bus.
- trycan running
- CPU load 40-44%
- htop output:
5871 msgs/s******** 44.1%] Tasks: 8, 0 thr; 2 running
Mem[***** 9/120MB] Load average: 0.37 0.33 0.21
Swp[#* 0/0MB] Uptime: 00:14:47
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1178 root 20 0 3016 828 724 S 41.7 0.7 0:11.72 /home/trycan
1179 root 20 0 2884 1180 980 R 1.6 1.0 0:00.80 htop
1 root 20 0 2276 692 620 S 0.0 0.6 0:00.69 init
1092 root 20 0 2276 448 392 S 0.0 0.4 0:00.00 syslogd
1135 root 20 0 1748 472 396 S 0.0 0.4 0:00.12 /usr/sbin/ifplugd
1151 root 20 0 2228 440 348 S 0.0 0.4 0:00.00 /usr/sbin/dropbea
1159 nobody 20 0 2072 404 268 S 0.0 0.3 0:00.00 /usr/sbin/boa
1167 root 20 0 2280 744 668 S 0.0 0.6 0:00.04 -/bin/sh
Am I doing something silly in my trycan? If so, then why don't I see high CPU load using USB-CAN dongle?
Regards
Edward
Edward,
The DTS for the the twr-vf610 should note that the GPIO-Keys conflicts with CAN on the i2c bus; this is a comment at ~Line 535.
We will execute your test application and review the results.
Can you clarify what you mean by: ~5800 messages / sec on CAN bus.
What is generating these ~6000 messages? Are those being sent to the hardware - if so, what is sending them?
Thank you,
Timesys Support
Hi,
Yes, there's a comment at line 535, but no instructions how to disable conflicting button :-). I forgot about it since I was adding functionality and didn't know that CPU gets busy even with no CAN app running. This part of problem is fixed, now CPU is not busy while no CAN app is running.
Some external device is generating those 6k msgs / sec.
Thank you, regards,
Edward
Hi Edward,
Yes - the comment could be more descriptive. Something along the lines of "To enable CAN, disable GPIO-Keys" would be better.
Thank you - we have a CANbus device we can generate inbound traffic on.
Regards,
Timesys Support
Hi Timesys Support,
Have you tried reproducing the problem?
Regards,
Edward
Hi Timesys Support,
any news? Did you try trycan app and can you confirm high CPU usage?
Regards,
Edward
This thread is false "solved", and I even can't change it to "unsolved". FlexCAN driver is still CPU hungry and is much worse than (any?) USB<->CAN dongle. Does anyone at Freescale cars about this? Is "no" - answer to my request? Is this why it is green and answered?
Regards
Edward
Hi Ed,
Our apologies for the delay in replying; other support interrupts have consumed available cycles to debug this issue.
Our test setup is the TWR-Vybrid VF6 module, with TWR-SER2 module providing CAN interface. We will be testing board to board with i.MX6 SABRE-Lite and, via Kvaser Leaf Light, to generate inbound CAN traffic. Does this match your own hardware setup?
We expect to be able to update whether we are seeing similar traffic tomorrow, 11/19.
Thank you,
Timesys Support
Hi,
My apologies for not being polite. Yes, TWR-Vybrid VF6 with TWR-SER2, CAN traffic comes to J15 on TWR-SER2. At least confirming the issue would be a great relief.
Thank You,
Edward
Hello Edward,
We've been working diligently with our Vybrid TWR module to validate the CAN functionality; despite performing the necessary re-work for R10/R11, it seems that we are unable to get any traffic to transmit over the CAN interface on the TWR_SER2 module. We are going to re-work another module and attempt to reproduce. Again, our apologies for the delay.
Thanks,
Timesys Support
Hello Timesys Support,
Thanks for trying.
1. Please make sure J4 (CAN_ISO) TX and RX jumpers on TWR-SER2 are installed. J4 pins 3-4 and pins 5-6 must be shorted.
2. I remember I had to solder not populated 0 Ohm resistor(s) on TWR-VF65GS10, don't remember which. Please make sure R10 and R11 are soldered.
3. Please don't forget about at least one 120 Ohm termination resistor between CAN_H and CAN_L .
Thanks,
Edward
timesyssupport Please continue with the follow up.
timesyssupport can you help here?
Hello,
Our testing of CAN has been limited to basic FlexCAN driver functionality in the 3.13 kernel; a loopback on the evaluation board, and between board communication with Vybrid Tower and MX6 based evaluation board. Performance metrics were not captured at this time, but it seems the FlexCAN driver likely needs work to perform well - as evidenced by other instances of the FlexCAN driver on older/current Freescale hardware.
karinavalencia - is there a Freescale engineer who may be more familiar with the inner workings of the CAN support to assist?
Thank you,
Timesys Support
I tried to compare on-chip FlexCAN driver vs sysWORXX USB<->CAN dongle.
1) CAN bus connected to FlexCAN, ~6 kmessages / sec on the bus, CAN application is not running. CPU load is about 30%. Starting CAN application CPU load ~ doubles.
2) CAN bus connected to sysWORXX USB dongle, ~6 kmessages / sec, CAN application running. CPU load << 10%.
No idea how to fix driver. Source looks good.
Hi,
If you want to increase the performance I would try to use the flexcan driver of MQX with the M4. This in case you need a Real Time feature in your application.
Best Regards,
Alejandro
Yeah, second MCU or switching to competition MCU also would do. And what to do if VF5's are ordered, no M4 and MQX? Is 6kHz interrupt rate killer for Vybrid Linux? I can't believe that USB is easier to handle with all those layers and etc. Isochronous USB HS still needs 8kHz interrupt rate. Even if interrupt rate is killer, why running read-from-CAN application doubles CPU load? FlexCAN buffers are read already, what's the problem reading buffers from app? Why there's no problem at all doing the same with USB<->CAN dongle?????