(02-05-2018, 02:10 AM)jamess Wrote: [ -> ] (02-02-2018, 08:20 PM)0xP1kachuHi! Wrote: [ -> ]Sorry to disturb again
I recompiled the kernel and loaded the CAN modules. I had some trouble with the 2.0.4 version so I stayed on the one I am now (though I think this is already this version, I bought the tinker board 3 weeks ago, but I haven't found any way to check)
Have you got any idea of which parts of the .dts would not be compatible ?
I still don't really understand what would need to be changed...
Thanks in advance 
Hi,
You can check /etc/version node for the image version.
and before you use other versions, please note the below tips.
Before V2.0.1 the overlay should located at /boot folder and the hw_intf.conf should be like below
intf:dts_overlay=/w1-gpio.dtbo
After V2.0.3 the overlay should located at /boot/overlays folder and the hw_intf.conf should be like below
intf:dtoverlay=w1-gpio
I'll check this, thanks!
(02-05-2018, 04:23 AM)ychou Wrote: [ -> ] (02-02-2018, 08:20 PM)0xP1kachu Wrote: [ -> ] (02-01-2018, 04:48 PM)jamess Wrote: [ -> ] (02-01-2018, 02:59 PM)0xP1kachu Wrote: [ -> ]From what I understood, this would "only" require to recompile the kernel with support for the mcp251x module, and modify the .dst in consequence (which is the hard part I think, but once I understand how it works should be good). Since the pinout is the same as the raspberry pi, everything else should be all right as long as the kernel has the correct module loaded.
(currently cloning debian_kernel)
Yes, I think so
Hi!
Sorry to disturb again
I recompiled the kernel and loaded the CAN modules. I had some trouble with the 2.0.4 version so I stayed on the one I am now (though I think this is already this version, I bought the tinker board 3 weeks ago, but I haven't found any way to check)
Have you got any idea of which parts of the .dts would not be compatible ?
I still don't really understand what would need to be changed...
Thanks in advance 
Hi 0xP1kachu,
here are some hints may be helpful for translation .dts :
1. Compatible
RPi:
Code:
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
Tinker:
Code:
compatible = "rockchip,rk3288-miniarm", "rockchip,rk3288";
2. SPI
RPi:
Tinker:
3. GPIO settings
Please note the formats are a bit different.
RPi:
Code:
brcm,pins = <17 25 24>;
brcm,function = <0 0 0>; /* in in in */
Tinker:
Code:
rockchip,pins = <5 19 0 &pcfg_pull_none>,
<5 11 0 &pcfg_pull_none>,
<5 12 0 &pcfg_pull_none>;
Please have a try and hope these are useful to you~
YC
I'll give it a try, thank you very much!
So, I went ahead and put
mcp2515-can0.dts into the recently cloned
debian_kernel/arch/arm/boot/dts folder. I compiled it using this script
Code:
IDE=mcp2515-can0
SRC=$IDE.dts
TMP=$IDE.tmp.dts
DST=$IDE.dtb
cpp -nostdinc -I include -undef -x assembler-with-cpp $SRC > $TMP
dtc -O dtb -b 0 -o $DST $TMP
rm $TMP
Here is the content of the source file, modified from what I understood
Code:
/*
* Device tree overlay for mcp251x/can0 for TinkerBoard
* Original: https://github.com/krzk/tizen-tv-rpi-linux/blob/master/arch/arm/boot/dts/overlays/mcp2515-can0-overlay.dts
*/
/dts-v1/;
#include <dt-bindings/clock/rockchip,rk808.h>
#include "rk3288.dtsi"
/ {
compatible = "rockchip,rk3288-miniarm", "rockchip,rk3288";
fragment@0 {
target = <&spi2>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
};
};
/*
// the interrupt pin of the can-controller
fragment@1 {
target = <&gpio>;
__overlay__ {
can0_pins: can0_pins {
brcm,pins = <25>;
brcm,function = <0>;
};
};
};
*/
/* the interrupt pin of the can-controller */
fragment@1 {
target = <&gpio8>; /*Not sure about this one */
__overlay__ {
can0_pins: can0_pins {
rockchip,pins = <8 25 0 &pcfg_pull_none>; /*Not sure about this one neither*/
};
};
};
/* the clock/oscillator of the can-controller */
fragment@2 {
target-path = "/clocks";
__overlay__ {
can0_osc: can0_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <16000000>;
};
};
};
/* the spi config of the can-controller itself binding everything together */
fragment@3 {
target = <&spi2>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
can0: mcp2515@0 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&can0_pins>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio8>;
interrupts = <25 0x2>;
clocks = <&can0_osc>;
};
};
};
__overrides__ {
oscillator = <&can0_osc>,"clock-frequency:0";
spimaxfrequency = <&can0>,"spi-max-frequency:0";
interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
};
};
I am running 1.8, and just remember this
post where it says the device tree overlay isn't available before 1.9.1.
I will upgrade to a more recent image, but if anybody can verify my dts above (just like, does it make any sense?), I'll be grateful :)
Thanks!
Update, I'm on 2.0.1, and enabling the above compiled dts (dtbo) prevents the machine from even getting to the screen init

So I'm left with nothing for debugging

(02-05-2018, 07:45 PM)0xP1kachu Wrote: [ -> ]Update, I'm on 2.0.1, and enabling the above compiled dts (dtbo) prevents the machine from even getting to the screen init 
So I'm left with nothing for debugging 
We got the device and try to enable it now. keep update if any
(02-06-2018, 01:26 AM)jamess Wrote: [ -> ] (02-05-2018, 07:45 PM)0xP1kachu Wrote: [ -> ]Update, I'm on 2.0.1, and enabling the above compiled dts (dtbo) prevents the machine from even getting to the screen init 
So I'm left with nothing for debugging 
We got the device and try to enable it now. keep update if any
Hi,
I have brought up the bus with the attached .dts; provide it for your reference first, and will update the details soon (writing now

).
Quote:/*
* Device tree overlay for mcp251x/can0 on spi0.0
*/
/dts-v1/;
/plugin/;
/ {
compatible = "rockchip,rk3288-miniarm", "rockchip,rk3288";
/* disable spi-dev for spi0.0 */
fragment@0 {
target = <&spi2>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
spidev@1{
status = "disabled";
};
};
};
/* the interrupt pin of the can-controller */
fragment@1 {
target = <&gpio5>;
__overlay__ {
can0_pins: can0_pins {
rockchip,pins = <5 19 0 &pcfg_pull_none>;
};
};
};
/* the clock/oscillator of the can-controller */
fragment@2 {
target-path = "/";
__overlay__ {
/* external oscillator of mcp2515 on SPI0.0 */
can0_osc: can0_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <16000000>;
};
};
};
/* the spi config of the can-controller itself binding everything together */
fragment@3 {
target = <&spi2>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <2>;
#size-cells = <0>;
can0: mcp2515@0 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&can0_pins>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio5>;
interrupts = <19 0x2>;
clocks = <&can0_osc>;
};
};
};
//__overrides__ {
// oscillator = <&can0_osc>,"clock-frequency:0";
// spimaxfrequency = <&can0>,"spi-max-frequency:0";
// interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
//};
};
YC
(02-06-2018, 07:22 AM)ychou Wrote: [ -> ] (02-06-2018, 01:26 AM)jamess Wrote: [ -> ] (02-05-2018, 07:45 PM)0xP1kachu Wrote: [ -> ]Update, I'm on 2.0.1, and enabling the above compiled dts (dtbo) prevents the machine from even getting to the screen init 
So I'm left with nothing for debugging 
We got the device and try to enable it now. keep update if any
Hi,
I have brought up the bus with the attached .dts; provide it for your reference first, and will update the details soon (writing now
).
Quote:/*
* Device tree overlay for mcp251x/can0 on spi0.0
*/
/dts-v1/;
/plugin/;
/ {
compatible = "rockchip,rk3288-miniarm", "rockchip,rk3288";
/* disable spi-dev for spi0.0 */
fragment@0 {
target = <&spi2>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
spidev@1{
status = "disabled";
};
};
};
/* the interrupt pin of the can-controller */
fragment@1 {
target = <&gpio5>;
__overlay__ {
can0_pins: can0_pins {
rockchip,pins = <5 19 0 &pcfg_pull_none>;
};
};
};
/* the clock/oscillator of the can-controller */
fragment@2 {
target-path = "/";
__overlay__ {
/* external oscillator of mcp2515 on SPI0.0 */
can0_osc: can0_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <16000000>;
};
};
};
/* the spi config of the can-controller itself binding everything together */
fragment@3 {
target = <&spi2>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <2>;
#size-cells = <0>;
can0: mcp2515@0 {
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&can0_pins>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio5>;
interrupts = <19 0x2>;
clocks = <&can0_osc>;
};
};
};
//__overrides__ {
// oscillator = <&can0_osc>,"clock-frequency:0";
// spimaxfrequency = <&can0>,"spi-max-frequency:0";
// interrupt = <&can0_pins>,"brcm,pins:0",<&can0>,"interrupts:0";
//};
};
YC
OMG!
No way?!
I'll take a look as soon as possible, you're amazing!
Hi 0xP1kachu,
Here is the document for your reference:
CAN-Bus document
If any question, please let me know.
Thank you!
YC
Had to recompile a bit, but I was finally able to get it working (on 2.0.1)!
I'll go try it on my car in the afternoon.
Thanks again to all of you!
If it works, I'll mark the conversation as solved (if it is possible, or I'll let you guys do it)
Thanks again

Just tested it, everything works perfectly!
Thanks again for everything :)