How to use hal external module with Zephyr?

I'm trying to create a HAL library to use it with zephyr application

From what I have read I need to create another module .

I can't figure out how to set up the module and how to compile it.

for the moment I have only 1 module to add with the following files hal_flash.c and hal_flash.h 

How can I add cmake files kconfig files to make it work with zephyr application

note: app on nRF9160

Parents
  • I used this project as reference https://github.com/zephyrproject-rtos/hal_nrfx

    I made those changes:

    and added flash.h file to "nrfx/drivers/include" and flash.c to "nrfx/drivers/src/"

    and changed the CMakeLists and added this line

    zephyr_sources_ifdef(CONFIG_NRFX_FLASH   nrfx/drivers/src/hal_flash.c)

    and for the test I created an app folder with this structure

    hal_nrfx/app
    ├── CMakeLists.txt
    ├── prj.conf
    └── src
        └── main.c
    

    in main i include 

    #include <hal_flash.h>

    In the prj.conf I added 

    CONFIG_NRFX_FLASH=y
    but I keep getting this error when I try to build with "west build -p auto -b nrf9160dk_nrf9160_ns ."
  • Hello

    Any reason you're trying to put your driver into the nrfx tree?

    If I wanted to include my own driver in a project I would just put the files under src/ in the application folder.

    Then you'll just need to add your drivers as sources in CMakeLists, see for example the Asset Tracker v2 sample in NCS as an example of how this is done.

    The error you're getting means that your CONFIG_NRFX_FLASH symbol isn't defined properly.

    I'm not entirely sure what you'll have to do to make Kconfig recognize your config symbol, but I can look into it.

    Best regards,

    Einar

  • Hi Einarh

    Thanks for helping

    I want to create external module with my own hal files.

    then when creating an application I just want only to include the hal

    #include <hal_xxx.h>

    and add this in prj.conf

    CONFIG_hal_xxx=y

Reply Children
Related