Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ SerialPrograms/bin/
discord_social_sdk_win/
discord_partner_sdk.dll
3rdPartyBinaries/discord_social_sdk_mac/
3rdPartyBinaries/discord_social_sdk_linux/
3rdPartyBinaries/onnxruntime-osx-arm64-*/
3rdPartyBinaries/onnxruntime-osx-x86_64-*/

Expand Down
Binary file added 3rdParty/sdbus-cpp/lib/libsdbus-c++-aarch64.a
Binary file not shown.
2 changes: 1 addition & 1 deletion Common/Cpp/CpuId/CpuId.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#elif _M_IX86 || _M_X64 || __i386__ || __x86_64__
#define PA_ARCH_x86 1
#include "CpuId_x86.h"
#elif __arm64__
#elif __arm64__ || __aarch64__
#define PA_ARCH_arm64 1
#include "CpuId_arm64.h"
#else
Expand Down
10 changes: 9 additions & 1 deletion Common/Cpp/CpuId/CpuId_arm64.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@


#include <stdint.h>
#ifdef __APPLE__
#include <sys/sysctl.h>
#endif
#include <iostream>

#include "CpuId.h"
Expand All @@ -18,9 +20,10 @@ const char* PA_ARCH_STRING = "arm64";

uint64_t detect_NEON()
{
#ifdef __APPLE__
// https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics
// But this developer webpage may be out of date.

uint64_t available = 0;
size_t size = sizeof(available);

Expand All @@ -35,6 +38,11 @@ uint64_t detect_NEON()
}
}
return available;
#else
// On Linux aarch64, AdvSIMD (NEON) is part of the mandatory ARMv8-A baseline,
// so it is always available.
return 1;
#endif
}

CPU_Features& CPU_Features::set_to_current(){
Expand Down
4 changes: 4 additions & 0 deletions Common/Cpp/Hardware/Hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
#ifdef PA_ARCH_x86
#include "Hardware_x86_Linux.tpp"
#elif PA_ARCH_arm64
#ifdef __APPLE__
#include "Hardware_arm64_Mac.tpp"
#else
#include "Hardware_arm64_Linux.tpp"
#endif
#endif
#endif


namespace PokemonAutomation{
Expand Down
127 changes: 76 additions & 51 deletions Common/Cpp/Hardware/Hardware_arm64_Linux.tpp
Original file line number Diff line number Diff line change
@@ -1,51 +1,76 @@
/* Environment (arm64 Linux)
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
* Currently only used for M-series Apple environment
*/


#include <stdio.h>
#include <stdint.h>
#include <thread>
#include <sys/sysctl.h>
#include "Hardware.h"

namespace PokemonAutomation{


uint64_t get_cpu_freq()
{
uint64_t freq = 0;
size_t size = sizeof(freq);

if (sysctlbyname("hw.cpufrequency", &freq, &size, NULL, 0) < 0)
{
perror("sysctl");
}
return freq;
}

std::string get_processor_name(){
char name_buffer[100] = "";
size_t size = 100;
if (sysctlbyname("machdep.cpu.brand_string", name_buffer, &size, NULL, 0) < 0)
{
perror("sysctl");
}
return name_buffer;
}


ProcessorSpecs get_processor_specs(){
ProcessorSpecs specs;
specs.name = get_processor_name();
specs.base_frequency = get_cpu_freq();
specs.threads = std::thread::hardware_concurrency();

return specs;
}


}
/* Hardware (arm64 Linux)
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
* Used for Linux aarch64 environment.
*/


#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string>
#include <fstream>
#include <thread>
#include "Hardware.h"

namespace PokemonAutomation{


// Linux: /proc/cpuinfo does not have a "Model name" line on ARM kernels,
// so fall back to the SoC "Hardware" line, and finally the kernel name.

static std::string cpuinfo_value(const std::string& file_path, const std::string& key){
std::ifstream file(file_path);
std::string line;
while (std::getline(file, line)){
if (line.rfind(key, 0) == 0){
size_t pos = line.find(": ");
if (pos == std::string::npos){
return "";
}
return line.substr(pos + 2);
}
}
return "";
}

uint64_t get_cpu_freq(){
// /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq is in kHz.
std::string max_freq = cpuinfo_value("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "");
if (!max_freq.empty()){
return (uint64_t)atoll(max_freq.c_str()) * 1000ULL;
}

// Fallback: "cpu MHz" in /proc/cpuinfo.
std::string mhz = cpuinfo_value("/proc/cpuinfo", "cpu MHz");
if (!mhz.empty()){
return (uint64_t)(atof(mhz.c_str()) * 1000000.);
}

return 0;
}

std::string get_processor_name(){
std::string name = cpuinfo_value("/proc/cpuinfo", "Model name");
if (name.empty()){
name = cpuinfo_value("/proc/cpuinfo", "Hardware");
}
if (name.empty()){
name = "aarch64";
}
return name;
}


ProcessorSpecs get_processor_specs(){
ProcessorSpecs specs;
specs.name = get_processor_name();
specs.base_frequency = get_cpu_freq();
specs.threads = std::thread::hardware_concurrency();

return specs;
}


}
51 changes: 51 additions & 0 deletions Common/Cpp/Hardware/Hardware_arm64_Mac.tpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/* Hardware (arm64 Mac)
*
* From: https://github.com/PokemonAutomation/Arduino-Source
*
* Used for Apple M-series (macOS) environment.
*/


#include <stdio.h>
#include <stdint.h>
#include <thread>
#include <sys/sysctl.h>
#include "Hardware.h"

namespace PokemonAutomation{


uint64_t get_cpu_freq()
{
uint64_t freq = 0;
size_t size = sizeof(freq);

if (sysctlbyname("hw.cpufrequency", &freq, &size, NULL, 0) < 0)
{
perror("sysctl");
}
return freq;
}

std::string get_processor_name(){
char name_buffer[100] = "";
size_t size = 100;
if (sysctlbyname("machdep.cpu.brand_string", name_buffer, &size, NULL, 0) < 0)
{
perror("sysctl");
}
return name_buffer;
}


ProcessorSpecs get_processor_specs(){
ProcessorSpecs specs;
specs.name = get_processor_name();
specs.base_frequency = get_cpu_freq();
specs.threads = std::thread::hardware_concurrency();

return specs;
}


}
106 changes: 106 additions & 0 deletions SerialPrograms/BuildInstructions/Build-Ubuntu-ARM64-Qt6.8.3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# How to Build (Qt 6.8.3) - Ubuntu 24.04 aarch64 (ARM64)

This covers building on **Linux ARM64/aarch64**, as opposed to x86\_64 Ubuntu (see `Build-Ubuntu-Qt6.8.2.md` for limited x86\_64 guidance) or macOS (see `CompilingForMac.md`).

NOTE: This is only for ARM Linux server build testing. There is no GUI testing to guarantee the GUI of the built application works.

NOTE: The content below in this document is generated by a local AI agent and Claude on Sep 5, 2026 as a build reference.
No humans have followed through the guide to ensure its correctness yet.

Ubuntu's own Qt6 packages are far too old (Qt 6.4 on 24.04), and Qt does not publish prebuilt Linux ARM64 packages through its online installer, so Qt has to be built from source. Everything else (OpenCV, Tesseract, D-Bus) is available through `apt` on Ubuntu 24.04.

This was verified with:
- Ubuntu 24.04.4 LTS, kernel 6.17, aarch64
- Qt 6.8.3 (built from source)
- CMake 3.28, Ninja, GCC (system default)

## 1. Install build tools and dependencies

```bash
sudo apt update
sudo apt install build-essential cmake ninja-build git pkg-config

# Libraries this project links against directly
sudo apt install libopencv-dev libtesseract-dev libleptonica-dev \
libsystemd-dev libopenexr-dev libgl1-mesa-dev libglx-dev \
libglu1-mesa-dev

# Dependencies needed to build Qt itself (xcb platform plugin, fonts, etc.)
sudo apt install libxkbcommon-dev libxkbcommon-x11-dev libxcb-cursor-dev \
libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev \
libxcb-render-util0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev \
libxcb-xinerama0-dev libxcb-xkb-dev libxcb1-dev libx11-dev libx11-xcb-dev \
libxext-dev libxfixes-dev libxi-dev libxrender-dev libfontconfig1-dev \
libfreetype-dev libssl-dev

# FFmpeg dev libs so Qt Multimedia gets a working webcam/video backend
sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswscale-dev \
libswresample-dev
```

Note: `libopencv-dev` on 24.04 provides OpenCV 4.6, and `libtesseract-dev` provides Tesseract 5.3.4. Both are picked up via `pkg-config` (`opencv4`, `tesseract`) by `SerialPrograms/CMakeLists.txt` — no manual OpenCV build is required on Linux (unlike Windows/Mac, which use prebuilt binaries from the `Packages` repo).

## 2. Build Qt 6.8.3 from source

```bash
mkdir -p ~/src && cd ~/src
wget https://download.qt.io/official_releases/qt/6.8/6.8.3/single/qt-everywhere-src-6.8.3.tar.xz
tar xf qt-everywhere-src-6.8.3.tar.xz
cd qt-everywhere-src-6.8.3

mkdir build && cd build
../configure -prefix "$HOME/qt/6.8.3" -release -opensource -confirm-license \
-nomake examples -nomake tests \
-skip qtwebengine -skip qt3d -skip qtwayland

cmake --build . --parallel "$(nproc)"
cmake --install .
```

This builds the full "everywhere" module set (qtbase, qtdeclarative, qtmultimedia, qtserialport, qtsvg, qttools, qtwebsockets, etc.), which is what this project needs (`Widgets`, `SerialPort`, `Multimedia`, `MultimediaWidgets`, `OpenGLWidgets`, `Qml`, `Quick`, `QuickWidgets`). Expect this step to take a long time (well over an hour on most ARM64 boards) and to need ~20-30 GB of free disk space during the build.

If you already have a Qt 6.8.x install (e.g. built previously, or via `aqtinstall`/a distro package new enough to include the above modules), you can skip this step — you just need its install prefix for step 4.

## 3. Get the `Resources` folder (Packages repo)

`SerialPrograms/CMakeLists.txt` expects a sibling `Packages` checkout next to this repo (i.e. `Arduino-Source/Packages`, not a `Resources` folder copied inside `SerialPrograms/`):

```bash
cd /path/to/Arduino-Source # the repo root, containing SerialPrograms/, Common/, etc.
git clone https://github.com/PokemonAutomation/Packages
```

CMake copies `Packages/Resources` into the build output automatically on first configure/build.

## 4. Configure and build

From the repo root:

```bash
cmake -S SerialPrograms -B build/RelWithDebInfo -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_PREFIX_PATH="$HOME/qt/6.8.3"

cmake --build build/RelWithDebInfo --parallel "$(nproc)"
```

Notes:
- **Discord Social SDK is auto-disabled on Linux ARM64.** Discord doesn't offer a Linux ARM64 build of the Social SDK (per their platform-compatibility docs, Linux support is x86_64-only; Windows ARM64 and macOS ARM64 are both fully supported). `CMakeLists.txt` defaults the `PA_SOCIAL_SDK` option to `OFF` automatically when it detects a non-Apple ARM/aarch64 target, so you don't need to pass anything for this — it's mentioned here only so you know why `Compiling with Discord social SDK integration disabled` shows up during configure. You can still force it on/off explicitly with `-DPA_SOCIAL_SDK=ON` or `=OFF` on any platform.
- **ONNX Runtime** is downloaded automatically for you (aarch64 build, from the official `microsoft/onnxruntime` GitHub releases) if you don't already have one. If you want to point at a pre-downloaded copy instead, pass `-DONNX_ROOT_PATH=/path/to/onnxruntime-linux-aarch64-1.23.0`.
- `DPP` (D++ / Discord bot library) is optional and auto-detected via `pkg-config`; it isn't installed by the apt commands above, so you'll see `Compiling with DPP integration disabled`, which is expected and fine.

The two binaries are produced at `build/RelWithDebInfo/SerialPrograms` (GUI) and `build/RelWithDebInfo/SerialProgramsCommandLine`.

## 5. Run

```bash
./build/RelWithDebInfo/SerialPrograms
```

Only the command-line tool and a headless (`QT_QPA_PLATFORM=offscreen`) launch of the GUI binary were exercised while verifying this build — both start up and resolve all shared libraries correctly (checked with `ldd`). Actual on-screen GUI behavior (e.g. the video-preview flicker noted for x86_64 Ubuntu in `Build-Ubuntu-Qt6.8.2.md`) has not been separately verified on ARM64.

<hr>

**Discord Server:**

[<img src="https://canary.discordapp.com/api/guilds/695809740428673034/widget.png?style=banner2">](https://discord.gg/cQ4gWxN)
Loading
Loading