2025年5月22日 星期四

Send SMS via AT commands

Module:
Telit LN920A06
def text_to_ucs2_hex(text):
    return text.encode('utf-16-be').hex().upper()

def encode_phone_number(number):
    # 處理台灣號碼,如 0966123456 → +886966123456
    if number.startswith('0'):
        number = '886' + number[1:]
    elif number.startswith('+'):
        number = number[1:]

    if len(number) % 2 != 0:
        number += 'F'

    swapped = ''.join([number[i+1] + number[i] for i in range(0, len(number), 2)])
    return swapped, len(number)

def generate_pdu_and_cmgs(phone, message):
    # UCS2 編碼
    ucs2 = text_to_ucs2_hex(message)
    ucs2_len = len(ucs2) // 2  # bytes

    # 編碼電話號碼
    phone_enc, phone_digits = encode_phone_number(phone)
    phone_len_hex = f"{phone_digits:X}".zfill(2)

    # 組合 PDU
    smsc = "00"
    pdu_type = "11"
    mr = "00"
    toa = "91"
    pid = "00"
    dcs = "08"
    vp = "AA"  # 約 4 天
    udl = f"{ucs2_len:02X}"

    pdu_body = (
        pdu_type + mr + phone_len_hex + toa + phone_enc +
        pid + dcs + vp + udl + ucs2
    )

    full_pdu = smsc + pdu_body

    # CMGS = 從 PDU_TYPE 開始的長度(即去掉 SMSC 的 "00" 開頭,長度為 1 byte = 2 hex)
    cmgs_len = (len(full_pdu) - 2) // 2

    return full_pdu, cmgs_len

# 測試
phone = "0966123456"
message = "哈囉世界"

pdu, cmgs_len = generate_pdu_and_cmgs(phone, message)
print(f"AT+CMGF=0")
print(f"AT+CMGS={cmgs_len}")
print(pdu)
ref:
1. GSM Modem 傳送簡訊的幾個 AT 指令
2. GPRS應用之: AT指令發送PDU簡訊詳解

2025年5月20日 星期二

enable gnss_nmea for Le910Cx

Le910Cx開啟gnss nmea時,
用哪個ttyUSB開啟,就會直接輸出,加入下面條件,應該可以開機時,順利啟動NMEA
環境: NV Orin R36.3

avoid blocking ttyUSB2 by modemmanager
$ cat /etc/udev/rules.d/99-le910Cx.rules
KERNEL=="ttyUSB2", SUBSYSTEM=="tty", ENV{ID_VENDOR_ID}=="1bc7", ENV{ID_MODEL_ID}=="1031", ENV{ID_MM_DEVICE_IGNORE}="1"

。Setting ENV{ID_MM_DEVICE_IGNORE}="1" on a USB device or interface tells ModemManager to ignore all related ports.
。ENV{ID_MM_DEVICE_IGNORE}="1" tells ModemManager to ignore this port only.


enable_gnss.c (delay 5 secs)
#include <errno.h>
#include <fcntl.h>
#include <libudev.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>

#define TIMEOUT_MS 3000 // Timeout in milliseconds
#define MAX_BUFFER_SIZE 256
#define MAX_AT_RESPONSE 16
#define MAX_DEVICE_PATH 64 // Define a constant for device path size

// Structure to hold AT command and its response time
typedef struct {
  char command[32];
  double response_time;
} ATCommand;

// Structure to hold the AT command responses
typedef struct {
  char device_path[MAX_DEVICE_PATH]; // Use the defined constant
  char response[MAX_BUFFER_SIZE];
} DeviceResponse;

DeviceResponse device_responses[MAX_AT_RESPONSE];

pthread_mutex_t response_mutex = PTHREAD_MUTEX_INITIALIZER;
int response_count = 0;

// Function prototypes (for clarity)
int open_serial_port(const char *port_name);
int send_at_command(int fd, const char *command, char *response,
                    size_t response_size, double response_time);
void close_serial_port(int fd);
void *process_device(void *arg);
int find_tty_acm(int argc, char *argv[], int *get_count,
                 char dev_path[][MAX_DEVICE_PATH]); // Use the defined constant
void GetResponseData(char *input, char *output, size_t array_size,
                     int line_sopt);

ATCommand ATCS[] = {
    {"at$GPSP=1", 0.5}, // Example response time of 300ms (converted to seconds)
    {"AT$GPSNMUN=1,1,1,1,1,1,1", 0.4}, // Example response time of 400ms
};

int open_serial_port(const char *port_name) {
  int fd = open(port_name, O_RDWR | O_NOCTTY | O_NDELAY);
  if (fd == -1) {
    perror("open_serial_port: open failed");
    return -1;
  }

  struct termios tty;
  memset(&tty, 0, sizeof(tty));
  if (tcgetattr(fd, &tty) != 0) {
    perror("open_serial_port: tcgetattr failed");
    close(fd);
    return -1;
  }

  cfsetospeed(&tty, B115200); // Set baud rate (adjust as needed)
  cfsetispeed(&tty, B115200);

  tty.c_cflag &= ~PARENB; // No parity
  tty.c_cflag &= ~CSTOPB; // 1 stop bit
  tty.c_cflag &= ~CSIZE;
  tty.c_cflag |= CS8;            // 8 data bits
  tty.c_cflag &= ~CRTSCTS;       // No hardware flow control
  tty.c_cflag |= CREAD | CLOCAL; // Enable read and ignore control lines

  tty.c_lflag &= ~ICANON; // Disable canonical mode
  tty.c_lflag &= ~ECHO;   // Disable echo
  tty.c_lflag &= ~ECHOE;  // Disable erasure
  tty.c_lflag &= ~ECHONL; // Disable new-line echo
  tty.c_lflag &= ~ISIG;   // Disable interpretation of interrupt, quit, and
                          // suspend characters

  tty.c_iflag &= ~(IXON | IXOFF | IXANY); // Disable software flow control
  tty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR |
                   ICRNL); // Disable special handling of received bytes

  tty.c_oflag &= ~OPOST; // Prevent special interpretation of output bytes
  tty.c_oflag &=
      ~ONLCR; // Prevent conversion of newline to carriage return/line feed

  tty.c_cc[VTIME] = TIMEOUT_MS / 100; // Timeout in deciseconds (correct)
  tty.c_cc[VMIN] = 0;                 // Minimum number of characters to receive

  if (tcsetattr(fd, TCSANOW, &tty) != 0) {
    perror("open_serial_port: tcsetattr failed");
    close(fd);
    return -1;
  }

  return fd;
}

int send_at_command(int fd, const char *command, char *response,
                    size_t response_size, double response_time) {
  tcflush(fd, TCIFLUSH); // Flush the input buffer

  ssize_t bytes_written = write(fd, command, strlen(command));
  if (bytes_written < 0) {
    perror("send_at_command: write failed");
    return -1;
  }

  memset(response, 0, response_size);
  size_t total_bytes_read = 0;

  struct timeval start_time, current_time;
  gettimeofday(&start_time, NULL); // Use gettimeofday for better precision

  while (total_bytes_read < response_size - 1) {
    ssize_t bytes_read = read(fd, response + total_bytes_read,
                              response_size - 1 - total_bytes_read);
    if (bytes_read < 0) {
      if (errno == EAGAIN || errno == EWOULDBLOCK) {
        gettimeofday(&current_time, NULL);
        double elapsed_time =
            (current_time.tv_sec - start_time.tv_sec) +
            (current_time.tv_usec - start_time.tv_usec) / 1000000.0;

        if (elapsed_time > response_time) {
          tcflush(fd, TCIFLUSH); // clear the buffer
          fprintf(stderr, "send_at_command: Timeout occurred\n");
          return -1; // Timeout occurred
        }
        usleep(10000); // small delay before retry (10ms)
        continue;      // retry read
      } else {
        perror("send_at_command: read failed");
        return -1;
      }
    }

    if (bytes_read == 0) {
      // End of file or no more data
      break;
    }

    total_bytes_read += bytes_read;
    if (strstr(response, "OK\r\n") != NULL) {
      break; // Stop reading when OK is received.
    }
  }

  response[total_bytes_read] = '\0'; // Null-terminate the string
  return 0;
}

void close_serial_port(int fd) { close(fd); }

void *process_device(void *arg) {
  int serial_fd;
  char *dev_path = (char *)arg;
  char response[MAX_BUFFER_SIZE];
  int at_command_count =
      sizeof(ATCS) / sizeof(ATCS[0]); // Calculate number of AT commands

  printf("Thread processing device: %s\n", dev_path);
  serial_fd = open_serial_port(dev_path);
  if (serial_fd == -1) {
    fprintf(stderr, "Error opening serial port: %s\n", strerror(errno));
    return NULL;
  }

  // Send AT commands
  for (int i = 0; i < at_command_count; i++) {
    char command[128]; // Ensure enough space for the command
    snprintf(command, sizeof(command) - 1, "%s\r",
             ATCS[i].command); // Append \r

    if (send_at_command(serial_fd, command, response, sizeof(response),
                        ATCS[i].response_time) == 0) {
      printf("Response to '%s': %s\n", ATCS[i].command, response);

      pthread_mutex_lock(&response_mutex);
      if (response_count < MAX_AT_RESPONSE) {
        strncpy(device_responses[response_count].device_path, dev_path,
                MAX_DEVICE_PATH - 1);
        device_responses[response_count].device_path[MAX_DEVICE_PATH - 1] =
            '\0'; // Ensure null termination

        strncpy(device_responses[response_count].response, response,
                MAX_BUFFER_SIZE - 1);
        device_responses[response_count].response[MAX_BUFFER_SIZE - 1] =
            '\0'; // Ensure null termination

        response_count++; // Increment response count

      } else {
        fprintf(stderr, "Response buffer is full!\n");
      }
      pthread_mutex_unlock(&response_mutex);

    } else {
      fprintf(stderr, "Error sending command '%s'\n", ATCS[i].command);
    }
  }

  close_serial_port(serial_fd);
  pthread_exit(NULL);
}

int find_tty_acm(int argc, char *argv[], int *get_count,
                 char dev_path[][MAX_DEVICE_PATH]) {
  if (argc != 4) {
    fprintf(stderr, "Usage: %s  \n", argv[0]); // Corrected Usage message
    return 1;
  }

  const char *target_vid = argv[1];
  const char *target_pid = argv[2];
  const char *target_bInterfaceNumber = argv[3];

  struct udev *udev = udev_new();
  if (!udev) {
    fprintf(stderr, "Failed to create udev object\n");
    return 1;
  }

  struct udev_enumerate *enumerate = udev_enumerate_new(udev);
  udev_enumerate_add_match_subsystem(enumerate, "tty");
  udev_enumerate_add_match_property(enumerate, "ID_VENDOR_ID", target_vid);
  udev_enumerate_add_match_property(enumerate, "ID_MODEL_ID", target_pid);
  udev_enumerate_scan_devices(enumerate);

  struct udev_list_entry *devices = udev_enumerate_get_list_entry(enumerate);
  struct udev_list_entry *entry;

  int i = 0;
  udev_list_entry_foreach(entry, devices) {
    const char *path = udev_list_entry_get_name(entry);
    struct udev_device *dev = udev_device_new_from_syspath(udev, path);
    if (!dev) {
      fprintf(stderr, "Error creating udev_device from syspath: %s\n", path);
      continue; // Skip to the next device
    }

    const char *devnode = udev_device_get_devnode(dev);
    const char *bInterface =
        udev_device_get_property_value(dev, "ID_USB_INTERFACE_NUM");

    if (devnode && bInterface &&
        strcmp(bInterface, target_bInterfaceNumber) == 0) {
      if (i < MAX_AT_RESPONSE) { // Check for overflow
        strncpy(dev_path[i], devnode, MAX_DEVICE_PATH - 1); // Use strncpy
        dev_path[i][MAX_DEVICE_PATH - 1] = '\0';            // Null-terminate
        printf("Found device: %s\n", devnode);
        i++;
        (*get_count)++;
      } else {
        fprintf(stderr, "Too many devices found.  Increase MAX_AT_RESPONSE.\n");
        break;
      }
    }
    udev_device_unref(dev);
  }

  udev_enumerate_unref(enumerate); // Free enumerate object
  udev_unref(udev);

  return 0;
}

void GetResponseData(char *input, char *output, size_t array_size,
                     int line_sopt) {
  char *line, *saveptr;
  int stop = 0;

  output[0] = '\0'; // Initialize output string

  line = strtok_r(input, "\n", &saveptr);
  while (line != NULL) {
    if (stop == line_sopt) {
      strncpy(output, line, array_size - 1); // Use strncpy for safety
      output[array_size - 1] = '\0';         // Ensure null termination
      return;
    }
    line = strtok_r(NULL, "\n", &saveptr);
    stop++;
  }
  output[0] = '\0'; // If line_sopt is out of range, return an empty string
}

int main(int argc, char *argv[]) {
  int device_count = 0;
  char dev_path[MAX_AT_RESPONSE]
               [MAX_DEVICE_PATH];     // Array to store device paths
  pthread_t threads[MAX_AT_RESPONSE]; // Array to store thread IDs
  int thread_creation_result;

  sleep(5); //waiting for systemctl...le910cx.service and Modemanager

  if (find_tty_acm(argc, argv, &device_count, dev_path) != 0) {
    fprintf(stderr, "find_tty_acm failed\n");
    exit(EXIT_FAILURE);
  }

  printf("Loop count: %d\n", device_count);
  if (device_count == 0) {
    printf("No devices found. Exiting.\n");
    exit(EXIT_SUCCESS);
  }

  // Create threads for each device found
  for (int i = 0; i < device_count; i++) {
    printf("Creating thread for device: %s\n", dev_path[i]);
    thread_creation_result =
        pthread_create(&threads[i], NULL, process_device, (void *)dev_path[i]);
    if (thread_creation_result != 0) {
      fprintf(stderr, "ERROR; return code from pthread_create() is %d\n",
              thread_creation_result);
      exit(EXIT_FAILURE);
    }
  }

  // Wait for all threads to complete
  for (int i = 0; i < device_count; i++) {
    pthread_join(threads[i], NULL);
  }

  exit(EXIT_SUCCESS);
}

compile
$ gcc enable_gnss.c -o enable_gnss -Wall -Wextra -pthread -ludev

$ ./enable_gnss 1bc7 1031 02

$ cat /etc/systemd/system/le910cx.service
[Unit]
Description=enGNSS_NMEA_LE910Cx
After=ModemManager.service
After=network.target

[Service]
ExecStart=/home/nvidia/gnss/enable_gnss 1bc7 1031 02
Type=oneshot
RemainAfterExit=yes
User=root
Group=root

[Install]
WantedBy=multi-user.target

reboot and check it
//$ sudo systemctl daemon-reload

reboot


$ sudo systemctl start le910cx.service


$ sudo systemctl status le910cx.service
● le910cx.service - enGNSS_NMEA_LE910Cx
     Loaded: loaded (/etc/systemd/system/le910cx.service; disabled; vendor pres>
     Active: active (exited) since Tue 2025-05-20 08:30:16 UTC; 8s ago
    Process: 2228 ExecStart=/home/nvidia/gnss/enable_gnss 1bc7 1031 02 (code=ex>
   Main PID: 2228 (code=exited, status=0/SUCCESS)
        CPU: 23ms

May 20 08:30:11 tegra-ubuntu systemd[1]: Starting enGNSS_NMEA_LE910Cx...
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: Found device: /dev/ttyUSB2
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: Loop count: 1
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: Creating thread for device: /de>
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: Thread processing device: /dev/>
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: Response to 'at$GPSP=1': at$GPS>
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: OK
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: Response to 'AT$GPSNMUN=1,1,1,1>
May 20 08:30:16 tegra-ubuntu enable_gnss[2228]: OK
May 20 08:30:16 tegra-ubuntu systemd[1]: Finished enGNSS_NMEA_LE910Cx.


開機啟動
$ sudo systemctl enable le910cx.service


ref:
1. ModemManager-filter

2025年5月14日 星期三

Cross-compile for QT6

先說結論…一定要先編一次x86,才能再cross compiler...= ="
環境:
1. x86 PC
2. 準備STM32MP2 for QT6
3. QT6 version 6.5.3, 下載
4. 因為一直卡在OpenGL的問題
    本來在build_x86編好後,再一個build_aarch64,
    aarch64一直出現OpenGL的問題,MP2的環境應該都有準備好,但還是解不掉
    突然想回頭再試一次x86,也出現一樣的問題@@
    後來砍掉,再解壓一次6.5.3.tar.xz,全部重來,aarch64就可以了 = ="
ERROR: The OpenGL functionality tests failed! You might need to modify the OpenGL package search path by setting the OpenGL_DIR CMake variable to the OpenGL library's installation directory.
CMake Error at qtbase/cmake/QtBuildInformation.cmake:194 (message):
  Check the configuration messages for an error that has occurred.

Call Stack (most recent call first):
  qtbase/cmake/QtBuildInformation.cmake:24 (qt_configure_print_summary)
  CMakeLists.txt:127 (qt_print_feature_summary)
5. 不像QT5,交叉編譯後的qmake,就能幫qt code編成arm平台使用
    QT6的qmake編出來後只能給x86, 但是aarch64用起來就有問題...
    不管是buildroot編出來的
    還是整個6.5.3編出來的...
1. cd output/target/usr/bin
$ file qmake
qmake: POSIX shell script, ASCII text executable
$ file qmake6
qmake6: POSIX shell script, ASCII text executable

aarch64平台
$ ./qmake
./qmake: 7: /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6: not found
$ ./qmake6
./qmake6: 7: /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6: not found
$ ile /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6
/home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/bin/qmake6: ELF 64-bit LSB shared object, x86-64...
為什麼會連到x86...??
試著把此連結用aarch64的qmake6代替,qmake後,就會停在那,不會動
6. 可以用qt-cmake來編專案,只是要寫CmakeLists.txt

======================================================

STM32MP2環境:
1. buildroot-external-st, remotes/origin/st/2024.02.9
2. buildroot, remotes/origin/st/2024.02.9, 6ea7024a34d4e7f994a7d9ded573c340c8adba1e
3. 此版buildroot是6.8.1, 需自行手動更改成6.5.3
4. target config: st_stm32mp257f_dk_defconfig

======================================================

Build QT6.5.3 on x86 PC
$ mkdir build_x86; cd build_x86
$ cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINPUT_opengl=es2 -DQT_BUILD_EXAMPLES=OFF -DQT_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/home/ubuntu/STMicroelectronics/QT6_Source/qt6Host_x86 ..

compile
//build code
//build_x86 folder
$ cmake --build . --parallel 2

//install
cmake --install .

x86 output

Building for: linux-g++ (x86_64, CPU features: mmx sse sse2)
Compiler: gcc 11.4.0
Build options:
  Mode ................................... release (with debug info)
  Optimize release build for size ........ no
  Fully optimize release builds (-O3) .... no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Unity Build ............................ no
  Using new DTAGS ........................ yes
  Generating GDB index ................... no
  Relocatable ............................ yes
  Using precompiled headers .............. yes
  Using Link Time Optimization (LTCG) .... no
  Using Intel CET ........................ yes
  Target compiler supports:
    x86 Intrinsics ....................... Basic VAES AVX512VBMI2
  Sanitizers:
    Addresses ............................ no
    Threads .............................. no
    Memory ............................... no
    Fuzzer (instrumentation only) ........ no
    Undefined ............................ no
  Build parts ............................ libs tools
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... yes
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt PrintSupport ........................ yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... yes
  udev ................................... yes
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ no
  OpenSSL 1.1 ............................ no
  OpenSSL 3.0 ............................ yes
  Using system zlib ...................... yes
  Zstandard support ...................... yes
  Thread support ......................... yes
Common build options:
  Linker can resolve circular dependencies  yes
Qt Core:
  backtrace .............................. yes
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ no
  GLib ................................... yes
  ICU .................................... yes
  Using system libb2 ..................... no
  Built-in copy of the MIME database ..... yes
  cpp/winrt base ......................... no
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  PCRE2 .................................. yes
    Using system PCRE2 ................... yes
  CLONE_PIDFD support in forkfd .......... yes
  Application permissions ................ no
Qt Sql:
  SQL item models ........................ yes
Qt Network:
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  Linux AF_NETLINK ....................... yes
  DTLS ................................... yes
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes
  GSSAPI ................................. no
  Brotli Decompression Support ........... yes
  qIsEffectiveTLD() ...................... yes
    Built-in publicsuffix database ....... yes
    System publicsuffix database ......... yes
Core tools:
  Android deployment tool ................ yes
  macOS deployment tool .................. no
  Windows deployment tool ................ no
  qmake .................................. yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ yes
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ yes
  Fontconfig ............................. yes
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... yes
    PNG .................................. yes
      Using system libpng ................ yes
  Text formats:
    HtmlParser ........................... yes
    CssParser ............................ yes
    OdfWriter ............................ yes
    MarkdownReader ....................... yes
      Using system libmd4c ............... no
    MarkdownWriter ....................... yes
  EGL .................................... yes
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ yes
    OpenGL ES 3.2 ........................ yes
  Vulkan ................................. yes
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  HiRes wheel support in libinput ........ no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon .............................. yes
  X11 specific:
    XLib ................................. yes
    XCB Xlib ............................. no
    EGL on X11 ........................... yes
    xkbcommon-x11 ........................ no
    xcb-sm ............................... no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS OpenWFD ........................ no
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS RCAR ........................... no
    EGLFS EGLDevice ...................... yes
    EGLFS GBM ............................ yes
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  VK_KHR_display ......................... yes
  QNX:
    lgmon ................................ no
    IMF .................................. no
  XCB:
    Using system-provided xcb-xinput ..... no
    GL integrations:
      GLX Plugin ......................... no
        XCB GLX .......................... no
      EGL-X11 Plugin ..................... no
  Windows:
    Direct 2D ............................ no
    Direct 2D 1.1 ........................ no
    DirectWrite .......................... no
    DirectWrite 3 ........................ no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt Testlib:
  Tester for item models ................. yes
  Batch tests ............................ no
Qt PrintSupport:
  CUPS ................................... no
Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite ................................. yes
    Using system provided SQLite ......... no
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. yes
  WEBP ................................... yes
    Using system libwebp ................. no
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML just-in-time compiler .............. yes
  QML XML http request ................... yes
  QML Locale ............................. yes
Qt QML Models:
  QML list model ......................... yes
  QML delegate model ..................... yes
Qt Quick:
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  TableView item ......................... yes
  TreeView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  Repeater item .......................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
  Calendar support ....................... yes
Qt Quick Controls 2:
  Styles ................................. Basic Fusion Imagine iOS Material Universal macOS Windows
QtQuick3D:
  Assimp ................................. yes
  System Assimp .......................... no
Qt Multimedia:
  Spatial Audio .......................... yes
  Spatial Audio (Quick3D) ................ yes
  Low level Audio Backend:
    ALSA (experimental) .................. no
    PulseAudio ........................... yes
    MMRenderer ........................... no
    CoreAudio ............................ no
    Windows Media SDK .................... no
    Open SLES (Android) .................. no
    Web Assembly ......................... no
  Plugin:
    GStreamer 1.0 ........................ no
    FFmpeg ............................... no
    MMRenderer ........................... no
    AVFoundation ......................... no
    Windows Media Foundation ............. no
  Hardware acceleration and features:
    Video for Linux ...................... yes
    VAAPI support ........................ no
    Linux DMA buffer support ............. yes
    VideoToolbox ......................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Use SSE2 instructions .................. yes
  Use AVX2 instructions .................. no
  Aspects:
    Render aspect ........................ yes
    Input aspect ......................... yes
    Logic aspect ......................... yes
    Animation aspect ..................... yes
    Extras aspect ........................ yes
Qt 3D APIs:
  Vulkan ................................. yes
Qt 3D Renderers:
  OpenGL Renderer ........................ yes
  RHI Renderer ........................... yes
Qt3D Geometry Loaders:
  Autodesk FBX ........................... no
Qt 5 Compatibility Libraries:
  iconv .................................. no
Qt Charts Types:
  Area Chart ............................. yes
  Line Chart ............................. yes
  Spline Chart ........................... yes
  Scatter Chart .......................... yes
  Bar Chart .............................. yes
  Pie Chart .............................. yes
  Boxplot Chart .......................... yes
  Candlestick Chart ...................... yes
Qt Axis Types:
  DateTime Axis .......................... yes
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
  WinRT Bluetooth API .................... no
Qt Tools:
  Qt Assistant ........................... yes
  QDoc ................................... yes
  Clang-based lupdate parser ............. yes
  Qt Designer ............................ yes
  Qt Distance Field Generator ............ yes
  Qt Linguist ............................ yes
  pixeltool .............................. yes
  qdbus .................................. yes
  Qt Attributions Scanner ................ yes
  qtdiag ................................. yes
  qtplugininfo ........................... yes
Serial Port:
  ntddmodm ............................... no
WebEngine Repository Build Options:
  Build Ninja ............................ no
  Build Gn ............................... yes
  Jumbo Build ............................ yes
  Developer build ........................ no
  Build QtWebEngine Modules:
    Build QtWebEngineCore ................ no
    Build QtWebEngineWidgets ............. no
    Build QtWebEngineQuick ............... no
  Build QtPdf Modules:
    Build QtPdfWidgets ................... no
    Build QtPdfQuick ..................... no
  Optional system libraries:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . no
    opus ................................. no
    ffmpeg ............................... no
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. yes
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. yes
    jpeg ................................. yes
    libopenjpeg2 ......................... no
    harfbuzz ............................. no
    freetype ............................. yes
    libpci ............................... no
Qt Protobuf tools:
  Qt Protobuf generator .................. no
Qt GRPC:
  gRPC support ........................... yes
  Native gRPC support .................... no
Qt GRPC tools:
  Qt GRPC generator ...................... no
Qt Opcua:
  Open62541 .............................. yes
  Unified Automation C++ SDK ............. no
  Support for namespace 0 NodeId names ... yes
  Namespace 0 NodeIds generator .......... no
  Open62541 security support ............. yes
  Support for global discovery server .... yes
Qt Remote Objects:
  High Availability Manager (ham) ........ no
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Sensors:
  sensorfw ............................... no
  sensorfw_enabled_with_cmake ............ no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
  SerialPort Support ..................... yes
Qt TextToSpeech:
  Flite .................................. no
  Flite with ALSA ........................ no
  Speech Dispatcher ...................... no
Qt Virtualkeyboard:
  Desktop integration .................... yes
  Built-in layouts ....................... yes
  Key navigation ......................... no
  Retro style as default ................. no
  Sensitive Debug ........................ no
  Cerence ................................ no
    Static Linking ....................... no
    Handwriting .......................... no
      Alphabetic ......................... no
      CJK ................................ no
    XT9 .................................. no
      XT9 Debug .......................... no
      XT9 9-key layouts .................. no
    Bundle resources ..................... no
      Handwriting ........................ no
      XT9 ................................ no
  Hunspell ............................... no
    Using Hunspell copy from 3rdparty/ ... no
  OpenWnn ................................ yes
  MyScript ............................... no
  Language support enabled for:
    Arabic ............................... yes
    Bulgarian ............................ yes
    Czech ................................ yes
    Danish ............................... yes
    German ............................... yes
    Greek ................................ yes
    English GB ........................... yes
    English US ........................... yes
    Spanish .............................. yes
    Spanish Mexico ....................... yes
    Estonian ............................. yes
    Farsi ................................ yes
    Finnish .............................. yes
    French Canada ........................ yes
    French France ........................ yes
    Hebrew ............................... yes
    Hindi ................................ yes
    Croatian ............................. yes
    Hungarian ............................ yes
    Indonesian ........................... yes
    Italian .............................. yes
    Japanese ............................. yes
    Korean ............................... yes
    Malay ................................ yes
    Norwegian ............................ yes
    Dutch ................................ yes
    Polish ............................... yes
    Portuguese Brazil .................... yes
    Portuguese Portugal .................. yes
    Romanian ............................. yes
    Russian .............................. yes
    Slovak ............................... yes
    Slovenian ............................ yes
    Albanian ............................. yes
    Serbian .............................. yes
    Swedish .............................. yes
    Thai ................................. yes
    Turkish .............................. yes
    Ukrainian ............................ yes
    Vietnamese ........................... yes
    Simplified Chinese ................... yes
    Traditional Chinese .................. yes
    HongKong Chinese ..................... no
  Traditional chinese input methods:
    Zhuyin ............................... yes
    Cangjie .............................. yes
Qt Wayland TextInput Protocol V4(WIP) .... no
Qt Wayland Client ........................ yes
Qt Wayland Compositor .................... yes
Qt Wayland Drivers:
  EGL .................................... yes
  Raspberry Pi ........................... no
  DRM EGL ................................ yes
  libhybris EGL .......................... no
  Linux dma-buf server buffer integration  yes
  Shm emulation server buffer integration  yes
  Vulkan-based server buffer integration . yes
Qt Wayland Client Shell Integrations:
  xdg-shell .............................. yes
  ivi-shell .............................. yes
  wl-shell (deprecated) .................. yes
  qt-shell ............................... yes
Qt Wayland Compositor Layer Plugins:
  VSP2 hardware layer integration ........ no
Note: Hunspell in Qt Virtual Keyboard is not enabled. Spelling correction will not be available.
WARNING: QtWebEngine won't be built. Python3 html5lib is missing.
WARNING: QtPdf won't be built. Python3 html5lib is missing.
WARNING: SensorFW support currently not enabled with cmake

==========================================================
Build QT6.5.3 for aarch64
1. Create a sysroot folder, ex, $HOME/STMicroelectronics/QT6_Source/sysroot
    a. Copy it from buildroot, ex: $HOME/STMicroelectronics/buildroot_qt653/output/host/aarch64-  buildroot-linux-gnu/sysroot
    or
    b. Copy usr/ and lib/ from your target aarch64 platform.
$ ls /home/ubuntu/STMicroelectronics/buildroot_qt653/output/host/aarch64-buildroot-linux-gnu/sysroot
bin  dev  etc  lib  lib64(softlink to lib)  media  mnt  opt  proc  root  run  sbin  sys  tmp  usr  var

2. aarch64.cmake, copy it from 鲁班猫Qt应用开发实战
# 这里设置cmake支持的最小版本
cmake_minimum_required(VERSION 3.18)
include_guard(GLOBAL)

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# 指定sysroot目录
set(TARGET_SYSROOT /home/ubuntu/STMicroelectronics/QT6_Source/sysroot)

# 指定前面获取的交叉编译器路径
set(CROSS_COMPILER /usr/bin/aarch64-linux-gnu)

set(CMAKE_SYSROOT ${TARGET_SYSROOT})

set(CMAKE_C_COMPILER ${CROSS_COMPILER}-gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}-g++)

set(CMAKE_LIBRARY_ARCHITECTURE )

# 库路径
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/lib -L${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}  -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib -I${TARGET_SYSROOT}/usr/include -I${TARGET_SYSROOT}/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")

# pkg config路径
set(ENV{PKG_CONFIG_PATH} ${TARGET_SYSROOT}/usr/lib/pkgconfig:${TARGET_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${TARGET_SYSROOT}/usr/share/pkgconfig/)
set(ENV{PKG_CONFIG_LIBDIR} ${TARGET_SYSROOT}/usr/lib/pkgconfig:${TARGET_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${TARGET_SYSROOT}/usr/share/pkgconfig/)
set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})

set(QT_COMPILER_FLAGS "-march=armv8-a")
set(QT_COMPILER_FLAGS_RELEASE "-O2 -pipe")
set(QT_LINKER_FLAGS "-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-fuse-ld=gold -ldbus-1")

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)

include(CMakeInitializeConfigs)

function(cmake_initialize_per_config_variable _PREFIX _DOCSTRING)
if (_PREFIX MATCHES "CMAKE_(C|CXX|ASM)_FLAGS")
   set(CMAKE_${CMAKE_MATCH_1}_FLAGS_INIT "${QT_COMPILER_FLAGS}")

   foreach (config DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
      if (DEFINED QT_COMPILER_FLAGS_${config})
      set(CMAKE_${CMAKE_MATCH_1}_FLAGS_${config}_INIT "${QT_COMPILER_FLAGS_${config}}")
      endif()
   endforeach()
endif()

if (_PREFIX MATCHES "CMAKE_(SHARED|MODULE|EXE)_LINKER_FLAGS")
   foreach (config SHARED MODULE EXE)
      set(CMAKE_${config}_LINKER_FLAGS_INIT "${QT_LINKER_FLAGS}")
   endforeach()
endif()

_cmake_initialize_per_config_variable(${ARGV})
endfunction()

3. Cross compile on x86 PC
 $ mkdir build_aarch64; cd build_aarch64
$ cmake -GNinja \
      -DCMAKE_BUILD_TYPE=Release \
      -DINPUT_opengl=es2 \
      -DQT_BUILD_EXAMPLES=OFF \
      -DQT_BUILD_TESTS=OFF \
      -DQT_HOST_PATH=/home/ubuntu/STMicroelectronics/QT6_Source/qt6Host_x86 \
      -DCMAKE_STAGING_PREFIX=/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix \
      -DCMAKE_INSTALL_PREFIX=/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix \
      -DCMAKE_TOOLCHAIN_FILE=/home/ubuntu/STMicroelectronics/QT6_Source/qt-everywhere-src-6.5.3/aarch64.cmake \
      -DQT_FEATURE_xcb=ON \
      -DFEATURE_xcb_xlib=ON \
      -DQT_FEATURE_xlib=ON \
      -DFEATURE_qtwebengine_build=OFF ..


aarch64 output:


-- Configure summary:

Building for: linux-g++ (arm64, CPU features: cx16 neon)
Compiler: gcc 11.4.0
Build options:
  Mode ................................... release
  Optimize release build for size ........ no
  Fully optimize release builds (-O3) .... no
  Building shared libraries .............. yes
  Using C standard ....................... C11
  Using C++ standard ..................... C++17
  Using ccache ........................... no
  Unity Build ............................ no
  Using new DTAGS ........................ yes
  Relocatable ............................ yes
  Using precompiled headers .............. yes
  Using Link Time Optimization (LTCG) .... no
  Using Intel CET ........................ no
  Target compiler supports:
    ARM Extensions ....................... NEON
  Sanitizers:
    Addresses ............................ no
    Threads .............................. no
    Memory ............................... no
    Fuzzer (instrumentation only) ........ no
    Undefined ............................ no
  Build parts ............................ libs
Qt modules and options:
  Qt Concurrent .......................... yes
  Qt D-Bus ............................... yes
  Qt D-Bus directly linked to libdbus .... yes
  Qt Gui ................................. yes
  Qt Network ............................. yes
  Qt PrintSupport ........................ yes
  Qt Sql ................................. yes
  Qt Testlib ............................. yes
  Qt Widgets ............................. yes
  Qt Xml ................................. yes
Support enabled for:
  Using pkg-config ....................... yes
  udev ................................... no
  OpenSSL ................................ yes
    Qt directly linked to OpenSSL ........ no
  OpenSSL 1.1 ............................ no
  OpenSSL 3.0 ............................ yes
  Using system zlib ...................... yes
  Zstandard support ...................... no
  Thread support ......................... yes
Common build options:
  Linker can resolve circular dependencies  yes
Qt Core:
  backtrace .............................. yes
  DoubleConversion ....................... yes
    Using system DoubleConversion ........ yes
  GLib ................................... yes
  ICU .................................... no
  Using system libb2 ..................... yes
  Built-in copy of the MIME database ..... yes
  cpp/winrt base ......................... no
  Tracing backend ........................ <none>
  Logging backends:
    journald ............................. no
    syslog ............................... no
    slog2 ................................ no
  PCRE2 .................................. yes
    Using system PCRE2 ................... yes
  CLONE_PIDFD support in forkfd .......... yes
  Application permissions ................ no
Qt Sql:
  SQL item models ........................ yes
Qt Network:
  getifaddrs() ........................... yes
  IPv6 ifname ............................ yes
  libproxy ............................... no
  Linux AF_NETLINK ....................... yes
  DTLS ................................... yes
  OCSP-stapling .......................... yes
  SCTP ................................... no
  Use system proxies ..................... yes
  GSSAPI ................................. no
  Brotli Decompression Support ........... no
  qIsEffectiveTLD() ...................... yes
    Built-in publicsuffix database ....... yes
    System publicsuffix database ......... yes
Core tools:
  Android deployment tool ................ no
  macOS deployment tool .................. no
  Windows deployment tool ................ no
  qmake .................................. yes
Qt Gui:
  Accessibility .......................... yes
  FreeType ............................... yes
    Using system FreeType ................ yes
  HarfBuzz ............................... yes
    Using system HarfBuzz ................ no
  Fontconfig ............................. yes
  Image formats:
    GIF .................................. yes
    ICO .................................. yes
    JPEG ................................. yes
      Using system libjpeg ............... yes
    PNG .................................. yes
      Using system libpng ................ yes
  Text formats:
    HtmlParser ........................... yes
    CssParser ............................ yes
    OdfWriter ............................ yes
    MarkdownReader ....................... yes
      Using system libmd4c ............... no
    MarkdownWriter ....................... yes
  EGL .................................... yes
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ yes
    OpenGL ES 3.2 ........................ yes
  Vulkan ................................. no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  HiRes wheel support in libinput ........ no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon .............................. no
  X11 specific:
    xlib ................................. yes
    XCB Xlib ............................. yes
    EGL on X11 ........................... no
    xkbcommon-x11 ........................ no
    xcb-sm ............................... no
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS OpenWFD ........................ no
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS RCAR ........................... no
    EGLFS EGLDevice ...................... yes
    EGLFS GBM ............................ yes
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  VK_KHR_display ......................... no
  QNX:
    lgmon ................................ no
    IMF .................................. no
  XCB:
    Using system-provided xcb-xinput ..... no
    GL integrations:
      GLX Plugin ......................... no
        XCB GLX .......................... no
      EGL-X11 Plugin ..................... yes
  Windows:
    Direct 2D ............................ no
    Direct 2D 1.1 ........................ no
    DirectWrite .......................... no
    DirectWrite 3 ........................ no
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
Qt Testlib:
  Tester for item models ................. yes
  Batch tests ............................ no
Qt PrintSupport:
  CUPS ................................... no
Qt Sql Drivers:
  DB2 (IBM) .............................. no
  InterBase .............................. no
  MySql .................................. no
  OCI (Oracle) ........................... no
  ODBC ................................... no
  PostgreSQL ............................. no
  SQLite ................................. yes
    Using system provided SQLite ......... no
Further Image Formats:
  JasPer ................................. no
  MNG .................................... no
  TIFF ................................... yes
    Using system libtiff ................. no
  WEBP ................................... yes
    Using system libwebp ................. no
Qt QML:
  QML network support .................... yes
  QML debugging and profiling support .... yes
  QML just-in-time compiler .............. yes
  QML XML http request ................... yes
  QML Locale ............................. yes
Qt QML Models:
  QML list model ......................... yes
  QML delegate model ..................... yes
Qt Quick:
  AnimatedImage item ..................... yes
  Canvas item ............................ yes
  Support for Qt Quick Designer .......... yes
  Flipable item .......................... yes
  GridView item .......................... yes
  ListView item .......................... yes
  TableView item ......................... yes
  TreeView item .......................... yes
  Path support ........................... yes
  PathView item .......................... yes
  Positioner items ....................... yes
  Repeater item .......................... yes
  ShaderEffect item ...................... yes
  Sprite item ............................ yes
Qt Quick Templates 2:
  Hover support .......................... yes
  Multi-touch support .................... yes
  Calendar support ....................... yes
Qt Quick Controls 2:
  Styles ................................. Basic Fusion Imagine iOS Material Universal macOS Windows
QtQuick3D:
  Assimp ................................. yes
  System Assimp .......................... no
Qt Multimedia:
  Spatial Audio .......................... yes
  Spatial Audio (Quick3D) ................ yes
  Low level Audio Backend:
    ALSA (experimental) .................. no
    PulseAudio ........................... yes
    MMRenderer ........................... no
    CoreAudio ............................ no
    Windows Media SDK .................... no
    Open SLES (Android) .................. no
    Web Assembly ......................... no
  Plugin:
    GStreamer 1.0 ........................ yes
    FFmpeg ............................... no
    MMRenderer ........................... no
    AVFoundation ......................... no
    Windows Media Foundation ............. no
  Hardware acceleration and features:
    Video for Linux ...................... yes
    VAAPI support ........................ no
    Linux DMA buffer support ............. yes
    VideoToolbox ......................... no
Qt 3D:
  Assimp ................................. yes
  System Assimp .......................... no
  Use SSE2 instructions .................. no
  Use AVX2 instructions .................. no
  Aspects:
    Render aspect ........................ yes
    Input aspect ......................... yes
    Logic aspect ......................... yes
    Animation aspect ..................... yes
    Extras aspect ........................ yes
Qt 3D APIs:
  Vulkan ................................. no
Qt 3D Renderers:
  OpenGL Renderer ........................ yes
  RHI Renderer ........................... yes
Qt3D Geometry Loaders:
  Autodesk FBX ........................... no
Qt 5 Compatibility Libraries:
  iconv .................................. yes
Qt Charts Types:
  Area Chart ............................. yes
  Line Chart ............................. yes
  Spline Chart ........................... yes
  Scatter Chart .......................... yes
  Bar Chart .............................. yes
  Pie Chart .............................. yes
  Boxplot Chart .......................... yes
  Candlestick Chart ...................... yes
Qt Axis Types:
  DateTime Axis .......................... yes
Qt Bluetooth:
  BlueZ .................................. no
  BlueZ Low Energy ....................... no
  Linux Crypto API ....................... no
  WinRT Bluetooth API .................... no
Qt Tools:
  Qt Assistant ........................... yes
  QDoc ................................... no
  Clang-based lupdate parser ............. no
  Qt Designer ............................ yes
  Qt Distance Field Generator ............ yes
  Qt Linguist ............................ yes
  pixeltool .............................. yes
  qdbus .................................. yes
  Qt Attributions Scanner ................ yes
  qtdiag ................................. yes
  qtplugininfo ........................... yes
Serial Port:
  ntddmodm ............................... no
WebEngine Repository Build Options:
  Build Ninja ............................ no
  Build Gn ............................... yes
  Jumbo Build ............................ yes
  Developer build ........................ no
  Build QtWebEngine Modules:
    Build QtWebEngineCore ................ no
    Build QtWebEngineWidgets ............. no
    Build QtWebEngineQuick ............... no
  Build QtPdf Modules:
    Build QtPdfWidgets ................... no
    Build QtPdfQuick ..................... no
  Optional system libraries:
    re2 .................................. no
    icu .................................. no
    libwebp, libwebpmux and libwebpdemux . no
    opus ................................. no
    ffmpeg ............................... no
    libvpx ............................... no
    snappy ............................... no
    glib ................................. yes
    zlib ................................. yes
    minizip .............................. no
    libevent ............................. no
    libxml2 and libxslt .................. no
    lcms2 ................................ no
    png .................................. yes
    jpeg ................................. yes
    libopenjpeg2 ......................... no
    harfbuzz ............................. no
    freetype ............................. yes
    libpci ............................... no
Qt Protobuf tools:
  Qt Protobuf generator .................. no
Qt GRPC:
  gRPC support ........................... yes
  Native gRPC support .................... no
Qt GRPC tools:
  Qt GRPC generator ...................... no
Qt Opcua:
  Open62541 .............................. yes
  Unified Automation C++ SDK ............. no
  Support for namespace 0 NodeId names ... yes
  Namespace 0 NodeIds generator .......... no
  Open62541 security support ............. yes
  Support for global discovery server .... yes
Qt Remote Objects:
  High Availability Manager (ham) ........ no
Qt Scxml:
  ECMAScript data model for QtScxml ...... yes
Qt Sensors:
  sensorfw ............................... no
  sensorfw_enabled_with_cmake ............ no
Qt SerialBus:
  Socket CAN ............................. yes
  Socket CAN FD .......................... yes
  SerialPort Support ..................... yes
Qt TextToSpeech:
  Flite .................................. no
  Flite with ALSA ........................ no
  Speech Dispatcher ...................... no
Qt Virtualkeyboard:
  Desktop integration .................... yes
  Built-in layouts ....................... yes
  Key navigation ......................... no
  Retro style as default ................. no
  Sensitive Debug ........................ no
  Cerence ................................ no
    Static Linking ....................... no
    Handwriting .......................... no
      Alphabetic ......................... no
      CJK ................................ no
    XT9 .................................. no
      XT9 Debug .......................... no
      XT9 9-key layouts .................. no
    Bundle resources ..................... no
      Handwriting ........................ no
      XT9 ................................ no
  Hunspell ............................... no
    Using Hunspell copy from 3rdparty/ ... no
  OpenWnn ................................ yes
  MyScript ............................... no
  Language support enabled for:
    Arabic ............................... yes
    Bulgarian ............................ yes
    Czech ................................ yes
    Danish ............................... yes
    German ............................... yes
    Greek ................................ yes
    English GB ........................... yes
    English US ........................... yes
    Spanish .............................. yes
    Spanish Mexico ....................... yes
    Estonian ............................. yes
    Farsi ................................ yes
    Finnish .............................. yes
    French Canada ........................ yes
    French France ........................ yes
    Hebrew ............................... yes
    Hindi ................................ yes
    Croatian ............................. yes
    Hungarian ............................ yes
    Indonesian ........................... yes
    Italian .............................. yes
    Japanese ............................. yes
    Korean ............................... yes
    Malay ................................ yes
    Norwegian ............................ yes
    Dutch ................................ yes
    Polish ............................... yes
    Portuguese Brazil .................... yes
    Portuguese Portugal .................. yes
    Romanian ............................. yes
    Russian .............................. yes
    Slovak ............................... yes
    Slovenian ............................ yes
    Albanian ............................. yes
    Serbian .............................. yes
    Swedish .............................. yes
    Thai ................................. yes
    Turkish .............................. yes
    Ukrainian ............................ yes
    Vietnamese ........................... yes
    Simplified Chinese ................... yes
    Traditional Chinese .................. yes
    HongKong Chinese ..................... no
  Traditional chinese input methods:
    Zhuyin ............................... yes
    Cangjie .............................. yes
Qt Wayland TextInput Protocol V4(WIP) .... no
Qt Wayland Client ........................ yes
Qt Wayland Compositor .................... yes
Qt Wayland Drivers:
  EGL .................................... yes
  Raspberry Pi ........................... no
  DRM EGL ................................ yes
  libhybris EGL .......................... no
  Linux dma-buf server buffer integration  yes
  Shm emulation server buffer integration  yes
  Vulkan-based server buffer integration . no
Qt Wayland Client Shell Integrations:
  xdg-shell .............................. yes
  ivi-shell .............................. yes
  wl-shell (deprecated) .................. yes
  qt-shell ............................... yes
Qt Wayland Compositor Layer Plugins:
  VSP2 hardware layer integration ........ no


NNote: Disabling X11 Accessibility Bridge: D-Bus or AT-SPI is missing.
Note: Hunspell in Qt Virtual Keyboard is not enabled. Spelling correction will not be available.
Note: Due to CMAKE_STAGING_PREFIX usage and an unfixed CMake bug,
      to ensure correct build time rpaths, directory-level install
      rules like ninja src/gui/install will not work.
      Check QTBUG-102592 for further details.

WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
Either set CMAKE_PREFIX_PATH or LLVM_INSTALL_DIR to the location of your llvm installation.
On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.
On macOS, you can use Homebrew's llvm package.
You will also need to set the FEATURE_clang CMake variable to ON to re-evaluate this check.
WARNING: Clang-based lupdate parser will not be available. LLVM and Clang C++ libraries have not been found.
You will need to set the FEATURE_clangcpp CMake variable to ON to re-evaluate this check.
WARNING: QtWebEngine won't be built. Python3 html5lib is missing.
WARNING: QtPdf won't be built. Python3 html5lib is missing.
WARNING: SensorFW support currently not enabled with cmake

--

Qt is now configured for building. Just run 'cmake --build . --parallel'

Once everything is built, you must run 'cmake --install .'
Qt will be installed into '/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix'

To configure and build other Qt modules, you can use the following convenience script:
        /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-configure-module

If reconfiguration fails for some reason, try removing 'CMakeCache.txt' from the build directory
Alternatively, you can add the --fresh flag to your CMake flags.

-- Configuring done (27.5s)
-- Generating done (3.9s)
-- Build files have been written to: /home/ubuntu/STMicroelectronics/QT6_Source/qt-everywhere-src-6.5.3/build_aarch64

compile
//build code
//不要用ninja build
$ cmake --build . --parallel 2

//install
$ cmake --install .

hello專案
$ ls
CMakeLists.txt  main.cpp

-----------------------------------------------------

main.cpp
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[]) {
  QApplication app(argc, argv);
  QLabel label("Hello World");
  label.setWindowTitle("Hello World");
  label.resize(200, 100);
  label.show();
  return app.exec();
}

-----------------------------------------------------

 cat CMakeLists.txt
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.16)
project(hellogl2 LANGUAGES CXX)


#AARCH64
set(TARGET_SYSROOT /home/ubuntu/STMicroelectronics/QT6_Source/sysroot)
set(CROSS_COMPILER /usr/bin/aarch64-linux-gnu)
set(CMAKE_SYSROOT ${TARGET_SYSROOT})

set(CMAKE_C_COMPILER ${CROSS_COMPILER}-gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}-g++)
set(CMAKE_LIBRARY_ARCHITECTURE)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE} -fPIC -Wl,-rpath-link,${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/lib -L${CMAKE_SYSROOT}/lib/${CMAKE_LIBRARY_ARCHITECTURE}  -L${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} -L${CMAKE_SYSROOT}/usr/lib -I${TARGET_SYSROOT}/usr/include -I${TARGET_SYSROOT}/usr/include/${CMAKE_LIBRARY_ARCHITECTURE}")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}")
#end for AARCH64

find_package(Qt6 REQUIRED COMPONENTS Widgets)

qt_standard_project_setup()

qt_add_executable(hello
    main.cpp
)

set_target_properties(hello PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)

target_link_libraries(hello PRIVATE
    Qt6::Widgets
)

Cross-compile hello project
$ file /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-cmake
/home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-cmake: POSIX shell script, ASCII text executable

$ mkdir build_aarch64; cd build_aarch64
$ /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/opt/prefix/bin/qt-cmake ..
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/aarch64-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Performing Test HAVE_EGL
-- Performing Test HAVE_EGL - Success
-- Found EGL: /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/usr/include (found version "1.5")
-- Performing Test HAVE_GLESv2
-- Performing Test HAVE_GLESv2 - Success
-- Found GLESv2: /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/usr/include
-- Found XKB: /home/ubuntu/STMicroelectronics/QT6_Source/sysroot/usr/lib/libxkbcommon.so (found suitable version "1.4.0", minimum required is "0.5.0")
-- Configuring done (0.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/ubuntu/STMicroelectronics/QT6/hello/build_aarch64

$ cmake --build .
[  0%] Built target hello_autogen_timestamp_deps
[ 20%] Automatic MOC and UIC for target hello
[ 20%] Built target hello_autogen
[ 40%] Building CXX object CMakeFiles/hello.dir/hello_autogen/mocs_compilation.cpp.o
[ 60%] Building CXX object CMakeFiles/hello.dir/main.cpp.o
[ 80%] Linking CXX executable hello
[100%] Built target hello

$ file ./hello
hello: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=2bccf14786fd2d593f5ae8d64847d30365ca2f4b, not stripped

ref:
1. 鲁班猫Qt应用开发实战