Skip to content

Commit

Permalink
Merge pull request #125 from hnez/barebox-2024-03
Browse files Browse the repository at this point in the history
meta-lxatac-bsp: barebox: update to 2024.03.0 with Gen 3 support
  • Loading branch information
hnez authored Apr 10, 2024
2 parents 40e2de9 + 335e347 commit 0909511
Show file tree
Hide file tree
Showing 42 changed files with 1,564 additions and 5,819 deletions.
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ Next you can upload the required pieces of software:
# Nothing is being flashed permanently yet.
$ dfu-util --alt 3 -D emmc-boot-image-lxatac.fip

# Start a fastboot command in the background that disables the watchdog
# once the LXA TAC shows up as fastboot device.
# This also stops the automatic boot process.
$ fastboot oem exec "wd -x" &

# Exit the USB Boot mode. The TF-A will run and jump into the Barebox in
# RAM.
$ dfu-util --alt 0 -e
Expand All @@ -500,9 +505,11 @@ Next you can upload the required pieces of software:
# This will overwrite the data you've stored there.
$ fastboot flash mmc emmc-image-lxatac.simg

# Boot the newly flashed root filesystem
$ fastboot oem exec boot root-a

You are now done flashing the LXA TAC and can remove the pull-down on `BT1`
and power cycle it to boot into your newly flashed image.
The LXA TAC should now boot into the newly flashed image.
Once that is done you can remove the pull-down on `BT1`.

#### Troubleshooting

Expand All @@ -523,16 +530,6 @@ If `fastboot` sits idle `< waiting for any device >`, this can be an error with
the permissions on the USB device. Any easy check for this is to run `fastboot`
as `root` using e.g. `sudo`.

##### The TAC disconnects during fastboot

This can happen when the watchdog timer is set up in the barebox bootloader
loaded into RAM via `dfu-util`.
To prevent the TAC from rebooting during fastboot connect to the barebox
console via the debug UART adapter / the USB console provided by barebox
and execute `wd -x` on the shell. E.g.:

barebox@Linux Automation Test Automation Controller (TAC):/ wd -x

Contributing
------------

Expand Down
144 changes: 144 additions & 0 deletions meta-lxatac-bsp/recipes-bsp/barebox/barebox.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
SUMMARY = "barebox is a bootloader designed for embedded systems. It runs on a variety of architectures including x86, ARM, MIPS, PowerPC and others."
HOMEPAGE = "https://barebox.org/"
SECTION = "bootloaders"
PROVIDES = "virtual/bootloader"

LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=f5125d13e000b9ca1f0d3364286c4192"

PACKAGE_ARCH = "${MACHINE_ARCH}"

require conf/image-uefi.conf

inherit kernel-arch deploy cml1 pkgconfig

# libusb1 is only required for usb tools like imx-usb-loader. These tools may
# be enabled within the defconfig file so depend on it here to be more user
# friendly (do not abort the build). The actual tools are provided by the
# barebox-tools package.
DEPENDS = "libusb1 bison-native flex-native"

export KBUILD_BUILD_USER ?= "oe-user"
export KBUILD_BUILD_HOST ?= "oe-host"

SRC_URI = "https://barebox.org/download/barebox-${PV}.tar.bz2"

S = "${WORKDIR}/barebox-${PV}"
B = "${WORKDIR}/build"

def get_layer_rev(path):
try:
rev, _ = bb.process.run("git describe --match='' --always --dirty --broken", cwd=path)
except bb.process.ExecutionError:
rev = ""
return rev.strip()

BAREBOX_BUILDSYSTEM_VERSION[doc] = "Build system version to add to the barebox image. By default this is the git description of the containing layer."
BAREBOX_BUILDSYSTEM_VERSION ??= "${@get_layer_rev(os.path.dirname(d.getVar('FILE')))}"

BAREBOX_FIRMWARE_DIR[doc] = "Overwrite barebox' firmware blobs search directory (CONFIG_EXTRA_FIRMWARE_DIR) with this path, default ${B}/firmware"
BAREBOX_FIRMWARE_DIR ??= "${B}/firmware"

EXTRA_OEMAKE = " \
CROSS_COMPILE=${TARGET_PREFIX} -C ${S} O=${B} \
BUILDSYSTEM_VERSION=${BAREBOX_BUILDSYSTEM_VERSION} \
CONFIG_EXTRA_FIRMWARE_DIR=${BAREBOX_FIRMWARE_DIR} \
"

BAREBOX_CONFIG[doc] = "The barebox kconfig defconfig file. Not used if a file called defconfig is added to the SRC_URI."
BAREBOX_CONFIG ?= ""

# prevent from acting as non-buildable provider
python () {
bareboxconfig = d.getVar('BAREBOX_CONFIG')
bareboxdefconfig = 'file://defconfig' in d.getVar('SRC_URI')

if not bareboxconfig and not bareboxdefconfig:
PN = d.getVar("PN")
FILE = os.path.basename(d.getVar("FILE"))
raise bb.parse.SkipRecipe("BAREBOX_CONFIG must be set in the %s machine configuration or file://defconfig must be given in SRC_URI." % d.getVar("MACHINE"))
}

do_configure() {
if [ -e ${WORKDIR}/defconfig ]; then
cp ${WORKDIR}/defconfig ${B}/.config
else
if [ -n "${BAREBOX_CONFIG}" ]; then
oe_runmake ${BAREBOX_CONFIG}
else
bbfatal "No defconfig given. Either add file 'file://defconfig' to SRC_URI or set BAREBOX_CONFIG"
fi
fi

${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))}
cml1_do_configure
}

BAREBOX_ENV_DIR[doc] = "Overlay the barebox built-in environment with the environment provided by the BSP if specified."
BAREBOX_ENV_DIR ??= "${WORKDIR}/env/"

do_compile () {
export userccflags="${TARGET_LDFLAGS}${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
unset LDFLAGS
unset CFLAGS
unset CPPFLAGS
unset CXXFLAGS
unset MACHINE

if [ -d ${BAREBOX_ENV_DIR} ]; then
BAREBOX_DEFAULT_ENV="$(grep ^CONFIG_DEFAULT_ENVIRONMENT_PATH .config | cut -d '=' -f 2 | tr -d '"')"
oe_runmake CONFIG_DEFAULT_ENVIRONMENT_PATH="\"${BAREBOX_DEFAULT_ENV} ${BAREBOX_ENV_DIR}\""
else
oe_runmake
fi
}
BAREBOX_BINARY[doc] = "Specify the barebox binary to install. If not specified all barebox artifacts are installed."
BAREBOX_BINARY ??= "${@'barebox.efi' if d.getVar('EFI_PROVIDER') == 'barebox' else ''}"
BAREBOX_SUFFIX[doc] = "Specify the suffix for ${BAREBOX_IMAGE}."
BAREBOX_SUFFIX ??= "img"
BAREBOX_IMAGE[doc] = "A unique barebox image name. Unused if ${BAREBOX_BINARY} is not set."
BAREBOX_IMAGE_DEFAULT ?= "${PN}-${MACHINE}-${PV}-${PR}.${BAREBOX_SUFFIX}"
BAREBOX_IMAGE ?= "${@'${EFI_BOOT_IMAGE}' if d.getVar('EFI_PROVIDER') == 'barebox' else '${BAREBOX_IMAGE_DEFAULT}'}"
BAREBOX_INSTALL_PATH ?= "${@'${EFI_FILES_PATH}' if d.getVar('EFI_PROVIDER') == 'barebox' else '/boot'}"
do_install () {
if [ -n "${BAREBOX_BINARY}" ]; then
BAREBOX_BIN=${B}/${BAREBOX_BINARY}
if [ ! -f "${BAREBOX_BIN}" ]; then
BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
fi
if [ ! -f "${BAREBOX_BIN}" ]; then
bbfatal "Failed to locate ${BAREBOX_BINARY}"
fi
install -D -m 644 ${BAREBOX_BIN} ${D}${BAREBOX_INSTALL_PATH}/${BAREBOX_IMAGE}
ln -sf ${BAREBOX_IMAGE} ${D}${BAREBOX_INSTALL_PATH}/${BAREBOX_BINARY}
else
install -d ${D}${BAREBOX_INSTALL_PATH}/
for image in $(cat ${B}/barebox-flash-images); do
install -m 644 ${B}/${image} ${D}${BAREBOX_INSTALL_PATH}/
done
fi
}
FILES:${PN} = "${BAREBOX_INSTALL_PATH}"
do_deploy () {
if [ -n "${BAREBOX_BINARY}" ]; then
BAREBOX_BIN=${B}/${BAREBOX_BINARY}
if [ ! -f "${BAREBOX_BIN}" ]; then
BAREBOX_BIN=${B}/images/${BAREBOX_BINARY}
fi
install -D -m 644 ${BAREBOX_BIN} ${DEPLOYDIR}/${BAREBOX_IMAGE}
ln -sf ${BAREBOX_IMAGE} ${DEPLOYDIR}/${BAREBOX_BINARY}
else
for image in $(cat ${B}/barebox-flash-images); do
cp ${B}/${image} ${DEPLOYDIR}
done
fi
}
addtask deploy after do_compile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
require recipes-bsp/barebox/barebox.inc
# Use a local barebox.inc (instead of the one from meta-ptx that we have
# used before) that matches closely what will likely be included in oe-core
# soon. The file was taken from
# https://lore.kernel.org/all/20230425184720.456896-2-ejo@pengutronix.de/
# This should be changed to use the barebox.inc from oe-core once it is
# included.
require barebox.inc

SRC_URI += " \
file://defconfig \
file://env \
"
require files/patches/series.inc

SRC_URI[sha256sum] = "d0f78a69ba240327247c8fd0e1d45287e4a0dff99ed847e9a696cc2da0cf388c"
SRC_URI[sha256sum] = "7dda8cc4e989d38162dc04d287a882edc828093f75baace9e40b2ab7902958ea"

COMPATIBLE_MACHINE = "lxatac"

Expand All @@ -17,8 +23,7 @@ do_deploy:append () {
for DTB in ${BAREBOX_DTBS_TO_DEPLOY}; do
if [ -e ${DTB} ]; then
BAREBOX_DTB_BASENAME=barebox-$(basename ${DTB} .dtb)${BAREBOX_IMAGE_SUFFIX}
install -m 644 -T ${DTB} ${DEPLOYDIR}/${BAREBOX_DTB_BASENAME}-${DATETIME}.dtb
ln -sf ${BAREBOX_DTB_BASENAME}-${DATETIME}.dtb ${DEPLOYDIR}/${BAREBOX_DTB_BASENAME}.dtb
install -m 644 -T ${DTB} ${DEPLOYDIR}/${BAREBOX_DTB_BASENAME}.dtb
fi
done
}
Expand Down
Loading

0 comments on commit 0909511

Please sign in to comment.