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

Best Practices for Starting a New Project in SES Based on Example Application

I am about to start a new project for the nRF52840DK using SES in Ubuntu 18.04. I would like to start with an existing application but I don't want to change the original example application that comes with SES in case I get things wrong and need to start a second time. I have been reading the chapter in the SES manual on projects, but it is not clear to me what best practices are:

1) I am guessing I need to start a new "Workspace", and copy an existing example into this workspace. Is there a recommended location relative to $(StudioDir) that this new workspace should be located (aside: where is $(StudioDir) defined? I can't find it in Tools->Options or Project->ContxtMnu->Options). The PrjName.emProject files all use relative addressing for everything needed to build the project. Such as:

      c_user_include_directories="../../../config;../../../../../../components;../../../../../../components/ble/ble_advertising;../../../../../../components/ble/ble_dtm;../../../../../../components/ble/ble_racp;../../../../../../components/ble/ble_services/ble_ancs_c;../../../../../../components/ble/ble_services/ble_ans_c;../../../../../../components/ble/ble_services/ble_bas;../../../../../../components/ble/ble_services/ble_bas_c;../../../../../../components/ble/ble_services/

... for many many lines

Do we need to modify all of these by hand using an editor, or is there some automated way we can copy an example project to a new Workspace, and have the PrjName.emProject file updated automatically? Should we place the new workspace somewhere in $(StudioDir) to make this process easier?

My previous experience had under the File menu, a choice "New->Project->From Existing Project" choice that looked after almost all of the necessary changes of the configuration files. Does SES have something like this? Or is there a recommended best practices way to simplify this task? Sort of related, is there an automated way of making the PrjName.emProject file based on a template, and say a value for $(StudioDir) that will look after most of the boiler plate, compilation flags, etc.?

Finally, is there a link to a tutorial that starts a new project based on an existing project, or should I write one (I need it for future projects for student groups).

  • Hello,

    It seems like the most commonly used approach is to make a copy of the example project and simply keep it in the same SDK directory as the original one. But as I've tried to illustrate by the screenshots below,  it's possible with relatively few steps to move an example outside of the SDK tree if you can edit the xml formatted project file with a text editor that supports "search&replace".

    Moving SDK example to a different location.

    1. Pick an example project that best fits the requirements and copy it to your workspace.

    2. Open project files you just copied in SES and add a new project macro that points to your SDK copy. To make sure the setting is applied globally for all configurations, open the project settings at the top level ('Solution') and add the macro under the 'Common' configuration. 

    3. Now we can replace the relative source paths with the macro we added in step 2.

    4. That's it. Now you only need to update the SDK_ROOT macro if you want to move the project.

    Example:

    workspace.zip

    Should we place the new workspace somewhere in $(StudioDir) to make this process easier?

    StudiDir can be used if you want to add source files that have been installed through the package Manager in SES.

  • Vidar, thank you; I will give this a try. It is very difficult for me to see the details of the embedded pictures on my machine (my eyesight is not great). I'm guessing, I download the attached zip file, unzip, and add it as a global macro in step 2; I can't make out exactly where to add it from the picture, but I think I might be able to figure it out from the text. Regarding step 3, again I can't make out the details, but I'm guessing the window that is opened is a search and replace window. I'm not used to using a "macro" in a search and replace window; I'm guessing this might be an option specific to SES? Anyways, I will give it a try. Your e-mail has been useful in telling me: 1) there is no automated way, but by: 2) carefully choosing where to copy a project to, and 3) using some of the existing tools with the down-loaded macron, it shouldn't be too difficult.

  • Maybe you did it already, but you should be able to zoom in on the pictures if you click on them?

    again I can't make out the details, but I'm guessing the window that is opened is a search and replace window

    Correct. It's taken from the Notepad++ editor which I don't think is available on Linux. But most code editor should support this.

    Let me know if you are not able to zoom in on the pictures. Then I can make new ones an upload them in a zip file instead.

  • Got stuck before I got going at 2)

    "Open project files you just copied in SES and add a new project macro that points to your SDK copy. "

    I don't know how to "add a new project macro". Is this a macro that makes a new project.

    I went back to the user manual for Segger Embedded Studio and on pg 88 under Project Macros is :

    Project macros
    To define a project macro:
    To set the project macros:
    1. Select the appropriate solution/project in the Project Explorer.
    2. Use Project > Options to show the project options dialog.
    3. In the Project Options dialog's General Options group, select the Macros option.
    4. Click the ellipsis button on the right.
    5. Set the macro using the syntax name = replacement text.

    I selected the Solution line of my copied solution/project, then under the Menu Project, I selected Options. I was careful in the upper left where the configurations can be chosen to select : Private Configurations: Common. I can see on the left a line with General, and when I click that, I can see (I tried pasting in a screen shot; didn't work):

    General

        Environment Variables                                                 ...

    I think I can use this to add an environment variable which I'm guessing is what you are instructing when you say "add a new project macro that points to your SDK copy". Is an environment variable a macro? I'm guessing yes. But I don't know the name I should choose for the environment variable and do I point it at my new copied project or the original place I copied it from, and I don't know how to use it. When I figure all this out, I really think I will need to write a Getting Started Guide.

    Still, I have my SDK in .../SDK. Under SDK, I made a new directory called Workspace. Under this I put a new directory called ble_peripheral/. In this directory, I copied the original project (ble_app_blinky). I then changed everywhere the original project name was to ble_blink_pca10056_s140... including in the project file.

    This leaves all the relative paths in the project file (now called ble_blink_pca10056_s140.emProject) pointing to same location and I can successfully build the project. This gives me a copy I can start to modify. I also found that I think I can see the settings for all of the Segger Environment Variables (again, are these also called macros?) by  right-click solutions line, choosing Options, and then under Code->Build left-click in the line called Project Directory, and then left click on the three dots that appear, and then in the window that pops up, left-click on the round circle at the right of where it says Macros (I really wish I could copy in a screen shot). This might be useful in the future.

    Anyways, thank you for your help. Due to my inexperience, I can not follow your directions, but I think that just by copying to the carefully chosen location that didn't break relative paths, I can continue on.

  • P.S. the workspace.zip file contained a complete SDK hierarchy; I think this is the same as what I already have and I'm not sure if I should replace my current SDK; for now, I'm assuming I don't need the new downloaded SDK.

Related