Edit Device Tree and active SPI with Fenix - VIM3

Hello I would like to use SPI but I am not sure how to activate and I’m a novice with linux so sorry for the dumb questions i can ask.
First time with fenix too.

I understand that the steps to follow are:

First step
$ sudo apt-get install git make lsb-release qemu-user-static
$ mkdir ~/project/
$ cd ~/project/
$ git clone --depth 1 https://github.com/khadas/fenix
$ cd fenix

next setp
$ source env/setenv.sh

next step
$ make (or make kernel) (or make kernel && make debs && make) WHICH I HAVE TO USE?
"this step is to make the file appear, right?"I mean, when you clone git repo there is not a linux/…/amlogic folder, where the file kvim3_linux.dts is suppose to be.

next step
after (make, make kernel or make debs) finish
I have edit kvim3_linux.dts file to activate SPI, so do i have to disable pwm_ef, enable spicc1, enable pcie_A and disable uart_c? or what i have to do?

next step
I have to make again right? but again which one?
$ make (or make kernel) (or make kernel && make debs && make)
When this step finish, an image (fenix/linux/arch/arm64/boot/Image) and a .dtb file (fenix/linux/arch/arm64/boot/dts/amlogic/kvim3_linux.dtb) are supposed to appear right?

And finally i have to copy and replace the image and .dtb file to my board
then
$ sync
$ sudo reboot

and spidev1.0 should appear.
Are these all the steps or is there a step that I forget about my dumb’s guide?
Do i have to do both makes in fenix folder or linux folder? or where?
Thanks in advance.

1 Like

@vaayroon When you edit the dts . Just need to open spicc1.

&spicc1 {
    status = "okay";
    pinctrl-names = "default";
    pinctrl-0 = <&spicc1_pins>;
    cs-gpios = <&gpio GPIOH_6 0>;

    spidev@0 {
        status = "okay";

        compatible = "linux,spidev";
        /* spi default max clock 100Mhz */
        spi-max-frequency = <100000000>;
        reg = <0>; 
    };   
};

Then run source env/setenv.sh . And then run make .
If you compiled vim3 of Fenix before modification. You should run this command make kernel && make debs && make

4 Likes

Finally, I have managed to activate the SPI following my steps and using the command make kernel && make debs && make. Thanks, @Frank

Hi Frank! i am trying to use the external MCP2515 Spi-Can ic for communicate khadas with other can devices(ardunio, stm etc.). I changed /boot/env.txt and added spi1, removed the fan_pwm and uart. Actually only spi1 typed overlays. When i check with oscilloscope while i am sending any message over spi with GitHub - cpb-/spi-tools: Simple command line tools to help using Linux spidev devices library i notice that CS pin not working. After for a week and hardwork, i couldn’t be successful. What should i do to operate spi with cs pin active? Any idea or advice?
(Khadas Vim3)

1 Like