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

nRF52 SDK directory structure, why is it organized as it is?

I'm pretty new to embedded systems development, but I've started to find my way around. I am trying to strip the SDK example programs down to minimal examples, in order to better understand them. However, before I throw away something I might need later, I thought that I should ask.

I have the nRF52 development board (the PCA10036). This is the only device I plan to use. I have SDK version 0.9.1. I've managed to get a few of the examples to compile, flash, and execute. I started with a Windows development environment and the free version of Keil MicroVision. My permanent development environment is pure Linux, running Ubuntu 15.04. I'm compiling with GCC ARM Embedded from the terminal prompt, using Nordic's GCC-compatible source code and makefiles. I flash the board using Segger's JLinkExe for Linux. And while I haven't gotten a UART listener working on my machine, I did manage to get Segger's JLinkRTTClient running (which is supposedly better anyway?). I may attempt to add Eclipse into this mix at some point -- but for now, I am getting some work done.

I am now contemplating how to set things up for my own code development. I have managed to modify a makefile, so that I can build programs outside of the SDK directory structure. However, for now, I have preserved the deeply-nested directory structures that are inside the SDK source directories themselves. But do I really need all of this structure to hold my main.c, my makefile, and my linker?

./
  main.c
  config/
     xxx_pca10036/
        nrf_drv_config.h
  pca10036/
     blank/
        arm5_no_packs/
           xxx_pca10036.uvprojx
           xxx_pca10036.uvoptx
        armgcc/
           makefile
           xxx_gcc_nrf52.ld

Clearly, I can remove the arm5_no_packs folder, since I'm not using Keil MicroVision any more. What exactly would I lose if I move the makefile and the linker into the base folder? The blank and pca10036 folders, as far as I can tell, do nothing for me. And once I eliminate those two nested folders, I might as well go all the way and remove armgcc as well, placing its files in the base folder.

Also: the makefiles I have examined so far did not include the config/xxx_pca10036 folder, which contains the file nrf_drv_config.h. While the contents of the file appear to define several critical SoC-specific constants, I have deleted this file (and its enclosing folders) in my own copies of the examples, with no apparent consequences. So, what is the purpose of nrf_drv_config.h, and why is it in that subfolder?

I know that my posts are long, but I try to be complete. If you read this far -- thanks!

Parents
  • You can reorder things any way you like. The directory structure Nordic uses in the SDK makes sense because they are trying to support examples which run with and without softdevices on a variety of boards, so you want the common code in the example main directory, and makefiles and board-specific files in subdirectories below that so you just cd into the subdirectory for your board and make and get a build for that device in that dir. It's quite handy for those of us who have quite the collection of boards, as well as for compiling the examples which run on more than one softdevice.

    Good example would be examples/ble_peripheral/ble_app_hrs/pca10028, look at the number of softdevice combinations that example supports.

    I'd suggest if you're just starting out and learning that you keep the basic skeleton of the project structure, with only the subdirectories you need. Even if that means you end up with directories which contain just one file or one directory, matching what the examples use removes one possible source of difference. When you get comfortable with it later, change it however you like.

  • Thank you, RK, for answering my question. I suspected that the directory structure had something to do with supporting multiple boards in an organized way. But since I'm new to this, I wasn't certain.

Reply Children
No Data
Related