Skip to content

Hexagon architecture support#107122

Draft
androm3da wants to merge 9 commits intozephyrproject-rtos:mainfrom
androm3da:bcain/hexagon_support
Draft

Hexagon architecture support#107122
androm3da wants to merge 9 commits intozephyrproject-rtos:mainfrom
androm3da:bcain/hexagon_support

Conversation

@androm3da
Copy link
Copy Markdown

@androm3da androm3da commented Apr 10, 2026

This patch series introduces architecture support for Qualcomm's Hexagon DSP processor to Zephyr.

The Hexagon architecture is a VLIW DSP architecture used in Qualcomm SoCs like SnapDragon and DragonWing. They're currently used for functions such as: Compute DSP / NPU, Audio DSP, Cellular modem, and more.

https://en.wikipedia.org/wiki/Qualcomm_Hexagon

For the sake of portability among DSP generations, we're creating a zephyr port that depends on the Hexagon Virtual Machine Specification. This is unfortunately unlike other architectures but perhaps strikes the best compromise for consistency's sake when new DSP generations make changes to the system architecture. This is the same approach we took for the linux kernel port to Hexagon.

The initial target is a QEMU-based virtual platform.

The Clang/LLVM and Rust/LLVM toolchains can target Hexagon. No modern gcc toolchain exists with support for Hexagon.

@androm3da
Copy link
Copy Markdown
Author

Sorry -- I realize it might be a bit premature to lump this into a single PR. I'll break it down into PRs for some of these commits that should land independently. I'll cut the hexagon-specific bits down into whatever size is suitable/reasonable for the community to accept at-a-time.

cc @quic-mliebel @ChidvilasYQC

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 10, 2026

The following west manifest projects have changed revision in this Pull Request:

Name Old Revision New Revision Diff

All manifest checks OK

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@github-actions github-actions bot added manifest manifest-picolibc DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Apr 10, 2026
@henrikbrixandersen
Copy link
Copy Markdown
Member

Sorry -- I realize it might be a bit premature to lump this into a single PR. I'll break it down into PRs for some of these commits that should land independently. I'll cut the hexagon-specific bits down into whatever size is suitable/reasonable for the community to accept at-a-time.

Adding a description to the PR would be a good place to start.

@androm3da
Copy link
Copy Markdown
Author

Sorry -- I realize it might be a bit premature to lump this into a single PR. I'll break it down into PRs for some of these commits that should land independently. I'll cut the hexagon-specific bits down into whatever size is suitable/reasonable for the community to accept at-a-time.

Adding a description to the PR would be a good place to start.

You're right -- thanks. Done.

Copy link
Copy Markdown
Contributor

@nordicjm nordicjm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an incredibly quick/brief check

Comment thread boards/qemu/hexagon/board.c Outdated
#include <zephyr/arch/hexagon/arch.h>

/* Board-specific initialization */
static int qemu_hexagon_init(void)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file to go

Comment thread boards/qemu/hexagon/board.cmake Outdated
set(QEMU_FLAGS_${ARCH}
-machine virt
-m 4G
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misaliged bracket line 11, fix in whole PR

CONFIG_LLVM_USE_ELD=y

# System configuration
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=1000000
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 23 -> set in soc Kconfig.defconfig file and get from dt using dts functions

Comment on lines +25 to +26
CONFIG_SRAM_BASE_ADDRESS=0xa0000000
CONFIG_PICOLIBC=y
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem superfluous/wrong place

Comment on lines +28 to +32
# Memory configuration
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_IDLE_STACK_SIZE=2048
CONFIG_ISR_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=16384
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as above

Comment thread cmake/linker/eld/linker_flags.cmake Outdated
# SPDX-License-Identifier: Apache-2.0

check_set_linker_property(TARGET linker PROPERTY base
${LINKERFLAGPREFIX},--gc-sections
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misindentation, it is 2 spaces

Comment thread soc/qemu/hexagon/Kconfig Outdated
Comment on lines +14 to +19

config SOC_SERIES
default "" if SOC_QEMU_HEXAGON_VIRT

config SOC_FAMILY
default "" if SOC_QEMU_HEXAGON_VIRT
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Comment thread soc/qemu/hexagon/Kconfig
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.

config SOC_QEMU_HEXAGON_VIRT
bool "QEMU Hexagon Virtual Machine"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not valid for hwmv2

Comment thread soc/qemu/hexagon/soc.c Outdated
Comment on lines +11 to +14
void soc_early_init_hook(void)
{
/* SoC-specific early initialization */
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to go

Comment thread boards/qemu/hexagon/CMakeLists.txt Outdated
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.

set(SUPPORTED_EMU_PLATFORMS qemu)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file to go unless line 4 is seen to be actually doing anything?

Add build system infrastructure for the Hexagon architecture port:

- arch/Kconfig, archs.yml: register hexagon in the arch list
- arch/hexagon/{CMakeLists.txt,Kconfig,defconfig}: top-level arch build
- arch/hexagon/core/{CMakeLists.txt,Kconfig}: core build and config
- arch/hexagon/core/offsets/offsets.c: kernel offset definitions
- soc/qemu/hexagon/{CMakeLists.txt,linker.ld}: SoC build and linker script
- include/zephyr/{linker,toolchain}: hexagon hooks for linker output
  format and toolchain macros

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Add public and private header files for the Hexagon architecture:

Public API:
- arch.h: architecture interface (IRQ locking, syscall, nop, etc.)
- arch_inlines.h, error.h, exception.h, thread.h

Private headers:
- hexagon_vm.h: Hexagon VM operations and trap interfaces
- irq.h, irq_connect.h: interrupt management
- kernel_arch_data.h, kernel_arch_func.h: kernel integration
- offsets_short_arch.h, thread_stack.h: thread/stack layout

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Add the core runtime implementation for the Hexagon architecture:

- hvm_event_vectors.S: HVM guest event vector base (GEVB) with reset,
  exception, trap0, and interrupt entry points
- event_handlers.S: EVENT_ENTRY/EXIT macros for saving and restoring
  context on interrupt and exception entry
- switch.S: arch_switch() context switch and thread start trampoline
- irq_manage.c: interrupt dispatcher
- intc.c: VM-based interrupt controller
- cpu_idle.c: idle implementation using vmsetie with self-posted timer
- vmsetie_cached.c: cached IE state tracking for nested irq_lock/unlock
- thread.c: thread initialization with fake switch frames
- tls.c: thread-local storage using UGP register
- fatal.c: fatal error handling and exception dump
- prep_c.c: early C entry point

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Pass --no-default-config to both compile and link phases.  The
Hexagon cross-toolchain ships a hexagon-unknown-none-elf.cfg that
clang auto-discovers.  It injects -nostdlibinc and -isystem
<picolibc> before command-line flags, causing picolibc headers to
shadow Zephyr's minimal libc headers and breaking all
CONFIG_MINIMAL_LIBC builds (ZRESTRICT undefined, conflicting types).

With the default config suppressed, supply -nostdlibinc and the
picolibc include path explicitly so include search order is correct
regardless of libc selection.

Note: clang >= 23 no longer leaks host /usr/include into the
Hexagon target search path (see llvm/llvm-project#188824).

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
@androm3da androm3da force-pushed the bcain/hexagon_support branch from a819989 to 681e9f6 Compare April 15, 2026 05:34
@github-actions github-actions bot removed manifest manifest-picolibc DNM (manifest) This PR should not be merged (controlled by action-manifest) labels Apr 15, 2026
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants