add initial loong64 support

This commit is contained in:
Jianfeng Liu 2025-07-24 09:39:42 +08:00
parent dda6950c34
commit fb363e8829
17 changed files with 5240 additions and 6 deletions

View File

@ -0,0 +1,5 @@
# loong64 via UEFI for all UEFI-enabled boards
export BOARD_NAME="UEFI loong64"
export BOARDFAMILY="uefi-loong64"
export KERNEL_TARGET="current,edge"
export SERIALCON="ttyS0,115200"

View File

@ -1 +1 @@
arm64,armhf,riscv64,amd64
arm64,armhf,riscv64,amd64,loong64

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
debian-ports-archive-keyring

View File

@ -0,0 +1,16 @@
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
#
# Important: LINUXFAMILY and ARCH are defined _before_ including the common family include
declare -g UBOOT_USE_GCC="none"
declare -g UEFI_GRUB_TERMINAL="gfxterm"
declare -g LINUXFAMILY="loong64"
declare -g ARCH="loong64"
# shellcheck source=config/sources/families/include/uefi_common.inc
source "${BASH_SOURCE%/*}/include/uefi_common.inc"
enable_extension "grub"

View File

@ -0,0 +1,33 @@
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2013-2023 Igor Pecovnik, igor@armbian.com
#
# This file is a part of the Armbian Build Framework
# https://github.com/armbian/build/
#
# 'common.conf' is already sourced when this arch is sourced.
declare -g ARCH='loong64'
declare -g ARCHITECTURE='loongarch'
declare -g QEMU_BINARY='qemu-loongarch64-static'
declare -g IMAGE_PARTITION_TABLE='gpt'
declare -g SKIP_EXTERNAL_TOOLCHAINS='yes'
declare -g KERNEL_SRC_ARCH='loongarch'
# Linux root has a different Type-UUID for every architecture
# See https://uapi-group.org/specifications/specs/discoverable_partitions_specification/
declare -g PARTITION_TYPE_UUID_ROOT="77055800-792c-4f94-b39a-98c91b762bb6" # "Linux root (LoongArch 64-bit)"
# Defaults, if not set by board or family.
declare -g KERNEL_IMAGE_TYPE="${KERNEL_IMAGE_TYPE:-"vmlinux"}"
declare -g KERNEL_INSTALL_TYPE="${KERNEL_INSTALL_TYPE:-"install"}"
declare -g NAME_KERNEL="${NAME_KERNEL:-"vmlinux"}"
declare -g NAME_INITRD="${NAME_INITRD:-"initrd.img"}"
[[ -z $KERNEL_COMPILER ]] && KERNEL_COMPILER='loongarch64-linux-gnu-'
[[ -z $UBOOT_COMPILER ]] && UBOOT_COMPILER='loongarch64-linux-gnu-'
[[ -z $KERNEL_USE_GCC ]] && KERNEL_USE_GCC='> 13.0'
[[ -z $UBOOT_USE_GCC ]] && UBOOT_USE_GCC='> 13.0'
true # make sure to exit with 0 status; this protects against shortcircuits etc above.

View File

@ -38,11 +38,14 @@ function extension_prepare_config__prepare_grub_standard() {
else
packages+=("grub-efi-${ARCH}")
fi
else
packages+=("grub-efi-${ARCH}")
fi
if [[ "${ARCH}" == "arm64" ]]; then
packages+=("grub-efi-${ARCH}")
declare -g UEFI_GRUB_TARGET="arm64-efi" # Default for arm64-efi
elif [[ "${ARCH}" == "loong64" ]]; then
declare -g UEFI_GRUB_TARGET="loongarch64-efi"
fi
fi

View File

@ -385,6 +385,7 @@ function kernel_package_callback_linux_headers() {
[[ "${SRC_ARCH}" == "amd64" ]] && SRC_ARCH="x86"
[[ "${SRC_ARCH}" == "armhf" ]] && SRC_ARCH="arm"
[[ "${SRC_ARCH}" == "riscv64" ]] && SRC_ARCH="riscv"
[[ "${SRC_ARCH}" == "loong64" ]] && SRC_ARCH="loongarch"
# @TODO: added KERNEL_SRC_ARCH to each arch'es .config file; let's make sure they're sane. Just use KERNEL_SRC_ARCH after confirmed.
# Lets check and warn if it isn't. If warns don't popup over time we remove and just use ARCHITECTURE later.
if [[ "${SRC_ARCH}" != "${KERNEL_SRC_ARCH}" ]]; then

View File

@ -318,7 +318,8 @@ function do_main_configuration() {
esac
# enable APA extension for Debian Unstable release
[ "$RELEASE" = "sid" ] && enable_extension "apa"
# loong64 is not supported now
[ "$RELEASE" = "sid" ] && [ "$ARCH" != "loong64" ] && enable_extension "apa"
## Extensions: at this point we've sourced all the config files that will be used,
## and (hopefully) not yet invoked any extension methods. So this is the perfect
@ -370,6 +371,8 @@ function do_extra_configuration() {
fi
DEBIAN_MIRROR='deb.debian.org/debian'
# loong64 is using debian-ports repo now
[[ "${ARCH}" == "loong64" ]] && DEBIAN_MIRROR='deb.debian.org/debian-ports'
DEBIAN_SECURITY='security.debian.org/'
[[ "${ARCH}" == "amd64" ]] &&
UBUNTU_MIRROR='archive.ubuntu.com/ubuntu/' ||

View File

@ -39,6 +39,8 @@ function apt_find_upstream_package_version_and_download_url() {
fi
declare base_down_url="http://${mirror_with_slash}pool/main/${first_letter_of_sought_package_name}/${sought_package_name}"
# loong64 is using debian-ports repo, and download from pool-loong64
[[ "${ARCH}" == "loong64" ]] && declare base_down_url="http://${mirror_with_slash}pool-loong64/main/${first_letter_of_sought_package_name}/${sought_package_name}"
# get json with latest pacakge info generated by GHA
case "${GITHUB_MIRROR}" in

View File

@ -52,6 +52,11 @@ function run_tool_oras() {
ORAS_ARCH="riscv64"
ORAS_VERSION="1.2.0-beta.1" # Only v1.2.0-beta.1+ has risv64 support
;;
*loongarch64*)
ORAS_ARCH="loong64"
ORAS_VERSION="1.3.0-beta.3-loong64" # Only v1.3.0-beta.3-loong64+ has loong64 support
ORAS_REPO="amazingfate" # This is my fork repo, we can delete it if oras releases official loong64 binary in the future
;;
*)
exit_with_error "unknown arch: $MACHINE"
;;
@ -59,7 +64,7 @@ function run_tool_oras() {
declare ORAS_FN="oras_${ORAS_VERSION}_${ORAS_OS}_${ORAS_ARCH}"
declare ORAS_FN_TARXZ="${ORAS_FN}.tar.gz"
declare DOWN_URL="${GITHUB_SOURCE:-"https://github.com"}/oras-project/oras/releases/download/v${ORAS_VERSION}/${ORAS_FN_TARXZ}"
declare DOWN_URL="${GITHUB_SOURCE:-"https://github.com"}/${ORAS_REPO:-"oras-project"}/oras/releases/download/v${ORAS_VERSION}/${ORAS_FN_TARXZ}"
declare ORAS_BIN="${DIR_ORAS}/${ORAS_FN}"
declare ACTUAL_VERSION

View File

@ -92,6 +92,11 @@ function run_tool_shellcheck() {
display_alert "No RISC-V riscv64 support for SHELLCHECK" "SHELLCHECK will not run" "wrn"
return 0
;;
*loongarch64*)
# check https://github.com/koalaman/shellcheck in the future, build might be possible
display_alert "No LoongArch support for SHELLCHECK" "SHELLCHECK will not run" "wrn"
return 0
;;
*)
exit_with_error "unknown arch: $MACHINE"
;;

View File

@ -18,7 +18,7 @@ function obtain_and_check_host_release_and_arch() {
case "${HOSTARCH}" in
amd64 | arm64) ;; # officially supported
armhf | riscv64) # experimental
armhf | riscv64 | loong64) # experimental
display_alert "EXPERIMENTAL build host support" "${HOSTARCH}" "wrn"
;;
*)

View File

@ -269,6 +269,11 @@ function adaptative_prepare_host_dependencies() {
host_dependencies+=("debian-archive-keyring")
fi
if [[ "${wanted_arch}" == "loong64" || "${wanted_arch}" == "all" ]]; then
host_dependencies+=("gcc-loongarch64-linux-gnu") # crossbuild-essential-loongarch64 is not even available "yet"
host_dependencies+=("debian-ports-archive-keyring")
fi
if [[ "${wanted_arch}" != "amd64" ]]; then
host_dependencies+=("libc6-amd64-cross") # Support for running x86 binaries (under qemu on other arches)
fi

View File

@ -121,13 +121,19 @@ function create_sources_list_and_deploy_repo_key() {
sid | unstable)
distro="debian"
if [[ "${ARCH}" == loong64 ]]; then
# loong64 is using debian-ports repo, we can change it to default after debian supports it officially
keyring_filename=/usr/share/keyrings/debian-ports-archive-keyring.gpg
else
keyring_filename=/usr/share/keyrings/debian-archive-keyring.gpg
fi
# sid is permanent unstable development and has no such thing as updates or security
cat <<- EOF > "${basedir}/etc/apt/sources.list.d/${distro}.sources"
Types: deb
URIs: http://${DEBIAN_MIRROR}
Suites: ${release}
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Signed-By: ${keyring_filename}
EOF
# Required for some packages on riscv64.

View File

@ -98,6 +98,8 @@ function create_new_rootfs_cache_via_debootstrap() {
"'--components=${AGGREGATED_DEBOOTSTRAP_COMPONENTS_COMMA}'" # from aggregation.py
)
# This is necessary to debootstrap from a non-official repo
[[ $ARCH == loong64 ]] && deboostrap_arguments+=("--keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg")
# Small detour for local apt caching option.
local_apt_deb_cache_prepare "before debootstrap" # sets LOCAL_APT_CACHE_INFO
if [[ "${LOCAL_APT_CACHE_INFO[USE]}" == "yes" ]]; then