Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TI AM62x Starter Kit EVM (SK-AM62B-P1) board on Common Torizon #215

Open
wants to merge 4 commits into
base: scarthgap-7.x.y
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ BBFILES_DYNAMIC += "\
toradex-bsp-common-layer:${LAYERDIR}/dynamic-layers/meta-toradex-bsp-common/*/*/*.bbappend \
toradex-ti-layer:${LAYERDIR}/dynamic-layers/meta-toradex-ti/*/*/*.bb \
toradex-ti-layer:${LAYERDIR}/dynamic-layers/meta-toradex-ti/*/*/*.bbappend \
meta-ti-bsp:${LAYERDIR}/dynamic-layers/meta-ti-bsp/*/*/*.bb \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, this is really minor, but could we order these? 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? You mean put the meta-ti-bsp lines in alphabetical order i.e. like below?

    intel:${LAYERDIR}/dynamic-layers/meta-intel/*/*/*.bb \
    intel:${LAYERDIR}/dynamic-layers/meta-intel/*/*/*.bbappend \
+   meta-ti-bsp:${LAYERDIR}/dynamic-layers/meta-ti-bsp/*/*/*.bb \
+   meta-ti-bsp:${LAYERDIR}/dynamic-layers/meta-ti-bsp/*/*/*.bbappend \
    toradex-bsp-common-layer:${LAYERDIR}/dynamic-layers/meta-toradex-bsp-common/*/*/*.bb \
    toradex-bsp-common-layer:${LAYERDIR}/dynamic-layers/meta-toradex-bsp-common/*/*/*.bbappend \
    toradex-ti-layer:${LAYERDIR}/dynamic-layers/meta-toradex-ti/*/*/*.bb \
    toradex-ti-layer:${LAYERDIR}/dynamic-layers/meta-toradex-ti/*/*/*.bbappend \

meta-ti-bsp:${LAYERDIR}/dynamic-layers/meta-ti-bsp/*/*/*.bbappend \
"
28 changes: 28 additions & 0 deletions conf/machine/include/am62xx-evm.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
WKS_FILE:sota:am62xx-evm = "torizon-am62xx-sota.wks"
jsrc27 marked this conversation as resolved.
Show resolved Hide resolved

OSTREE_KERNEL_ARGS:sota:am62xx-evm:append = "console=ttyS2,115200 earlycon root=LABEL=otaroot rootfstype=ext4"

UBOOT_BOOT_PARTITION_NUMBER:am62xx-evm = "2"
OTAROOT_PARTITION_NUMBER:am62xx-evm = "2"
EXTRA_BOARD_FIXUPS:am62xx-evm = "if test "${board_name}" = "am62b_p1_skevm"; then if test "${fdtfile}" = "ti/k3-am625-sk.dtb"; then env set fdtfile k3-am625-sk.dtb; fi; fi"

KERNEL_DEVICETREE:am62xx-evm = " \
ti/k3-am625-sk.dtb \
ti/k3-am62x-sk-csi2-imx219.dtbo \
ti/k3-am62x-sk-csi2-ov5640.dtbo \
ti/k3-am62x-sk-csi2-tevi-ov5640.dtbo \
ti/k3-am62x-sk-hdmi-audio.dtbo \
"
# Overlays in KERNEL_DEVICETREE to be applied during boot time
KERNEL_DEVICETREE_OVERLAY_BOOT:am62xx-evm = " \
k3-am62x-sk-csi2-imx219.dtbo \
k3-am62x-sk-csi2-ov5640.dtbo \
k3-am62x-sk-csi2-tevi-ov5640.dtbo \
k3-am62x-sk-hdmi-audio.dtbo \
"

IMAGE_FSTYPES:append = " wic"
IMAGE_BOOT_FILES:append:am62xx-evm = " tispl.bin u-boot.img tiboot3.bin tiboot3-am62x-hs-fs-evm.bin tiboot3-am62x-gp-evm.bin tiboot3-am62x-hs-evm.bin"

PREFERRED_PROVIDER_virtual/dtb = ""
hostname:pn-base-files = "am62xx-evm"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require recipes-bsp/u-boot/u-boot-rollback.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require recipes-kernel/linux/linux-torizon.inc
11 changes: 9 additions & 2 deletions recipes-bsp/u-boot/u-boot-distro-boot.bb
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,23 @@ keep_fusing_block() {

inherit deploy

UBOOT_BOOT_PARTITION_NUMBER ?= "1"
OTAROOT_PARTITION_NUMBER ?= "1"
EXTRA_BOARD_FIXUPS ?= ""

do_compile() {
sed -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
sed -e 's/@@UBOOT_BOOT_PARTITION_NUMBER@@/${UBOOT_BOOT_PARTITION_NUMBER}/' \
-e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
-e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \
-e 's/@@KERNEL_DTB_PREFIX@@/${DTB_PREFIX}/' \
-e 's/@@APPEND@@/${APPEND}/' \
-e 's/@@FITCONF_FDT_OVERLAYS@@/${FITCONF_FDT_OVERLAYS}/' \
"${WORKDIR}/boot.cmd.in" > boot.cmd

bbdebug 1 "Building uEnv.txt..."
sed -e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
sed -e 's#@@EXTRA_BOARD_FIXUPS@@#${EXTRA_BOARD_FIXUPS}#' \
-e 's/@@OTAROOT_PARTITION_NUMBER@@/${OTAROOT_PARTITION_NUMBER}/' \
-e 's/@@KERNEL_BOOTCMD@@/${KERNEL_BOOTCMD}/' \
-e 's/@@KERNEL_IMAGETYPE@@/${KERNEL_IMAGETYPE}/' \
-e 's/@@KERNEL_DTB_PREFIX@@/${DTB_PREFIX}/' \
-e 's/@@FITCONF_FDT_OVERLAYS@@/${FITCONF_FDT_OVERLAYS}/' \
Expand Down
4 changes: 2 additions & 2 deletions recipes-bsp/u-boot/u-boot-distro-boot/boot.cmd.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ env set fdtfile2 "${fdtfile}"

if test -n "${loadaddr}"
then
ext4load ${devtype} ${devnum}:1 ${loadaddr} /boot/loader/uEnv.txt; env import -t ${loadaddr} ${filesize}
ext4load ${devtype} ${devnum}:@@UBOOT_BOOT_PARTITION_NUMBER@@ ${loadaddr} /boot/loader/uEnv.txt; env import -t ${loadaddr} ${filesize}
else
ext4load ${devtype} ${devnum}:1 ${scriptaddr} /boot/loader/uEnv.txt; env import -t ${scriptaddr} ${filesize}
ext4load ${devtype} ${devnum}:@@UBOOT_BOOT_PARTITION_NUMBER@@ ${scriptaddr} /boot/loader/uEnv.txt; env import -t ${scriptaddr} ${filesize}
fi

run bootcmd_run
6 changes: 4 additions & 2 deletions recipes-bsp/u-boot/u-boot-distro-boot/uEnv.txt.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
kernel_image_type=@@KERNEL_IMAGETYPE@@
overlays_file="overlays.txt"
otaroot=1
otaroot=@@OTAROOT_PARTITION_NUMBER@@
fitconf_fdt_overlays="@@FITCONF_FDT_OVERLAYS@@"

set_bootargs=env set bootcmd_args env set bootargs ${defargs} root=LABEL=otaroot rootfstype=ext4 ${bootargs} ${tdxargs}
Expand Down Expand Up @@ -85,6 +85,8 @@ set_bootargs_custom=if test -n "${fdt_overlays}"; then \
done; \
fi || true

extra_board_fixups=@@EXTRA_BOARD_FIXUPS@@

board_fixups=if test "${board}" = "verdin-imx8mm"; then \
if test "${fdtfile}" = "imx8mm-verdin-nonwifi-v1.1-dahlia.dtb"; then \
env set fdtfile imx8mm-verdin-nonwifi-dahlia.dtb; \
Expand All @@ -95,7 +97,7 @@ board_fixups=if test "${board}" = "verdin-imx8mm"; then \
elif test "${fdtfile}" = "imx8mm-verdin-wifi-v1.1-dev.dtb"; then \
env set fdtfile imx8mm-verdin-wifi-dev.dtb; \
fi; \
fi || true
fi || if test -n "${extra_board_fixups}"; then run extra_board_fixups; fi || true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line ever running?
Maybe we just rename extra_board_fixups to something else and add it straight into bootcmd_run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think U-Boot runs the if statement for this board. I created a Torizon OS image with the above change and it's able to boot successfully.

If I change uEnv.txt and set the extra_board_fixups variable to an empty string, the fixup isn't made i.e. U-Boot can't find the DTB due to the ti/ prefix in the filename:

7049 bytes read in 21 ms (327.1 KiB/s)
Failed to load '/boot/boot/ostree/torizon-d27d6b32eccb464636330b8ea50c3e45abe251ff93956934e96b97c16cd3042d/dtb/ti/k3-am625-sk.dtb'
133 bytes read in 21 ms (5.9 KiB/s)
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
Applying Overlay: k3-am62x-sk-csi2-imx219.dtbo
2361 bytes read in 22 ms (104.5 KiB/s)
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
Applying Overlay: k3-am62x-sk-csi2-ov5640.dtbo
2332 bytes read in 21 ms (108.4 KiB/s)
No FDT memory address configured. Please configure
the FDT address via "fdt addr <address>" command.
Aborting!
[...]
21029376 bytes read in 849 ms (23.6 MiB/s)
31239767 bytes read in 1318 ms (22.6 MiB/s)
ERROR: Did not find a cmdline Flattened Device Tree
Could not find a valid device tree

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant having it in uenv like

uenv_extra_configs=@@UENV_EXTRA_CONFIGS@@
...
bootcmd_run=... && run uenv_extra_configs && ...

And in the recipe having a default like

UENV_EXTRA_CONFIGS ?= "true"

This way this is a separate u-boot command that we're always calling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, currently the only case where the command doesn't run is when the board is a Verdin iMX8M Mini, as it has its own DTB fixups hardcoded there.

But I guess it makes sense to have a more general command that always gets executed. I'll change it then.


bootcmd_boot=if test ${bootscript_debug} != 1; then \
if test ${kernel_image_type} = "fitImage"; then \
Expand Down
3 changes: 3 additions & 0 deletions recipes-bsp/u-boot/u-boot-rollback/am62xx-evm/bootcommand.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_LEGACY_IMAGE_FORMAT=y
CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="setenv devtype mmc; setenv devnum 1; ext4load ${devtype} ${devnum}:2 ${loadaddr} /boot.scr && source"
3 changes: 2 additions & 1 deletion recipes-extended/ostree/ostree_%.bbappend
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def is_ti(d):

def get_deps(d):
if is_ti(d): # TI
return 'u-boot-toradex-ti' if d.getVar('PREFERRED_PROVIDER_u-boot') else ''
preferred_provider_uboot = d.getVar('PREFERRED_PROVIDER_u-boot')
return preferred_provider_uboot if preferred_provider_uboot is not None else ''
else: # NXP/x86 generic/QEMU
return 'u-boot-default-script' if d.getVar('PREFERRED_PROVIDER_u-boot-default-script') else ''

Expand Down
4 changes: 2 additions & 2 deletions recipes-images/images/torizon-base.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CORE_IMAGE_BASE_INSTALL:append = " \
networkmanager \
openssh-sftp-server \
ostree-customize-plymouth \
ostree-devicetree-overlays \
packagegroup-core-full-cmdline-multiuser \
packagegroup-core-full-cmdline-utils \
parted \
Expand All @@ -63,7 +64,6 @@ CORE_IMAGE_BASE_INSTALL:append = " \

CORE_IMAGE_BASE_INSTALL:append:tdx = " \
alsa-ucm-conf-tdx \
ostree-devicetree-overlays \
set-hostname \
tdx-info \
udev-toradex-rules \
Expand All @@ -84,7 +84,7 @@ CORE_IMAGE_BASE_INSTALL:append:mx8-nxp-bsp = " \
kernel-module-imx-gpu-viv \
"

CORE_IMAGE_BASE_INSTALL:append:verdin-am62 = " \
CORE_IMAGE_BASE_INSTALL:append:am62xx = " \
ti-img-rogue-driver \
"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,40 @@ PACKAGES:prepend = "ostree-devicetree-overlays "
ALLOW_EMPTY:ostree-devicetree-overlays = "1"
FILES:ostree-devicetree-overlays = "${nonarch_base_libdir}/modules/*/dtb/*.dtbo ${nonarch_base_libdir}/modules/*/dtb/overlays.txt"

# Overlays in KERNEL_DEVICETREE to be applied during boot time
KERNEL_DEVICETREE_OVERLAY_BOOT ?= ""

do_install:append () {
if [ ${@ oe.types.boolean('${OSTREE_DEPLOY_DEVICETREE}')} = True ]; then
install -d $kerneldir/dtb/overlays
if [ ! -e ${DEPLOY_DIR_IMAGE}/overlays/none_deployed ]; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/overlays/*.dtbo $kerneldir/dtb/overlays
if [ -d "${DEPLOY_DIR_IMAGE}/overlays" ]; then
if [ ! -e ${DEPLOY_DIR_IMAGE}/overlays/none_deployed ]; then
install -m 0644 ${DEPLOY_DIR_IMAGE}/overlays/*.dtbo $kerneldir/dtb/overlays
install -m 0644 ${DEPLOY_DIR_IMAGE}/overlays.txt $kerneldir/dtb
fi
fi

kernel_overlays=""
if [ -n "$(find "$kerneldir/dtb/" -maxdepth 1 -type f -name "*.dtbo" | head -n1)" ]; then
for dtbo in ${KERNEL_DEVICETREE_OVERLAY_BOOT}; do
if [ ! -e "$kerneldir/dtb/$dtbo" ]; then
bbfatal "$dtbo wasn't generated during the kernel build step, please make sure it's listed in KERNEL_DEVICETREE."
fi
kernel_overlays="$kernel_overlays $dtbo"
done

# Move overlays built during kernel compilation to the correct directory
mv $kerneldir/dtb/*.dtbo $kerneldir/dtb/overlays/
fi

if [ ! -f "$kerneldir/dtb/overlays.txt" ]; then
echo "fdt_overlays=$(echo $kernel_overlays)" > "${DEPLOY_DIR_IMAGE}/overlays.txt"
install -m 0644 ${DEPLOY_DIR_IMAGE}/overlays.txt $kerneldir/dtb
elif [ -n "$kernel_overlays" ]; then
bbwarn "overlays.txt already exists in the boot filesystem. Appending kernel overlays listed in KERNEL_DEVICETREE_OVERLAY_BOOT."
echo " $kernel_overlays" >> "$kerneldir/dtb/overlays.txt"
fi

elif [ "${KERNEL_IMAGETYPE}" = "fitImage" ]; then
if [ -e ${DEPLOY_DIR_IMAGE}/overlays.txt ]; then
install -d $kerneldir/dtb
Expand Down
10 changes: 10 additions & 0 deletions scripts/lib/wic/canned-wks/torizon-am62xx-sota.wks
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# short-description: Create OTA-enabled SD card image
# long-description: Creates a partitioned SD card image with OSTree
# physical sysroot as a payload. Boot files are located in the
# first vfat partition.
# Based on:
# meta-ti/meta-ti-bsp/wic/sdimage-2part.wks
# meta-updater/scripts/lib/wic/canned-wks/sdimage-sota.wks

part --source bootimg-partition --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M
part / --source otaimage --ondisk mmcblk --fstype=ext4 --align 1024