Target: M54418 TWR
Target Kernel Version:ltib-modelo-20100709
Host: ubuntu 10.10
Our development team is fairly new to the uC Linuc environment. So far we have acheive a the 'welcome' project (on CW10.0) on the target board but some questions comes to mind regarding the BSP (flexcan for instance):
- where to find the drivers (socket can for instance)
- Which header file to use the BSP, in other words which API to start coding?
regards,
FB
One way is to use the socketCAN On the linux 2.6.29 Kernel.
For setting the bit rate this command is typed to the target's terminal. ex: 1Mbps:
$ echo 1000000 > /sys/devices/platform/mcf-flexcan.1/net\:can1/can_bittiming/bitrate
Then for enabling the can interface:
$ ifconfig can1 ip
Then you can program a linux application using the open source socket can I/F. It is like coding with the socket API but it is on the CAN bus.
So far the experiences has gone OK except when stress testing the CAN interface, the Whole system seems to reboot when running the following CAN loop program. :
while(numofmsg){ nbytes = write(can_socket, &tx_frame, sizeof(struct can_frame)); numofmsg--; // recv() nbytes = recv(can_socket, &rx_frame, sizeof(struct can_frame), MSG_DONTWAIT ); // ...}
now prior to reboot the following message is displayed via the serialk terminal:
Transmission code active 0xc080000
reg->caniflg = 0x3
** MB[1] : CODE=0x6 LEN=8
** RX
OVERRUN
DATA[0]
every time I looked it rebooting either in the middle of DATA[4] or DATA[3].
Any ideas why?
thanks,
Francois
P.S.socket creation code // create socket if ((can_socket = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) { int err_num = errno; if(verbose)fprintf(stderr, "CAN_Open_Socket() socket() %d", err_num); return -1; // error socket } // bind to specific address strcpy(ifr.ifr_name, "can1" ); ioctl(can_socket, SIOCGIFINDEX, &ifr); addr.can_family = AF_CAN; addr.can_ifindex = ifr.ifr_ifindex; // bind if (bind(can_socket, (struct sockaddr*) &addr, sizeof(addr)) != 0) { int err_num = errno; if(verbose)fprintf(stderr,"CAN_Open_Socket() bind() %d", err_num); return -1; // error socket }