A13 (WiFi) + CAN bus SPI support. Need help please

Started by vinzer, November 16, 2013, 06:56:23 AM

Previous topic - Next topic

vinzer

Hello everyone!
I am new here as well as in Linux stuff.
So far I got A13 with Wifi and A10s boards for testing purposes.
After reading the forums and playing around with different images I got some sucess and liked all this even more.
Now I have some sort of project which I want to build up. I want to write some C code for CAN bus communication based on A13 board. As a CAN interface I will use MCP2515 SPI with appropriate CAN transiever chip. I already build a schematic and conencted it to UEXT port on A13 (I found the only SPI channel 2 available there).
Now I also found the SocketCAN which in my opinion should work jsut fine for me. As I understood this is exactly what I may need - it creates a virtual network adapter out of CAN controller and I can communicate with it as with other network adapter.
After some reading I realized that this SocketCAN (http://en.wikipedia.org/wiki/SocketCAN) become a part of the kernel. As I understood none of existed on forum images includes CAN support part  :(
I tried to ifconfig -a and in my understanding I should see the CAN controller in there together with network controllers.

Am I correct on my assumption and no images here includes CAN part? If so then I think I need to add somehow CAN support to the existed image.
Please help and explain a little How to do this ?
Should I rebuild the image comlletelly (this will probably take me some time to understand and study) or I can just take some image (for example the one provided by Olimex as an official image for A13 board) and add CAN support in there. If so - how to do this ?

I am very new in all this and I would apreciate some step by step simple directions. I will read more and for sure will get to it, jsut a little bit of help would really help me.

Looking forward to any help or comments.
Thank you,
Vinz

JohnS

You can be almost certain it will not be in now.  It also may not be in the kernel version at all as linux-sunxi is in development.

It still may work.  One thing to do would be to get used to building your own kernel.
Also, find out more about how that CAN stuff is used in the current mainline kernel or at least its equivalent of the version linux-sunxi uses (3.4).

It's going to be some quite hard work.  http://linux-sunxi.org/Main_Page has lots of info

John

vinzer

Hey John,
Thank you for your response.

So what I understood is:

First I must check if the SocketCAN is a part of the linux-sunxi at all. If this is the case than I am lucky and may try to add CAN part while building my own kernel based on the sunxi.
In case if CAN is not a part of the sunxi then I am stucked and probably have to wait until it becomes available.

I will read and study more during next weeks to get better understanding of the processes and how all this works. I am Windows/VS/Keil guy and have never developped any embedded or non embedded code under Linux.
This is something I want to study now.

Fadil Berisha

Quote from: vinzer on November 16, 2013, 05:26:09 PM
First I must check if the SocketCAN is a part of the linux-sunxi at all.
CAN bus subsystem is part of kernel. Here is good example how to compile kernel with CAN bus subsystem support and how to add your CAN device on kernel: http://elinux.org/RPi_CANBus
Check also following link http://lnxpps.de/rpie/. Those examples are for Pi board but you can use them as reference.

If you  think that my answer were correct or useful in this thread, please mark it with + .

vinifr

#4
The link pointed to by Fadil explains clearly what must be done, but board specific is diferent.

I think if the function fails http://lxr.free-electrons.com/source/drivers/net/can/mcp251x.c?v=3.4#L1051, you can use script.fex to board info.

[spi_board0]
modalias = "mcp2515"
max_speed_hz = 10000000
bus_num = 2
chip_select = 0
platform_data = ?
mode = 3

vinzer

Fadil and vinfr - Thank you for your commments and suggestions.

I am in process of building my first own image. So far have more questions then answers but hopefully I will find all answers on my own :) I built two images but none works yet :) I think this is good beginning

The only I want to say is that I was not able to find any step by step guide on image build where all recent versions and changes would be properly reflected. All existed step by step guides contain some broken links for repositories. I understand that due to constant developemnt many things changes rapidly and the lates guide I fould was dated in the very beginning of 2013.

vinifr


dhlii

vinzer;

I am doing much the same as you. Though I am using the A13 board.

I am using an ET-MINI-SPI CAN as a development board.

I am working through the fex configuration and linux kernel setup to get the MCP2515 working.

It is also likely that you may wish to backport more recent MCP2515 drivers as there are a number of fixes.

I am currently trying to figure out how to configure one of the UEXT pins to be an interrupt and how to
get the platform data to the Kernel.


I beleive this will require some minor changes in the A13 BSP.