This is just a basic linux device driver which explains about the file operations.
Please update your Beaglebone board's kernel directory in the Makefile.
Build for Beaglebone: sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-
Build for Raspberry Pi or Virtualbox Ubuntu: sudo make
Please refer this URL for the complete tutorial of this example source code. https://embetronicx.com/tutorials/linux/device-drivers/cdev-structure-and-file-operations-of-character-drivers/
You can check the video tutorial of this example here (https://youtu.be/20dQsadVdII).
The Linux Device Driver Video Playlist - https://www.youtube.com/watch?v=BRVGchs9UUQ&list=PLArwqFvBIlwHq8WMKgsXSQdqIvymrEz9k
How to Setup Ubuntu and Raspberry PI - https://www.youtube.com/watch?v=e6gNeje3ljA How to Setup BeagleBone and Cross compile the kernel - https://www.youtube.com/watch?v=am-dgmrMgYY&t