Hi,
we are using an nRF9160 on a custom board with NCS 1.8.0. I have been able to reproduce the following behaviour with a nRF9160 DK 1.0 and NCS 1.9.1
For our application, we need mcuboot to have its secondary on an external SPI flash. We use SPI3 for that and of course configure it for mcuboot in its device tree.
In our main application, we need 3 UARTs (we use UART0,1,2) and on the "3" block, we need to use SPI and I2C "simultaneously" using PRS with the nrfx drivers. Of course that SPI3 and I2C3 are not running at the same time, but they get initialized, used and deinitialized consecutively. just one time it's a spim3 and one time it's a twim3.
But some strange problems start to occur, when using the function block 3 slightly different.
If you init the spim/twim as "blocking", i.e. without a callback function for events, and initialize, transfer and deinitialize consecutively, everything seems to work fine.
But when I want to use a callback function, I get a fault at runtime.
void main(void)
{
printk("Hello World ! %s\n", CONFIG_BOARD);
eErr = nrfx_spim_init(&sSpimInstance, &sDevCfgSpim, NULL, NULL);
eErr = nrfx_spim_xfer(&sSpimInstance, &sSpiRxTxData, 0); /* xfer necessary to get crash */
nrfx_spim_uninit(&sSpimInstance);
eErr = nrfx_twim_init(&sTwimInstance, &sDevCfg, Main_EvtHandler, &sTwimInstance); /* crash */
nrfx_twim_enable(&sTwimInstance);
nrfx_twim_uninit(&sTwimInstance);
}
I always seem to crash at this function it looks like: __STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn),that wants to enable the interrupt for that function block for the callback.
I only seem to get these crashes when I use SPI3 also for the mcuboot flash access. For the MCUBOOT I obviously have the SPI3 "activated" in the device tree, while in my main application, i have it disabled in the device tree. My guess is, that MCUBOOT marks something somewhere, that the regular application cannot unmark or something, when just using nrfx drivers and not devicetree-zephyr-stuff.
When the Function block is used to do one thing, the other seems not to work anymore. Likewise I get a crash when using certain functions "between" the xfer and the deinit like so:
void main(void)
{
printk("Hello World ! %s\n", CONFIG_BOARD);
eErr = nrfx_spim_init(&sSpimInstance, &sDevCfgSpim, Main_TestEvtHandlerSpi, NULL);
eErr = nrfx_spim_xfer(&sSpimInstance, &sSpiRxTxData, 0);
k_sem_take(&sMain_Sem, K_MSEC(500)); /* crash */
nrfx_spim_uninit(&sSpimInstance);
}
This does not seem to be related to the SPI3 being used by MCUBOOT, but it's frustrating nonetheless.
I have attached a project for the DK that reproduces the fault.
It would be interesting to see, if there's a way to make this work, since ti is crucial to our project.