Skip to content

Commit 503cf64

Browse files
committed
nrf52: Make interrupt stack sizes configurable
1 parent 34484c9 commit 503cf64

4 files changed

Lines changed: 37 additions & 5 deletions

File tree

nrf52_src/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,29 @@ light_tasking_nrf52840.LFCLK_Src = "RC"
130130
light_tasking_nrf52840.Time_Base = "RTC0"
131131
```
132132

133+
The following variables configure the interrupt stack sizes:
134+
135+
<table>
136+
<thead>
137+
<th>Variable</th>
138+
<th>Values</th>
139+
<th>Default</th>
140+
<th>Description</th>
141+
</thead>
142+
<tr>
143+
<td><tt>Interrupt_Stack_Size</tt></td>
144+
<td>Any positive integer</td>
145+
<td><tt>1024</tt></td>
146+
<td>Specifies the size of the primary stack used for interrupt handlers.</td>
147+
</tr>
148+
<tr>
149+
<td><tt>Interrupt_Secondary_Stack_Size</tt></td>
150+
<td>Any positive integer</td>
151+
<td><tt>128</tt></td>
152+
<td>Specifies the size of the secondary stack used for interrupt handlers.</td>
153+
</tr>
154+
</table>
155+
133156
### GPR Scenario Variables
134157

135158
The runtime project files expose `*_BUILD` and and `*_LIBRARY_TYPE` GPR

nrf52_src/s-bbpara.ads

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@
4040

4141
-- This is the nRF52840 (ARMv7) version of this package
4242

43+
pragma Restrictions (No_Elaboration_Code);
44+
4345
with System.BB.Board_Parameters;
4446
with System.BB.MCU_Parameters;
4547

48+
with NRF52_Runtime_Config;
49+
4650
package System.BB.Parameters is
47-
pragma No_Elaboration_Code_All;
4851
pragma Preelaborate (System.BB.Parameters);
4952

5053
Clock_Frequency : constant := Board_Parameters.Main_Clock_Frequency;
@@ -98,12 +101,14 @@ package System.BB.Parameters is
98101
-- Stacks --
99102
------------
100103

101-
Interrupt_Stack_Size : constant := 2 * 1024;
104+
Interrupt_Stack_Size : constant :=
105+
NRF52_Runtime_Config.Interrupt_Stack_Size;
102106
-- Size of each of the interrupt stacks in bytes. While there nominally is
103107
-- an interrupt stack per interrupt priority, the entire space is used as a
104108
-- single stack.
105109

106-
Interrupt_Sec_Stack_Size : constant := 128;
110+
Interrupt_Sec_Stack_Size : constant :=
111+
NRF52_Runtime_Config.Interrupt_Secondary_Stack_Size;
107112
-- Size of the secondary stack for interrupt handlers
108113

109114
Has_FPU : constant Boolean := True;

nrf52_src/templates/alire.toml.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@ LFCLK_Src = { type = "Enum", values = ["Xtal", "RC", "Synth"], default = "Xtal"
4444
Use_SWO_Trace = { type = "Boolean", default = true }
4545
Use_Reset_Pin = { type = "Boolean", default = true }
4646

47+
Interrupt_Stack_Size = { type = "Integer", first = 1, default = 1024 }
48+
Interrupt_Secondary_Stack_Size = { type = "Integer", first = 1, default = 128 }
49+
4750
[[depends-on]]
4851
gnat_arm_elf = "^15"

nrf52_src/templates/ravenscar_build.gpr.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ project Ravenscar_Build is
3434
-- Always build System.BB.CPU_Primitives at -O2 as some targets may make
3535
-- use of inline assembly that rely on specific compiler behaviour to
3636
-- load constants that are not enabled at -O0.
37-
for Switches ("s-bbcppr.adb") use Target_Options.GNARL_ADAFLAGS & ("-O2");
37+
for Switches ("s-bbcppr.adb") use Target_Options.GNARL_ADAFLAGS
38+
& ("-O2", "-gnaty-d");
3839
-- Some runtime files need to be compiled with debug info, so that gdb
3940
-- is not blind.
4041
for Switches ("s-tasdeb.adb") use Target_Options.ALL_ADAFLAGS
41-
& ("-g", "-O0");
42+
& ("-g", "-O0", "-gnaty-d");
4243
end Compiler;
4344

4445
end Ravenscar_Build;

0 commit comments

Comments
 (0)