You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/27 21:57:28 UTC

[GitHub] andrzej-kaczmarek opened a new pull request #72: [RFC] Porting NimBLE

andrzej-kaczmarek opened a new pull request #72: [RFC] Porting NimBLE
URL: https://github.com/apache/mynewt-nimble/pull/72
 
 
   This is initial version of porting layer to have some generic and relatively easy way to run NimBLE on different OS. Also included is working port for FreeRTOS with working example code for nRF52 + nRF5 SDK (needs to be downloaded separately).
   
   Since this is not yet documented (except for some sparse comments in FreeRTOS port), below is short description how it works (I'll use it as base for more detailes docs later).
   
   Porting code consists of 2 parts:
   - `porting/nimble` - parts of `kernel/os` and few headers from Mynewt which are required to build/run NimBLE, "startup" code to initialize NimBLE easily and makefile helpers
   - `porting/npl` - implementation of APIs for specific target OS (template and FreeRTOS variant available)
   
   Assuming target OS is built using own makefile, process of porting NimBLE is as follows (see `porting/examples/freertos_nrf5_sdk` where this process is implemented in fully working app):
   1. get target OS
   2. add following to makefile
   ```
   # set mynet-nimble root
   NIMBLE_ROOT := /here/is/my/mynewt-nimble
   # enable controller (host is by default)
   NIMBLE_CFG_CONTROLLER := 1
   # enable local TinyCrypt (can be omitted if target OS has TinyCrypt with AES and ECC)
   NIMBLE_CFG_TINYCRYPT := 1
   # setup NimBLE defs
   include $(NIMBLE_ROOT)/porting/nimble/Makefile.defs 
   ```
   3. including `Makefile.defs` defines few variable which should be used to add NimBLE files to build:
   * `NIMBLE_SRC` - sources to be included in build
   * `NIMBLE_OBJ` - same as above, but includes objects insteads
   * `NIMBLE_INCLUDE` - include paths to be added (only paths, not prefixed with `-I`)
   * `NIMBLE_CFLAGS` - extra flags to use when building (at least for NimBLE files)
   4. add implementation of interfaces defined in `npl/npl.h` (see `porting/npl/template`) and include this in build
   5. if building host-only, add HCI transport to build (see `porting/npl/template` for template, do not forget to initialize in code)
   6. in application, call `nimble_port_init()` before calling anything from NimBLE code (preferably during startup)
   7. in application, create task for NimBLE host (app priority) and, if required, for NimBLE controller (highest prio)
   * host task should do more or less the same as `main()` in Mynewt app, i.e. configure host and run default queue
   * controller task should just call `nimble_port_ll_task_func()`
   8. build and run
   
   Note on configuration: since Mynewt (and thus NimBLE) in configured using syscfg mechanism provided by `newt` tool, the configuration is provided by `syscfg.h` file generated by this tool. It can be either modified by hand or substituted by other configuration file. To make things a bit easier, `porting/nimble` has an app package which NimBLE dependencies - just create target for this app, change syscfg values, build (it won't link since there is no `main()` etc. but it does not matter) and extract generated `syscfg.h` file.
   
   What should be done next:
   - document porting process
   - make configuration easier
   - figure our sysinit configuration (which extra packages should be inited, like GATT services)
   - parts of `porting/nimble` is a bit of a mess so need to remove unused stuff
   - ideally NPL should have own API for mutexes (`struct npl_mutex`), semaphores (`struct npl_sem`), queues etc. used everywhere in NimBLE; currently some structures have to include certain fields only because they are accessed directly in Mynewt code - own APIs would resolve this; this means also shim porting layer for Mynewt would be necessary though
   - ???

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services