Before ordering I wanted to make sure that I can talk to the QCA with the linux kernel.
It is a bit of a palaver.
Here's the howto running QCA7000 on BeagleBone via SPI
Find out which kernel your BeagleBone is running:
Now you need to get the matching kernel. On your desktop PC run
Code: Select all
git clone https://github.com/RobertCNelson/ti-linux-kernel-dev.git
cd ti-linux-kernel-dev/
git checkout 5.10.168-ti-r71
./build_kernel.sh
obviously you need to checkout the version matching your kernel in the 3rd command
The script will now endlessly download stuff (I think the standard linux kernel) and patch it. Then it will open the configuration menu. You need to set
Code: Select all
Device Drivers -> Network Device Support -> Ethernet Driver Support -> [*] Qualcomm Devices -> <M> Qualcomm Atheros QCA7000 SPI support
So once you find Qualcomm Devices you select them with the space key. Then the various devices show up and you select ....QCA7000 SPI and press M.
Then navigate to the Save button and press it, then Exit by selecting "Exit" until the menu exits
Then the build process automatically starts.
Now in the "deploy" directory you will find 5.10.168-ti-r71-modules.tar.gz. Open it and navigate to
Code: Select all
./lib/modules/5.10.168-ti-r71/kernel/drivers/net/ethernet/qualcomm
Here you'll find two .ko.xz files. Copy them to your BeagleBone
Now back to the BeagleBone console. Extract the xz files and copy them into the kernel tree with
Code: Select all
xz -d qca_7k_common.ko.xz
xz -d qcaspi.ko.xz
sudo mkdir /lib/modules/5.10.168-ti-r71/kernel/drivers/net/ethernet/qualcomm
sudo mv *.ko /lib/modules/5.10.168-ti-r71/kernel/drivers/net/ethernet/qualcomm
sudo depmod -a
Now create the file
Code: Select all
/opt/source/bb.org-overlays/src/arm/BB-SPI0-QCASPI-00A0.dts
and put the following code into it:
Code: Select all
/*
* Copyright (C) 2019 Tomas Arturo Herrera Castro <taherrera@uc.cl>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* Written as part of my master's thesis at PUC Chile,
* to run the BeagleBone as an OpenThread Border Router w/o an NCP.
*
* https://www.sltech.cl
*
* Compiled using: make ./src/arm/BB-SPI0-QCASPI-00A0.dtbo
*
* Tested on BeagleBone Black Rev. C + REB233-XPRO. Linux beaglebone 4.14.71-ti-r80.
*
*/
/dts-v1/;
/plugin/;
#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/interrupt-controller/irq.h>
/ {
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
fragment@0 {
target-path="/";
__overlay__ {
chosen {
overlays {
BB-SPI0-QCASPI-00A0 = __TIMESTAMP__;
};
};
};
};
/*
* Free up the pins used by the cape from the pinmux helpers.
*/
fragment@1 {
target = <&ocp>;
__overlay__ {
P9_17_pinmux { status = "disabled"; }; /* P9_17 (A16) spi0_cs0.spi0_cs0 */
P9_18_pinmux { status = "disabled"; }; /* P9_18 (B16) spi0_d1.spi0_d1 */
P9_21_pinmux { status = "disabled"; }; /* P9_21 (B17) spi0_d0.spi0_d0 */
P9_22_pinmux { status = "disabled"; }; /* P9_22 (A17) spi0_sclk.spi0_sclk */
P9_15_pinmux { status = "disabled"; }; /* irq P9_15 (R13) gpmc_a0.gpio1[16] */
};
};
fragment@2 {
target = <&am33xx_pinmux>;
__overlay__ {
bb_qca_pins: bb_qca_pins {
pinctrl-single,pins = <
AM33XX_PADCONF(AM335X_PIN_GPMC_A0, PIN_INPUT_PULLDOWN, MUX_MODE7) /* irq P9_15 (R13) gpmc_a0.gpio1[16] */
>;
};
spi0_qca_s0: spi0_qca_s0 {
pinctrl-single,pins = <
AM33XX_PADCONF(AM335X_PIN_SPI0_SCLK, PIN_INPUT, MUX_MODE0) /* P9_22 (A17) spi0_sclk.spi0_sclk */
AM33XX_PADCONF(AM335X_PIN_SPI0_D0, PIN_INPUT, MUX_MODE0) /* P9_21 (B17) spi0_d0.spi0_d0 */
AM33XX_PADCONF(AM335X_PIN_SPI0_D1, PIN_INPUT, MUX_MODE0) /* P9_18 (B16) spi0_d1.spi0_d1 */
AM33XX_PADCONF(AM335X_PIN_SPI0_CS0, PIN_INPUT, MUX_MODE0) /* P9_17 (A16) spi0_cs0.spi0_cs0 */
>;
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&spi0_qca_s0>;
eth1: qcaspi@0 {
compatible = "qca,qca7000";
pinctrl-names = "default";
pinctrl-0 = <&bb_qca_pins>;
spi-max-frequency = <12000000>;
reg = <0>;
interrupt-parent = <&gpio1>;
interrupts = <16 IRQ_TYPE_EDGE_RISING>; /* gpio1[16] active high */
};
};
};
};
The interrupt line of the QCA chip is connected to P9_15 and the other pins are connected to P9 as well:
SPI0_CS:17 -> CS
SPI0_D1:18 -> MOSI
SPI0_D0:21 -> MISO
SPI0_CLK:22 -> CLK
Now compile the device trees and copy the new file where it is expected with
Code: Select all
cd /opt/source/bb.org-overlays/
make
sudo cp src/arm/BB-SPI0-QCASPI-00A0.dtbo /lib/firmware/
Now in /boot/uEnv.txt enable the new file with
Code: Select all
uboot_overlay_addr0=BB-SPI0-QCASPI-00A0.dtbo
Of course it can be any other addrX, too if you're already using other files.
Now reboot and watch the debug terminal in case something goes wrong.
Ultimately you should see
Code: Select all
[ 28.949382] qcaspi spi0.0: ver=0.2.7-i, clkspeed=12000000, burst_len=5000, pluggable=0
[ 29.041706] qcaspi spi0.0: Using random MAC address: 56:7b:be:8b:cd:74
Check that you can find the chip with
Code: Select all
> int6klist -v -i eth1
00000000 00 B0 52 00 00 01 AA 38 9F A8 13 32 88 E1 00 00 ..R....8...2....
00000010 A0 00 B0 52 00 00 00 00 00 00 00 00 00 00 00 00 ...R............
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000030 00 00 00 00 00 00 00 00 00 00 00 00 ............
00000000 AA 38 9F A8 13 32 04 65 65 FF FF FF 88 E1 00 01 .8...2.ee.......
00000010 A0 00 B0 52 00 22 25 4D 41 43 2D 51 43 41 37 30 ...R."%MAC-QCA70
00000020 30 35 2D 31 2E 31 2E 30 2E 37 33 30 2D 30 34 2D 05-1.1.0.730-04-
00000030 32 30 31 34 30 38 31 35 2D 43 53 00 CC CC CC CC 20140815-CS.....
Now pyPLC should run as well