Adding a device driver to a nRF Connect SDK Zephyr freestanding application

Hello,

I am having a lot of trouble adding a driver to my application. I have followed the tutorial here: https://www.zephyrproject.org/how-to-build-drivers-for-zephyr-rtos/ and am attempting to use the example application here: https://github.com/zephyrproject-rtos/example-application along with looking at how the current Zephyr drivers are implemented.

Specifically I am using an NRF5340DK and need to modify the nrf_qspi_nor.c implementation slightly to better fit my needs. I can still use the Flash API to interact with the driver. I would like to set up the driver to use a freestanding application as it is easier to deal with, however I am willing to use a workspace application. 

I was originally planning to simply copy it into my own driver folder and make modifications there. However I am having trouble with that so I am trying to simplify it to a bare minimum implementation.

I have stripped the project and driver implementation down to the basics and have a very simple driver setup using the flash API (based off of flash_esp32.c since it was a very simple flash implementation. I have stripped it of any dependencies or references to ESP and other files. I have also forgone any Kconfig files and am always including the driver in the zephyr library in the Cmake files. I have tried this in both a workspace project and freestanding application project and both result in device_get_binding returning null at runtime.

The tutorials seem to differ slightly from the workspace and freestanding applications that the nRF Connect VSCode extension generates. Is there an example or tutorial for adding a driver that is updated for the latest version of Zephyr and the nRF Connect SDK anywhere?

I have attached the projects so that it is more clear what I am talking about and so it can be tested elsewhere.

My file tree looks like this:

.
├── CMakeLists.txt
└── drivers/
    ├── flash
    └── CMakeLists.txt/
        ├── qspi
        └── CMakeLists.txt/
            ├── CMakeLists.txt
            └── flash_tester.c

For the freestanding application, the root is in the project folder. For the workspace application, the root is in the workspace root.

Thank you,

flash_test_workspace.zip spi_flash_bare_freestanding.zip

Windows 10 21H2

VSCode 1.71.2

nRF Connect SDK extension for VSCode v2022.9.179

nRF Connect SDK v2.0.0  for the freestanding application and v2.0.2 for the workspace application

Parents Reply Children
  • Thank you very much, that link was what I needed to get my modified driver working!

    The only portion of the tutorial that didn't seem to work was 

    CONFIG_FLASH_NRF_FORCE_ALT=y
    can't be set in my case - but it doesn't seem to need to be set.
    I really appreciate the help here! I would love if there was an official tutorial post or DevAcademy tutorial that would go through adding a driver to an application and modifying an existing Zephyr driver and the various options that there are (in tree and maintaining a fork, out of tree, for freestanding applications, for workspace applications, etc). Hopefully you can see how I had a hard time finding the post and answer that you linked to. In addition, that post linked to multiple other posts and it gets a bit complicated when it's all through the forum.
    Again, thanks for the help Simon!
Related