345 lines
13 KiB
PHP
345 lines
13 KiB
PHP
# Amlogic Common Configuration Include
|
|
# This file contains common configuration for all Amlogic boards
|
|
# Include this file in board configurations with: source amlogic_common.inc
|
|
#
|
|
# AMLOGIC TODO: This file provides:
|
|
# - Local source paths configuration
|
|
# - Non-interactive build configuration
|
|
# - Common U-Boot/Kernel functions
|
|
# - Docker mount configuration
|
|
|
|
# AMLOGIC TODO: Configuration loaded - verify local source paths
|
|
display_alert "AMLOGIC TODO: Loading amlogic common configuration" "${BOARD:-unknown}" "info"
|
|
|
|
# ==============================================================================
|
|
# Section 1: Non-Interactive Build Configuration
|
|
# ==============================================================================
|
|
|
|
|
|
# ==============================================================================
|
|
# Section 2: Local Source Paths Configuration
|
|
# ==============================================================================
|
|
|
|
# Default local source paths - can be overridden by environment variables
|
|
# These paths are relative to amlbian directory when not in Docker
|
|
# In Docker, they will be mounted from host
|
|
#LOCAL_UBOOT_PATH="${LOCAL_UBOOT_PATH:-../aml-comp/uboot/bl33/v2023}"
|
|
#LOCAL_KERNEL_PATH="${LOCAL_KERNEL_PATH:-../aml-comp/kernel}"
|
|
#LOCAL_GPU_PATH="${LOCAL_GPU_PATH:-../aml-comp/gpu}"
|
|
#LOCAL_NPU_PATH="${LOCAL_NPU_PATH:-../aml-comp/npu}"
|
|
#LOCAL_WIFI_PATH="${LOCAL_WIFI_PATH:-../aml-comp/wifi}"
|
|
|
|
# AML_COMP_DIR is the Docker mount point for compiled artifacts
|
|
AML_COMP_DIR="${AML_COMP_DIR:-/aml-comp}"
|
|
|
|
# Default to using local sources if not specified
|
|
USE_LOCAL_SOURCES="${USE_LOCAL_SOURCES:-yes}"
|
|
|
|
#BUILD_UNITS=( uboot kernel rootfs wifi npu )
|
|
#system defined BUILD_UNITS take priority
|
|
|
|
if [[ -n "${BUILD_UNITS}" ]]; then
|
|
display_alert "AMLOGIC: BUILD_UNITS from env var" "${BUILD_UNITS}" "info"
|
|
fi
|
|
|
|
if [ -z "${BUILD_UNITS:-}" ]; then
|
|
BUILD_UNITS=(
|
|
uboot
|
|
kernel
|
|
rootfs
|
|
modules-load
|
|
udev
|
|
gpu
|
|
npu
|
|
wifi
|
|
bt
|
|
media-modules
|
|
optee
|
|
libion
|
|
libge2d
|
|
liblog
|
|
libencoder
|
|
dma-allocator
|
|
gst-aml
|
|
gst-aml-vendor
|
|
isp
|
|
vendor-files
|
|
tvserver
|
|
devtool
|
|
screencapture
|
|
linux-uapi-headers
|
|
mediactrlsrc
|
|
hdmi-test
|
|
)
|
|
else
|
|
# Note: BUILD_UNITS is transformed into an array during processing.
|
|
# Any subsequent use as an environment variable requires converting it back to a string.
|
|
BUILD_UNITS=($BUILD_UNITS)
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "${SRC}/../yocto-release-info" ]; then
|
|
RELEASE_VERSION="${RELEASE_VERSION:-$(grep '^RELEASE_VERSION' "${SRC}/../yocto-release-info" | sed 's/.*= *"\([^"]*\)".*/\1/')}"
|
|
RELEASE_SPIN="${RELEASE_SPIN:-$(grep '^RELEASE_SPIN' "${SRC}/../yocto-release-info" | sed 's/.*= *"\([^"]*\)".*/\1/')}"
|
|
DATETIME="${DATETIME:-$(grep '^DATETIME' "${SRC}/../yocto-release-info" | sed 's/.*= *"\([^"]*\)".*/\1/')}"
|
|
else
|
|
RELEASE_SPIN="${RELEASE_SPIN:-$(hostname)#$(whoami)}"
|
|
fi
|
|
|
|
GPT_TABLE="partition_table.txt"
|
|
EXTLINUX_CONF="extlinux.conf"
|
|
|
|
COMMON_PACKAGE_LIST_ADDITIONAL="\
|
|
mawk vim-tiny util-linux \
|
|
net-tools iputils-ping \
|
|
htop sysstat \
|
|
e2fsprogs \
|
|
build-essential git curl wget unzip pkg-config \
|
|
vim less tree dos2unix"
|
|
|
|
EXTRA_BUILD_DEPS+=" libarchive-zip-perl"
|
|
MEDIA_DECODER_SUPPORTED_FORMATS="${MEDIA_DECODER_SUPPORTED_FORMATS:-MPEG2 MPEG4 VC1 H264 H265 VP9 MJPEG REAL AVS AVS2 AV1}"
|
|
|
|
# ==============================================================================
|
|
# Section 3: Skip Git Operations for Local Sources
|
|
# ==============================================================================
|
|
|
|
if [[ "${USE_LOCAL_SOURCES}" == "yes" ]]; then
|
|
display_alert "AMLOGIC TODO: Using local sources" \
|
|
"UBoot: ${LOCAL_UBOOT_PATH}, Kernel: ${LOCAL_KERNEL_PATH}" "info"
|
|
|
|
# Skip git clone operations
|
|
BOOTSOURCE=""
|
|
KERNELSOURCE=""
|
|
|
|
# Skip checkout verification
|
|
FORCE_CHECKOUT="no"
|
|
|
|
# Skip git info generation
|
|
GENERATE_GIT_INFO="no"
|
|
SKIP_GIT_INFO="yes"
|
|
|
|
# Use local sources
|
|
USE_LOCAL_UBOOT="yes"
|
|
USE_LOCAL_KERNEL="yes"
|
|
LOCAL_UBOOT_READY="yes"
|
|
LOCAL_KERNEL_READY="yes"
|
|
|
|
# Skip artifact version generation
|
|
SKIP_UBOOT_ARTIFACT_VERSION="yes"
|
|
SKIP_KERNEL_ARTIFACT_VERSION="yes"
|
|
|
|
# Disable remote artifact download
|
|
CREATE_UBOOT_ARTIFACT="no"
|
|
CREATE_KERNEL_ARTIFACT="no"
|
|
|
|
# Set local branch names (avoid 'local' which triggers git validation errors)
|
|
if [[ -d "${LOCAL_UBOOT_PATH}" && -d "${LOCAL_UBOOT_PATH}/.git" ]]; then
|
|
local actual_commit
|
|
actual_commit=$(cd "${LOCAL_UBOOT_PATH}" && git rev-parse HEAD 2>/dev/null | cut -c1-12 || echo "unknown")
|
|
BOOTBRANCH="commit:${actual_commit}"
|
|
else
|
|
BOOTBRANCH="branch:amlogic-dev-2023" # Fallback — Armbian git_parse_ref requires "branch:"/"tag:"/"commit:" prefix
|
|
fi
|
|
|
|
if [[ -d "${LOCAL_KERNEL_PATH}" && -d "${LOCAL_KERNEL_PATH}/.git" ]]; then
|
|
local actual_commit
|
|
actual_commit=$(cd "${LOCAL_KERNEL_PATH}" && git rev-parse HEAD 2>/dev/null | cut -c1-12 || echo "unknown")
|
|
KERNELBRANCH="commit:${actual_commit}"
|
|
else
|
|
KERNELBRANCH="branch:android16-6.12" # Fallback — same prefix requirement as BOOTBRANCH
|
|
fi
|
|
|
|
BOOTPATCHDIR="none"
|
|
KERNELPATCHDIR="none"
|
|
else
|
|
display_alert "AMLOGIC TODO: Using remote sources" \
|
|
"Fallback to default remote repositories" "warn"
|
|
fi
|
|
|
|
# ==============================================================================
|
|
# Section 4: Common U-Boot Functions
|
|
# ==============================================================================
|
|
|
|
# Smarter/faster/better to-spi writer using flashcp
|
|
function write_uboot_platform_mtd__amlbian() {
|
|
declare -a extra_opts_flashcp=("--verbose")
|
|
echo "Writing U-Boot to SPI flash /dev/mtd0 using flashcp... ${extra_opts_flashcp}" >&2
|
|
if flashcp -h 2>/dev/null | grep -q -e '--partition'; then
|
|
echo "Confirmed flashcp supports --partition" >&2
|
|
extra_opts_flashcp+=("--partition")
|
|
else
|
|
echo "flashcp does not support --partition, will write full blocks" >&2
|
|
fi
|
|
flashcp "${extra_opts_flashcp[@]}" "${1}/u-boot-spi.bin" /dev/mtd0
|
|
}
|
|
|
|
# Common post-processing for U-Boot FIP blobs
|
|
function post_uboot_custom_postprocess__amlbian() {
|
|
display_alert "AMLOGIC TODO: Signing u-boot FIP" "${BOARD}" "info"
|
|
# AMLOGIC TODO: Implement FIP signing
|
|
# uboot_s6_postprocess "${SRC}"/cache/sources/amlogic-boot-fip/${BOARD} ${BOARDFAMILY}
|
|
}
|
|
|
|
# Common extra U-Boot config options
|
|
function post_config_uboot_target__amlbian_extra_configs() {
|
|
display_alert "AMLOGIC TODO: post_config_uboot_target hook" "${BOARD}" "info"
|
|
# AMLOGIC TODO: Add extra U-Boot config options if needed
|
|
return 0
|
|
}
|
|
|
|
# ==============================================================================
|
|
# Section 5: Common Kernel Functions
|
|
# ==============================================================================
|
|
|
|
# Common kernel post-processing
|
|
function post_kernel_custom_postprocess__amlbian() {
|
|
display_alert "AMLOGIC TODO: post_kernel_custom_postprocess hook" "${BOARD}" "info"
|
|
# AMLOGIC TODO: Add custom kernel post-processing if needed
|
|
return 0
|
|
}
|
|
|
|
# ==============================================================================
|
|
# Section 6: Custom Image Packaging
|
|
# ==============================================================================
|
|
|
|
# Custom image packaging function for Amlogic boards
|
|
function custom_image_packaging__amlbian() {
|
|
display_alert "AMLOGIC TODO: Starting custom image packaging" "${BOARD}" "info"
|
|
|
|
# AMLOGIC TODO: Implement custom image packaging method
|
|
# This function is called during image creation to apply custom packaging
|
|
#
|
|
# Example custom packaging steps:
|
|
# 1. Sign the image with custom keys
|
|
# 2. Add custom partitions or layout
|
|
# 3. Compress with specific settings
|
|
# 4. Generate checksums
|
|
|
|
display_alert "AMLOGIC TODO: Custom packaging not yet implemented" \
|
|
"Using Armbian native packaging" "warn"
|
|
|
|
# For now, just call the default Armbian packaging
|
|
return 0
|
|
}
|
|
|
|
# Hook to integrate custom packaging into Armbian build process
|
|
function post_image_creation__amlbian_custom_packaging() {
|
|
display_alert "AMLOGIC TODO: Post image creation hook for custom packaging" "${BOARD}" "info"
|
|
custom_image_packaging__amlbian
|
|
}
|
|
|
|
# Rootfs building uses Armbian native implementation - no changes needed
|
|
# AMLOGIC TODO: Rootfs is built by Armbian, no custom modifications required
|
|
display_alert "AMLOGIC TODO: Rootfs building uses Armbian native implementation" \
|
|
"No custom rootfs modifications" "info"
|
|
|
|
# ==============================================================================
|
|
# Section 7: Display Configuration Info
|
|
# ==============================================================================
|
|
|
|
function display_amlbian_config_info() {
|
|
display_alert "AMLIbian Configuration" \
|
|
"Board: ${BOARD}, Family: ${BOARDFAMILY}, Branch: ${BRANCH}" "info"
|
|
display_alert "AMLIbian Local Sources" \
|
|
"UBOOT: ${LOCAL_UBOOT_PATH:-not set}, KERNEL: ${LOCAL_KERNEL_PATH:-not set}" "info"
|
|
display_alert "AMLIbian Build Mode" \
|
|
"USE_LOCAL_SOURCES: ${USE_LOCAL_SOURCES}, BOOTBRANCH: ${BOOTBRANCH}" "info"
|
|
}
|
|
|
|
function set_external_toolchain() {
|
|
display_alert "AMLOGIC: Setting external toolchain" "checking for custom toolchain configuration" "info"
|
|
|
|
# Priority order: 1. Build arguments (if passed to this function) 2. Environment variables 3. Default values
|
|
# Default values
|
|
# local DEFAULT_TOOLCHAIN_PATH="/opt/arm-gnu-toolchain-14.3.rel1-x86_64-aarch64-none-linux-gnu"
|
|
local DEFAULT_TOOLCHAIN_PATH="/opt/arm-gnu-toolchain-11.3.rel1-x86_64-aarch64-none-linux-gnu"
|
|
local DEFAULT_CROSS_PREFIX="aarch64-none-linux-gnu"
|
|
|
|
# Check for environment variables first (priority 2)
|
|
local TOOLCHAIN_PATH="${TOOLCHAIN_PATH:-${DEFAULT_TOOLCHAIN_PATH}}"
|
|
local CROSS_PREFIX="${CROSS_PREFIX:-${DEFAULT_CROSS_PREFIX}}"
|
|
|
|
# Check for build arguments (priority 1) - if function was called with parameters
|
|
# Note: This function doesn't currently accept parameters, but we leave the structure for future expansion
|
|
# if [[ $# -ge 1 ]]; then
|
|
# TOOLCHAIN_PATH="$1"
|
|
# fi
|
|
# if [[ $# -ge 2 ]]; then
|
|
# CROSS_PREFIX="$2"
|
|
# fi
|
|
|
|
local TOOLCHAIN_BIN="${TOOLCHAIN_PATH}/bin"
|
|
|
|
# Display what we're using
|
|
display_alert "AMLOGIC: Toolchain configuration" \
|
|
"TOOLCHAIN_PATH=${TOOLCHAIN_PATH}, CROSS_PREFIX=${CROSS_PREFIX}" "info"
|
|
|
|
# Check if the toolchain exists
|
|
if [[ -d "${TOOLCHAIN_PATH}" ]]; then
|
|
display_alert "AMLOGIC: External toolchain found" "${TOOLCHAIN_PATH}" "info"
|
|
|
|
# Add toolchain bin directory to PATH if not already there
|
|
if [[ ":${PATH}:" != *":${TOOLCHAIN_BIN}:"* ]]; then
|
|
export PATH="${TOOLCHAIN_BIN}:${PATH}"
|
|
display_alert "AMLOGIC: Added toolchain to PATH" "${TOOLCHAIN_BIN}" "info"
|
|
fi
|
|
|
|
# Set cross-compilation environment variables
|
|
# Use existing values if already set, otherwise set to our calculated values
|
|
export CROSS_COMPILE="${CROSS_COMPILE:-${CROSS_PREFIX}-}"
|
|
export CC="${CC:-${CROSS_PREFIX}-gcc}"
|
|
export CXX="${CXX:-${CROSS_PREFIX}-g++}"
|
|
export LD="${LD:-${CROSS_PREFIX}-ld}"
|
|
export AR="${AR:-${CROSS_PREFIX}-ar}"
|
|
export AS="${AS:-${CROSS_PREFIX}-as}"
|
|
export RANLIB="${RANLIB:-${CROSS_PREFIX}-ranlib}"
|
|
export STRIP="${STRIP:-${CROSS_PREFIX}-strip}"
|
|
export OBJCOPY="${OBJCOPY:-${CROSS_PREFIX}-objcopy}"
|
|
export OBJDUMP="${OBJDUMP:-${CROSS_PREFIX}-objdump}"
|
|
export READELF="${READELF:-${CROSS_PREFIX}-readelf}"
|
|
|
|
# Set architecture-specific variables (only if not already set)
|
|
export ARCH="${ARCH:-arm64}"
|
|
export SYSROOT="${SYSROOT:-${TOOLCHAIN_PATH}/${CROSS_PREFIX}}"
|
|
|
|
# Check if the compiler is accessible
|
|
if command -v "${CROSS_PREFIX}-gcc" >/dev/null 2>&1; then
|
|
local gcc_version=$("${CROSS_PREFIX}-gcc" -dumpversion 2>/dev/null || echo "unknown")
|
|
display_alert "AMLOGIC: Toolchain GCC version" "${gcc_version}" "info"
|
|
else
|
|
display_alert "AMLOGIC: WARNING" "Compiler ${CROSS_PREFIX}-gcc not found in PATH" "warn"
|
|
fi
|
|
|
|
# Set these for Armbian build system compatibility (only if not already set)
|
|
export KERNEL_COMPILER="${KERNEL_COMPILER:-${CROSS_PREFIX}-}"
|
|
export UBOOT_COMPILER="${UBOOT_COMPILER:-${CROSS_PREFIX}-}"
|
|
export ATF_COMPILER="${ATF_COMPILER:-${CROSS_PREFIX}-}"
|
|
|
|
display_alert "AMLOGIC: External toolchain configured" \
|
|
"CROSS_COMPILE=${CROSS_COMPILE}, TOOLCHAIN_PATH=${TOOLCHAIN_PATH}" "info"
|
|
else
|
|
display_alert "AMLOGIC: WARNING" \
|
|
"External toolchain not found at ${TOOLCHAIN_PATH}" "warn"
|
|
|
|
# Check if we're using the default or a custom path
|
|
if [[ "${TOOLCHAIN_PATH}" == "${DEFAULT_TOOLCHAIN_PATH}" ]]; then
|
|
display_alert "AMLOGIC: WARNING" \
|
|
"Default toolchain not found, will use system toolchain" "warn"
|
|
else
|
|
display_alert "AMLOGIC: WARNING" \
|
|
"Custom toolchain specified but not found, check TOOLCHAIN_PATH environment variable" "warn"
|
|
fi
|
|
fi
|
|
|
|
# Log final configuration for debugging
|
|
display_alert "AMLOGIC: Final toolchain configuration" \
|
|
"PATH includes: $(echo ${PATH} | tr ':' '\n' | grep -E "(toolchain|gcc|bin)" | head -5 | tr '\n' ', ')" "debug"
|
|
}
|
|
# Display configuration info on load
|
|
display_amlbian_config_info
|
|
set_external_toolchain
|
|
|
|
# End of amlogic_common.inc
|