Enable AArch64 builds for Raspberry Pi 3 and 4

This commit is contained in:
Dale Whinham committed 2020-11-22 23:16:44 +00:00
1 parent 5a5663adca
commit 8bf865008b
5 files changed
+110 -48

No files matched your search

+52 -24
View File
@@ -2,6 +2,9 @@ name: mt32-pi CI
on: [push, pull_request]
env:
toolchain-version: 9.2-2019.12
jobs:
build:
runs-on: ubuntu-latest
@@ -9,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
board: [pi2, pi3, pi4]
board: [pi2, pi3-64, pi4-64]
env:
toolchain-version: 9.2-2019.12
@@ -18,22 +21,29 @@ jobs:
with:
submodules: recursive
- name: Cache ARM toolchain
- name: Cache ARM toolchains
id: cache-toolchains
uses: actions/cache@v2
with:
path: ~/gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi
key: cache-arm-toolchain-${{ env.toolchain-version }}
path: |
~/gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi
~/gcc-arm-${{ env.toolchain-version }}-x86_64-aarch64-none-elf
key: cache-arm-toolchains-${{ env.toolchain-version }}
- name: Install toolchain if not retrieved from cache
- name: Install toolchains if not retrieved from cache
if: steps.cache-toolchains.outputs.cache-hit != 'true'
run: |
if [ ! -d ~/gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi ]; then
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-a/${{ env.toolchain-version }}/binrel/gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi.tar.xz
tar -xf gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi.tar.xz -C ~
rm gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi.tar.xz
fi
for triplet in arm-none-eabi aarch64-none-elf; do
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-a/${{ env.toolchain-version }}/binrel/gcc-arm-${{ env.toolchain-version }}-x86_64-${triplet}.tar.xz
tar -xf gcc-arm-${{ env.toolchain-version }}-x86_64-${triplet}.tar.xz -C ~
rm gcc-arm-${{ env.toolchain-version }}-x86_64-${triplet}.tar.xz
done
- name: Update PATH
run: echo "$HOME/gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi/bin" >> $GITHUB_PATH
run: |
for triplet in arm-none-eabi aarch64-none-elf; do
echo "$HOME/gcc-arm-${{ env.toolchain-version }}-x86_64-${triplet}/bin" >> $GITHUB_PATH
done
- name: Build
run: make -j BOARD=${{ matrix.board }}
@@ -56,9 +66,11 @@ jobs:
submodules: recursive
- name: Cache boot files
id: cache-boot-files
uses: actions/cache@v2
with:
path: |
sdcard/armstub8-rpi4.bin
sdcard/bcm2711-rpi-4-b.dtb
sdcard/bootcode.bin
sdcard/COPYING.linux
@@ -69,20 +81,36 @@ jobs:
sdcard/start4cd.elf
key: cache-boot-files-${{ hashFiles(join(env.boot-home, '/Makefile')) }}
- name: Download boot files if not retrieved from cache
- name: Cache ARM toolchains
if: steps.cache-boot-files.outputs.cache-hit != 'true'
uses: actions/cache@v2
with:
path: |
~/gcc-arm-${{ env.toolchain-version }}-x86_64-arm-none-eabi
~/gcc-arm-${{ env.toolchain-version }}-x86_64-aarch64-none-elf
key: cache-arm-toolchains-${{ env.toolchain-version }}
- name: Update PATH
if: steps.cache-boot-files.outputs.cache-hit != 'true'
run: |
if [ ! -f sdcard/bootcode.bin ]; then
make -C ${{ env.boot-home }}
cp ${{ env.boot-home }}/bcm2711-rpi-4-b.dtb \
${{ env.boot-home }}/bootcode.bin \
${{ env.boot-home }}/COPYING.linux \
${{ env.boot-home }}/fixup_cd.dat \
${{ env.boot-home }}/fixup4cd.dat \
${{ env.boot-home }}/LICENCE.broadcom \
${{ env.boot-home }}/start_cd.elf \
${{ env.boot-home }}/start4cd.elf \
sdcard
fi
for triplet in arm-none-eabi aarch64-none-elf; do
echo "$HOME/gcc-arm-${{ env.toolchain-version }}-x86_64-${triplet}/bin" >> $GITHUB_PATH
done
- name: Download boot files and build ARM stub if not retrieved from cache
if: steps.cache-boot-files.outputs.cache-hit != 'true'
run: |
make -C ${{ env.boot-home }} firmware armstub64
cp ${{ env.boot-home }}/armstub8-rpi4.bin \
${{ env.boot-home }}/bcm2711-rpi-4-b.dtb \
${{ env.boot-home }}/bootcode.bin \
${{ env.boot-home }}/COPYING.linux \
${{ env.boot-home }}/fixup_cd.dat \
${{ env.boot-home }}/fixup4cd.dat \
${{ env.boot-home }}/LICENCE.broadcom \
${{ env.boot-home }}/start_cd.elf \
${{ env.boot-home }}/start4cd.elf \
sdcard
- name: Retrieve built kernels
uses: actions/download-artifact@v2
+38 -1
View File
@@ -2,8 +2,9 @@
# Build configuration
#
# Path to ARM toolchain
# Paths to ARM toolchains
ARM_HOME?=$(HOME)/gcc-arm-9.2-2019.12-x86_64-arm-none-eabi
AARCH64_HOME?=$(HOME)/gcc-arm-9.2-2019.12-x86_64-aarch64-none-elf
# Valid options: pi0, pi2, pi3, pi4, pi4-64
BOARD?=pi4
@@ -17,6 +18,42 @@ USERBAUD?=115200
# Enable section garbage collection
GC_SECTIONS?=0
# Toolchain setup
ifeq ($(BOARD), pi0)
RASPBERRYPI=1
BITS=32
PREFIX=arm-none-eabi-
else ifeq ($(BOARD), pi2)
RASPBERRYPI=2
BITS=32
PREFIX=arm-none-eabi-
else ifeq ($(BOARD), pi3)
RASPBERRYPI=3
BITS=32
PREFIX=arm-none-eabi-
else ifeq ($(BOARD), pi3-64)
RASPBERRYPI=3
BITS=64
PREFIX=aarch64-none-elf-
else ifeq ($(BOARD), pi4)
RASPBERRYPI=4
BITS=32
PREFIX=arm-none-eabi-
else ifeq ($(BOARD), pi4-64)
RASPBERRYPI=4
BITS=64
PREFIX=aarch64-none-elf-
else
$(error Invalid board type "$(BOARD)"; please specify one of [ pi0 | pi2 | pi3 | pi3-64 | pi4 | pi4-64 ])
endif
ifeq ($(PREFIX), arm-none-eabi-)
CMAKE_TOOLCHAIN_FLAGS=-DARM_HOME=$(ARM_HOME) -DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi.cmake
else
CMAKE_TOOLCHAIN_FLAGS=-DAARCH64_HOME=$(AARCH64_HOME) -DCMAKE_TOOLCHAIN_FILE=../cmake/aarch64-none-elf.cmake
endif
# Paths
CIRCLESTDLIBHOME=$(realpath external/circle-stdlib)
CIRCLE_STDLIB_CONFIG=$(CIRCLESTDLIBHOME)/Config.mk
+5 -21
View File
@@ -12,24 +12,8 @@ include Config.mk
#
.ONESHELL:
$(CIRCLE_STDLIB_CONFIG) $(CIRCLE_CONFIG)&:
ifeq ($(BOARD), pi0)
@echo -n "Configuring for Raspberry Pi 0/1"
$(CIRCLESTDLIBHOME)/configure --raspberrypi=1
else ifeq ($(BOARD), pi2)
@echo -n "Configuring for Raspberry Pi 2"
$(CIRCLESTDLIBHOME)/configure --raspberrypi=2
else ifeq ($(BOARD), pi3)
@echo -n "Configuring for Raspberry Pi 3"
$(CIRCLESTDLIBHOME)/configure --raspberrypi=3
else ifeq ($(BOARD), pi4)
@echo -n "Configuring for Raspberry Pi 4"
$(CIRCLESTDLIBHOME)/configure --raspberrypi=4
else ifeq ($(BOARD), pi4-64)
@echo -n "Configuring for Raspberry Pi 4 (64 bit)"
$(CIRCLESTDLIBHOME)/configure --raspberrypi=4 --prefix=aarch64-none-elf
else
$(error Invalid board type "$(BOARD)"; please specify one of [ pi0 | pi2 | pi3 | pi4 | pi4-64 ])
endif
@echo "Configuring for Raspberry Pi $(RASPBERRYPI) ($(BITS) bit)"
$(CIRCLESTDLIBHOME)/configure --raspberrypi=$(RASPBERRYPI) --prefix=$(PREFIX)
# Enable multi-core
echo "DEFINE += -DARM_ALLOW_MULTI_CORE" >> $(CIRCLE_CONFIG)
@@ -48,6 +32,7 @@ circle-stdlib: $(CIRCLESTDLIBHOME)/.done
$(CIRCLESTDLIBHOME)/.done: $(CIRCLE_STDLIB_CONFIG)
@$(MAKE) -C $(CIRCLESTDLIBHOME)
touch $@
#
# Build mt32emu
#
@@ -56,9 +41,8 @@ mt32emu: $(MT32EMUBUILDDIR)/.done
$(MT32EMUBUILDDIR)/.done: $(CIRCLESTDLIBHOME)/.done
@export CFLAGS="$(CFLAGS_FOR_TARGET)"
@export CXXFLAGS="$(CFLAGS_FOR_TARGET)"
@cmake -B $(MT32EMUBUILDDIR) \
-DARM_HOME=$(ARM_HOME) \
-DCMAKE_TOOLCHAIN_FILE=../cmake/arm-none-eabi.cmake \
@cmake -B $(MT32EMUBUILDDIR) \
$(CMAKE_TOOLCHAIN_FLAGS) \
-DCMAKE_CXX_FLAGS_RELEASE="-Ofast" \
-DCMAKE_BUILD_TYPE=Release \
-Dlibmt32emu_C_INTERFACE=FALSE \
+7
View File
@@ -0,0 +1,7 @@
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(CMAKE_C_COMPILER ${AARCH64_HOME}/bin/aarch64-none-elf-gcc)
set(CMAKE_CXX_COMPILER ${AARCH64_HOME}/bin/aarch64-none-elf-g++)
+8 -2
View File
@@ -4,6 +4,12 @@ disable_splash=1
force_eeprom_read=0
gpu_mem=16
# Ensure that the Pi 4 doesn't try to boot the Pi 3-optimized kernel (kernel8-32.img)
# Enable 64-bit mode (AArch64) for Pi 3 and 4
[pi3]
arm_64bit=1
kernel=kernel8.img
[pi4]
kernel=kernel7l.img
arm_64bit=1
armstub=armstub8-rpi4.bin
kernel=kernel8-rpi4.img