diff --git a/app/demo-stm32h7-nucleo/app-h743.toml b/app/demo-stm32h7-nucleo/app-h743.toml index a027771c3..ac5b9e9e5 100644 --- a/app/demo-stm32h7-nucleo/app-h743.toml +++ b/app/demo-stm32h7-nucleo/app-h743.toml @@ -138,7 +138,7 @@ start = true features = ["h743"] priority = 3 name = "drv-stm32h7-rng" -stacksize = 256 +stacksize = 512 start = true task-slots = ["sys", "user_leds"] uses = ["rng"] diff --git a/app/demo-stm32h7-nucleo/app-h753.toml b/app/demo-stm32h7-nucleo/app-h753.toml index a7d0129c1..ebf12447d 100644 --- a/app/demo-stm32h7-nucleo/app-h753.toml +++ b/app/demo-stm32h7-nucleo/app-h753.toml @@ -189,7 +189,7 @@ start = true features = ["h753"] priority = 3 name = "drv-stm32h7-rng" -stacksize = 256 +stacksize = 512 start = true task-slots = ["sys", "user_leds"] uses = ["rng"] diff --git a/app/gemini-bu/app.toml b/app/gemini-bu/app.toml index c223105eb..e0cd5e24b 100644 --- a/app/gemini-bu/app.toml +++ b/app/gemini-bu/app.toml @@ -158,7 +158,7 @@ name = "drv-stm32h7-rng" priority = 6 uses = ["rng"] start = true -stacksize = 256 +stacksize = 512 task-slots = ["sys", "user_leds"] [tasks.update_server] diff --git a/app/gimletlet/base-gimletlet2.toml b/app/gimletlet/base-gimletlet2.toml index 98ae9139e..83f668d6c 100644 --- a/app/gimletlet/base-gimletlet2.toml +++ b/app/gimletlet/base-gimletlet2.toml @@ -107,7 +107,7 @@ name = "drv-stm32h7-rng" priority = 6 uses = ["rng"] start = true -stacksize = 256 +stacksize = 512 task-slots = ["sys", "user_leds"] [tasks.update_server] diff --git a/app/sidecar/base.toml b/app/sidecar/base.toml index d4eb1ff91..eb3861346 100644 --- a/app/sidecar/base.toml +++ b/app/sidecar/base.toml @@ -59,7 +59,7 @@ name = "drv-stm32h7-rng" priority = 6 uses = ["rng"] start = true -stacksize = 256 +stacksize = 512 task-slots = ["sys"] [tasks.update_server] diff --git a/build/xtask/src/dist.rs b/build/xtask/src/dist.rs index 8b0ef6ca4..1ecc6c9c5 100644 --- a/build/xtask/src/dist.rs +++ b/build/xtask/src/dist.rs @@ -1236,17 +1236,24 @@ pub fn get_max_stack( } chunks.extend(chunk); // don't forget the trailing chunk! + let frame_size = addr_to_frame_size.get(&base_addr).copied(); let mut calls = BTreeSet::new(); for (addr, chunk) in chunks { let instrs = cs .disasm_all(&chunk, addr.into()) .map_err(|e| anyhow!("disassembly failed: {e:?}"))?; - for instr in instrs.iter() { + for (i, instr) in instrs.iter().enumerate() { let detail = cs.insn_detail(instr).map_err(|e| { anyhow!("could not get instruction details: {e}") })?; + + // Detect tail calls, which are jumps at the final instruction + // when the function itself has no stack frame. + let can_tail = frame_size == Some(0) && i == instrs.len() - 1; if detail.groups().iter().any(|g| { g == &InsnGroupId(InsnGroupType::CS_GRP_CALL as u8) + || (g == &InsnGroupId(InsnGroupType::CS_GRP_JUMP as u8) + && can_tail) }) { let arch = detail.arch_detail(); let ops = arch.operands(); @@ -1290,7 +1297,7 @@ pub fn get_max_stack( FunctionData { name, short_name, - frame_size: addr_to_frame_size.get(&base_addr).map(|i| *i), + frame_size, calls, }, );