Skip to content

Instantly share code, notes, and snippets.

@benemorius
Created November 12, 2019 01:51
Show Gist options
  • Save benemorius/5316899f07d29d3892d5007d9a74be15 to your computer and use it in GitHub Desktop.
Save benemorius/5316899f07d29d3892d5007d9a74be15 to your computer and use it in GitHub Desktop.
configure a raspberry pi for a kw41z-slip module
#!/bin/bash
set -x
# This script enables the UART and disables kernel output and getty on it
# and installs OpenOCD from source and compiles RIOT from source and flashes
# the gnrc_border_router example onto a kw41z-slip module.
#
# It takes about 5 minutes on rpi4 up to maybe an hour on rpi0.
#
# A reboot is required if /dev/serial0 isn't already enabled.
sudo apt install -y git picocom gcc-arm-none-eabi libtool
# disable getty on uart
sudo systemctl stop serial-getty@ttyS0.service
sudo systemctl mask serial-getty@ttyS0.service
# disable kernel output to uart
sudo sed 's/serial0,115200 //' -i /boot/cmdline.txt
# rpis with bluetooth have the uart disabled by default
# a reboot is required for this to take effect
if ! grep "^enable_uart=1" /boot/config.txt; then
/bin/echo -e "\n# enable uart for kw41z-slip radio\nenable_uart=1" | sudo tee -a /boot/config.txt
fi
# fetch compile and install openocd
cd
git clone https://github.com/beduino-project/openocd.git
cd openocd/
./bootstrap
./configure --enable-bcm2835gpio --enable-sysfsgpio --disable-jlink
nice make -j4
sudo make install
# fetch compile and flash riot onto kw41z-slip
cd
git clone https://github.com/benemorius/RIOT.git
cd RIOT/
# compile uhcpd and ethos
cd dist/tools/uhcpd/
make
cd ../ethos/
make
cd ../../..
# compile and flash firmware
# rpi4 introduced a new gpio base, so just use sysfsgpio instead of bcm2835gpio
#sudo ETHOS_BAUDRATE=115200 BOARD=openlabs-kw41z-slip make -j4 flash -C examples/gnrc_border_router/
sudo ETHOS_BAUDRATE=115200 DEBUG_ADAPTER=sysfsgpio BOARD=openlabs-kw41z-slip make -j4 flash -C examples/gnrc_border_router/
cd
set +x
echo 'now run `sudo RIOT/dist/tools/ethos/start_network.sh /dev/serial0 tap0 2001:db8:0:1540::/64 115200`'
echo '(reboot first if necessary to enable serial port /dev/serial0)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment