Saturday, September 24, 2016

OrangePI PC with 4.8.x using buildroot

Finally got some time to get back to testing OrangePI-PC as a Flight Controller board.  The OrangePI-PC offers several advantages over the Pi Zero:
  • Multiple serial ports (3) 
  • Multiple USB ports (each have port has its own controller not a Hub)
  • Camera (Still working on that)
  • Cost is low around $12

I'm using standard buildroot with the orangePI defconfig, but using a different Linux kernel which has several patches for Ethernet, USB (slave), and thermal control (Which is big).   Using orange-pi-4.8 branch.

Also made a couple of code changes:
  • spidev 
static const struct of_device_id spidev_dt_ids[] = {
    { .compatible = "rohm,dh2228fv" },
    { .compatible = "lineartechnology,ltc2488" },
        { .compatible = "spidev" },

  • device tree: 
    • sun8i-h3-orangepi-pc.dts:
        spi0_pins_a: spi0@0 {
                allwinner,pins = "PC0", "PC1", "PC2";
                allwinner,function = "spi0";
                allwinner,drive = <SUN4I_PINCTRL_10_MA>;
                allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
            };

    spi0_cs0_pins_a: spi0_cs0@0 {
                allwinner,pins = "PC3";
                allwinner,function = "spi0";
                allwinner,drive = <SUN4I_PINCTRL_10_MA>;
                allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
            };
           
        i2c0_pins_a: i2c0@0 {
        allwinner,pins = "PA11", "PA12";
            allwinner,function = "i2c0";
            allwinner,drive = <SUN4I_PINCTRL_10_MA>;
            allwinner,pull = <SUN4I_PINCTRL_NO_PULL>;
        };

.....
&spi0 {
    pinctrl-names = "default";
    pinctrl-0 = <&spi0_pins_a>, <&spi0_cs0_pins_a>;
    status = "okay";
        spidev0: spidev@0 {
                #address-cells = <1>;
            #size-cells = <0>;
            compatible = "spidev";
        reg = <0>;
        spi-max-frequency = <50000000>;
        };
};

&i2c0 {
    pinctrl-names = "default";
    pinctrl-0 = <&i2c0_pins_a>;
    status = "okay";
}; 

      • sun8i-h3.dtsi
        spi0: spi@01c68000 {
            compatible = "allwinner,sun6i-a31-spi";
            reg = <0x01c68000 0x1000>;
            interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
            clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
            clock-names= "ahb", "mod";
            resets = <&ccu RST_BUS_SPI0>;
            dmas = <&dma 23>, <&dma 23>;
            dma-names = "rx", "tx";
            status = "disabled";
            #address-cells = <1>;
            #size-cells = <0>;
        };
       
        i2c0: i2c@01c2ac00 {
            compatible = "allwinner,sun6i-a31-i2c";
            reg = <0x01c2ac00 0x400>;
            interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
            clocks = <&ccu CLK_BUS_I2C0>;
            resets = <&ccu  RST_BUS_I2C0>;
            status = "disabled";
            #address-cells = <1>;
           
#size-cells = <0>;
        };
So, this adds a SPI interface and another I2C.

Next is to do some testing with SPI and I2C.

Also, still adding code to CleanFlight port to Linux.   Please post if you have any questions. 

1 comment:

  1. can you please share your modified kernl source code for orange pi to test gpio, i2c and spi

    ReplyDelete