Hello everyone. I will go over setting up BeaglePlay for Driver Development in this post. I will write a simple "Hello World" driver once BeaglePlay is set up to demonstrate this. Check out my previous post for more information about my project.
Setup BeaglePlay
Update board with the latest software
- Download the flasher image from beagleboard.org distros page.
- Flash this image onto an SD Card. I used balenaEtcher for this.
- Insert SD Card and boot the board. The lights will start flashing in the following order: 0-1-2-3-2-1-0 in a loop. This signifies that image is being flashed into eMMC.
- The board will power down once the flashing is over. Remove the SD Card now.
Setup Networking
- Connect the Board to Linux Host using USB.
- SSH into the board. The default credentials are as follows:
- username: debian
- password: temppwd
- hostname: beagleplay.local
- Connect to WiFi using
wpa_cli:- Run
wpa_cli.
$ wpa_cli- Use
scanandscan_resultsto see available networks.
> scan OK <3>CTRL-EVENT-SCAN-RESULTS > scan_results bssid / frequency / signal level / flags / ssid 00:00:00:00:00:00 2462 -49 [WPA2-PSK-CCMP][ESS] MYSSID 11:11:11:11:11:11 2437 -64 [WPA2-PSK-CCMP][ESS] ANOTHERSSID- To associate with MYSSID, add the network, set the credentials, and enable it:
> add_network 0 > set_network 0 ssid "MYSSID" > set_network 0 psk "passphrase" > enable_network 0 <2>CTRL-EVENT-CONNECTED - Connection to 00:00:00:00:00:00 completed (reauth) [id=0 id_str=]- If the SSID does not have password authentication, you must explicitly configure the network as keyless by replacing the command
set_network 0 psk "passphrase"withset_network 0 key_mgmt NONE. - Finally, save this network in the configuration file and quit wpa_cli:
> save_config OK > quit - Run
Now it should be possible to ssh into BeaglePlay without being connected using USB.
Copy SSH key
Since we have to ssh into the BeaglePlay so many times, it is better to use ssh key instead of password.
- Check if the ssh key is present:
ls -al ~/.ssh- Generate new ssh key if not present.
- Copy public key to BeaglePlay:
ssh-copy-id debian@beagleplay.localYou should now be able to ssh into BeaglePlay without a password.
Build Kernel
While building the kernel module on BeaglePlay is possible, I prefer using my Linux host device for development. As such, I needed to have the BeaglePlay kernel source on my host.
- Download the [beagle kernel] source using git:
git clone https://git.beagleboard.org/beagleboard/linux.git && cd linux- Check out the branch corresponding to BeaglePlay's Kernel. In my case, BeaglePlay was running
5.10.168
git checkout v5.10.168-ti-arm64-r103- Copy the config from BeaglePlay.
scp debian@beagleplay.local:/boot/config-5.10.168-ti-arm64-r103 ./.config- Download dependencies. I am listing the fedora linux dependencies here:
sudo dnf install bison flex gcc-aarch64-linux-gnu -y- Generate config from the previous one:
make ARCH=arm64 CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- oldconfig- Build the kernel
make ARCH=arm64 CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- -j${nproc}- Generate
compiler_commands.jsonto use LSP:
python scripts/clang-tools/gen_compile_commands.pyBuild Kernel Module
Now we will build a simple "Hello World" module for our BeaglePlay Kernel.
- Create a new directory for our project:
mkdir hello-world- Write a
Makefile:
obj-m += hello-world.o
KDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(CURDIR)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean- Write
hello-world.c:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/printk.h>
static int __init bcf_greybus_init(void) {
pr_info("Hello World 1.\n");
return 0;
}
static void __exit bcf_greybus_exit(void) { pr_info("Goodbye World 1.\n"); }
module_init(bcf_greybus_init);
module_exit(bcf_greybus_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Ayush Singh <ayushdevel1325@gmail.com>");
MODULE_DESCRIPTION("A simple Hello World Driver");- Build the Module:
make KDIR=${PATH_TO_BEAGLE_KERNEL} ARCH=arm64 CROSS_COMPILE=/usr/bin/aarch64-linux-gnu- -j12Run on BeaglePlay
- Copy the module to BeaglePlay:
scp hello-world.ko debian@beagleplay.local:~/- Install Module in BeaglePlay:
sudo insmod hello-world.ko- Remove Module:
sudo rmmod hello_world- Check out the Kernel logs using
dmesg:
dmesg -HConclusion
The Kernel module I am writing for GSoC 23 can be found here. You can follow my GSoC23-related blog posts using this feed.
Consider supporting me if you like my work.