Skip to content

Commit 6ddb12b

Browse files
Damian-Nordicnordicjm
authored andcommitted
samples: nrf_rpc: ps_server: turn off alive LED on fatal error
Wrap z_fatal_error() in order to turn off the RPC alive LED as soon as the fatal error occurs. Signed-off-by: Damian Krolik <[email protected]>
1 parent 4890c58 commit 6ddb12b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

samples/nrf_rpc/protocols_serialization/server/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,16 @@ project(protocols_serialization_server)
1313
target_sources(app PRIVATE src/main.c)
1414

1515
if(CONFIG_NRF_PS_SERVER_FATAL_ERROR_TRIGGER)
16-
target_sources(app PRIVATE src/fatal_error_trigger.c)
16+
target_sources(app PRIVATE src/fatal_error_trigger.c)
17+
endif()
18+
19+
if(CONFIG_NRF_PS_SERVER_RPC_ALIVE_LED)
20+
# Wrap z_fatal_error to turn off the RPC alive LED on fatal error
21+
target_link_options(app INTERFACE -Wl,--wrap=z_fatal_error)
1722
endif()
1823
# NORDIC SDK APP END
1924

2025
# Link OpenThread CLI even though OPENTHREAD_SHELL is not selected
2126
if(CONFIG_OPENTHREAD_RPC)
22-
zephyr_link_libraries(openthread-cli-ftd)
27+
zephyr_link_libraries(openthread-cli-ftd)
2328
endif()

samples/nrf_rpc/protocols_serialization/server/src/main.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ void nrf_rpc_uart_initialized_hook(const struct device *uart_dev)
2929
LOG_ERR("Failed to configure RPC alive GPIO: %d", ret);
3030
}
3131
}
32+
33+
void __real_z_fatal_error(unsigned int reason, const struct arch_esf *esf);
34+
35+
void __wrap_z_fatal_error(unsigned int reason, const struct arch_esf *esf)
36+
{
37+
const struct gpio_dt_spec alive_gpio = GPIO_DT_SPEC_GET(DT_ALIAS(rpc_alive_led), gpios);
38+
39+
(void)gpio_pin_configure_dt(&alive_gpio, GPIO_OUTPUT_INACTIVE);
40+
41+
__real_z_fatal_error(reason, esf);
42+
}
3243
#endif
3344

3445
int main(void)

0 commit comments

Comments
 (0)