Skip to content

Commit 617840c

Browse files
Merge pull request #364 from rust-embedded/riscv-rt/fix-stack-alloc
`riscv-rt`: fix stack allocation for targets without M extension
2 parents d79290b + 78e1410 commit 617840c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

riscv-rt/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- Bump MSRV to 1.68 for latest syn 2.0 release
1515
- Adapted to new `riscv` version.
1616

17+
### Fixed
18+
19+
- Fix stack allocation algorithm for multi-core targets without M extension
20+
1721
## [v0.16.0] - 2025-09-08
1822

1923
### Added

riscv-rt/src/asm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ _abs_start:
105105
#[cfg(not(feature = "single-hart"))]
106106
{
107107
"mv t2, a0
108-
lui t0, %hi(_hart_stack_size)
109-
add t0, t0, %lo(_hart_stack_size)",
108+
lui t1, %hi(_hart_stack_size)
109+
add t1, t1, %lo(_hart_stack_size)",
110110
#[cfg(riscvm)]
111-
"mul t0, t2, t0",
111+
"mul t0, t2, t1",
112112
#[cfg(not(riscvm))]
113-
"beqz t2, 2f // skip if hart ID is 0
114-
mv t1, t0
113+
"mv t0, x0
114+
beqz t2, 2f // skip if hart ID is 0
115115
1:
116116
add t0, t0, t1
117117
addi t2, t2, -1

0 commit comments

Comments
 (0)