mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-12 00:20:43 +01:00
91 lines
3.1 KiB
Bash
Executable file
91 lines
3.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Script to compile Thames DSP kernel on remote board
|
|
# The kernel must be compiled on the TI board due to NFS issues
|
|
|
|
set -e
|
|
|
|
BOARD_IP="192.168.1.29"
|
|
BOARD_USER="tomeu"
|
|
CGT_VERSION="ti-cgt-c7000_5.0.0.LTS"
|
|
CL7X_PATH="/home/tomeu/ti/${CGT_VERSION}/bin/cl7x"
|
|
OFD7X_PATH="/home/tomeu/ti/${CGT_VERSION}/bin/ofd7x"
|
|
KERNEL_SRC="src/gallium/drivers/thames/test_kernel.c"
|
|
KERNEL_BIN="src/gallium/drivers/thames/thames_kernel_bin.h"
|
|
|
|
# MMALib paths on alcachofa (the remote board)
|
|
MMALIB_INC="/home/tomeu/src/ti-processor-sdk-rtos-j722s-evm-09_02_00_05/mmalib_09_02_00_08/ti/mmalib/src"
|
|
MMALIB_LIB="/home/tomeu/src/ti-processor-sdk-rtos-j722s-evm-09_02_00_05/mmalib_09_02_00_08/lib/C7524/release/mmalib_C7524.lib"
|
|
|
|
echo "=== Compiling Thames DSP Kernel with MMALib ==="
|
|
echo "Board: ${BOARD_USER}@${BOARD_IP}"
|
|
echo ""
|
|
|
|
# Copy source to board
|
|
echo "[1/5] Copying test_kernel.c to board..."
|
|
scp "${KERNEL_SRC}" "${BOARD_USER}@${BOARD_IP}:/tmp/test_kernel.c"
|
|
|
|
# Create linker command file on board to ensure proper section placement
|
|
echo "[1.5/5] Creating linker.cmd on board..."
|
|
ssh "${BOARD_USER}@${BOARD_IP}" "cat > /tmp/linker.cmd <<EOF
|
|
MEMORY
|
|
{
|
|
L2SRAM (RWX) : origin = 0x0, length = 0x200000
|
|
}
|
|
SECTIONS
|
|
{
|
|
.text : {
|
|
*(.text.entry)
|
|
*(.text)
|
|
*(.const)
|
|
*(.switch)
|
|
*(.kernel_data)
|
|
*(.data)
|
|
*(.bss)
|
|
} > L2SRAM
|
|
}
|
|
EOF"
|
|
|
|
# Compile and link on board with MMALib
|
|
echo "[2/5] Compiling and linking with cl7x on board (with MMALib)..."
|
|
ssh "${BOARD_USER}@${BOARD_IP}" "cd /tmp && ${CL7X_PATH} -mv7524 --abi=eabi -O0 --c99 \
|
|
-I${MMALIB_INC} \
|
|
-I${MMALIB_INC}/common \
|
|
-I/home/tomeu/ti/${CGT_VERSION}/include \
|
|
test_kernel.c \
|
|
-z \
|
|
-i/home/tomeu/ti/${CGT_VERSION}/lib \
|
|
--reread_libs --warn_sections \
|
|
--rom_model \
|
|
-l${MMALIB_LIB} \
|
|
-l/home/tomeu/src/ti-processor-sdk-rtos-j722s-evm-09_02_00_05/mmalib_09_02_00_08/lib/C7524/release/mmalib_cn_C7524.lib \
|
|
-l/home/tomeu/src/ti-processor-sdk-rtos-j722s-evm-09_02_00_05/mmalib_09_02_00_08/lib/C7524/release/common_C7524.lib \
|
|
-lrts7524_le.lib \
|
|
linker.cmd \
|
|
-o test_kernel.out"
|
|
|
|
|
|
# Copy binary back
|
|
echo "[3/5] Copying test_kernel.out back..."
|
|
scp "${BOARD_USER}@${BOARD_IP}:/tmp/test_kernel.out" /tmp/thames_kernel.out
|
|
|
|
# Extract .text section offset and size using ofd7x
|
|
echo "[4/5] Extracting .text section info with ofd7x..."
|
|
TEXT_INFO=$(ssh "${BOARD_USER}@${BOARD_IP}" "${OFD7X_PATH} -x /tmp/test_kernel.out" | grep -A 10 "sh_name_string>.text<")
|
|
TEXT_OFFSET=$(echo "$TEXT_INFO" | grep "sh_offset>" | sed 's/.*<sh_offset>\(0x[0-9a-f]*\)<.*/\1/')
|
|
TEXT_SIZE=$(echo "$TEXT_INFO" | grep "sh_size>" | sed 's/.*<sh_size>\(0x[0-9a-f]*\)<.*/\1/')
|
|
|
|
echo " .text offset: $TEXT_OFFSET"
|
|
echo " .text size: $TEXT_SIZE"
|
|
|
|
# Generate header with xxd
|
|
echo "[5/5] Generating thames_kernel_bin.h with xxd..."
|
|
xxd -i -s "$TEXT_OFFSET" -l "$TEXT_SIZE" /tmp/thames_kernel.out > "${KERNEL_BIN}"
|
|
|
|
echo ""
|
|
echo "✓ Kernel compiled successfully!"
|
|
echo " Binary header: ${KERNEL_BIN}"
|
|
echo " .text section: offset=$TEXT_OFFSET size=$TEXT_SIZE"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Rebuild Mesa: ninja -C build"
|
|
echo " 2. Test on board: sh thames-run.sh"
|