Pocketbeagle 2 yocto stdout struggle

Mission:

Get all the debug log out of ttyS7/serial7/uart0 from the pin header.

Status:

Struggling.

Me:

I just got the new pocketbeagle 2 and trying to learn more about yocto.

Captain’s log:

I tried having SERIAL_CONSOLES = "115200;ttyS7" in my distro and I managed to get u-boot SPL(this was already in uart0 in devicetree) and linux login prompt to this, but no u-boot nor boot messages.

I managed to insert my own devicetree(with only changing the stdout-path to “main_uart0“ or serial3 or serial7. And the same with a patch file) to u-boot and got the u-boot messages to show up, but now linux doesn’t boot.

I tried adding my own u-boot env, but yocto just copied it to deploy folder and not to the device. env default -a changed it to a default not mine.

...
CONFIG_BOOTDELAY=2

CONFIG_USE_DEFAULT_ENV_FILE=y
CONFIG_DEFAULT_ENV_FILE=u-boot-initial-env
CFG_EXTRA_ENV_SETTINGS="console=ttyS7,115200n8\0"
CONFIG_SYS_BOARD="pocketthing"
CONFIG_SERIAL=y
CONFIG_SYS_NS16550=y
CONFIG_SYS_NS16550_SERIAL=y
CONFIG_CONS_INDEX=1

I did managed to get my own u-boot defconfig to do SOME changes, and I did try these in different order, but nothing really changed anything(the only thing that changed was the BOOTDELAY).

# TI_WKS_BOOTLOADER_APPEND:remove = "console=*"
# TI_WKS_BOOTLOADER_APPEND += "console=ttyS7,115200n8"

# UBOOT_ENV_EXTRA:remove = "console=*"
# UBOOT_ENV_EXTRA += "console=ttyS7,115200n8"
# KERNEL_CONSOLE = "ttyS7"

I also tried these in my distro.

Plead:

How is this supposed to be done? I want ALL consoles to be ttyS7/serial7/uart0 from devicetree. And I would like to modify the u-boot env.

Could somebody help me?

Thanks

BL

So, apparently this is main_uart0 problem. Something does something to the main_uart0 at boot. I noticed that at one point something changed the kernel baudrate to 9600. AI said that wkup_uart0 uses the same clock and changes that at boot, but I didn’t find any evidence for that. If anyone knows whats going on, feel free to explain.

To get u-boot defconfig you can use this:

FILESEXTRAPATHS:prepend := "${THISDIR}/files:"

SRC_URI += "file://pocketbeagle2_defconfig \
            file://pocketbeagle2_r5_defconfig \
"

inherit uboot-config

UBOOT_MACHINE = "pocketbeagle2_defconfig"
UBOOT_MACHINE:k3r5 = "pocketbeagle2_r5_defconfig"

do_configure:prepend() {
    install -Dm0644 ${WORKDIR}/pocketbeagle2_defconfig ${S}/configs/pocketbeagle2_defconfig
    install -Dm0644 ${WORKDIR}/pocketbeagle2_r5_defconfig ${S}/configs/pocketbeagle2_r5_defconfig
}

To get u-boot env to the device you add CONFIG_ENV_SOURCE_FILE to the u-boot defconfig. If you want to use saveenv, you can add the rest. Notice that the u-boot env needs to be copied to board/<vendor>/<board>/<CONFIG_ENV_SOURCE_FILE>.env and needs to have .env. [source]

CONFIG_ENV_IS_IN_FAT=y
CONFIG_ENV_IS_NOWHERE=n
CONFIG_ENV_SOURCE_FILE="pocketbeagle2-uboot-env"
CONFIG_ENV_FAT_INTERFACE="mmc"
CONFIG_ENV_FAT_DEVICE_AND_PART="1:1"

I still don’t know how to properly add custom devicetree for linux, without replacing the existing one. The fdtfile u-boot env comes from this C code:

#if IS_ENABLED(CONFIG_BOARD_LATE_INIT)
int board_late_init(void)
{
	char fdtfile[50];

	snprintf(fdtfile, sizeof(fdtfile), "%s.dtb", CONFIG_DEFAULT_DEVICE_TREE);

	env_set("fdtfile", fdtfile);

	return 0;
}
#endif

If I change the CONFIG_DEFAULT_DEVICE_TREE, it changes also u-boot devicetree. If I disable CONFIG_BOARD_LATE_INIT, it uses the same u-boot env for all the u-boots… I would say, I just need to change the bootcmd to boot my own devicetree.

You may find this of use for understanding how to add your own custom device tree.

Note that k3-am625- <boardname>.dts is used by both Uboot and Linux

I use:

git clone GitHub - beagleboard/BeagleBoard-DeviceTrees

Then find a dtso file to base it off - modify it, save somewhere else, then use the make file a few directories up. That will give a .dtbo that you can use … oh yes enter the url as a literal …

Yea, this was the problem. I tried to only replace linux devicetree, but the C code forces the uboot and linux devicetrees to be the same name, hence the need to modify the uboot boot command. I know I’m overengineering this, but it’s a learning process. :grinning_face_with_smiling_eyes:

But thank you for confirming this and for the link.

I did find the sources from yocto kernel source, but thanks for the link. I’m probably gonna just manually poke the devicetree.