Skip to content

px4 notes

HackInvent edited this page Nov 13, 2016 · 13 revisions

nuttx integration in px4:

  • nuttx is integrated as a git submodule
  • actually it use a very old version (NuttX-6.27 vs NuttX-7.18)
  • the nuttx is compiled and exported using (make export) to NuttX/nuttx-export/libs/libnuttx.a

px4 application

Middleware

consist of 2 parts:

  • DriverFramework the driver abstraction layer.
  • uORB: the IPC communication layer, that handle communication between px4 components: it's an asynchrounous ipc. and it's implement the reactive manifesto. it implement (like Binder of android) a publish()/subcribe() API.

Flight Stack

the source code is hosted in: modules folder like (modules/navigator)

the examples folder is very interesting.

Host Control

the most used flight control software for px4 is QGroundControl

Creating a new module for samv7

NuttxConfig

  • Need to create a new nuttx-config in Firmware/nuttx-configs with the configuration of the new board
  • The current revision of PX4 stack doesn't include a board with with a samv7 chip
  • We copy an existing, let's take px4fmu-v4
  • We call the new one: tinker-sam70, an existing board that uses an cortex-m7 (Atmel's SAME70)
  • The first step will be to be able to compile the copied configuration with the new name, and the second step is to modify the configuration tinker-same70 with the new boards parameters

Step1: compling the renamed configuration

  • no modification is required inside the folder nuttx-configs/tinker-same70/
  • we will add the new copied board to the compilation configuration

src/drivers/boards

  • copy px4fmu-v4 into tinker-same70
  • It contains bus and GPIO mappings and the board initialization code.

cmake/configs

  • cp nuttx_px4fmu-v4_default.cmake nuttx_tinker-same70_default.cmake

Images/

  • cp px4fmu-v4.prototype tinker-same70.prototype
  • you can modify the attributes, they will be used to identify the board in the nuttx OS

Makefile

  • add a compilation entry for tinker-same70

Step1 done!

  • now normally you can build your new clone board by hitting "make tinker-same70_default"

Step2: updating the new configuration with cortex-m7 same70 target

  • before that you continue, you need to make sure that the PX4 stack you are using includes the same70 chips in NuttX/nuttx/arch/arm/src/
  • now that we finished creating the tinker-same70 board, we configure it to the real board configuration

cmake/nuttx/px4_nuttx_impl.cmake:

  • add: elseif (${config_nuttx_hw} STREQUAL "m7") set(cpu_flags -mcpu=cortex-m7 -mthumb ) in function(px4_os_add_flags)

cmake/configs/nuttx_tinker-same70_default.cmake

  • replace m4 by m7 in px4_nuttx_configure
  • TBD

nuttx-configs/tinker-same70/

  • board.h, remove all the links to STM32

src/drivers/boards/tinker-same70/

  • board_config.h, remove all the links to STM32

App

  • The start script is located in ROMFS/px4fmu_common