Skip to content

Commit 5afcea6

Browse files
authored
Merge pull request #95 from sixtyfourktec/uboot
Uboot
2 parents 61eedab + 0244e6e commit 5afcea6

19 files changed

Lines changed: 704 additions & 57 deletions

classes/uboot.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Convenience methods for creating a uboot build
2+
#
3+
# Here we define helper methods for building the uboot bootloader
4+
inherit: [make, pkg-config, python3]
5+
6+
depends:
7+
- tools:
8+
target-toolchain: host-compat-toolchain
9+
depends:
10+
- python::pylibfdt # python support
11+
- libs::openssl-dev # FIT
12+
- libs::gnutls-dev # mkeficapsule/tools
13+
- name: utils::efitools # uefi
14+
use: [tools]
15+
- name: utils::xxd # UBOOT_ENV
16+
use: [tools]
17+
- name: devel::dtc # dts
18+
use: [tools]
19+
20+
buildTools: [target-toolchain, host-toolchain, m4, bison, flex, dtc, python3, efitools]
21+
buildToolsWeak: [xxd]
22+
buildVars: [CROSS_COMPILE]
23+
buildSetup: |
24+
HOSTCC=gcc
25+
DTC=$(which dtc)
26+
# All the dependencies are for the host tools. We have to manually collect
27+
# the paths and provide them to the make command.
28+
for i in "${@:2}" ; do
29+
if [[ -d "$i/usr/include" ]] ; then
30+
HOSTCFLAGS+=" -I$i/usr/include"
31+
fi
32+
for j in lib usr/lib ; do
33+
if [[ -d "$i/$j" ]] ; then
34+
HOSTLDFLAGS+=" -L$i/$j"
35+
if compgen -G "$i/$j/*.so" >/dev/null ; then
36+
HOSTLDFLAGS+=" -Wl,-rpath-link=$i/$j"
37+
fi
38+
fi
39+
done
40+
done
41+
42+
# Build the initial uboot config. This will be used by all other steps.
43+
#
44+
# $1: uboot source directory
45+
# $2: defconfig (optional)
46+
# - if this is an actual file, use it as the config
47+
# - if this is not a file, check if a defconfig for the target arch by
48+
# that name exists and if yes, use that one
49+
ubootConfig()
50+
{
51+
DEF_CFG=${2:-defconfig}
52+
if [[ -f "$1/configs/${DEF_CFG}" ]] ; then
53+
DEF_CFG=$1/configs/${DEF_CFG}
54+
fi
55+
# check if the defconfig file exists
56+
if [[ ! -f "$DEF_CFG" ]]; then
57+
>&2 echo "Don't know how to use $DEF_CFG as uboot config!"
58+
false
59+
fi
60+
# check if the source file is newer than .config
61+
if [[ -f .config && .config -nt $DEF_CFG ]]; then
62+
break;
63+
fi
64+
# redo the .config file
65+
cp -u "$DEF_CFG" .config
66+
makeSequential -C $1 O=$PWD \
67+
CROSS_COMPILE="$CROSS_COMPILE" \
68+
DTC="$DTC" \
69+
HOSTCC="$HOSTCC" \
70+
HOSTCFLAGS="$HOSTCFLAGS" \
71+
HOSTLDFLAGS="$HOSTLDFLAGS" \
72+
olddefconfig
73+
}
74+
75+
# Build the actual target uboot image(s) and all configured modules
76+
#
77+
# $@: list of targets to package
78+
ubootBuild()
79+
{
80+
makeParallel \
81+
CROSS_COMPILE="$CROSS_COMPILE" \
82+
DTC="$DTC" \
83+
HOSTCC="$HOSTCC" \
84+
HOSTCFLAGS="$HOSTCFLAGS" \
85+
HOSTLDFLAGS="$HOSTLDFLAGS" \
86+
$@
87+
}
88+
89+
packageSetup: |
90+
# Install the uboot files
91+
#
92+
# $@: list of targets to package
93+
ubootPackage()
94+
{
95+
for i in "${@:2}" ; do
96+
cp "$1/$i" "$PWD"
97+
done
98+
}

classes/uboot/menuconfig.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
inherit: [uboot]
2+
3+
depends:
4+
- tools:
5+
target-toolchain: host-compat-toolchain
6+
depends:
7+
- libs::ncurses-dev
8+
9+
buildSetup: |
10+
# Calls the uboot savedefconfig target
11+
#
12+
# Especially in the sandbox this can be tricky. Provide some convenience method.
13+
ubootSavedefconfig()
14+
{
15+
makeParallel \
16+
HOSTCC="$HOSTCC" \
17+
savedefconfig
18+
}
19+
20+
# Calls the uboot menuconfig target
21+
#
22+
# Especially in the sandbox this can be tricky. Provide some convenience method.
23+
ubootMenuconfig()
24+
{
25+
NCDEP=${BOB_DEP_PATHS[libs::ncurses-dev]}/usr
26+
makeParallel \
27+
HOSTCC="$HOSTCC" \
28+
HOSTCFLAGS="-I${NCDEP}/include -DCURSES_LOC=\"<ncurses.h>\" -DLOCALE $(pkg-config --cflags ncurses)" \
29+
HOSTLDLIBS="-L${NCDEP}/lib $(pkg-config --libs ncurses)" \
30+
menuconfig
31+
# Always save a defconfig
32+
ubootSavedefconfig
33+
}

recipes/bsp/uboot.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
inherit: [uboot, install]
2+
3+
metaEnvironment:
4+
PKG_VERSION: "2025.04"
5+
PKG_LICENSE: "GPL-2.0+"
6+
7+
checkoutSCM:
8+
scm: url
9+
url: https://ftp.denx.de/pub/u-boot/u-boot-${PKG_VERSION}.tar.bz2
10+
digestSHA1: 6bc4fd62d5b135ff2fbb11fcecbb4b8ca055022a
11+
stripComponents: 1
12+
13+
multiPackage:
14+
"":
15+
depends:
16+
- if: "${UBOOT_CUSTOM_CONFIG:-}"
17+
name: "${UBOOT_CUSTOM_CONFIG_PKG:-uboot-custom-cfg}"
18+
19+
buildVars: [UBOOT_CONFIG, UBOOT_TARGETS, UBOOT_CUSTOM_CONFIG, UBOOT_CUSTOM_CONFIG_PKG]
20+
buildScript: |
21+
# Use plain "defconfig" if we have no specific target. Otherwise check if
22+
# defconfig has changed.
23+
if [[ ${UBOOT_CUSTOM_CONFIG:+true} ]] ; then
24+
PKG="${UBOOT_CUSTOM_CONFIG_PKG:-uboot-custom-cfg}"
25+
LCFG="${BOB_DEP_PATHS[$PKG]}/$UBOOT_CUSTOM_CONFIG"
26+
# Copy all files from custom config, in case the config file
27+
# refers to some of them (e.g. env files)
28+
cp -f ${BOB_DEP_PATHS[$PKG]}/* .
29+
elif [[ ${UBOOT_CONFIG:+true} ]] ; then
30+
LCFG="${UBOOT_CONFIG}"
31+
else
32+
LCFG="sandbox_defconfig"
33+
fi
34+
35+
ubootConfig $1 $LCFG
36+
ubootBuild \
37+
${UBOOT_TARGETS:-u-boot.bin}
38+
39+
packageVars: [UBOOT_TARGETS]
40+
packageScript: |
41+
ubootPackage $1 \
42+
${UBOOT_TARGETS:-u-boot.bin}
43+
44+
"tools":
45+
buildScript: |
46+
# we need a defconfig, so use the sandbox defconfig which is ok for
47+
# a tools only build
48+
ubootConfig $1 \
49+
sandbox_defconfig
50+
ubootBuild \
51+
CROSS_BUILD_TOOLS=y \
52+
tools-only
53+
54+
install -D -m 0755 \
55+
$(find tools/ -executable -type f) \
56+
-t install/usr/bin
57+
58+
packageScript: |
59+
installPackageBin "$1/install/"
60+
provideTools:
61+
uboot-tools: "usr/bin"

recipes/devel/swig.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
inherit: [autotools]
2+
3+
metaEnvironment:
4+
PKG_VERSION: "4.3.1"
5+
PKG_LICENSE: "GPL-3.0+, BSD-2-Clause, BSD-3-Clause"
6+
7+
checkoutSCM:
8+
scm: url
9+
url: ${SOURCEFORGE_MIRROR}/swig/swig-${PKG_VERSION}.tar.gz
10+
digestSHA1: a111f4433c2348a3186698e1b750b4944bc34c7b
11+
stripComponents: 1
12+
13+
depends:
14+
- libs::pcre2-dev
15+
- use: []
16+
depends:
17+
- libs::pcre2-tgt
18+
19+
buildScript: |
20+
autotoolsBuild $1 \
21+
--with-pcre2-prefix=${BOB_DEP_PATHS[libs::pcre2-dev]}/usr
22+
23+
multiPackage:
24+
"":
25+
packageScript: |
26+
autotoolsPackageTgt
27+
28+
"tools":
29+
packageVars: [PKG_VERSION]
30+
packageScript: |
31+
autotoolsPackageTgt
32+
# swig has runtime files it needs to find. Create a wrapper script
33+
# which sets the runtime path to the correct location and call the
34+
# real binary afterwards.
35+
mv usr/bin/swig usr/bin/swig_real
36+
cat > usr/bin/swig <<EOF
37+
#!/bin/sh
38+
export SWIG_LIB=\$(realpath \$(dirname \$0)/../share/swig/${PKG_VERSION})
39+
exec \$(dirname \$0)/swig_real \$@
40+
EOF
41+
chmod a+x usr/bin/swig
42+
provideTools:
43+
swig: "usr/bin"
44+
45+
provideDeps: ['*-tgt']

recipes/libs/gnu-efi.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
inherit: [cpackage, make, install]
2+
3+
metaEnvironment:
4+
PKG_VERSION: "4.0.1"
5+
PKG_LICENSE: "BSD-3-Clause and/or GPL-2.0+ (gnuefi), BSD-3-Clause (efilib), BSD-2-Clause-Patent (EDK2 routines)"
6+
7+
checkoutSCM:
8+
scm: url
9+
url: ${GITHUB_MIRROR}/ncroxon/gnu-efi/archive/refs/tags/${PKG_VERSION}.tar.gz
10+
digestSHA1: 603db6264741da9f84e2a8e386a36fdf69464ba8
11+
stripComponents: 1
12+
13+
buildTools: [host-toolchain, target-toolchain]
14+
buildVars: [CROSS_COMPILE]
15+
buildScript: |
16+
mkdir -p build
17+
cp -arsf $1/* build/
18+
19+
unset LDFLAGS
20+
makeParallel -C build \
21+
CROSS_COMPILE="${CROSS_COMPILE}" \
22+
HOSTCC="gcc"
23+
24+
makeParallel -C build \
25+
DESTDIR=$BOB_CWD/install \
26+
PREFIX=/usr \
27+
install
28+
29+
multiPackage:
30+
dev:
31+
packageScript: |
32+
installPackageDev "$1/install/"
33+
# gnu-efi is somewhat special, because it delivers .efi/.lds/.o
34+
# files for the final linking step of an efi app. We have to ensure
35+
# they are available to the user of this package.
36+
installCopy "$1/install/" \
37+
"/usr/" "/usr/lib/" "/usr/lib/*.lds" "/usr/lib/*.o" \
38+
"/usr/lib/gnuefi/" "/usr/lib/gnuefi/***" \
39+
"!*"
40+
41+
tgt:
42+
packageScript: installPackageTgt "$1/install/"

recipes/libs/pcre2.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ multiPackage:
2525
provideDeps: [ "*-tgt" ]
2626

2727
dev:
28-
packageScript: autotoolsPackageDev
28+
packageScript: |
29+
autotoolsPackageDev
30+
# install pcre2-config and fix it for bob usage
31+
mkdir -p usr/bin
32+
sed 's,prefix=/usr,prefix=$(dirname $0)/..,' $1/install/usr/bin/pcre2-config > usr/bin/pcre2-config
33+
chmod a+x usr/bin/pcre2-config
2934
3035
tgt:
3136
packageScript: autotoolsPackageLib

recipes/python/pylibfdt.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
inherit: ["python3::setuptools", "python3::cext"]
2+
3+
metaEnvironment:
4+
PKG_VERSION: "1.7.2.post1"
5+
6+
checkoutSCM:
7+
scm: url
8+
url: https://files.pythonhosted.org/packages/source/p/pylibfdt/pylibfdt-${PKG_VERSION}.tar.gz
9+
digestSHA256: 08ec69755f7565dc25e4e640e0315795888d4caeb7f146de4e05bf12b03c94c8
10+
stripComponents: 1
11+
12+
depends:
13+
- python::setuptools-scm
14+
- name: devel::swig-tools
15+
use: [tools]
16+
tools:
17+
target-toolchain: host-compat-toolchain
18+
19+
buildTools: [swig]
20+
buildScript: |
21+
python3BuildSetuptools $1
22+
23+
packageScript: |
24+
python3CExtPackageTgt

recipes/utils/efitools.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
inherit: [cpackage, patch, make, install]
2+
3+
metaEnvironment:
4+
PKG_VERSION: "1.9.2"
5+
PKG_LICENSE: "GPL-2 LGPL-2.1"
6+
7+
checkoutSCM:
8+
scm: url
9+
url: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/efitools.git/snapshot/${PKG_VERSION}.tar.gz
10+
digestSHA1: 351105b03d6589d4fdbca059a0cdfb517728fc75
11+
stripComponents: 1
12+
13+
depends:
14+
- tools:
15+
target-toolchain: host-compat-toolchain
16+
depends:
17+
- use: [tools]
18+
depends:
19+
- libs::openssl
20+
- utils::sbsigntools
21+
- name: utils::xxd
22+
23+
- libs::openssl-dev
24+
- libs::gnu-efi-dev
25+
- use: []
26+
depends:
27+
- libs::openssl-tgt
28+
- libs::gnu-efi-tgt
29+
30+
checkoutDeterministic: True
31+
checkoutScript: |
32+
patchApplySeries $<@efitools/*.patch@>
33+
34+
buildTools: [target-toolchain, openssl, sbsigntools, xxd]
35+
buildVars: [CC, AR, LD, NM, ARCH, OBJCOPY]
36+
buildScript: |
37+
mkdir -p build install
38+
cp -arsf $1/* build/
39+
40+
# openssl needs a conf file; create an empty one
41+
touch openssl.cnf
42+
export OPENSSL_CONF=$PWD/openssl.cnf
43+
44+
GNUEFI="${BOB_DEP_PATHS[libs::gnu-efi-dev]}/usr"
45+
export CFLAGS="$CFLAGS -I${GNUEFI}/include -I${GNUEFI}/include/efi $(pkg-config --cflags libcrypto openssl)"
46+
export LDFLAGS="-L${GNUEFI}/lib $(pkg-config --libs-only-L libcrypto openssl)"
47+
makeSequential -C build \
48+
OBJCOPY="$OBJCOPY" \
49+
LD="$LD" \
50+
AR="$AR" \
51+
NM="$NM" \
52+
LDSCRIPT="${GNUEFI}/lib/elf_${ARCH}_efi.lds" \
53+
CRTPATHS="${GNUEFI}/lib" \
54+
LDFLAGS_TOOLS="$(pkg-config --libs libcrypto)" \
55+
DESTDIR=$BOB_CWD/install \
56+
install
57+
58+
packageScript: |
59+
installPackageTgt "$1/install/"
60+
provideTools:
61+
efitools: "usr/bin"

0 commit comments

Comments
 (0)