This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

using spi in bootloader

Hi,

i'm doing my own bootloader and i want to use external flash to download image trough a spi. The bootloader project based on example from SDK11, now just an external flash interface is added by me.The problem is that spi only works if softdevice is already enabled ( calling nrf_drv_spi_xfer(); before ble_stack_init(!app_reset); hangs system and no spi activity on oscilloscope). Is my suggestion true? If so, how to enable spi functionality without the softdevice?

  • No it's not true - the spi driver does not need the softdevice. You can see that for yourself just by looking through the c code, there are no sd_ calls in there. That driver works just fine standalone.

    So your problem may have something else to do with the fact it's compiled for use with a softdevice but it's not the spi driver.

    So hit break in your debugger and find out where you are, possibly you asserted or an error code was returned and you're sitting in a spin loop in an error handler.

  • Hi, RK

    I understand the spi does not require SD but in this my experience it doesn't work without properly enabled SD, and i wonder why. Yes, the project uses SD, it is a bootloader for DFU via BLE.

    nrf_drv_spi.c, line 495, while (!nrf_spim_event_check(p_spim, NRF_SPIM_EVENT_END)){} In that line the program is looped. That means we are waiting for an ending flag. In debugger all NRF_SPI1 module registers settings seems to be correct, but no any physical activity on spi pins. Direct write in debugger in NRF_SPI1->START_TASK also has no effect. It seems like there is no any clock source for the spi module.

  • Nothing comes to mind instantly. It's not clock source, the SPI module will start the HF clock it needs when it needs it, it doesn't need a LF clock so that's not it.

    If you're writing the registers directly and not getting anything then that's even more odd. All these peripherals work just fine standalone and there's very little that requires setting up before you use them, unlike other MCUs you don't have to set up a complicated clock and power config, it's all automatic.

    The only other thought I had was that just having SOFTDEVICE_PRESENT defined, which you do if you're building something with a softdevice makes some of the library code use sd_ calls instead of native ones, however I didn't find anything like that when I was looking.

    Try setting PSEL, FREQUENCY, TXD and RXD, CONFIG and ENABLE (make sure you write 7 to that) and starting the task, just to prove it works natively.

  • The problem is solved, it was my fault. I forget to set the CONFIG_NFCT_PINS_AS_GPIOS key for the bootloader project (since in my pCB spi uses pin 9 - shared this NFCT) but set it for my application project. So accidentally run of app set pin 9 as gpio and enables the SD. I misplaced that signs as enabling the SD in bootloader project.

Related