Ooops, forgot to attach my example Cape Overlay.
Neil,
Here’s some loooooong info based on the information you sent. They correlate to the answers you provided below plus more.
-
That’s good that i2cdetect found the device on the bus. This tells me that ALSA is not setting up the device driver properly (Through the MCASP pins). I noticed in my development, everything has to be just right in order for that to happen.
-
for the MCASP Pins, you are also using "P9.31 " /* mcasp0: mcasp0_axr3 */
-
Both axr2 and axr3 cannot be both inputs. AXR is bi-directional, but the audio codec needs one to be set to transmit (X) and one to be receive ®. Why it ever worked before is a mystery. And setting up their direction is two parts… in the device tree pinmux and in the serialization of the “sound” node of the device tree. I’ll give an example below. I’ve always had to define whether it’s a PULLUP or PULLDOWN also and do not believe these can be left free-floating.
-
If you are creating a “.dtbo” file, that is a CAPE OVERLAY, not a DEVICE TREE file (which ends with “.dtb”). It’s been stated to move away from CAPE OVERLAYS as they are extremely buggy. You can create a Device Tree and it is used an overlay to the active device tree. The reason you seen what you did is that address “190” was being used by the Kernel and you can’t allocate two device pinmux using the same pin address.
-
To see issues, you should be using $ dmesg in your terminal. It outputs the kernel log form /var/logs/ messages. It’ll tell you if it’s running the TLV320 in there. You can also see if your sound codec is being used by typing $ alsamixer in the terminal. This will bring up a GUI of your sound codec. It should be something different than PulseAudio. Furthermore, add the following line to your overlay in the fragment for sound {…}, just below the capability line: simple-audio-card,name = “Audio Name I Want”;
Whatever you put as “Audio Name I Want” will show up in place of PulseAudio if ASLA is using the TLV320 codec when you check alsamixer.
- Whenever you change or create a Cape Overlay you MUST run “/opt/source/bb.org-overlays/install.sh”. You are doing most of what needs to be done… except rebuilding the /boot/initrd.img- file (mine is initrd.img-4.19.94-ti-r50). Just running install.sh is all you need to do, it will put everything in the firmware directory and rebuild the image.
So why does it have to be this way?.. Form my understanding, if your new cape is different than the one in that image file or you created a new cape overlay, it will not match what’s in that image file. I believe this is done as sort of a checksum to ensure it’s a valid overlay for a device. That you cna’t just plug anything in and destroy the device. The idea was a cape can be added (connected) and nothing done to the uEnv.txt file and the cape is automatically loaded for use by detecting the cape, putting it’s overlay in one of the four cape manager slots and using it to overlay the active device tree. I bet if you check $ dmesg in the terminal, you’ll find a line that says it failed to load BB-BONE-AUDI-02.
Device trees are in an entirely different location… /opt/source/dtb--ti/src/arm. As an example, mine is /opt/source/dtb-4.19-ti/src/arm. Be weary, they now add the last and newest dtb directories as well. use the one that matches your kernel number in the uEnv.txt file. If you create a device tree, the make file will use dtc to build it from /opt/source/dtb--ti/. Here’s an example of how I rebuild device trees and use them. I copy “my_devicetree.dts” to /opt/source/dtb-4.19/src/arm/. usually by just putting the uSD card in my laptop.
$ cd /opt/source/dtb-4.19-ti/
$ sudo touch src/arm/*
sudo touch will change the timestamp of all files (*) in that directory. If not you will get an error when building the device tree for the time being in the future.
$ sudo make src/arm/my_devicetree.dtb
If there are any errors, it’ll tell you the line number. fix it.
$ sudo cp src/arm/my_devicetree.dtb /boot/dtbs//
Then in the uEnv.txt file, I uncomment #dtb= to dtb=my_devicetree.dtb. A device tree does not have to be built into the intird.img file.
Lastly,
In your mcasp{…} node fragment. You’ll see numbers under the serial-dir configuraiton. Those number correlate to te RX you are using. In BB-BONE-AUDI-02, the first line is 0 0 2 1 and correlate to RX0 RX1 RX2 RX3. As you can see RX2 is set as Recieve (or RX) and RX3 is set to Transmit (or TX). Those need to match the input/output direction in the pinmux… which is not the case we see. I never got my development audio board to work until I set the direcitons accordingly. If RX2 is set to RX, then the pin should be an INPUT, if RX3 is set to TX, then it’s pin should be an OUTPUT.
I attached an example of the Cape Overlay I did before I moved to using a device tree instead. This worked fine for my prototype device (not the exact same as your audio cape device), but you can see how I had to change things to make it work. If you are using a 3104, just change everything form 3106 to 3104 (I think it’s 3 places).
Sorry it was a lot but I learned a lot over the last 2 years working on a linux based Embedded System for my employer. And I like ppl to try and use information to develop on their own.
Does the Audio Cape Device pinout actually match BB-BONE-AUDI-02?
Hi Ray,
Thanks for the offer of help, very much appreciated! I’ve been going around in circles for days with this problem. I developed my own cape around the TLV320 (in c. 2016) and it had been working fine previously. I’ve upgraded from 3.x kernel to 4.x with some issues with device tree changes (in c. 2018) but solved them pretty quickly. This time, again I want to upgrade to a later kernel and use a RT kernel due to some timing ‘jitter’ issues I was having with the collected data. The cape records the VLF radio spectrum (basically audio) and is used to detect things like solar flares. It’s very sensitive to phase shifts in signal so needs very precise timing to keep running (I use a GPS Pulse per second fed into the other channel of the sound card to act as an accurate phase reference marker - GPS satellites use atomic clocks). I started with a fresh Beaglebone Install using the latest LTS RT kernel rather than working with a patched system with numerous ‘hacks’. I moved my DTS files across and recompiled but have gotten stuck with the McASP not working and ALSA not detecting the soundcard. It is to do with either the DTS file or some step with uBoot loading the DTBO and ALSA detecting the hardware.
Anyway, on to your questions:
-
I2C is using i2C2 ‘bus 2’
TLV320 is mapped to 0x1b
I can also see the device assigned on this bus with the i2cdetect command.
-
McASP Pins:
"P9.31", /* mcasp0: mcasp0_aclkx */
"P9.29", /* mcasp0: mcasp0_fsx */
"P9.28", /* mcasp0: mcasp0_axr2 */
"P9.25", /* mcasp0: mcasp0_ahclkx */
3.
Direction and Mode setting of the multiplexer:
pinctrl-single,pins = <
0x190 0x20 /* mcasp0_aclkx.mcasp0_aclkx, INPUT | MODE0 */
0x194 0x20 /* mcasp0_fsx.mcasp0_fsx, INPUT | MODE0 */
0x19c 0x22 /* mcasp0_ahclkr.mcasp0_axr2, INPUT | MODE2 */
0x1ac 0x22 /* mcasp0_ahclkx.mcasp0_axr3, INPUT | MODE2 */
NB: ^^^ not sure this direction setting ir tight but it has worked fine previously so I have not touched it.
-
The dtbo worked fine in the last iteration using a 4.4 Kernel. I upgraded to a 5.4 RT kernel (RT_PREEMPT patch). At first it complained with mapping the pins:
[ 43.009888] pinctrl-single 44e10800.pinmux: pin PIN100 already requested by ocp:P9_31_pinmux; cannot claim for 48038000.mcasp
[ 43.009914] pinctrl-single 44e10800.pinmux: pin-100 (48038000.mcasp) status -22
[ 43.009926] pinctrl-single 44e10800.pinmux: could not request pin 100 (PIN100) from group pinmux_bone_audio_cape_audio_pins on device pinctrl-single
Doing a bit of searching on the web (where is the documentation for all this new/changed information?) I found I now need to add the following to the DTS file:
P9_25_pinmux { status = "disabled"; }; /* mcasp0_ahclkx */
P9_28_pinmux { status = "disabled"; }; /* mcasp0_axr2 */
P9_29_pinmux { status = "disabled"; }; /* mcasp0_fsx */
P9_30_pinmux { status = "disabled"; }; /* mcasp0_axr0 */
P9_31_pinmux { status = "disabled"; }; /* mcasp0_aclkx */
Like I say, I’m not sure if this is what needs to be done since I can’t find any documentation to confirm but after drilling into newer DTS files (AUDI-02), I see that to define my own pins, I need to ‘disable’ them from some sort of generic Devicetree mapping.
-
Running ‘sudo /opt/scripts/tools.version.sh’ to look for problems, I am now seeing no conflicts with ^^4. added to my DTS file. However, Alsa is still not detecting the soundcard; using aplay -l. I’m not sure if it is to do with me misunderstanding ^^ 4. or I am missing a further step somewhere along the way. I’ve done quite a bit of Alsa work before and I am used to editing asound.conf files. I dsnoop to allow different experiments to connect to the same input sound stream simultaneously. For some reason the Kernel is loading Alsa BUT Alsa isn’t seeing any soundcard hardware. (BTW I’ve disabled HDMI; uboot_overlay_options:[disable_uboot_overlay_video=1) since this use to conflict with adding an additional soundcard.
-
RE: ‘If using a cape and making changes, use install.sh or it won’t work.’
Can you explain what you mean here? Previously, I compiled dts in my own directory with dtc to get dtbo, copied dtbo to /lib/firmware then pointed the uEnv file at the dtbo file. Has this step changed or do I need to do another intermediate step?
RE: ‘-The better option is to learn how to create your own device tree and put it as an Overlay in the uEnv.txt file.’
I think this is what I am doing already.
What would be really good to have is some diagnostic tools like we had in the older 3.x kernel. Someway of easily checking the pin assignments and some sort of debugging of the device tree. Also a reference document. A lot of the stuff I find on line to explain how to create DTS files and add user defined cape boards is out of date and mappings in /sys have changed.
I’ve attached by DTS file. NB: I have added fragment@0 to fix ^^^4 but other than that the old ‘working’ DTS file is the same.
Thanks for offering to help Ray!
Neil
TLV320-OVERLAY-01-00A0.dts (3.8 KB)