Skip to content

Commit d605f78

Browse files
committed
k3: Factor out all K3 common configuration into k3_common.inc
Vendors using TI K3 devices may use kernels downstream from the TI vendor kernel and U-Boot. To make this easier factor out from k3.conf all other configuration that would be common to any kernel and U-Boot used. Signed-off-by: Andrew Davis <[email protected]>
1 parent b10d11f commit d605f78

File tree

2 files changed

+101
-90
lines changed

2 files changed

+101
-90
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Copyright (c) 2013-2023 Igor Pecovnik, [email protected]
5+
#
6+
# This file is a part of the Armbian Build Framework
7+
# https://github.com/armbian/build/
8+
#
9+
10+
declare -g ARCH="arm64"
11+
declare -g OVERLAY_DIR="/boot/dtb/ti/overlay"
12+
13+
declare -g ATFSOURCE="https://github.com/TexasInstruments/arm-trusted-firmware"
14+
15+
declare -g BOOTSCRIPT="boot-k3.cmd:uEnv.txt"
16+
declare -g SPD_OPTEED="SPD=opteed"
17+
18+
declare -g INSTALL_HEADERS="yes"
19+
20+
declare -g TI_PACKAGES=()
21+
if [[ "${CC33XX_SUPPORT}" == "yes" ]] ; then
22+
if [[ "${RELEASE}" == "trixie" || "${RELEASE}" == "noble" ]] ; then
23+
TI_PACKAGES+=("cc33xx-fw" "cc33xx-target-scripts" "cc33conf" "cc33calibrator")
24+
fi
25+
fi
26+
27+
enable_extension "ti-debpkgs"
28+
enable_extension "apa"
29+
30+
ATF_PLAT="k3"
31+
ATF_TARGET_MAP="PLAT=$ATF_PLAT TARGET_BOARD=$ATF_BOARD ${SPD_OPTEED} ${ATF_K3_USART_OFFSET} bl31;;build/$ATF_PLAT/$ATF_BOARD/release/bl31.bin:bl31.bin"
32+
33+
UBOOT_TARGET_MAP="BL31=bl31.bin TEE=${SRC}/cache/sources/optee-os/out/arm-plat-k3/core/tee-raw.bin BINMAN_INDIRS=${SRC}/cache/sources/ti-linux-firmware all;;tiboot3.bin ${SYSFW_FILE:+sysfw.itb} tispl.bin u-boot.img"
34+
35+
# To match what our current SDK produces
36+
BOOT_FS_LABEL="boot"
37+
ROOT_FS_LABEL="root"
38+
39+
function add_host_dependencies__k3_python3_dep() {
40+
display_alert "Preparing K3 U-Boot host-side dependencies" "${EXTENSION}" "info"
41+
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} python3-yaml python3-jsonschema yamllint python3-cryptography python3-pyelftools python3-setuptools"
42+
}
43+
44+
function compile_k3_bootgen() {
45+
# Source code checkout
46+
(fetch_from_repo "https://github.com/TexasInstruments/ti-linux-firmware" "ti-linux-firmware" ${TI_LINUX_FIRMWARE_BRANCH})
47+
48+
pushd ${SRC}/cache/sources/u-boot-worktree/${BOOTDIR}/${BOOTBRANCH##*:} || exit
49+
50+
run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm O=build-r5 ${TIBOOT3_BOOTCONFIG}
51+
run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm O=build-r5 BINMAN_INDIRS=${SRC}/cache/sources/ti-linux-firmware
52+
53+
popd
54+
}
55+
56+
function compile_k3_optee() {
57+
(fetch_from_repo "https://github.com/OP-TEE/optee_os.git" "optee-os" ${OPTEE_BRANCH})
58+
pushd ${SRC}/cache/sources/optee-os || exit
59+
run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- CFG_ARM64_core=y PLATFORM=${OPTEE_PLATFORM} ${OPTEE_ARGS}
60+
popd
61+
}
62+
63+
function pre_config_uboot_target__build_first_stage() {
64+
# Compile first stage bootloader
65+
compile_k3_optee
66+
compile_k3_bootgen
67+
68+
cp ${SRC}/cache/sources/u-boot-worktree/${BOOTDIR}/${BOOTBRANCH##*:}/build-r5/${TIBOOT3_FILE} tiboot3.bin
69+
cp ${SRC}/cache/sources/u-boot-worktree/${BOOTDIR}/${BOOTBRANCH##*:}/build-r5/${SYSFW_FILE} sysfw.itb || true
70+
}
71+
72+
function post_uboot_custom_postprocess__update_uboot_names() {
73+
cp ${TISPL_FILE} tispl.bin || true
74+
cp ${UBOOT_FILE} u-boot.img || true
75+
}
76+
77+
function pre_prepare_partitions() {
78+
# Filesystem must fill partition regardless of alignment
79+
mkopts[fat]='-a'
80+
}
81+
82+
function post_create_partitions() {
83+
display_alert "Setting boot partition flags on" "${SDCARD}.raw" "debug"
84+
85+
# ROM is very particular about boot flags
86+
run_host_command_logged parted "${SDCARD}".raw set 1 boot on
87+
run_host_command_logged parted "${SDCARD}".raw set 1 bls_boot off
88+
}
89+
90+
function format_partitions() {
91+
# ROM is very particular about partition IDs
92+
run_host_command_logged sfdisk --part-type ${LOOP} 1 e
93+
}
94+
95+
function write_uboot_platform() {
96+
cp $1/tiboot3.bin ${MOUNT}/boot
97+
cp $1/sysfw.itb ${MOUNT}/boot || true
98+
cp $1/tispl.bin ${MOUNT}/boot
99+
cp $1/u-boot.img ${MOUNT}/boot
100+
}

config/sources/families/k3.conf

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,10 @@
77
# https://github.com/armbian/build/
88
#
99

10-
declare -g ARCH="arm64"
1110
declare -g LINUXFAMILY="k3"
12-
declare -g OVERLAY_DIR="/boot/dtb/ti/overlay"
13-
1411
declare -g KERNELSOURCE="https://github.com/TexasInstruments/ti-linux-kernel"
15-
declare -g ATFSOURCE="https://github.com/TexasInstruments/arm-trusted-firmware"
1612
declare -g BOOTSOURCE="https://github.com/TexasInstruments/ti-u-boot"
1713

18-
declare -g BOOTSCRIPT="boot-k3.cmd:uEnv.txt"
19-
declare -g SPD_OPTEED="SPD=opteed"
20-
21-
declare -g INSTALL_HEADERS="yes"
22-
23-
declare -g TI_PACKAGES=()
24-
if [[ "${CC33XX_SUPPORT}" == "yes" ]] ; then
25-
if [[ "${RELEASE}" == "trixie" || "${RELEASE}" == "noble" ]] ; then
26-
TI_PACKAGES+=("cc33xx-fw" "cc33xx-target-scripts" "cc33conf" "cc33calibrator")
27-
fi
28-
fi
29-
30-
enable_extension "ti-debpkgs"
31-
enable_extension "apa"
32-
3314
case "${BRANCH}" in
3415

3516
current | current-rt)
@@ -60,74 +41,4 @@ case "${BRANCH}" in
6041

6142
esac
6243

63-
ATF_PLAT="k3"
64-
ATF_TARGET_MAP="PLAT=$ATF_PLAT TARGET_BOARD=$ATF_BOARD ${SPD_OPTEED} ${ATF_K3_USART_OFFSET} bl31;;build/$ATF_PLAT/$ATF_BOARD/release/bl31.bin:bl31.bin"
65-
66-
UBOOT_TARGET_MAP="BL31=bl31.bin TEE=${SRC}/cache/sources/optee-os/out/arm-plat-k3/core/tee-raw.bin BINMAN_INDIRS=${SRC}/cache/sources/ti-linux-firmware all;;tiboot3.bin ${SYSFW_FILE:+sysfw.itb} tispl.bin u-boot.img"
67-
68-
# To match what our current SDK produces
69-
BOOT_FS_LABEL="boot"
70-
ROOT_FS_LABEL="root"
71-
72-
function add_host_dependencies__k3_python3_dep() {
73-
display_alert "Preparing K3 U-Boot host-side dependencies" "${EXTENSION}" "info"
74-
declare -g EXTRA_BUILD_DEPS="${EXTRA_BUILD_DEPS} python3-yaml python3-jsonschema yamllint python3-cryptography python3-pyelftools python3-setuptools"
75-
}
76-
77-
function compile_k3_bootgen() {
78-
# Source code checkout
79-
(fetch_from_repo "https://github.com/TexasInstruments/ti-linux-firmware" "ti-linux-firmware" ${TI_LINUX_FIRMWARE_BRANCH})
80-
81-
pushd ${SRC}/cache/sources/u-boot-worktree/${BOOTDIR}/${BOOTBRANCH##*:} || exit
82-
83-
run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm O=build-r5 ${TIBOOT3_BOOTCONFIG}
84-
run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- ARCH=arm O=build-r5 BINMAN_INDIRS=${SRC}/cache/sources/ti-linux-firmware
85-
86-
popd
87-
}
88-
89-
function compile_k3_optee() {
90-
(fetch_from_repo "https://github.com/OP-TEE/optee_os.git" "optee-os" ${OPTEE_BRANCH})
91-
pushd ${SRC}/cache/sources/optee-os || exit
92-
run_host_command_logged make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf- CFG_ARM64_core=y PLATFORM=${OPTEE_PLATFORM} ${OPTEE_ARGS}
93-
popd
94-
}
95-
96-
function pre_config_uboot_target__build_first_stage() {
97-
# Compile first stage bootloader
98-
compile_k3_optee
99-
compile_k3_bootgen
100-
101-
cp ${SRC}/cache/sources/u-boot-worktree/${BOOTDIR}/${BOOTBRANCH##*:}/build-r5/${TIBOOT3_FILE} tiboot3.bin
102-
cp ${SRC}/cache/sources/u-boot-worktree/${BOOTDIR}/${BOOTBRANCH##*:}/build-r5/${SYSFW_FILE} sysfw.itb || true
103-
}
104-
105-
function post_uboot_custom_postprocess__update_uboot_names() {
106-
cp ${TISPL_FILE} tispl.bin || true
107-
cp ${UBOOT_FILE} u-boot.img || true
108-
}
109-
110-
function pre_prepare_partitions() {
111-
# Filesystem must fill partition regardless of alignment
112-
mkopts[fat]='-a'
113-
}
114-
115-
function post_create_partitions() {
116-
display_alert "Setting boot partition flags on" "${SDCARD}.raw" "debug"
117-
118-
# ROM is very particular about boot flags
119-
run_host_command_logged parted "${SDCARD}".raw set 1 boot on
120-
run_host_command_logged parted "${SDCARD}".raw set 1 bls_boot off
121-
}
122-
123-
function format_partitions() {
124-
# ROM is very particular about partition IDs
125-
run_host_command_logged sfdisk --part-type ${LOOP} 1 e
126-
}
127-
128-
function write_uboot_platform() {
129-
cp $1/tiboot3.bin ${MOUNT}/boot
130-
cp $1/sysfw.itb ${MOUNT}/boot || true
131-
cp $1/tispl.bin ${MOUNT}/boot
132-
cp $1/u-boot.img ${MOUNT}/boot
133-
}
44+
source "${BASH_SOURCE%/*}/include/k3_common.inc"

0 commit comments

Comments
 (0)