Skip to content

Commit 73b17ae

Browse files
authored
Merge pull request #464 from sonroyaalmerol/qemu-compatibility-mode
Better compatibility for ARM64 hosts
2 parents 03fa6b8 + acff203 commit 73b17ae

File tree

6 files changed

+71
-9
lines changed

6 files changed

+71
-9
lines changed

Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN wget -q https://github.com/gorcon/rcon-cli/archive/refs/tags/v${RCON_VERSION
2020
FROM cm2network/steamcmd:root as base-amd64
2121
# Ignoring --platform=arm64 as this is required for the multi-arch build to continue to work on amd64 hosts
2222
# hadolint ignore=DL3029
23-
FROM --platform=arm64 thijsvanloef/steamcmd-arm64:root as base-arm64
23+
FROM --platform=arm64 sonroyaalmerol/steamcmd-arm64:root-2024-02-29 as base-arm64
2424

2525
ARG TARGETARCH
2626
# Ignoring the lack of a tag here because the tag is defined in the above FROM lines
@@ -109,6 +109,7 @@ ENV HOME=/home/steam \
109109
DISCORD_POST_SHUTDOWN_MESSAGE="Server has been stopped!" \
110110
ENABLE_PLAYER_LOGGING=true \
111111
PLAYER_LOGGING_POLL_PERIOD=5 \
112+
ARM_COMPATIBILITY_MODE=false \
112113
DISABLE_GENERATE_ENGINE=true
113114

114115
COPY ./scripts /home/steam/server/

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ It is highly recommended you set the following environment values before startin
244244
| DISABLE_GENERATE_ENGINE | Whether to automatically generate the Engine.ini | true | true/false |
245245
| ENABLE_PLAYER_LOGGING | Enables Logging and announcing when players join and leave | true | true/false |
246246
| PLAYER_LOGGING_POLL_PERIOD | Polling period (in seconds) to check for players who have joined or left | 5 | !0 |
247+
| ARM_COMPATIBILITY_MODE | Switches the compatibility layer from Box86 to QEMU when executing steamcmd for server updates. This setting is only applicable for ARM64 hosts. | false | true/false |
247248

248249
*highly recommended to set
249250

docusaurus/docs/getting-started/configuration/server-settings.md

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ It is highly recommended you set the following environment values before startin
5959
| DISABLE_GENERATE_ENGINE | Whether to automatically generate the Engine.ini | true | true/false |
6060
| ENABLE_PLAYER_LOGGING | Enables Logging and announcing when players join and leave | true | true/false |
6161
| PLAYER_LOGGING_POLL_PERIOD | Polling period (in seconds) to check for players who have joined or left | 5 | !0 |
62+
| ARM_COMPATIBILITY_MODE | Switches the compatibility layer from Box86 to QEMU when executing steamcmd for server updates. This setting is only applicable for ARM64 hosts. | false | true/false |
6263

6364
*highly recommended to set
6465

docusaurus/docs/known-issues/known-issues.md

+32
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,38 @@ it means that you'll need to look at the following:
5656
* Firewall settings, make sure that you allow port 8211/udp and 27015/udp through your firewall
5757
* Make sure you've correctly port forwarded your 8211/udp 27015/udp
5858

59+
## Only ARM64 hosts with 4k page size is supported
60+
61+
This error occurs when the container detects that the host kernel does not have a 4k page size,
62+
which is required for the emulation used for ARM64 architecture. The container relies on this specific page
63+
size for proper execution.
64+
65+
If the host kernel does not have a 4k page size, you have a couple of alternatives:
66+
67+
* **Download server files in a different machine**: The 4k page size limitation is only applicable for steamcmd
68+
ARM emulation. You may try initializing the container in a fully supported machine (AMD64 or ARM64 with 4k page size)
69+
and let it download the server files with `UPDATE_ON_BOOT` enabled. Make sure to disable `UPDATE_ON_BOOT` in the
70+
problematic machine to prevent steamcmd from executing.
71+
72+
* **Change/Modify Kernel**: You can consider changing the kernel of your host machine to one that supports a 4k page size.
73+
* The Raspberry Pi 5 with Raspberry Pi OS has an easy [switch](https://github.com/raspberrypi/bookworm-feedback/issues/107#issuecomment-1773810662).
74+
75+
* **Switch OS**: Another option is to switch OS to ones shipped with 4k page size kernels.
76+
* Debian and Ubuntu are known working Linux distros.
77+
78+
* **Run within a VM**: Another option is to run the container within a virtual machine (VM) that is configured
79+
with a kernel supporting a 4k page size. By doing so, you can ensure compatibility and proper execution of the
80+
container.
81+
82+
## /usr/local/bin/box86: cannot execute binary file: Exec format error (ARM64 hosts)
83+
84+
This means that the Docker host is unable to run AArch32 binaries such as Box86 without an additional
85+
compatibility layer which is the case for Apple Silicon.
86+
87+
Docker Desktop solves this by running its containers inside a VM (QEMU) with a compatible kernel.
88+
However, if you're unable to use Docker Desktop, then try setting `ARM_COMPATIBILITY_MODE` to `true`.
89+
This will switch the container from using Box86 to QEMU when running steamcmd.
90+
5991
## FAQ
6092

6193
[A useful FAQ that gets updated regularly](https://gist.github.com/Toakan/3c78a577c21a21fcc5fa917f3021d70e#file-palworld-server-faq-community-md)

scripts/helper_install.sh

+10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ UpdateRequired() {
113113
}
114114

115115
InstallServer() {
116+
# Get the architecture using dpkg
117+
architecture=$(dpkg --print-architecture)
118+
119+
# Get host kernel page size
120+
kernel_page_size=$(getconf PAGESIZE)
121+
122+
# Check kernel page size for arm64 hosts before running steamcmd
123+
if [ "$architecture" == "arm64" ] && [ "$kernel_page_size" != "4096" ]; then
124+
LogWarn "WARNING: Only ARM64 hosts with 4k page size is supported when running steamcmd. Expect server installation to fail."
125+
fi
116126

117127
if [ -z "${TARGET_MANIFEST_ID}" ]; then
118128
DiscordMessage "Install" "${DISCORD_PRE_UPDATE_BOOT_MESSAGE}" "in-progress"

scripts/start.sh

+25-8
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ cd /palworld || exit
1515
# Get the architecture using dpkg
1616
architecture=$(dpkg --print-architecture)
1717

18-
# Get host kernel page size
19-
kernel_page_size=$(getconf PAGESIZE)
18+
if [ "$architecture" == "arm64" ] && [ "${ARM_COMPATIBILITY_MODE,,}" = true ]; then
19+
LogInfo "ARM compatibility mode enabled"
20+
export DEBUGGER="/usr/bin/qemu-i386-static"
2021

21-
# Check kernel page size for arm64 hosts before running steamcmdac
22-
if [ "$architecture" == "arm64" ] && [ "$kernel_page_size" != "4096" ]; then
23-
LogError "Only ARM64 hosts with 4k page size is supported."
24-
exit 1
22+
# Arbitrary number to avoid CPU_MHZ warning due to qemu and steamcmd
23+
export CPU_MHZ=2000
2524
fi
2625

2726
IsInstalled
@@ -46,8 +45,26 @@ fi
4645
if [ "$architecture" == "arm64" ]; then
4746
# create an arm64 version of ./PalServer.sh
4847
cp ./PalServer.sh ./PalServer-arm64.sh
49-
# shellcheck disable=SC2016
50-
sed -i 's|\("$UE_PROJECT_ROOT\/Pal\/Binaries\/Linux\/PalServer-Linux-Test" Pal "$@"\)|LD_LIBRARY_PATH=/home/steam/steamcmd/linux64:$LD_LIBRARY_PATH box64 \1|' ./PalServer-arm64.sh
48+
49+
pagesize=$(getconf PAGESIZE)
50+
box64_binary="box64"
51+
52+
case $pagesize in
53+
8192)
54+
LogInfo "Using Box64 for 8k pagesize"
55+
box64_binary="box64-8k"
56+
;;
57+
16384)
58+
LogInfo "Using Box64 for 16k pagesize"
59+
box64_binary="box64-16k"
60+
;;
61+
65536)
62+
LogInfo "Using Box64 for 64k pagesize"
63+
box64_binary="box64-64k"
64+
;;
65+
esac
66+
67+
sed -i "s|\(\"\$UE_PROJECT_ROOT\/Pal\/Binaries\/Linux\/PalServer-Linux-Test\" Pal \"\$@\"\)|LD_LIBRARY_PATH=/home/steam/steamcmd/linux64:\$LD_LIBRARY_PATH $box64_binary \1|" ./PalServer-arm64.sh
5168
chmod +x ./PalServer-arm64.sh
5269
STARTCOMMAND=("./PalServer-arm64.sh")
5370
else

0 commit comments

Comments
 (0)