Skip to content

Add support for arm32#359

Open
luodeb wants to merge 51 commits intoarceos-org:mainfrom
rslabbox:debin/arm32
Open

Add support for arm32#359
luodeb wants to merge 51 commits intoarceos-org:mainfrom
rslabbox:debin/arm32

Conversation

@luodeb
Copy link
Copy Markdown
Contributor

@luodeb luodeb commented Mar 16, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 16, 2026 08:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds initial ARM32 (ARMv7-A) architecture support to the ArceOS operating system, alongside upgrading several dependencies (page_table_multiarch 0.5→0.6, various crate bumps) and adapting the page table API to a new cursor-based interface.

Changes:

  • Adds ARM32 target (armv7a-none-eabi) across build system, CI, QEMU configuration, platform crate wiring, and architecture-specific code paths (TLS, percpu, paging, C headers, setjmp/longjmp stubs).
  • Migrates page table operations from direct map/unmap/protect_region calls to a cursor-based API (pt.cursor().map_region(...)) to match page_table_multiarch v0.6.
  • Fixes potential overflow in network benchmarks by changing counter types from usize to u64 (needed for 32-bit targets where 10 * GB overflows usize).

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
Cargo.toml Adds workspace deps and patches for arm32 fork dependencies
Cargo.lock Dependency version updates and new arm32-related crates
Makefile Adds arm32 target, changes default MEM to 1G
rust-toolchain.toml Adds armv7a-none-eabi target
scripts/make/*.mk Adds arm32 QEMU machine, CFLAGS, platform mappings
modules/axhal/* Adds arm32 platform crate, page table type, TLS/percpu, paging API migration
modules/axmm/src/backend/*.rs Migrates to cursor-based page table API
modules/axmm/src/aspace.rs Cursor-based API + access_flags conversion
modules/axnet/src/smoltcp_impl/bench.rs Fixes usize overflow on 32-bit by using u64
modules/axdriver/src/drivers.rs Adds debug log in ramdisk probe
ulib/axlibc/* Arm32 C header support, stub setjmp/longjmp, build.rs fix
api/arceos_posix_api/src/imp/time.rs Fixes tv_sec cast for 32-bit
examples/* Adds arm32 platform support
.github/workflows/*.yml Adds arm32 to CI matrix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread ulib/axlibc/src/setjmp.rs Outdated
Comment thread Makefile Outdated
Comment thread Cargo.toml Outdated
Comment thread modules/axdriver/src/drivers.rs Outdated
Comment thread ulib/axlibc/include/setjmp.h Outdated
Comment thread scripts/make/qemu.mk Outdated
Comment thread Makefile Outdated
Comment thread modules/axhal/linker.lds.S Outdated
Comment thread examples/shell/Cargo.toml Outdated
Comment thread Cargo.toml Outdated
Copilot AI review requested due to automatic review settings March 17, 2026 08:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 34 out of 35 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 17, 2026 09:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 32 out of 34 changed files in this pull request and generated no comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 20, 2026 04:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds ARM32 (armv7a) support across the build system, libc shims, HAL, and CI to enable building and running ArceOS on qemu-system-arm (virt).

Changes:

  • Add ARM32 target support in Makefiles, QEMU runner scripts, Rust toolchain targets, and CI matrices.
  • Extend axlibc/posix API headers and shims for ARM32 ABI details (TLS, setjmp/longjmp, stdint/float/assert).
  • Update core dependencies and paging/percpu integrations to newer crate APIs that support ARM32.

Reviewed changes

Copilot reviewed 35 out of 37 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ulib/axlibc/src/setjmp.rs Adds ARM32-specific returns/termination paths for setjmp/longjmp stubs.
ulib/axlibc/src/malloc.rs Aligns allocator metadata for ARM32 ABI expectations.
ulib/axlibc/include/stdint.h Defines intptr_t/uintptr_t sizing for __arm__.
ulib/axlibc/include/setjmp.h Introduces ARM32 __jmp_buf sizing.
ulib/axlibc/include/float.h Adds ARM32 long-double/decimal constants.
ulib/axlibc/include/assert.h Implements standard NDEBUG behavior for assert.
ulib/axlibc/build.rs Forces explicit clang --target for bindgen to avoid host ABI leakage.
scripts/make/qemu.mk Adds QEMU machine/cpu settings and args for ARM virt.
scripts/make/platform.mk Adds ARM platform package selection and updates error message.
scripts/make/build_c.mk Adds ARM soft-float CFLAGS when fp-simd is disabled.
rust-toolchain.toml Adds armv7a-none-eabi target to toolchain targets list.
modules/axtask/Cargo.toml Bumps percpu dependency version for ARM32 support.
modules/axruntime/Cargo.toml Bumps axplat/percpu versions for ARM32 support.
modules/axnet/src/smoltcp_impl/bench.rs Switches bandwidth counters to u64 to avoid 32-bit overflow.
modules/axmm/src/backend/mod.rs Updates to new page-table cursor-based protect_region API.
modules/axmm/src/backend/linear.rs Updates to cursor-based map/unmap region APIs.
modules/axmm/src/backend/alloc.rs Updates populate/map/unmap/remap to cursor-based APIs.
modules/axmm/src/aspace.rs Updates copy/protect logic to cursor API and truncates access flags.
modules/axipi/Cargo.toml Bumps percpu dependency version.
modules/axhal/src/tls.rs Adds ARM32 TLS layout constants and __aeabi_read_tp hook.
modules/axhal/src/percpu.rs Adds ARM32 IRQ-guarded current task access; updates percpu init API.
modules/axhal/src/paging.rs Adapts paging handler to multi-frame allocation API; adds ARM page table type.
modules/axhal/src/lib.rs Links ARM platform crate when targeting ARM32.
modules/axhal/linker.lds.S Changes .data alignment to 16K (affects all targets).
modules/axhal/Cargo.toml Updates feature lists and bumps deps (percpu, axplat, page_table_multiarch); adds ARM platform dep.
examples/shell/Cargo.toml Formatting-only change (no functional impact).
examples/helloworld-myplat/src/main.rs Adds ARM platform extern crate selection.
examples/helloworld-myplat/Cargo.toml Adds arm-qemu-virt feature and ARM target dependency.
arceos-apps Updates the subproject git commit pointer.
api/arceos_posix_api/src/imp/time.rs Changes tv_sec conversion casts (likely for 32-bit compatibility).
api/arceos_posix_api/src/imp/pthread/mutex.rs Adds alignment static assert for pthread mutex ABI.
api/arceos_posix_api/build.rs Adds 32-bit variants for pthread mutex initializer and forces 8-byte alignment.
Makefile Adds arm ARCH option and sets Rust target triple for ARM.
Cargo.toml Adds workspace-level deps and patches crates.io deps to git repos/branches for ARM32.
.github/workflows/test.yml Adds ARM to test matrix; switches arceos-apps source/commit.
.github/workflows/build.yml Adds ARM to build matrices and installs ARM target.
Comments suppressed due to low confidence (2)

ulib/axlibc/src/setjmp.rs:1

  • For ARM32, longjmp currently becomes an infinite loop (b .). While it does technically make the function non-returning, it will hard-hang the CPU and mask the real failure mode. If ARM32 longjmp isn't implemented yet, prefer an explicit trap/abort path (so failures are diagnosable) or implement the actual register restore/jump sequence consistent with the __jmp_buf ABI used by your headers.
    ulib/axlibc/include/setjmp.h:1
  • __jmp_buf[64] appears inconsistent with the comment (r4-r14 is 11 regs; d8-d15 is 8 double-precision regs = 16 32-bit words under typical AAPCS; total is far below 64 words even after adding SP/LR/PC/flags). A mismatch here will break the C ABI and any Rust asm implementation that assumes a particular buffer layout/size. Please align the buffer size (and ideally document exact saved slots/ordering) to match the actual ARM32 setjmp/longjmp implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/arceos_posix_api/src/imp/time.rs
Comment thread api/arceos_posix_api/src/imp/time.rs Outdated
Comment thread scripts/make/qemu.mk
Comment thread Cargo.toml Outdated
Comment thread modules/axhal/linker.lds.S Outdated
Comment thread api/arceos_posix_api/build.rs
Comment thread modules/axmm/src/backend/alloc.rs
Copilot AI review requested due to automatic review settings March 20, 2026 05:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 37 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (1)

Cargo.toml:84

  • The [patch.crates-io] entries point at moving git branches (e.g. branch = "arm32") and unpinned repos, which makes builds non-reproducible and can silently change dependencies without a lockfile update. Please pin to specific rev hashes (or tags) and consider scoping these patches behind an opt-in feature/profile so default builds keep using published crates.
[patch.crates-io]
axcpu = { git = "https://github.com/luodeb/axcpu.git" }
axplat = { git = "https://github.com/luodeb/axplat_crates.git", branch = "arm32" }
axplat-x86-pc = { git = "https://github.com/luodeb/axplat_crates.git",  branch = "arm32" }
axplat-arm-qemu-virt = { git = "https://github.com/luodeb/axplat_crates.git",  branch = "arm32" }


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ulib/axlibc/include/setjmp.h
Comment thread Cargo.toml Outdated
Comment thread api/arceos_posix_api/build.rs Outdated
Comment thread modules/axhal/linker.lds.S Outdated
Comment thread .github/workflows/test.yml
Comment thread ulib/axlibc/src/setjmp.rs Outdated
Comment thread ulib/axlibc/src/setjmp.rs Outdated
Copy link
Copy Markdown
Member

@equation314 equation314 left a comment

Choose a reason for hiding this comment

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

Please split this PR into two parts: one for updating dependency versions, and another for adding ARM support.

Comment thread api/arceos_posix_api/build.rs Outdated
Comment thread api/arceos_posix_api/build.rs Outdated
Copy link
Copy Markdown
Member

@equation314 equation314 left a comment

Choose a reason for hiding this comment

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

In ulib/axlibc/include/limits.h, __LONG_MAX should be 0x7fffffffL for 32-bit platforms. Otherwise, the following warning will appear when compiling the C application:

In file included from ulib/axlibc/c/stdlib.c:3:                                                                                        
ulib/axlibc/c/stdlib.c: In function ‘strtoul’:                                                                                         
/home/jyk/arceos/ulib/axlibc/include/limits.h:17:25: warning: integer overflow in expression of type ‘long long int’ results in ‘-2’ [-
Woverflow]                                                                                                                             
   17 | #define ULONG_MAX  (2UL * LONG_MAX + 1)                                                                                        
      |                         ^                                                                                                      
ulib/axlibc/c/stdlib.c:174:29: note: in expansion of macro ‘ULONG_MAX’                                                                 
  174 |     cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;                                                                   
      |                             ^~~~~~~~~                                                                                          
/home/jyk/arceos/ulib/axlibc/include/limits.h:17:25: warning: integer overflow in expression of type ‘long long int’ results in ‘-2’ [-
Woverflow]                                                                                                                             
   17 | #define ULONG_MAX  (2UL * LONG_MAX + 1)                                                                                        
      |                         ^                                                                                                      
ulib/axlibc/c/stdlib.c:175:29: note: in expansion of macro ‘ULONG_MAX’                                                                 
  175 |     cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;                                                                   
      |                             ^~~~~~~~~                                                                                          
/home/jyk/arceos/ulib/axlibc/include/limits.h:17:25: warning: integer overflow in expression of type ‘long long int’ results in ‘-2’ [-
Woverflow]                                                                                                                             
   17 | #define ULONG_MAX  (2UL * LONG_MAX + 1)                                                                                        
      |                         ^                                                                                                      
ulib/axlibc/c/stdlib.c:197:15: note: in expansion of macro ‘ULONG_MAX’                                                                 
  197 |         acc = ULONG_MAX;                                                                                                       
      |               ^~~~~~~~~
                                                                                                 ```

Copilot AI review requested due to automatic review settings March 23, 2026 01:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 38 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ulib/axlibc/src/setjmp.rs Outdated
Comment thread ulib/axlibc/src/setjmp.rs
Comment thread Makefile
Comment thread modules/axmm/src/backend/alloc.rs
Comment thread api/arceos_posix_api/src/imp/time.rs
@equation314 equation314 moved this from Todo to In Progress in ARM32 support Mar 31, 2026
luodeb added 10 commits April 15, 2026 10:33
Introduces support for the ARM QEMU Virt platform, enabling both example and shell use.
Upgrades and aligns various dependencies and platform crates to newer versions, improving consistency and compatibility.
Increases default memory allocation for QEMU runs, improves driver probing diagnostics, and fixes potential integer truncation in time and network benchmarking logic.
Enables additional features in the shell and driver modules for better out-of-the-box experience.
Copilot AI review requested due to automatic review settings April 20, 2026 01:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 36 out of 37 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/test.yml
Comment thread ulib/axlibc/src/setjmp.rs Outdated
Comment thread ulib/axlibc/src/setjmp.rs Outdated
Copilot AI review requested due to automatic review settings April 21, 2026 02:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 36 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

scripts/make/qemu.mk:33

  • qemu_args-x86_64 now passes $(FINAL_IMG) to -kernel, but FINAL_IMG is a stripped binary or uImage (not the ELF). If the x86_64 boot flow expects an ELF (e.g., for multiboot/segment loading), this will regress make run for x86_64. Please confirm QEMU x86_64 can boot the chosen FINAL_IMG format; otherwise keep using $(OUT_ELF) for x86_64 or set FINAL_IMG to an ELF-compatible image for that arch.
qemu_args-x86_64 := \
  -machine $(machine) \
  -kernel $(OUT_ELF)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ulib/axlibc/src/setjmp.rs
Comment thread ulib/axlibc/src/setjmp.rs
Comment thread ulib/axlibc/include/stdint.h
Copilot AI review requested due to automatic review settings April 21, 2026 03:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 36 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread api/arceos_posix_api/src/imp/time.rs Outdated
Comment thread ulib/axlibc/src/setjmp.rs Outdated
Comment thread ulib/axlibc/src/setjmp.rs Outdated
Comment thread ulib/axlibc/src/malloc.rs Outdated
Comment thread api/arceos_posix_api/build.rs Outdated
luodeb added 2 commits April 24, 2026 17:28
…pport in ARM architecture

fix: update timeval conversion to use c_longlong for tv_sec in time module
fix: change MemoryControlBlock representation to C-compatible in malloc module
fix: enhance setjmp/longjmp implementations with architecture checks and error handling
Copilot AI review requested due to automatic review settings April 24, 2026 09:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ulib/axlibc/src/setjmp.rs Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 10:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
fn from(d: Duration) -> Self {
ctypes::timespec {
tv_sec: d.as_secs() as c_long,
tv_sec: d.as_secs() as i64,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

c_longlong

Comment thread scripts/make/build_c.mk
endif
endif

ifeq ($(ARCH), arm)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Merge with the above libgcc :=

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

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants