GSoC23: Writing a Hello World Driver for BeaglePlay
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
.
- Use
scan
andscan_results
to see available networks.
> scan <3>CTRL-EVENT-SCAN-RESULTS > scan_results
- To associate with MYSSID, add the network, set the credentials, and enable it:
> add_network > set_network > set_network > enable_network <2>CTRL-EVENT-CONNECTED ) [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 > 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:
- Generate new ssh key if not present.
- Copy public key to BeaglePlay:
You 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:
&&
- Check out the branch corresponding to BeaglePlay’s Kernel. In my case, BeaglePlay was running
5.10.168
- Copy the config from BeaglePlay.
- Download dependencies. I am listing the fedora linux dependencies here:
- Generate config from the previous one:
- Build the kernel
- Generate
compiler_commands.json
to use LSP:
Build Kernel Module
Now we will build a simple “Hello World” module for our BeaglePlay Kernel.
- Create a new directory for our project:
- Write a
Makefile
:
- Write
hello-world.c
:
static int __init
static void __exit
;
;
;
;
;
- Build the Module:
Run on BeaglePlay
- Copy the module to BeaglePlay:
- Install Module in BeaglePlay:
- Remove Module:
- Check out the Kernel logs using
dmesg
:
Conclusion
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.