This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Best way for save project

Hi,

I would like to save my project and add something like a version number to it. I use an example from nordic SDK. So in my case I use solution from ...\examples\ble_peripheral\ble_app_uart.

If I press "save all" in SES, only main.c is saved.

But I modify also files such as ble_nus.c, which is saved in folder ...\components\ble\ble_services\ble_nus

Is it possible, to create a folder with all "used and customized files" (.c and .h) in it?

Parents
  • I agree with  that it isn't recommended to modify the libraries or drivers already present in the SDK, at least you shouldn't change the API (the functions in the .h file used to interact with). Since it may break other examples using that library. To copy the content into your own custom library and then modify it, is probably a safer option.

    However, to your question. One approach is is to put your custom libraries inside e.g. examples\ble_peripheral\ble_app_uart, since (I think) this will make them part of the solution and when you press "save all" they will be included. In addition, you could run git init inside examples\ble_peripheral\ble_app_uart which will make it easy to track all the changes you've done.

    Best regards,

    Simon

  • Hi,

    I´ve copied

    - main.c

    -flash_placement

    -EMPROJECT-file

    to another specific folder. Now, I would like to make the example "ble_app_uart" runable. Of course I got many errors after trying to compile. I have to include all libraries which are used in main.c to my new folder. Is there an easy way for doing this? Or do I have to copy every .h file to this new folder (there are a lot of it)?

  • Check out this ticket which explains how to build an example out of the SDK tree.

    This case may also be helpful.

    Best regards,

    Simon

  • Check out this ticket which explains how to build an example out of the SDK tree.

    I tried this, but it doesn´t works as espected. I did the steps as described in the instruction. But when I do the last step (build solution), I got a few errors. The libraries doesn´t exist.

    For make this working, I have to copy all the folders from SDK (components, external and so on) to my example folder. Sure, because the libraries are all in these folders. Is that the solution the older TO was looking for? In this case, the example folder contains all existing SDK libraries.

    My aim was it, to just serperate my examples and the libraries for just this example.

    So in my case I would like to have two folders:

    1. C:\\ble_app_uart  (with the example in it)

    2. C:\\ble_app_uart\libraries (with just all the needed libraries for the example in it)

    My opinion is, that I then have a very small project folder with just my needed files in it and not a big folder with every libraries from SKD in it.

    Isn´t that the normal way for developing?

  • simon1516 said:

    My opinion is, that I then have a very small project folder with just my needed files in it and not a big folder with every libraries from SKD in it.

    Isn´t that the normal way for developing?

    The normal (at least from what I've seen) and the easiest way of creating a project with the nRF5 SDK is to do it from within the SDK. E.g. inside <..>\examples\ble_peripheral. This is because all the paths in the example projects are relative from the location they are placed.

    Then you can run git init from e.g. <..>\examples\ble_peripheral\my_ble_project, upload my_ble_project to Github, and you can share it with other people. The folder/repo my_ble_project will also contain all your custom libraries. Then they can easily test it, by downloading the appropriate SDK and place it correctly within it.

    What are your main reasons for building it outside the SDK? The end result will not be any different (the compiler will only include the software that is actually being used by the project), and there are no practical differences except for the location of the project and all the paths it's using.

    Are your reason due to preference, and that it is a cleaner approach?

    If you would still like to build it outside the SDK I can help you with that.

    Best regards,

    Simon

  • The folder/repo my_ble_project will also contain all your custom libraries.

    Can you explain me that? I can´t see such folder when I create a copy of example project in  <..>\examples\ble_peripheral\my_ble_project


    However, to your question. One approach is is to put your custom libraries inside e.g. examples\ble_peripheral\ble_app_uart

    If I for example customize a few libraries (e.g.  <..>\components\ble\ble_services\ble_nus). Where should i save the copy? And where do I have to change the path to it?

    It´s okay for me, developing in the SDK environment, but maybe it´s neccessary to seperate the modified files. For example if I would like to upload the project with all modified files. How can I extract them?

    Is there a way, to delete unused .h and .c files from project? There are much included .h files in one project. I don´t know if I need them all.

Reply
  • The folder/repo my_ble_project will also contain all your custom libraries.

    Can you explain me that? I can´t see such folder when I create a copy of example project in  <..>\examples\ble_peripheral\my_ble_project


    However, to your question. One approach is is to put your custom libraries inside e.g. examples\ble_peripheral\ble_app_uart

    If I for example customize a few libraries (e.g.  <..>\components\ble\ble_services\ble_nus). Where should i save the copy? And where do I have to change the path to it?

    It´s okay for me, developing in the SDK environment, but maybe it´s neccessary to seperate the modified files. For example if I would like to upload the project with all modified files. How can I extract them?

    Is there a way, to delete unused .h and .c files from project? There are much included .h files in one project. I don´t know if I need them all.

Children
  • simon1516 said:
    Can you explain me that? I can´t see such folder when I create a copy of example project in  <..>\examples\ble_peripheral\my_ble_project

    The folder my_ble_project was just an imaginary folder I made up, e.g. you copy the folder examples\ble_peripheral\ble_app_uart, rename it to e.g. examples\ble_peripheral\my_ble_project, and modify it according to your needs.

    The reason you don't see any other .c/.h files in the default projects in the SDK is that nearly all drivers and libraries (source (.c) and header files (.h)) they're using are already present in the SDK. There are some exceptions, like the examples\ble_peripheral\ble_app_gatts_c example, which has created some custom files for that project (app_adv.c, app_adv.h and app_bsp.c). 

    simon1516 said:
    If I for example customize a few libraries (e.g.  <..>\components\ble\ble_services\ble_nus). Where should i save the copy? And where do I have to change the path to it?
    simon1516 said:
    It´s okay for me, developing in the SDK environment, but maybe it´s neccessary to seperate the modified files. For example if I would like to upload the project with all modified files. How can I extract them?

    While writing this, a "better" approach all the sudden popped into my head. Jump down to the arrows (⇒⇒⇒⇒⇒⇒) to go straight to it. Pick the approach that suits you best.

    You could rename folder components\ble\ble_services\ble_nus and it's subfiles and copy it into e.g. examples\ble_peripheral\my_ble_project. It will then look like this:

    Then you have to add #include "ble_nus_modified/ble_nus.h" to main.c in addition to adding examples\ble_peripheral\ble_app_uart\ble_nus_modified to the path's and the file examples\ble_peripheral\ble_app_uart\ble_nus_modified\ble_nus_modified.c in Project Explorer (https://www.youtube.com/watch?v=t-kh1EbesvI). It might be easier to add the files right into examples\ble_peripheral\my_ble_project since it is in the same folder as main.c and don't you don't need to add the path and the source file.

    Remember to remove all references to ble_nus.c and ble_nus.h in your project, so there won't be any collisions.

    Now your project is very portable, and you can upload examples\ble_peripheral\ble_app_uart\ble_nus_modified to e.g. GitHub and other people can easily test your project without modifying the SDK itself.

    ⇒⇒⇒⇒⇒⇒

    Another approach I just thought about, which actually allows you to modify the libraries directly, is to run git init inside e.g. nRF5_SDK_16.0.0_98a08e2, then create a branch my_ble_project_branch which is only intended to be used with your project (jump back to master when building other projects in the SDK). 

    Then you can modify the files you want, create a patch file, and you can simply share the patch files, which only includes the changes instead of the whole SDK and people can easily test your project by running git apply inside a fresh nRF5_SDK_16.0.0_98a08e2.

     

    simon1516 said:
    Is there a way, to delete unused .h and .c files from project? There are much included .h files in one project. I don´t know if I need them all.

    If there are header (.h) files included at the top of main.c in a default project, you should not delete it, since all of the .h files are included for a reason. Functions or variables or both from the included header files will be used somewhere in the project. However, if you remove all the functions/variables from the project, declared in a specific header file, you can remove the header file as well as the associated .c file. I don't think you should worry too much about unused .h and .c since the compiler will only include stuff that is actually used. Don't take my words for this, as I'm not an expert in compilers. There may be exceptions.

    If you are referring to all the source files in the Project Explorer window or all the included paths. This will not affect the size of the project unless it is used in the actual project. Like in main.c, or indirectly by functions called in main.c.

    Best regards,

    Simon

Related