Hi,
using SDK 3.0.2 and build for the *ns target.
The idea is to put the CPU to sleep and while it is sleeping GPIO events (e.g. button press) shall increment a counter. Once CPU wakes up it gets the counter value and processes it.
Therefore I want to use GPIO and PPI and Timer.
In a first step I just want a "light version", i.e. button press to switch an LED without counter. So one GPIO should be connected via PPI to another GPIO.
The function to do it looks like:
void button_hw_counter_init(void)
{
nrfx_gpiote_init(NULL, 0);
gpio_pin_configure_dt(&debug_led, GPIO_OUTPUT_INACTIVE);
// Use the correct struct for input config
nrfx_gpiote_input_pin_config_t gpiote_in_cfg = {
.p_pull_config = &pullup
};
nrfx_err_t res = nrfx_gpiote_input_configure(NULL, button3.pin, &gpiote_in_cfg);
if (res != NRFX_SUCCESS) {
LOG_ERR("nrfx_gpiote_input_configure failed: %d", res);
}
// // nrfx_gpiote_event_enable(BUTTON3_GPIOTE_CH, true); // Remove if not available
nrf_gpio_cfg_output(debug_led.pin);
nrf_gpio_pin_clear(debug_led.pin);
nrf_gpiote_task_configure(NRF_GPIOTE, BUTTON3_GPIOTE_CH + 1, debug_led.pin,
NRF_GPIOTE_POLARITY_LOTOHI, NRF_GPIOTE_INITIAL_VALUE_LOW);
nrf_gpiote_task_enable(NRF_GPIOTE, BUTTON3_GPIOTE_CH + 1);
uint8_t dppi_ch = BUTTON3_DPPI_CH;
#if defined(DPPI_PRESENT)
nrfx_dppi_channel_enable(NULL, dppi_ch);
#else
nrfx_ppi_channel_enable(dppi_ch);
#endif
uint32_t gpiote_evt_addr = nrfx_gpiote_in_event_address_get(NULL, BUTTON3_GPIOTE_CH);
uint32_t gpiote_task_addr = nrfx_gpiote_out_task_address_get(NULL, BUTTON3_GPIOTE_CH + 1);
#if defined(DPPI_PRESENT)
nrfx_gppi_channel_endpoints_setup(dppi_ch, gpiote_evt_addr, gpiote_task_addr);
#else
nrfx_ppi_channel_endpoint_setup(dppi_ch, gpiote_evt_addr, gpiote_task_addr);
#endif
}
The .config in the output looks like this:
# # Peripheral Secure mapping # # CONFIG_NRF_FPU_SECURE is not set # CONFIG_NRF_CLOCK_SECURE is not set # CONFIG_NRF_POWER_SECURE is not set # CONFIG_NRF_SPIM0_SECURE is not set # CONFIG_NRF_TWIM0_SECURE is not set CONFIG_NRF_UARTE0_SECURE=y # CONFIG_NRF_SPIM1_SECURE is not set # CONFIG_NRF_TWIM1_SECURE is not set # CONFIG_NRF_UARTE1_SECURE is not set # CONFIG_NRF_SPIM2_SECURE is not set # CONFIG_NRF_TWIM2_SECURE is not set # CONFIG_NRF_UARTE2_SECURE is not set # CONFIG_NRF_SPIM3_SECURE is not set # CONFIG_NRF_TWIM3_SECURE is not set # CONFIG_NRF_UARTE3_SECURE is not set # CONFIG_NRF_SAADC_SECURE is not set # CONFIG_NRF_TIMER0_SECURE is not set # CONFIG_NRF_TIMER1_SECURE is not set # CONFIG_NRF_TIMER2_SECURE is not set # CONFIG_NRF_RTC0_SECURE is not set # CONFIG_NRF_RTC1_SECURE is not set # CONFIG_NRF_DPPI_SECURE is not set # CONFIG_NRF_WDT0_SECURE is not set # CONFIG_NRF_EGU0_SECURE is not set # CONFIG_NRF_EGU1_SECURE is not set # CONFIG_NRF_EGU2_SECURE is not set # CONFIG_NRF_EGU3_SECURE is not set # CONFIG_NRF_EGU4_SECURE is not set # CONFIG_NRF_EGU5_SECURE is not set # CONFIG_NRF_PWM0_SECURE is not set # CONFIG_NRF_PWM1_SECURE is not set # CONFIG_NRF_PWM2_SECURE is not set # CONFIG_NRF_PWM3_SECURE is not set # CONFIG_NRF_PDM_SECURE is not set # CONFIG_NRF_I2S_SECURE is not set # CONFIG_NRF_IPC_SECURE is not set # CONFIG_NRF_NVMC_SECURE is not set # CONFIG_NRF_GPIO0_SECURE is not set # CONFIG_NRF_GPIOTE0_SECURE is not set CONFIG_NRF_GPIO0_PIN_MASK_SECURE=0x00000000 CONFIG_NRF_DPPI_CHANNEL_MASK_SECURE=0x00000000 CONFIG_NRF_VMC_SECURE=y # end of Peripheral Secure mapping
When I boot the previously working software prints:
All pins have been configured as non-secure Booting TF-M v2.1.1-ncs4-2 [Sec Thread] Secure image initializing! FATAL ERROR: SecureFault FATAL ERROR: HardFault
Tried to play with configs like:
#CONFIG_NRFX_GPIOTE=y #CONFIG_NRFX_TIMER2=y #CONFIG_NRFX_DPPI=y CONFIG_NRFX_GPPI=y # CONFIG_TFM_SECURE_UART=n # CONFIG_TFM_SECURE_UART_SHARE_INSTANCE=y CONFIG_NRF_GPIO0_SECURE=n CONFIG_NRF_GPIOTE0_SECURE=n CONFIG_NRF_DPPI_SECURE=n CONFIG_NRF_GPIO1_SECURE=n # CONFIG_NRF_UARTE0_SECURE=n # CONFIG_TFM_SECURE_UART=n CONFIG_NRF_GPIO0_PIN_MASK_SECURE=0x00000000 CONFIG_NRF_DPPI_CHANNEL_MASK_SECURE=0x00000000 # CONFIG_TFM_SECURE_UART=n #CONFIG_TFM_SECURE_UART_SHARE_INSTANCE=y # CONFIG_TFM_LOG_LEVEL_SILENCE=y #CONFIG_BUILD_WITH_TFM=n
but without luck.
Can you give me a very simple example or hint how to solve this?
