Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vaishnavachath/01a175d9e5a42480d2f5dd27104bfe82 to your computer and use it in GitHub Desktop.
Save vaishnavachath/01a175d9e5a42480d2f5dd27104bfe82 to your computer and use it in GitHub Desktop.
mikroBUS over Greybus BeagleConnect Freedom Demo

PocketBeagle Host

Host Image : Download the latest BeagleBoard.org debian image from here and load this image to an SD card.

Kernel Build(takes about 1-2 hours for a fresh build on an Ubuntu machine):

Only this step needs to be run on a separate machine, all other steps are executed on PocketBeagle, to skip this step download pre-built kernel image from

git clone https://github.com/vaishnav98/bb-kernel.git
cd bb-kernel
git checkout clickid
./build_deb.sh
cp deploy/*.deb to SD card/PocketBeagle

Install newly built kernel

In PocketBeagle from the directory where the *.deb files are copied, run

sudo dpkg -i *.deb
sudo reboot

Clone and Build gb-netlink

git clone https://github.com/jadonk/greybus.git
cd greybus
git checkout f7fe50f8c0ab4545a0850e0552b99ad7522287b8
makemak
e -j`nproc --all`

Host Tools

Install dependencies

sudo apt install -y libnl-3-dev libnl-genl-3-dev libbluetooth-dev libavahi-client-dev wpan-tools

Clone and build gb-netlink

git clone https://github.com/jadonk/greybus.git
cd greybus
git checkout 8ba7f56f04191d74b28346dcd5a22f01608f65dfy
make
sudo make install

Clone and build wpanusb

git clone https://github.com/jadonk/wpanusb.git
cd wpanusb
git checkout 1bfd42e3ffd7cfd38175094c38319ecbc5842500
make
sudo make install

Clone and build gbridge

git clone https://github.com/jadonk/gbridge.git
git checkout 8ba7f56f04191d74b28346dcd5a22f01608f65df
cd gbridge
autoreconf -vfi
GBNETLINKDIR=${PWD}/../greybus \
  ./configure --enable-uart --enable-tcpip --disable-gbsim --enable-netlink --disable-bluetooth
make -j`nproc --all`
sudo make install

qemu_x86_64 Host

git clone --recurse-submodules https://github.com/jadonk/beagleconnect.git
cd
wget "https://buildroot.org/downloads/buildroot-2020.11.1.tar.gz"
tar xzf buildroot-2020.08.tar.gz
cd ... /beagleconnect/sw/buildroot
make -C ~/buildroot-2020.08 O=$PWD BR2_EXTERNAL=$PWD beagleconnect_gateway_qemu_x86_64_defconfig

Common firmware build script

cd ..beagleconnect/sw <if not cloned already, clone beagleconnect repo with submodules>
./build-firmware.sh

To skip this step, download the pre-built firmware from : https://github.com/jadonk/beagleconnect/suites/4055985525/artifacts/102934099

BeagleConnectTM Freedom Gateway Device(over USB)

Flashing

Connect BeagleConnect Freedom device over USB, make sure proper msp430 usb-uart bridge FW is flashed

west flash -d build/wpanusb_beagleconnect (use _2G for 2.4GHz version)

Flashing mikroBUS Click ID Adapter with Add-on board manifest

For flashing mikrobus click ID EEPROM with a click manifest, perform(skip if not using Click ID adapter): from sw directory after plugging in the click ID adapter on the mikrobus port 1(USB, Battery Connector Side) on BeagleConnect Freedom

cd ..beagleconnect/sw
./flash-clickid.sh RTC-6-CLICK {or any other click with manifest available in manifests directory}

See this readme for details on describing add-on boards over greybus

BeagleConnectTM Freedom Remote Device

west flash -d build/greybus_mikrobus_beagleconnect 

Demo

Connect the BeagleConnect Freedom device with wpanusb to the host machine using usb. If using PocketBeagle as the host machine the module loading and initial communication setup needs to be performed as in the following script, in the qemu x86_64 image, the setup and gbridge is configured to run at startup, to start the VM run the following:

cd ..beagleconnect/sw/buildroot
sudo ./run <before running this make sure WPANUSB device is connected and remote device is powered up>
@vaishnavachath
Copy link
Author

Buildroot Console Output Sample:

buildroot login: $setting up wpanusb gateway for IEEE 802154 CHANNEL 26\n
killall: gbridge: no process killed
PING 2001:db8::1(2001:db8::1) from 2001:db8::2 lowpan0: 56 data bytes
64 bytes from 2001:db8::1: icmp_seq=1 ttl=64 time=78.9 ms
64 bytes from 2001:db8::1: icmp_seq=2 ttl=64 time=69.1 ms
64 bytes from 2001:db8::1: icmp_seq=3 ttl=64 time=45.8 ms
64 bytes from 2001:db8::1: icmp_seq=4 ttl=64 time=51.4 ms
64 bytes from 2001:db8::1: icmp_seq=5 ttl=64 time=52.6 ms

--- 2001:db8::1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4017ms
rtt min/avg/max/mdev = 45.799/59.546/78.878/12.400 ms
greybus 1-2.2: Interface added (greybus)
greybus 1-2.2: GMP VID=0x00000126, PID=0x00000126
greybus 1-2.2: DDBL1 Manufacturer=0x00000126, Product=0x00000126
greybus 1-2.2: excess descriptors in interface manifest
mikrobus:mikrobus_port_gb_register: mikrobus gb_probe , num cports= 3, manifest_size 428
mikrobus:mikrobus_port_gb_register: protocol added 11
mikrobus:mikrobus_port_gb_register: protocol added 3
mikrobus:mikrobus_port_gb_register: protocol added 2
mikrobus:mikrobus_port_register: registering port mikrobus-0
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 1, driver=opt3001, protocol=3, reg=44
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 2, driver=hdc2010, protocol=3, reg=40
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 3, driver=lis2dh12_accel, protocol=3, reg=18
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 4, driver=bme280, protocol=3, reg=76
mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 8, driver=mcp7941x, protocol=3, reg=6f
mikrobus_manifest:mikrobus_manifest_parse: Greybus Service Sample Application manifest parsed with 5 devices
mikrobus mikrobus-0: registering device : opt3001
opt3001 0-0044: Found TI OPT3001
mikrobus mikrobus-0: registering device : hdc2010
mikrobus mikrobus-0: registering device : lis2dh12_accel
iio iio:device1: registered accelerometer lis2dh12_accel
mikrobus mikrobus-0: registering device : bme280

Welcome to Buildroot
buildroot login: mikrobus mikrobus-0: registering device : mcp7941x
rtc-ds1307 0-006f: registered as rtc1

Welcome to Buildroot
buildroot login: root
Password:

iio_info
Library version: 0.19 (git tag: v0.19)
Compiled with backends: local xml ip usb serial
IIO context created with local backend.
Backend version: 0.19 (git tag: v0.19)
Backend description string: Linux buildroot 5.8.14 #1 SMP Tue Mar 2 01:01:36 IST 2021 x86_64
IIO context has 1 attributes:
local,kernel: 5.8.14
IIO context has 3 devices:
iio:device0: opt3001
1 channels found:
illuminance: (input)
2 channel-specific attributes found:
attr 0: input value: 11.420000
attr 1: integration_time value: 0.800000
2 device-specific attributes found:
attr 0: current_timestamp_clock value: realtime

			attr  1: integration_time_available value: 0.1 0.8
iio:device1: lis2dh12_accel (buffer capable)
	4 channels found:
		accel_x:  (input, index: 0, format: le:s12/16>>4)
		3 channel-specific attributes found:
			attr  0: raw value: -992
			attr  1: scale value: 0.009806
			attr  2: scale_available value: 0.009806 0.019613 0.039226 0.117679
		accel_y:  (input, index: 1, format: le:s12/16>>4)
		3 channel-specific attributes found:
			attr  0: raw value: -32
			attr  1: scale value: 0.009806
			attr  2: scale_available value: 0.009806 0.019613 0.039226 0.117679
		accel_z:  (input, index: 2, format: le:s12/16>>4)
		3 channel-specific attributes found:
			attr  0: raw value: 36
			attr  1: scale value: 0.009806
			attr  2: scale_available value: 0.009806 0.019613 0.039226 0.117679
		timestamp:  (input, index: 3, format: le:S64/64>>0)
	3 device-specific attributes found:
			attr  0: current_timestamp_clock value: realtime

			attr  1: sampling_frequency value: 1
			attr  2: sampling_frequency_available value: 1 10 25 50 100 200 400 1600
	2 buffer-specific attributes found:
			attr  0: data_available value: 0
			attr  1: watermark value: 1
iio:device2: bme280
	3 channels found:
		temp:  (input)
		2 channel-specific attributes found:
			attr  0: input value: 25320
			attr  1: oversampling_ratio value: 2
		pressure:  (input)
		2 channel-specific attributes found:
			attr  0: input value: 100.748921875
			attr  1: oversampling_ratio value: 16
		humidityrelative:  (input)
		2 channel-specific attributes found:
			attr  0: input value: 56785
			attr  1: oversampling_ratio value: 16
cat /sys/class/rtc/rtc1/name
rtc-ds1307 0-006f

@vaishnavachath
Copy link
Author

BeagleConnect Freedom Demo LPC2021 : https://youtu.be/ujBwLCa3W4M?t=6211

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment