# RISCV - how to install interrupt handler?

**URL:** <https://forums.freertos.org/t/riscv-how-to-install-interrupt-handler/21026>\
**Category:** Kernel\
**Created:** [July 24, 2024, 5:07pm UTC](https://forums.freertos.org/t/riscv-how-to-install-interrupt-handler/21026 "2024-07-24T17:07:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonjwright](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/simonjwright/32/4770_2.png) [@simonjwright](https://forums.freertos.org/u/simonjwright)\
**Post date:** [July 24, 2024, 5:07pm UTC](https://forums.freertos.org/t/riscv-how-to-install-interrupt-handler/21026/1 "2024-07-24T17:07:54Z")

</div>

I’m following the instructions [here](https://www.freertos.org/Using-FreeRTOS-on-RISC-V.html#GCC_COMMAND_LINE_OPTIONS), which say that for GCC I should use `-DportasmHANDLE_INTERRUPT=external_interrupt_handler`. I don’t see `portasmHANDLE_INTERRUPT` anywhere in the FreeRTOS Kernel source (V11.1.0).

What I do see in portASM.S is a weak symbol `freertos_risc_v_application_interrupt_handler` - is this what I should be defining in my code?

(you’ll gather from this that I’m actually having trouble generating interrupts at all on this ESP32-H2 chip, but that’s not your problem!)

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [July 25, 2024, 12:32pm UTC](https://forums.freertos.org/t/riscv-how-to-install-interrupt-handler/21026/2 "2024-07-25T12:32:26Z")

</div>

This is how you are supposed to install interrupt handler - [FreeRTOS/FreeRTOS/Demo/RISC-V\_RV32\_SiFive\_HiFive1-RevB\_IAR/main.c at main · FreeRTOS/FreeRTOS · GitHub](https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_IAR/main.c#L191-L199).

Those instructions are outdated. We will fix those. Thank you brining it to our attention.

---

<div class="post-metadata">

**Author:** ![simonjwright](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/simonjwright/32/4770_2.png) [@simonjwright](https://forums.freertos.org/u/simonjwright)\
**Post date:** [July 25, 2024, 3:34pm UTC](https://forums.freertos.org/t/riscv-how-to-install-interrupt-handler/21026/3 "2024-07-25T15:34:18Z")

</div>

Sorry, but the link you gave tells how to install the **trap** handler; I’ve already done that, and that section of the document is OK.

If you look down to [line 300](https://github.com/FreeRTOS/FreeRTOS/blob/36b803e3582a4f22bf6540fb07e9f57f09ee9127/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_IAR/main.c#L300) there’s a function `freertos_risc_v_application_interrupt_handler()` which defines the strong version of the symbol I noted above, and that’s what the trap handler calls eventually, and that’s what users need to provide.

If people are defining the interrupt handler in C++, they’ll need to take measures to ensure the right symbol is generated (`external (C) {...}`, I think?)

---

<div class="post-metadata">

**Author:** ![aggarg](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/aggarg/32/4245_2.png) [@aggarg](https://forums.freertos.org/u/aggarg)\
**Post date:** [July 25, 2024, 6:15pm UTC](https://forums.freertos.org/t/riscv-how-to-install-interrupt-handler/21026/4 "2024-07-25T18:15:29Z")

</div>

> [@simonjwright](#):
>
> If you look down to [line 300](https://github.com/FreeRTOS/FreeRTOS/blob/36b803e3582a4f22bf6540fb07e9f57f09ee9127/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_IAR/main.c#L300) there’s a function `freertos_risc_v_application_interrupt_handler()` which defines the strong version of the symbol I noted above, and that’s what the trap handler calls eventually, and that’s what users need to provide.

Apologies. You are exactly right.

> [@simonjwright](#):
>
> If people are defining the interrupt handler in C++, they’ll need to take measures to ensure the right symbol is generated (`external (C) {...}`, I think?)

Yes, that is right.
