Working Raspberry Pi support.
This commit is contained in:
parent
e3f0a7d76b
commit
d420e08255
6 changed files with 241 additions and 19 deletions
48
cmake/aarch64-rpi3-linux-gnu.cmake
Normal file
48
cmake/aarch64-rpi3-linux-gnu.cmake
Normal file
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# Kangaroo Punch Toolchains
|
||||
# Copyright 2023-2024 Scott Duensing <scott@kangaroopunch.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the “Software”), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/kangaroo-getconf.cmake)
|
||||
|
||||
kangaroo_getconf(SYSROOT)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR aarch64)
|
||||
|
||||
set(triple aarch64-rpi3-linux-gnu)
|
||||
|
||||
set(CMAKE_C_COMPILER aarch64-rpi3-linux-gnu-gcc)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER aarch64-rpi3-linux-gnu-c++)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
|
||||
#set(CMAKE_C_FLAGS "--sysroot ${SYSROOT}")
|
||||
#set(CMAKE_CXX_FLAGS "--sysroot ${SYSROOT}")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(KANGAROO_OS pi)
|
||||
set(KANGAROO_ARCH aarch64)
|
|
@ -22,22 +22,11 @@
|
|||
#
|
||||
|
||||
|
||||
macro(osxcross_getconf VAR)
|
||||
if(NOT ${VAR})
|
||||
set(${VAR} "$ENV{${VAR}}")
|
||||
if(${VAR})
|
||||
set(${VAR} "${${VAR}}" CACHE STRING "${VAR}")
|
||||
message(STATUS "Found ${VAR}: ${${VAR}}")
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot determine \"${VAR}\"")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/kangaroo-getconf.cmake)
|
||||
|
||||
|
||||
osxcross_getconf(OSXCROSS_TARGET_DIR)
|
||||
osxcross_getconf(OSXCROSS_TARGET)
|
||||
osxcross_getconf(OSXCROSS_SDK)
|
||||
kangaroo_getconf(OSXCROSS_TARGET_DIR)
|
||||
kangaroo_getconf(OSXCROSS_TARGET)
|
||||
kangaroo_getconf(OSXCROSS_SDK)
|
||||
|
||||
set(OSXCROSS_LOCATION $ENV{OSXCROSS_LOCATION})
|
||||
set(CMAKE_SYSTEM_NAME "Darwin")
|
||||
|
|
48
cmake/armv6-rpi-linux-gnueabihf.cmake
Normal file
48
cmake/armv6-rpi-linux-gnueabihf.cmake
Normal file
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# Kangaroo Punch Toolchains
|
||||
# Copyright 2023-2024 Scott Duensing <scott@kangaroopunch.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the “Software”), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/kangaroo-getconf.cmake)
|
||||
|
||||
kangaroo_getconf(SYSROOT)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv6)
|
||||
|
||||
set(triple armv6-rpi-linux-gnueabihf)
|
||||
|
||||
set(CMAKE_C_COMPILER armv6-rpi-linux-gnueabihf-gcc)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER armv6-rpi-linux-gnueabihf-c++)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
|
||||
#set(CMAKE_C_FLAGS "--sysroot ${SYSROOT}")
|
||||
#set(CMAKE_CXX_FLAGS "--sysroot ${SYSROOT}")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(KANGAROO_OS pi)
|
||||
set(KANGAROO_ARCH armv6)
|
48
cmake/armv8-rpi3-linux-gnueabihf.cmake
Normal file
48
cmake/armv8-rpi3-linux-gnueabihf.cmake
Normal file
|
@ -0,0 +1,48 @@
|
|||
#
|
||||
# Kangaroo Punch Toolchains
|
||||
# Copyright 2023-2024 Scott Duensing <scott@kangaroopunch.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the “Software”), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/kangaroo-getconf.cmake)
|
||||
|
||||
kangaroo_getconf(SYSROOT)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR armv8)
|
||||
|
||||
set(triple armv8-rpi3-linux-gnueabihf)
|
||||
|
||||
set(CMAKE_C_COMPILER armv8-rpi3-linux-gnueabihf-gcc)
|
||||
set(CMAKE_C_COMPILER_TARGET ${triple})
|
||||
set(CMAKE_CXX_COMPILER armv8-rpi3-linux-gnueabihf-c++)
|
||||
set(CMAKE_CXX_COMPILER_TARGET ${triple})
|
||||
|
||||
#set(CMAKE_C_FLAGS "--sysroot ${SYSROOT}")
|
||||
#set(CMAKE_CXX_FLAGS "--sysroot ${SYSROOT}")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
set(KANGAROO_OS pi)
|
||||
set(KANGAROO_ARCH armv8)
|
35
cmake/kangaroo-getconf.cmake
Normal file
35
cmake/kangaroo-getconf.cmake
Normal file
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# Kangaroo Punch Toolchains
|
||||
# Copyright 2023-2024 Scott Duensing <scott@kangaroopunch.com>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the “Software”), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
# IN THE SOFTWARE.
|
||||
#
|
||||
|
||||
|
||||
macro(kangaroo_getconf VAR)
|
||||
if(NOT ${VAR})
|
||||
set(${VAR} "$ENV{${VAR}}")
|
||||
if(${VAR})
|
||||
set(${VAR} "${${VAR}}" CACHE STRING "${VAR}")
|
||||
message(STATUS "Found ${VAR}: ${${VAR}}")
|
||||
else()
|
||||
message(FATAL_ERROR "Cannot determine \"${VAR}\"")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
|
@ -37,6 +37,8 @@ TC_G_SCRIPT=$(basename ${TC_G_SCRIPT_PATH})
|
|||
|
||||
|
||||
TC_G_PIURL=https://github.com/tttapa/docker-arm-cross-toolchain/releases/latest/download/x-tools-
|
||||
TC_G_PI64=https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2023-12-11/2023-12-11-raspios-bookworm-arm64-lite.img.xz
|
||||
TC_G_PI32=https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2023-12-11/2023-12-11-raspios-bookworm-armhf-lite.img.xz
|
||||
|
||||
|
||||
function buildMacOSXToolchain() {
|
||||
|
@ -113,6 +115,49 @@ NO_GCC
|
|||
}
|
||||
|
||||
|
||||
function build_pi_sysroot() {
|
||||
local BITS=$1
|
||||
local OS=
|
||||
local IMAGE=
|
||||
local START=
|
||||
local SYSROOT=../x-tools/sysroot-pi${BITS}
|
||||
|
||||
mkdir -p work
|
||||
pushd work
|
||||
if [[ ! -f sysroot-relativelinks.py ]]; then
|
||||
wget https://raw.githubusercontent.com/riscv/riscv-poky/master/scripts/sysroot-relativelinks.py
|
||||
fi
|
||||
if [[ "${BITS}" == "64" ]]; then
|
||||
OS=${TC_G_PI64}
|
||||
else
|
||||
OS=${TC_G_PI32}
|
||||
fi
|
||||
IMAGE=$(basename ${OS})
|
||||
if [[ ! -f $(basename ${OS} .xz) ]]; then
|
||||
wget ${OS}
|
||||
unxz ${IMAGE}
|
||||
fi
|
||||
IMAGE=$(basename ${IMAGE} .xz)
|
||||
START=$(fdisk -l ${IMAGE} | grep Linux | awk '{ print $2 }')
|
||||
START=$(( 512 * START ))
|
||||
mkdir -p ${SYSROOT}
|
||||
mkdir -p mnt
|
||||
sudo mount -t ext4 -o loop,offset=${START} ${IMAGE} mnt
|
||||
rsync -avz mnt/* ${SYSROOT} || true
|
||||
#rsync -avz mnt/lib ${SYSROOT}
|
||||
#rsync -avz mnt/usr/include ${SYSROOT}/usr
|
||||
#rsync -avz mnt/usr/lib ${SYSROOT}/usr
|
||||
sudo umount mnt
|
||||
python3 ./sysroot-relativelinks.py ${SYSROOT}
|
||||
if [[ "${BITS}" == "64" ]]; then
|
||||
cp -f $(which qemu-aarch64-static) ${SYSROOT}/usr/bin/.
|
||||
else
|
||||
cp -f $(which qemu-arm-static) ${SYSROOT}/usr/bin/.
|
||||
fi
|
||||
popd
|
||||
}
|
||||
|
||||
|
||||
function install_x86_64_linux() {
|
||||
# Required tools for Linux x86_64. These should always be installed.
|
||||
sudo apt-get install -y \
|
||||
|
@ -159,22 +204,22 @@ function install_x86_windows() {
|
|||
|
||||
function install_aarch64_pi() {
|
||||
# Raspberry Pi, aarch64.
|
||||
wget -O- ${TC_G_PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
|
||||
#***TODO*** sysroot
|
||||
# wget -O- ${TC_G_PIURL}aarch64-rpi3-linux-gnu.tar.xz | tar xJ
|
||||
build_pi_sysroot 64
|
||||
}
|
||||
|
||||
|
||||
function install_armv6_pi() {
|
||||
# Raspberry Pi, armv6.
|
||||
wget -O- ${TC_G_PIURL}armv6-rpi-linux-gnueabihf.tar.xz | tar xJ
|
||||
#***TODO*** sysroot
|
||||
build_pi_sysroot 32
|
||||
}
|
||||
|
||||
|
||||
function install_armv8_pi() {
|
||||
# Raspberry Pi, armv8.
|
||||
wget -O- ${TC_G_PIURL}armv8-rpi3-linux-gnueabihf.tar.xz | tar xJ
|
||||
#***TODO*** sysroot
|
||||
build_pi_sysroot 32
|
||||
}
|
||||
|
||||
|
||||
|
@ -268,12 +313,15 @@ function use_toolchain() {
|
|||
case "${ARCH}" in
|
||||
aarch64)
|
||||
TRIPLE="aarch64-rpi3-linux-gnu"
|
||||
echo "export SYSROOT=${TC_G_SCRIPT_DIR}/x-tools/sysroot-pi64"
|
||||
;;
|
||||
armv6)
|
||||
TRIPLE="armv6-rpi-linux-gnueabihf"
|
||||
echo "export SYSROOT=${TC_G_SCRIPT_DIR}/x-tools/sysroot-pi64"
|
||||
;;
|
||||
armv8)
|
||||
TRIPLE="armv8-rpi3-linux-gnueabihf"
|
||||
echo "export SYSROOT=${TC_G_SCRIPT_DIR}/x-tools/sysroot-pi64"
|
||||
;;
|
||||
esac
|
||||
CROSS_OS="linux"
|
||||
|
@ -320,6 +368,7 @@ COLS=2
|
|||
ROWS=11
|
||||
row=0
|
||||
declare -A PLATFORMS=()
|
||||
# List of ARCHs List of PLATs
|
||||
PLATFORMS[0]="x86_64"; PLATFORMS[1]="linux"
|
||||
PLATFORMS[2]="x86"; PLATFORMS[3]="linux"
|
||||
PLATFORMS[4]="x86_64"; PLATFORMS[5]="windows"
|
||||
|
@ -333,6 +382,11 @@ PLATFORMS[18]="aarch64"; PLATFORMS[19]="macos"
|
|||
PLATFORMS[20]="x86"; PLATFORMS[21]="dos"
|
||||
|
||||
if [[ "${MODE}" == "install" ]]; then
|
||||
# We need some more packages for Pi work.
|
||||
if [[ "${PLAT}" == "pi" ]]; then
|
||||
sudo apt-get -y install qemu-user-static
|
||||
fi
|
||||
|
||||
# Install all toolchains.
|
||||
if [[ "${ARCH}" == "all" && "${PLAT}" == "all" ]]; then
|
||||
HELP=0
|
||||
|
|
Loading…
Add table
Reference in a new issue