This repository contains the configuration for kernel drivers that are required for the CAN-Zero board.
- Add the following line to the
/boot/firmware/config.txt
file:sudo nano /boot/firmware/config.txt
dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
- Restart the device:
$ sudo reboot
- Add the following line to the
/boot/config.txt
file:dtoverlay=pwm-2chan,pin=12,func=4,pin2=13,func2=4
- Restart the device:
$ sudo reboot
- Install the device tree compiler:
sudo apt install device-tree-compiler
- Download
pwm-2chan-with-clk-overlay.dts
from this repository. - Compile the device tree:
sudo dtc -@ -I dts -O dtb -o pwm-2chan-with-clk-overlay.dtbo pwm-2chan-with-clk-overlay.dts
- Copy the new file to
/boot/overlays/
:sudo cp pwm-2chan-with-clk-overlay.dtbo /boot/overlays/
- Add the following line to the
/boot/config.txt
file:dtoverlay=pwm-2chan-with-clk-overlay,pin=12,func=4,pin2=13,func2=4
- Restart the device:
sudo reboot
sudo nano /etc/udev/rules.d/99-com.rules
Add the following lines:
SUBSYSTEM=="pwm", ACTION!="remove", PROGRAM="/bin/sh -c 'echo 0 > /sys/class/pwm/pwmchip0/export'"
SUBSYSTEM=="pwm", ACTION!="remove", PROGRAM="/bin/sh -c 'echo 1 > /sys/class/pwm/pwmchip0/export'"
-
Give every user access to the PWM controls:
sudo chmod -R 0666 /sys/class/pwm/pwmchip0/export sudo chmod -R 0666 /sys/class/pwm/pwmchip0/unexport
-
Create pwm0 and pwm1:
echo 0 > /sys/class/pwm/pwmchip0/export echo 1 > /sys/class/pwm/pwmchip0/export
-
Give every user access to the PWM:
chmod -R 0666 /sys/class/pwm/pwmchip0/*
Or alternatively to 1-3 add to
/etc/rc.local
the following lines:sudo chmod -R 0666 /sys/class/pwm/pwmchip0/export echo 0 > /sys/class/pwm/pwmchip0/export echo 1 > /sys/class/pwm/pwmchip0/export
-
Use pwm0.
4.1. Set period (in ns):echo 20000000 > /sys/class/pwm/pwmchip0/pwm0/period
4.2. Set duty cycle (in ns):
echo 5000000 > /sys/class/pwm/pwmchip0/pwm0/duty_cycle
4.3. Enable pwm0:
echo 1 > /sys/class/pwm/pwmchip0/pwm0/enable
-
Remove pwm0:
echo 0 > /sys/class/pwm/pwmchip0/unexport
pwm_test.py --chip 0 --channel 0 --period 20 --duty 1.5
dtparam=spi=on
dtoverlay=spi1-1cs,cs0_spidev=off
dtoverlay=mcp2515,spi1-0,oscillator=16000000,interrupt=25
- Install the device tree compiler:
sudo apt install device-tree-compiler
- Download
mcp2515-can2-overlay.dts
from this repository. - Compile the device tree:
sudo dtc -@ -I dts -O dtb -o mcp2515-can2-overlay.dtbo mcp2515-can2-overlay.dts
- Copy the new file to
/boot/overlays/
:sudo cp mcp2515-can2-overlay.dtbo /boot/overlays/
- Add the following lines to the
/boot/config.txt
file:dtparam=spi=on dtoverlay=spi1-1cs,cs0_spidev=off dtoverlay=mcp2515-can2-overlay,oscillator=16000000,interrupt=25
- Add the following lines to the
/etc/network/interfaces
file:auto can0 allow-hotplug can0 iface can0 inet manual pre-up /bin/ip link set can0 up type can restart-ms 100 bitrate 500000 down /bin/ip link set can0 down
- Install can-utils:
sudo apt install can-utils
- Restart the device:
$ sudo reboot
- Check if the can0 interface is up:
ifconfig | grep can0
- Add the following lines to the
/boot/config.txt
file:enable_uart=1 dtparam=i2c_arm=on dtparam=i2c1=on dtparam=i2c1_baudrate=1000000 dtoverlay=pi3-disable-bt
- Install i2c-tools:
sudo apt install i2c-tools
- Restart the device:
$ sudo reboot
- Check I2C:
i2cdetect -y 1
git clone --recurse-submodules https://github.com/karu2003/ardupilot
cd ardupilot
git checkout docker_rpi
docker build . -t ardupilot
docker build . -f Dockerfile_rpi1_zero -t ardupilot_rpi
docker build . -f Dockerfile_rpi2_3 -t ardupilot_rpi
docker build . -f Dockerfile_rpi3b_4 -t ardupilot_rpi
git checkout master
docker run --rm -it -v `pwd`:/ardupilot ardupilot_rpi:latest bash -c "./waf clean && ./waf configure --board=canzero --static && ./waf build"