FreeBSD 10.3 on beaglebone black: how to use all UART?

OlivierW

Member

Reaction score: 4
Messages: 40

Phishfry ok, thanks :)

aragats thanks for the explanation. I had seen those overlays in a previous post by Phishfry but I couldn't find how to make them work.
After quite some fight, it seems I've successfully compiled "BB-UART4-00A0.dtbo".


If it can help someone, I cloned the bb.org-overlays repo with:
git clone https://github.com/beagleboard/bb.org-overlays

Then I tried to compile directly with dtc but I got a "syntax error", then I found here: https://github.com/beagleboard/bb.org-overlays/issues/28 I needed to use "make" (well, gmake on FreeBSD).

Then with gmake src/arm/BB-UART4-00A0.dtbo I had an error about "-@" not being known by dtc: "dtc: invalid option -- @", of course the versions in base (1.4.0) and ports (1.4.2) were too old. This "-@" option appeared in 1.4.3 and the current version is 1.4.4.
I tried to compile 1.4.4 but got an error, so went with 1.4.3.

Here are all the commands used:

cd /tmp
pkg install git-lite gmake bison
git clone https://git.kernel.org/pub/scm/utils/dtc/dtc.git
cd /tmp/dtc
git checkout tags/v1.4.3
gmake
cd /tmp/bb.org-overlays
gmake src/arm/BB-UART4-00A0.dtbo DTC=/tmp/dtc/dtc

and you'll get "src/arm/BB-UART4-00A0.dtbo" :-D


Now, I don't know where I should move this dtbo file, in "/boot/dtb/"? And the "cape_universal=" line should go in "/boot/msdos/bb-uenv.txt"?
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

I am not sure that dtbo work on anything but the RPi3/ARM64. I know it works there. I am using it.
Maybe Gonzo backported it to ARMv6. I dunno.
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

The dtbo seems like a great solution for not compiling kernel to add new devices. You just compile the dtbo and add to config.txt.
In reality most accessories need to have their support in the kernel so you are compiling anyway.
Example1: RTC. Had to add DS3230 to kernconf, so compile kernel.
Example2 OW_Temp. Same thing, not in default kernel needs recompile.

So dtbo really isn't revolutionary but better for some devices.

A handbuilt dts is the way I do it generally. I modify the default dts adding entries.
 

OlivierW

Member

Reaction score: 4
Messages: 40

It's quite confusing…
I first tried "cape_universal=enable bone_capemgr.enable_partno=BB-UART1-00A0,BB-UART4-00A0" in "/boot/msdos/bb-uenv.txt": not working.

Then I tried "fdt_overlays="BB-UART1-00A0.dtbo,BB-UART4-00A0.dtbo"" in "/boot/loader.conf", from the thread pointed by aragats : https://lists.freebsd.org/pipermail/freebsd-arm/2017-March/015975.html : not working.

I tried both options above with a single and two .dtbo files.


Phishfry : I don't have a config.txt file. Should I create it?
And the article mention: "overlays/acme-board.dtbo", so should I move my .dtbo files in /boot/overlays? At the moment they are in /boot/dtb.

It's difficult to find up to date information how to use these DTB and DTBO files.
As I'm running "FreeBSD 12.0-CURRENT #0 r314137", I would say the best up to date information is in this thread from March 2017: https://lists.freebsd.org/pipermail/freebsd-arm/2017-March/015855.html

And is there a way to debug? How can I be sure my DTBO files are valid and loaded? I can't find anything in dmesg.


Edit: Phishfry, I just read your two last messages, it's not encouraging :-( But in the mailing list pointed above DTBO files seems to work.
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

Actually here is gonzo in that same mailing list post describing how to do it, so check that out. It does work on ARMv7
https://lists.freebsd.org/pipermail/freebsd-arm/2017-March/015975.html

Code:
3. Copy it to /boot/dtb/ directory on your BBB

4. Enable overlay in /boot/loader.conf by adding following line:

fdt_overlays="am335x-beaglebone-tscadc.dtbo"

--
gonzo
So maybe only newer ARM64/RPi3 uses the config.txt method. I never heard of fdt overlays in /boot/loader.conf
 

OlivierW

Member

Reaction score: 4
Messages: 40

I can't even compile the "am335x-beaglebone-tscadc.dts" file.
I tried with dtc 1.4.0 from base, 1.4.2 from ports and 1.4.3 from: https://git.kernel.org/pub/scm/utils/dtc/dtc.git and I'm getting:
# dtc -I dts -O dtb -o am335x-beaglebone-tscadc.dtbo am335x-beaglebone-tscadc.dts
Error: am335x-beaglebone-tscadc.dts:2.2-8 syntax error
FATAL ERROR: Unable to parse input tree


# /usr/local/bin/dtc -I dts -O dtb -o am335x-beaglebone-tscadc.dtbo am335x-beaglebone-tscadc.dts
Error: am335x-beaglebone-tscadc.dts:2.2-8 syntax error
FATAL ERROR: Unable to parse input tree


# /tmp/dtc/dtc -I dts -O dtb -o am335x-beaglebone-tscadc.dtbo am335x-beaglebone-tscadc.dts
Error: am335x-beaglebone-tscadc.dts:7.14-15 syntax error
FATAL ERROR: Unable to parse input tree


I don't know what those numbers means "2.2-8" and "7.14-15". It can't be line numebrs, or else they would be the same in the 3 versions.
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

I don't think you want multiple overlays. Combine all your accessories into one dtbo.
Overlay is just that. The boards default dts is still used its just the accessories that can go into the dtbo.

The original method still works -adding devices into your boards dts.
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

The ADC device example is not the easiest device to learn this. Probably one of the hardest.
I picked something easier to figure out what works. I started at RTC.
 

OlivierW

Member

Reaction score: 4
Messages: 40

Well, I found about the multiples overlays on gonzo's blog: https://kernelnomicon.org/?p=498
And as I said, I also tested with a single overlay in a "/boot/msdos/bb-uenv.txt" or "/boot/loader.conf", without more success.

A handbuilt dts is the way I do it generally. I modify the default dts adding entries.
You start from which DTS file? A decompiled one from /boot/dtb or one from FreeBSD source? And if it's from source, from which folder (you told me previously the one in the "gnu" folder couldn't work without modification for FreeBSD)?
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

This is the source I edit on BBB.
/usr/src/sys/boot/fdt/dts/arm/beaglebone-black.dts

I back up the original so I can revert.
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

The real trick on dts editing seems to be correct placement in the tree under the proper parent device.
 

aragats

Daemon

Reaction score: 540
Messages: 1,296

I first tried "cape_universal=enable bone_capemgr.enable_partno=BB-UART1-00A0,BB-UART4-00A0" in "/boot/msdos/bb-uenv.txt": not working.
I think the syntax depends on uboot version. I used to build it from git long time ago.

In reality most accessories need to have their support in the kernel so you are compiling anyway.
Yeah, for the same reason I just "forked" one of the include files (am335x-bone-common.dtsi) and added my changes to it, e.g. I needed mmc2.
 

Phishfry

Son of Beastie

Reaction score: 1,530
Messages: 4,440

I have to confess I use crochet for all my Arm compiling. It just makes it so easy.
https://github.com/freebsd/crochet
You still have to modify your source to suit your accessory but I do not enjoy cross compiling.

So I modify boards kernconf adding needed 'gadget' module, then edit dts to suit, run crochet to see if successful. Crochet saves your build and recompiling takes 5-10 minutes after your first compiling run.
 

OlivierW

Member

Reaction score: 4
Messages: 40

This is the source I edit on BBB.
/usr/src/sys/boot/fdt/dts/arm/beaglebone-black.dts

I back up the original so I can revert.
Thanks, I tried but it failed:
# /tmp/dtc/dtc -I dts -o /tmp/bbg-from-scratch.dtb -O dtb -b 0 head/sys/boot/fdt/dts/arm/beaglebone-black.dts
Error: head/sys/boot/fdt/dts/arm/beaglebone-black.dts:30.1-2 syntax error
FATAL ERROR: Unable to parse input tree



Actually, I built my image with crochet. But I would still have to edit those DTS files to enable UART.

Well, it's 3:22 here in France: time to sleep. I'll try again later. Thanks again a lot aragats and Phishfry for all your help!
 

OlivierW

Member

Reaction score: 4
Messages: 40

Hello,

I fought again for a few hours, and still failing to enable any others UART.
First question, does anyone know why in the original "beaglebone-green.dts" there are "pinmux_uart0_pins {" and "uart2_pins {" blocks? Why one of them is prefixed with "pinmux_" and not the other one?


I tried to decompile the 2 .dtbo files I compiled the other day: "BB-UART1-00A0.dtbo" and "BB-UART4-00A0.dtbo" and use them in my modified "beaglebone-green.dts" file (because the .dtbo files doesn't seems to be loaded and I've not been able to compile a .dts from scratch as suggested by Phishfry (see my post just above this one)).
So, now I have:
Code:
pinmux_uart1_pins {
        pinctrl-single,pins = <0x184 0x8 0x180 0x28>;
        linux,phandle = <0x51>;
        phandle = <0x51>;
};

pinmux_uart4_pins {
        pinctrl-single,pins = <0x74 0xe 0x70 0x2e>;
        linux,phandle = <0x52>;
        phandle = <0x52>;
};
just after this block:
Code:
uart2_pins {
        pinctrl-single,pins = <0x150 0x29 0x154 0x9>;
        linux,phandle = <0x2e>;
        phandle = <0x2e>;
};
I've recompiled but I still can't use UART1 or UART4.
I've checked with sysctl -b hw.fdt.dtb | dtc -I dtb to be sure my modifications were present, and they were there.

I've also tried using "uart1_pins" and "uart4_pins" (without the "pinmux_" prefix): no more luck.
The "phandle" values 0x51 and 0x52 are just random values which weren't already used in the .dts file.

I don't know what else to try.
 

comarius

Member

Reaction score: 4
Messages: 37

Hi,
Is 2019 and I am having same issues I have open couple of topics on this forum.
I am running into this post, lucky... I guess

Any success on your side or you never solved. I am on this UART thing for the last 3 days..

Thank you
 

OlivierW

Member

Reaction score: 4
Messages: 40

Hello,
I have never solved this problem and couldn't find more time to work on this project :-(
Good luck, I hope you'll find a solution and will share it here :)
 
Top