Patching the nRF Connect SDK (Options)

Hello,

I am new to Zephyr and I am trying to figure out the best way to set up a new project for a nRF91 modem. Ideally, the project should allow patching of the nRF Connect SDK in the future if needed. To preface, I have found a few ways to do this by researching online. I have tested none of these methods:

1. Create a fork of the nRF Connect SDK and update your west.yml file to point to the fork. Patch the fork directly as needed.

2. Use CMake to overwrite a file with the patched file:  Custom implementation for a source file in the NRF connect SDK/ Zephyr 

This assumes the SDK lives in your project repo and is downloaded via "west update". Otherwise you will overwrite the default installation directory of the SDK in C:\ncs\... which is not good.

3. Use "git apply" to apply a ".patch" file to your SDK after downloading the SDK with "west update".

I don't particularly like any of these methods, and was wondering if the following is possible:

Question 1: Can you apply a patch by excluding the patched file from the "clean" version of the nRF Connect SDK when it is downloaded with "west update"?

For example:

Lets say you want to patch the following (Random file I picked): C:\ncs\v2.9.0\nrf\subsys\uart_async_adapter\uart_async_adapter.c

Is it possible to commit ONLY this file to my project repo (I am using SVN) and exclude it from the nRF Connect SDK download via the west.yml file?

Such as (Pseudo code): west.yml

manifest:
  self:
    path: application
  remotes:
    - name: nrf
      url-base: https://github.com/nrfconnect
  projects:
    - name: sdk-nrf
      remote: nrf
      path: nrf
      revision: v2.9.0
      import:
        path-prefix: external
      clone-depth: 1
      exclude:
        nrf\subsys\uart_async_adapter\uart_async_adapter.c

In the above, note the following:

exclude:
    nrf\subsys\uart_async_adapter\uart_async_adapter.c

Again, this is pseudo code. I don't know what the correct syntax is, or if this is even possible.

My goal is to avoid managing a fork of the nRF Connect SDK. I will be using SVN for version control, not Git. I also don't want to apply patches manually as this seems prone to user error of forgetting to apply the patches. Thus, it should be automated so the user/developer doesn't have to think about it.

Is my proposed method of excluding a specific file from the vanilla nRF Connect SDK download possible?

Edit: Question 2: Can you apply patches to the nRF Connect SDK that is installed in the default location (C:\ncs\...) without modifying the SDK itself?

Perhaps put the patched files in a /patches folder in your project directory and point your project to use that file instead of the one in the nRF Connect SDK? This is what I used to do when developing with the old nRF SDK using Keil uVision IDE.

Thanks,

Derek

Parents
  • Hi,

     

    There are certain scenarios described here:

    https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/dev_model_and_contributions/adding_code.html

    Question 1: Can you apply a patch by excluding the patched file from the "clean" version of the nRF Connect SDK when it is downloaded with "west update"?

    For example:

    Lets say you want to patch the following (Random file I picked): C:\ncs\v2.9.0\nrf\subsys\uart_async_adapter\uart_async_adapter.c

    Is it possible to commit ONLY this file to my project repo (I am using SVN) and exclude it from the nRF Connect SDK download via the west.yml file?

    No, that isn't possible. For such a method, I would recommend forking the repo in question and aligning it towards what you require.

    One could manually patch as well for each checkout, but as you mention; this is error-prone. 

    Edit: Question 2: Can you apply patches to the nRF Connect SDK that is installed in the default location (C:\ncs\...) without modifying the SDK itself?

    Perhaps put the patched files in a /patches folder in your project directory and point your project to use that file instead of the one in the nRF Connect SDK? This is what I used to do when developing with the old nRF SDK using Keil uVision IDE.

    This is technically possible, but there is no method/command that will ensure that the patches are applied. This required logic will then be pushed onto your application.

    Is my proposed method of excluding a specific file from the vanilla nRF Connect SDK download possible?

    If you were to add features, like a i2c-sensor that does not exist in sdk-zephyr or sdk-nrf, one can add this locally to a dedicated application with extra_zephyr_modules (docs link: https://docs.zephyrproject.org/latest/develop/modules.html#integrate-modules-in-zephyr-build-system)

    With this, you add both the sensor/driver/i2c/my_sensor .c/.h implementation as well as the DT-yaml files.

     

    However, this is for additions, not patching what is already present.

     

    Kind regards,

    Håkon

  • A small thing to add since this is/was a common complaint:

    https://github.com/zephyrproject-rtos/zephyr/pull/83243

    There is a new feature and is not yet in Nordic's fork of Zephyr but may provide a path forward in a future nRF Connect SDK release.

  • Hey Helmut,

    This looks neat and promising! Seems similar to applying patches with git. Thanks for letting me know! I will be looking forward to this if it makes its way to future nRF Connect SDK releases.

    Thanks,

    Derek

Reply Children
No Data
Related