IMX6 can bus development guide. CAN bus is popular interface in industrial applications especially in automotive.
Schematic inspection and DTS modification.
Here CAN bus circuits:
here U3 and U4 are CAN transceivers. Their CANH/CANL pins routed to output connectors. CAN1_TX/CAN1_RX and CAN2_TX/CAN2_RX – to IMX6ULL’s pads:
Here we see that CAN1_TX connected to UART3_CTS pad of IMX6ULL that might be configured as CAN1.TX pin and. In linux hardware configuration we implement using so called DTS.
First we need to add root nodes presenting each interface:
Then time of pinctrl nodes:
It might look like a set of magic numbers and names. It is true. Linux DTS not well documented. So in a case when it can’t shed light to things you need implemented the only way to understand what to do is learning existing code base. Find and grep utils – your best friends. Commits history also might be useful. You may find link to commits implementing CAN bus support to NetSoM at the end of this article.
For example by running (image must be built before you get ability to make a search):
you may discover that there is imx6ul-pinfunc.h header file exists with set of PAD definitions exist:
with following name convention: ARCHITECTURE_PAD_PINNAME_PINFUNCTIONALITY.
Comparing it with schematic above convinces that there is exactly our target definition.
Also you may discover following:
DTS samples! In the easiest case configuration you need already implemented in DTS samples you may just copy and paste it from DTS sample to your DTS.
Unfortunately embedded linux not user friendly so you have to learn on your own.
CAN support enabling in kernel.
After DTS you have to enable hardware support in kernel. You can do it by running
In UI menu navigate to CAN support chapter and enable modules:
Besides this it is also might be useful to enable additional utilities to be included in resulted image to have a tools to test interface you are developing. Later you may exclude them from release image but on development stage they can simplify development process:
Now we are ready to compile and update device firmware. Here explained how you can do that.
Boot device and check logs:
Everything looks fine.
Let’s try to set up CAN interfaces:
and check them using ifconfig:
and send CAN packet to second one:
at first console you should see following:
Keep following as here at our telegram channel!