When I was researching for this project, my first find and the inspiration was Bela, the audio platform based on the BeagleBone. Bela utilizes the same TLV320AIC3104 codec in their sound card, but in very advanced way with real-time co-processor (PRU) that surpasses the kernel inner timings. That was a bit too much for me, since I need to learn how to get the basic audio working. The guy on their user forum told me that if I want to use the codec with the PocketBeagle in an easy way, I could simply invoke the BB-AUDI-02 overlay device tree overlay.
At this point I still had no idea what device tree overlays are nor how to use them. But after sniffing a bit around, things came to their place. My learning curve was as follows:
- First, in embedded Linux, there needs to be a way for kernel to know what hardware is the CPU connected to when the system boots up. This has been solved by something called a device tree, a piece of code that tells kernel where the drivers of that hardware are, and how to configure them. Reference.
- Device tree is compiled together with the kernel - so every change in the hardware, or in their respective drivers, would require you to re-compile everything, a tiresome and time consuming process. That's why some smart people have developed a something called a device tree overlay, another piece of code that kinda lies on top of the existing device tree backbone and tells kernel, on the run, how the drivers should be configured. Now, you can use an existing image and play with the HW any way you want. Reference
- In BeagleBoard eco-system there was a solutionn to easily load and unload the device tree overlays, called cape manager. And there is a guide on how to use it for the Audio Cape, that I based my sound card on. What seemed like an easy-peasy tutorial, turned out to be a lot harder endeavor, because the Cape Manger is discontinued in the kernel versions released since 2017 or so.
- An U-boot Overlay was introduced instead. It is the same piece of code as a device tree overlay, but instead of being loaded on the run, it is loaded by the bootloader during the boot process. A proper usage of the U-boot overlays consists of getting a valid dts file for your hw, compiling it into the dtbo file and editing /boot/uEnv.txt file and rebooting the device.
- Valid dts files can be found in the BeagleBone overlay repo. There is a valid dts file for the Audio Cape (BB-BONE-AUDI-02-00A0.dts), but it wont work on my PocketBeagle. The reason is a different pinout and clock setting of the two boards, BBB and PocketBeagle. In this DigiKey Tech Forum thread there is my attempt with the help of Robert Nelson, a Linux guru at BeagleBoard.org to fix the overlay to work on the PocketBeagle. It involves pinmux modifications.
- Although the pinmux issues were solved with Robert's help, my cape wouldn't work. Sound card was recognized by the alsa system, but the aplay wouldn't exit when I made it play a sound file. Also, the sound would never come out. The reason turned out to be invalid clocking settings between two. But, some years ago, a user at Bela Forum surpassed this issue by modifying existing TLV320AIC3104 dto made for the PocketBeagle. The modification is essentially changing the I2C instance from i2c1 to i2c2, where the TLV320 codec is connected on our (my and Bela) cape.
- After doing the same, and compiling the new dts file, editing /boot/uEnv.txt and rebooting, the capes got recognized, and aplay worked. There was, unfortunately, still no sound at my speakers.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.