diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4b3c5e34dfe151c31c7937d9e5dc325fa21dde9..c5f1bf449b4d385ab5d541e0a438ff53e23b585b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -397,6 +397,8 @@ endif()
 #=============================================================================
 # subdirectories
 #
+add_subdirectory(src/platforms/common)
+
 foreach(module ${config_module_list})
 	add_subdirectory(src/${module})
 endforeach()
diff --git a/Tools/astyle/files_to_check_code_style.sh b/Tools/astyle/files_to_check_code_style.sh
index 1fc7daf032773229e511684d7f0c7023d6a36dfe..cf1be67d0940d89177bc42aff0caebdff3755539 100755
--- a/Tools/astyle/files_to_check_code_style.sh
+++ b/Tools/astyle/files_to_check_code_style.sh
@@ -8,9 +8,9 @@ then
     PATTERN="$1"
 fi
 
-exec find src \
-    -path src/examples/attitude_estimator_ekf -prune -o \
-    -path src/examples/ekf_att_pos_estimator -prune -o \
+exec find src platforms \
+    -path platforms/nuttx/NuttX -prune -o \
+    -path platforms/nuttx/nuttx-configs -prune -o \
     -path src/lib/DriverFramework -prune -o \
     -path src/lib/ecl -prune -o \
     -path src/lib/matrix -prune -o \
diff --git a/cmake/configs/nuttx_aerocore2_default.cmake b/cmake/configs/nuttx_aerocore2_default.cmake
index 081ad2a757041d66de3fed8c6e07f7ed9ffe4e5f..3d201edd84599109484f9f25e7897873795978fc 100644
--- a/cmake/configs/nuttx_aerocore2_default.cmake
+++ b/cmake/configs/nuttx_aerocore2_default.cmake
@@ -126,11 +126,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_aerofc-v1_default.cmake b/cmake/configs/nuttx_aerofc-v1_default.cmake
index 7a2337fb3f7f777c20dfb8f72b18ec97ff5c8283..47cb05b4b61c0df6658a367c776eebe6d8a4bb64 100644
--- a/cmake/configs/nuttx_aerofc-v1_default.cmake
+++ b/cmake/configs/nuttx_aerofc-v1_default.cmake
@@ -87,7 +87,4 @@ set(config_module_list
 	lib/rc
 	lib/tailsitter_recovery
 	lib/version
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
 )
diff --git a/cmake/configs/nuttx_auav-x21_default.cmake b/cmake/configs/nuttx_auav-x21_default.cmake
index 408dbe2174025b981649f2b29d50a7ffd25f1db6..e8fb2875bcafb7b68a3c92ef0359990a6717b460 100644
--- a/cmake/configs/nuttx_auav-x21_default.cmake
+++ b/cmake/configs/nuttx_auav-x21_default.cmake
@@ -137,11 +137,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_crazyflie_default.cmake b/cmake/configs/nuttx_crazyflie_default.cmake
index 8da7b1cb2a3771c73bb6471a16e7c6d97b4e2fcb..e976f9030300beea134d5ae7a3330c796d11d26c 100644
--- a/cmake/configs/nuttx_crazyflie_default.cmake
+++ b/cmake/configs/nuttx_crazyflie_default.cmake
@@ -93,11 +93,6 @@ set(config_module_list
 	lib/tailsitter_recovery
 	lib/terrain_estimation
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_esc35-v1_default.cmake b/cmake/configs/nuttx_esc35-v1_default.cmake
index de768001cb1b7332f4996aca30b22502efddc159..1446f25ae8499fc000317a7eee206eac49ffd9e2 100644
--- a/cmake/configs/nuttx_esc35-v1_default.cmake
+++ b/cmake/configs/nuttx_esc35-v1_default.cmake
@@ -71,7 +71,4 @@ set(config_module_list
 	modules/systemlib
 	modules/systemlib/param
 	modules/uORB
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
 )
diff --git a/cmake/configs/nuttx_mindpx-v2_default.cmake b/cmake/configs/nuttx_mindpx-v2_default.cmake
index f7962b92b978e9a58f18567802751a6760743e7a..9f5486fd3b3a033d087f34fbf2d7e2baca027db2 100644
--- a/cmake/configs/nuttx_mindpx-v2_default.cmake
+++ b/cmake/configs/nuttx_mindpx-v2_default.cmake
@@ -141,11 +141,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_nxphlite-v3_default.cmake b/cmake/configs/nuttx_nxphlite-v3_default.cmake
index 18497332c983f8352de96b6eae2ad1676fbcb2cc..e298abbfd0ce5fe4b1ff56e915cb942275d94bf4 100644
--- a/cmake/configs/nuttx_nxphlite-v3_default.cmake
+++ b/cmake/configs/nuttx_nxphlite-v3_default.cmake
@@ -150,13 +150,6 @@ set(config_module_list
 	lib/version
 	lib/DriverFramework/framework
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake b/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake
index cffc6fb7d3d5021bcfb2cb49e1919ab7db80a0ce..46529d343c86abbc29a8e1b98e521ba01919fc1d 100644
--- a/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake
+++ b/cmake/configs/nuttx_px4-same70xplained-v1_default.cmake
@@ -119,11 +119,6 @@ set(config_module_list
 	lib/tailsitter_recovery
 	lib/terrain_estimation
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake b/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake
index fa45a6d0bb9278ae289b8593864e2319ec475a70..1585d3338a7dbb4079c479c4490983bb516271be 100644
--- a/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake
+++ b/cmake/configs/nuttx_px4-stm32f4discovery_default.cmake
@@ -43,11 +43,6 @@ set(config_module_list
 	lib/mathlib/math/filter
 	lib/mixer
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# Demo apps
diff --git a/cmake/configs/nuttx_px4cannode-v1_default.cmake b/cmake/configs/nuttx_px4cannode-v1_default.cmake
index 1eb386b10578a26de2835576004992e9ebcd21b4..bc9d6119d6ef4358a67dd57803fd95d659bdebf1 100644
--- a/cmake/configs/nuttx_px4cannode-v1_default.cmake
+++ b/cmake/configs/nuttx_px4cannode-v1_default.cmake
@@ -63,7 +63,5 @@ set(config_module_list
 	modules/systemlib
 	modules/systemlib/param
 	modules/uORB
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
+
 )
\ No newline at end of file
diff --git a/cmake/configs/nuttx_px4esc-v1_default.cmake b/cmake/configs/nuttx_px4esc-v1_default.cmake
index 0d7dd356f3ac7450b5d7f8b39f2f00199790e476..3c7d1ef1d3765ee081af664cc32d8f8e58eea581 100644
--- a/cmake/configs/nuttx_px4esc-v1_default.cmake
+++ b/cmake/configs/nuttx_px4esc-v1_default.cmake
@@ -72,7 +72,5 @@ set(config_module_list
 	modules/systemlib
 	modules/systemlib/param
 	modules/uORB
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
+
 )
\ No newline at end of file
diff --git a/cmake/configs/nuttx_px4fmu-v2_default.cmake b/cmake/configs/nuttx_px4fmu-v2_default.cmake
index cc6b33612f2db839bf756322b594cf8fcb9d8dcd..3074954189d563ac9cf70073428c90da715792f1 100644
--- a/cmake/configs/nuttx_px4fmu-v2_default.cmake
+++ b/cmake/configs/nuttx_px4fmu-v2_default.cmake
@@ -154,13 +154,6 @@ set(config_module_list
 	lib/tunes
 	lib/version
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/nuttx_px4fmu-v2_test.cmake b/cmake/configs/nuttx_px4fmu-v2_test.cmake
index 49db89e030a293de95c840df2ba7a551d4482d28..936403269f77b3bf04c0815511cc8442b5f88ba7 100644
--- a/cmake/configs/nuttx_px4fmu-v2_test.cmake
+++ b/cmake/configs/nuttx_px4fmu-v2_test.cmake
@@ -138,11 +138,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_px4fmu-v3_default.cmake b/cmake/configs/nuttx_px4fmu-v3_default.cmake
index 2fa87dd0b7166bee1ba8ed58b4b537503dea8607..940216d181b9a496cf484844992f5dbff5549a26 100644
--- a/cmake/configs/nuttx_px4fmu-v3_default.cmake
+++ b/cmake/configs/nuttx_px4fmu-v3_default.cmake
@@ -155,13 +155,6 @@ set(config_module_list
 	lib/tunes
 	lib/version
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/nuttx_px4fmu-v4_default.cmake b/cmake/configs/nuttx_px4fmu-v4_default.cmake
index 4535450c99a0206953077c0bc21efed9216c916b..ae7886af1e97d1f1fcbd97c51ce209fe631ff096 100644
--- a/cmake/configs/nuttx_px4fmu-v4_default.cmake
+++ b/cmake/configs/nuttx_px4fmu-v4_default.cmake
@@ -148,13 +148,6 @@ set(config_module_list
 	lib/tunes
 	lib/version
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/nuttx_px4fmu-v4pro_default.cmake b/cmake/configs/nuttx_px4fmu-v4pro_default.cmake
index b4735ae0fcc7b819a8c46102fcb2cc3dd62bf545..c07d33756c8c4e2fe51f9b39d5f7bf772a4cc8d9 100644
--- a/cmake/configs/nuttx_px4fmu-v4pro_default.cmake
+++ b/cmake/configs/nuttx_px4fmu-v4pro_default.cmake
@@ -147,13 +147,6 @@ set(config_module_list
 	lib/tunes
 	lib/version
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/nuttx_px4fmu-v5_default.cmake b/cmake/configs/nuttx_px4fmu-v5_default.cmake
index 111c9b58134d82e28230c8f2b3028c527090488f..72405c8959fb6898ed7af14c2d006cc109f1a540 100644
--- a/cmake/configs/nuttx_px4fmu-v5_default.cmake
+++ b/cmake/configs/nuttx_px4fmu-v5_default.cmake
@@ -149,13 +149,6 @@ set(config_module_list
 	lib/tunes
 	lib/version
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/nuttx
-	platforms/nuttx/px4_layer
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/nuttx_px4io-v2_default.cmake b/cmake/configs/nuttx_px4io-v2_default.cmake
index 78e3abe4d50102a5c926fe24373436a06cdd4662..0a0ebcb384086814f04a26c236c59fac43bda770 100644
--- a/cmake/configs/nuttx_px4io-v2_default.cmake
+++ b/cmake/configs/nuttx_px4io-v2_default.cmake
@@ -7,5 +7,4 @@ set(config_module_list
 	lib/mixer
 	lib/rc
 	modules/px4iofirmware
-	platforms/common
 )
diff --git a/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake b/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake
index bb1bb263e6a3a3d9a377388e67b79728b20b6f79..353de186e97d55d0c91e2253a51448a81ca0de40 100644
--- a/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake
+++ b/cmake/configs/nuttx_px4nucleoF767ZI-v1_default.cmake
@@ -126,11 +126,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 
 	#
 	# OBC challenge
diff --git a/cmake/configs/nuttx_s2740vc-v1_default.cmake b/cmake/configs/nuttx_s2740vc-v1_default.cmake
index 517692467364a1ee2b8f806b1a7162786b3d852d..2c6e3fe492455012399cfddfe848d74ea65f04ce 100644
--- a/cmake/configs/nuttx_s2740vc-v1_default.cmake
+++ b/cmake/configs/nuttx_s2740vc-v1_default.cmake
@@ -60,12 +60,4 @@ set(config_module_list
 	modules/systemlib/param
 	modules/systemlib
 	lib/version
-
-	#
-	# Libraries
-	#
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/nuttx
-	platforms/common
-	platforms/nuttx/px4_layer
 )
diff --git a/cmake/configs/nuttx_tap-v1_default.cmake b/cmake/configs/nuttx_tap-v1_default.cmake
index 6376193c4ef69ae8362ec365e87f04dcc7a5452c..a9474f00386328511ec67a928b2c7aa7d15856e2 100644
--- a/cmake/configs/nuttx_tap-v1_default.cmake
+++ b/cmake/configs/nuttx_tap-v1_default.cmake
@@ -102,9 +102,4 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-	platforms/nuttx
-
-	# had to add for cmake, not sure why wasn't in original config
-	platforms/common
-	platforms/nuttx/px4_layer
 )
diff --git a/cmake/configs/posix_bebop_default.cmake b/cmake/configs/posix_bebop_default.cmake
index 33c518e17cc5f19779f08b3db503f5a4fdc26fb8..cbca184cde15cb2da2396dfb73bd96a2de32d95f 100644
--- a/cmake/configs/posix_bebop_default.cmake
+++ b/cmake/configs/posix_bebop_default.cmake
@@ -85,13 +85,6 @@ set(config_module_list
 	lib/tailsitter_recovery
 	lib/terrain_estimation
 	lib/version
-
-	#
-	# POSIX
-	#
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 )
 
 set(config_df_driver_list
diff --git a/cmake/configs/posix_eagle_hil.cmake b/cmake/configs/posix_eagle_hil.cmake
index 65d48e7200dfaa01d1a86e6933f8fbb527528310..0efec4f18375164fb42311023e607d314cd045a2 100644
--- a/cmake/configs/posix_eagle_hil.cmake
+++ b/cmake/configs/posix_eagle_hil.cmake
@@ -48,9 +48,6 @@ set(config_module_list
 	lib/version
 	lib/DriverFramework/framework
 
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 	modules/muorb/krait
 	)
 
diff --git a/cmake/configs/posix_eagle_muorb.cmake b/cmake/configs/posix_eagle_muorb.cmake
index cf677300623f28ab3f9cf3a486c2273ead9be1d9..51ce40b9bb13b456b327f4bb3b150e98518fb4c8 100644
--- a/cmake/configs/posix_eagle_muorb.cmake
+++ b/cmake/configs/posix_eagle_muorb.cmake
@@ -19,9 +19,6 @@ set(config_module_list
 
 	lib/DriverFramework/framework
 
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
-
 	modules/muorb/krait
 	)
 
diff --git a/cmake/configs/posix_ocpoc_cross.cmake b/cmake/configs/posix_ocpoc_cross.cmake
index f1a07260ccf3b718bdf75e36c723d26ac9635560..47ae19d24eb5a70614610f08b3a7d2199d652cf2 100644
--- a/cmake/configs/posix_ocpoc_cross.cmake
+++ b/cmake/configs/posix_ocpoc_cross.cmake
@@ -95,13 +95,6 @@ set(config_module_list
 	lib/tailsitter_recovery
 	lib/terrain_estimation
 	lib/version
-
-	#
-	# POSIX
-	#
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 	
 	examples/px4_simple_app
 )
diff --git a/cmake/configs/posix_ocpoc_ubuntu.cmake b/cmake/configs/posix_ocpoc_ubuntu.cmake
index 20432e55dc63c55c7c73745d0d218ab4f476fdfd..a148295752a3c5be56e937c3168c40bdbb70b291 100644
--- a/cmake/configs/posix_ocpoc_ubuntu.cmake
+++ b/cmake/configs/posix_ocpoc_ubuntu.cmake
@@ -94,13 +94,6 @@ set(config_module_list
 	lib/tailsitter_recovery
 	lib/terrain_estimation
 	lib/version
-
-	#
-	# POSIX
-	#
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 	
 	examples/px4_simple_app
 )
diff --git a/cmake/configs/posix_rpi_common.cmake b/cmake/configs/posix_rpi_common.cmake
index cab5991d230d9c0a1d7a6a4aa0f8a555a63e6373..54023e3cb8a62bed31b10baa37e75766dfcddd68 100644
--- a/cmake/configs/posix_rpi_common.cmake
+++ b/cmake/configs/posix_rpi_common.cmake
@@ -107,13 +107,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-
-	#
-	# POSIX
-	#
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 )
 
 #
diff --git a/cmake/configs/posix_sdflight_default.cmake b/cmake/configs/posix_sdflight_default.cmake
index 2994d6342ab61ec753ab44dcf5f9f0322db8b5b6..657f7eea36e770590312a03fb4b6751051e102af 100644
--- a/cmake/configs/posix_sdflight_default.cmake
+++ b/cmake/configs/posix_sdflight_default.cmake
@@ -83,8 +83,4 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
-	)
+)
diff --git a/cmake/configs/posix_sdflight_legacy.cmake b/cmake/configs/posix_sdflight_legacy.cmake
index f7b05b7d749f0b69291271cf046ea874d309322a..f2c9ff3474eb90a19b87d572189a48a17ec14345 100644
--- a/cmake/configs/posix_sdflight_legacy.cmake
+++ b/cmake/configs/posix_sdflight_legacy.cmake
@@ -75,8 +75,4 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/tunes
 	lib/version
-
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 	)
diff --git a/cmake/configs/posix_sitl_default.cmake b/cmake/configs/posix_sitl_default.cmake
index 164357ac3b6ca9f1cc590e37edd728d027b0c233..e0122ec3cba5053c43128bf9a3d7c9cdaf2574b0 100644
--- a/cmake/configs/posix_sitl_default.cmake
+++ b/cmake/configs/posix_sitl_default.cmake
@@ -64,7 +64,6 @@ set(config_module_list
 	platforms/posix/tests/hrt_test
 	platforms/posix/tests/muorb
 	platforms/posix/tests/vcdev_test
-	platforms/posix/tests/wqueue
 
 	#
 	# General system control
@@ -135,13 +134,6 @@ set(config_module_list
 	lib/tunes
 	lib/version
 
-	#
-	# Platform
-	#
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
-
 	#
 	# OBC challenge
 	#
diff --git a/cmake/configs/posix_sitl_replay.cmake b/cmake/configs/posix_sitl_replay.cmake
index c61c95f0b4084dd3ccdad17e1f3be914c256ce6f..275dccb33eaf9edc52380ceb44a0a53a7031325f 100644
--- a/cmake/configs/posix_sitl_replay.cmake
+++ b/cmake/configs/posix_sitl_replay.cmake
@@ -4,9 +4,6 @@ set(CMAKE_TOOLCHAIN_FILE ${PX4_SOURCE_DIR}/cmake/toolchains/Toolchain-native.cma
 set(config_module_list
 	drivers/device
 	drivers/boards/sitl
-	platforms/common
-	platforms/posix/px4_layer
-	platforms/posix/work_queue
 	systemcmds/param
 	systemcmds/ver
 	systemcmds/perf
diff --git a/cmake/configs/qurt_eagle_hello.cmake b/cmake/configs/qurt_eagle_hello.cmake
index 741d9ee28d43e5b25589f3d55c5c62d91374ba75..aac80873b97737766cdfda8aeadd85f73f4a2e31 100644
--- a/cmake/configs/qurt_eagle_hello.cmake
+++ b/cmake/configs/qurt_eagle_hello.cmake
@@ -33,13 +33,5 @@ set(config_module_list
 	modules/systemlib/param
 	modules/systemlib
 	modules/uORB
-
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-	platforms/qurt/tests/hello
 	)
 
diff --git a/cmake/configs/qurt_eagle_hil.cmake b/cmake/configs/qurt_eagle_hil.cmake
index 4756b13620a22b5404228ac2fa6ec171bb26c7d3..0000d44997e2ab86c992fee4d210632dd3da4ada 100644
--- a/cmake/configs/qurt_eagle_hil.cmake
+++ b/cmake/configs/qurt_eagle_hil.cmake
@@ -73,13 +73,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/version
 
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-
 	#
 	# sources for muorb over fastrpc
 	#
diff --git a/cmake/configs/qurt_eagle_muorb.cmake b/cmake/configs/qurt_eagle_muorb.cmake
index 1089d9dab0f4127c57b55a5812959281e15215b9..059c7e545f5d33068a7fc6a778653b0daeeab0ac 100644
--- a/cmake/configs/qurt_eagle_muorb.cmake
+++ b/cmake/configs/qurt_eagle_muorb.cmake
@@ -45,14 +45,6 @@ set(config_module_list
 	lib/version
 	lib/DriverFramework/framework
 
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-	platforms/qurt/tests/muorb
-
 	#
 	# sources for muorb over fastrpc
 	#
diff --git a/cmake/configs/qurt_eagle_test.cmake b/cmake/configs/qurt_eagle_test.cmake
index 5ede3b3188ce43daa0763d69d7247038fbf70dcc..9757bec3f371eb75dfae9e0a4629dd888f70d74d 100644
--- a/cmake/configs/qurt_eagle_test.cmake
+++ b/cmake/configs/qurt_eagle_test.cmake
@@ -42,16 +42,5 @@ set(config_module_list
 	lib/mathlib
 	lib/mathlib/math/filter
 	lib/mixer
-
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-	platforms/qurt/tests/hello
-	platforms/posix/tests/vcdev_test
-	platforms/posix/tests/hrt_test
-	platforms/posix/tests/wqueue
 	)
 
diff --git a/cmake/configs/qurt_eagle_travis.cmake b/cmake/configs/qurt_eagle_travis.cmake
index 6b58ff2174e9440bca991a1a514633485c589266..987d7a6f29025870f120335d2b167e7e97e76d72 100644
--- a/cmake/configs/qurt_eagle_travis.cmake
+++ b/cmake/configs/qurt_eagle_travis.cmake
@@ -79,13 +79,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/version
 
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-
 	#
 	# sources for muorb over fastrpc
 	#
diff --git a/cmake/configs/qurt_sdflight_default.cmake b/cmake/configs/qurt_sdflight_default.cmake
index bd85d98215912b93573d70f3383cbea9adf2f22b..9d004b21d139e63cabb91c9a81e6bb75bfd31b95 100644
--- a/cmake/configs/qurt_sdflight_default.cmake
+++ b/cmake/configs/qurt_sdflight_default.cmake
@@ -97,13 +97,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/version
 
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-
 	#
 	# sources for muorb over fastrpc
 	#
diff --git a/cmake/configs/qurt_sdflight_legacy.cmake b/cmake/configs/qurt_sdflight_legacy.cmake
index 14c3530f45c9d77411b0d1320b88a98f36ab0452..c2229947fae3d4e728ba2110e8ff1b3c9fa66057 100644
--- a/cmake/configs/qurt_sdflight_legacy.cmake
+++ b/cmake/configs/qurt_sdflight_legacy.cmake
@@ -96,13 +96,6 @@ set(config_module_list
 	lib/terrain_estimation
 	lib/version
 
-	#
-	# QuRT port
-	#
-	platforms/common
-	platforms/qurt/px4_layer
-	platforms/posix/work_queue
-
 	#
 	# sources for muorb over fastrpc
 	#
diff --git a/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/CMakeLists.txt
index 647ee8f9361b63748883d8a82b995c4e9a08bfeb..b876adcfb58d98612df2834032c7edd2821a0f96 100644
--- a/platforms/nuttx/CMakeLists.txt
+++ b/platforms/nuttx/CMakeLists.txt
@@ -1,6 +1,41 @@
+############################################################################
+#
+#   Copyright (c) 2017 PX4 Development Team. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name PX4 nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
 include(common/px4_upload)
 include(cygwin_cygpath)
 
+add_subdirectory(src)
+
 if (NOT FW_NAME)
 	set(FW_NAME ${CONFIG}.elf)
 endif()
diff --git a/platforms/nuttx/cmake/px4_impl_os.cmake b/platforms/nuttx/cmake/px4_impl_os.cmake
index e3b2fba3c8534e87237ec58d55447df57720fe9d..a9877bce38bfc81611d410f23d0e289682d29a23 100644
--- a/platforms/nuttx/cmake/px4_impl_os.cmake
+++ b/platforms/nuttx/cmake/px4_impl_os.cmake
@@ -175,13 +175,17 @@ function(px4_os_add_flags)
 		LINK_DIRS ${LINK_DIRS}
 		DEFINITIONS ${DEFINITIONS})
 
-	set(added_include_dirs
+	include_directories(BEFORE SYSTEM
+		${PX4_BINARY_DIR}/NuttX/nuttx/include
+		${PX4_BINARY_DIR}/NuttX/nuttx/include/cxx
+	)
+
+	include_directories(
 		${PX4_BINARY_DIR}/NuttX/nuttx/arch/arm/src/armv7-m
 		${PX4_BINARY_DIR}/NuttX/nuttx/arch/arm/src/chip
 		${PX4_BINARY_DIR}/NuttX/nuttx/arch/arm/src/common
-		${PX4_BINARY_DIR}/NuttX/nuttx/include
-		${PX4_BINARY_DIR}/NuttX/nuttx/include/cxx
-		${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/apps/include
+
+		${PX4_BINARY_DIR}/NuttX/apps/include
 		)
 
 	#set(added_exe_linker_flags)
diff --git a/src/platforms/nuttx/px4_layer/CMakeLists.txt b/platforms/nuttx/src/CMakeLists.txt
similarity index 85%
rename from src/platforms/nuttx/px4_layer/CMakeLists.txt
rename to platforms/nuttx/src/CMakeLists.txt
index fd11e6e598c69608846894f538ec072ea31c2d85..602b1b710744f71f932377fcc0f524e855cf4cd6 100644
--- a/src/platforms/nuttx/px4_layer/CMakeLists.txt
+++ b/platforms/nuttx/src/CMakeLists.txt
@@ -1,6 +1,6 @@
 ############################################################################
 #
-#   Copyright (c) 2015 PX4 Development Team. All rights reserved.
+#   Copyright (c) 2017 PX4 Development Team. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -30,13 +30,5 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 ############################################################################
-px4_add_module(
-	MODULE platforms__nuttx__px4_layer
-	COMPILE_FLAGS
-	SRCS
-		px4_nuttx_tasks.c
-		../../posix/px4_layer/px4_log.c
-	DEPENDS
-		platforms__common
-	)
-# vim: set noet ft=cmake fenc=utf-8 ff=unix :
+
+add_subdirectory(px4_layer)
diff --git a/src/platforms/nuttx/CMakeLists.txt b/platforms/nuttx/src/px4_layer/CMakeLists.txt
similarity index 88%
rename from src/platforms/nuttx/CMakeLists.txt
rename to platforms/nuttx/src/px4_layer/CMakeLists.txt
index bd7e75c0aadbc852e95f37c8ae8e6f300fe68f03..cda2c1fbca015b0dc11f22b2b4c3ab8ba6c7888e 100644
--- a/src/platforms/nuttx/CMakeLists.txt
+++ b/platforms/nuttx/src/px4_layer/CMakeLists.txt
@@ -30,12 +30,16 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 ############################################################################
-px4_add_module(
-	MODULE platforms__nuttx
-	COMPILE_FLAGS
-	SRCS
-		px4_nuttx_impl.cpp
-	DEPENDS
-		platforms__common
-	)
-# vim: set noet ft=cmake fenc=utf-8 ff=unix :
+
+# skip for px4_layer support on an IO board
+if (NOT ${BOARD} MATCHES "px4io")
+
+	px4_add_module(
+		MODULE platform_px4_layer
+		SRCS
+			px4_nuttx_tasks.c
+			px4_nuttx_impl.cpp
+		DEPENDS
+			prebuild_targets
+		)
+endif()
diff --git a/src/platforms/nuttx/px4_nuttx_impl.cpp b/platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp
similarity index 99%
rename from src/platforms/nuttx/px4_nuttx_impl.cpp
rename to platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp
index b51303274d358607bb26435aa87a40ba9af7c684..7495b030cce9c7e9617e8845fe364bf9f943a8ac 100644
--- a/src/platforms/nuttx/px4_nuttx_impl.cpp
+++ b/platforms/nuttx/src/px4_layer/px4_nuttx_impl.cpp
@@ -41,7 +41,6 @@
 #include <px4_middleware.h>
 #include <drivers/drv_hrt.h>
 
-
 namespace px4
 {
 
diff --git a/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c b/platforms/nuttx/src/px4_layer/px4_nuttx_tasks.c
similarity index 96%
rename from src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c
rename to platforms/nuttx/src/px4_layer/px4_nuttx_tasks.c
index 1bf359d617abfb767e06bc5b8d53db0b8c6933f5..1f149d1a094b185b9ed961b6ef99cf4db23fa679 100644
--- a/src/platforms/nuttx/px4_layer/px4_nuttx_tasks.c
+++ b/platforms/nuttx/src/px4_layer/px4_nuttx_tasks.c
@@ -37,24 +37,22 @@
  * Implementation of existing task API for NuttX
  */
 
-#include <px4_config.h>
-#include <px4_tasks.h>
-#include <unistd.h>
+#include <nuttx/config.h>
+
+#include <sys/wait.h>
+#include <stdbool.h>
 #include <stdio.h>
-#include <fcntl.h>
-#include <sched.h>
-#include <signal.h>
+#include <stdlib.h>
 #include <unistd.h>
-#include <float.h>
+#include <signal.h>
 #include <string.h>
+#include <sched.h>
+#include <errno.h>
+#include <stdbool.h>
 
-#include <sys/stat.h>
-#include <sys/types.h>
-
-
+#include <px4_config.h>
 #include <px4_log.h>
-#include <systemlib/systemlib.h>
-
+#include <px4_tasks.h>
 
 void
 px4_systemreset(bool to_bootloader)
@@ -115,4 +113,3 @@ const char *px4_get_taskname(void)
 	return "app";
 #endif
 }
-
diff --git a/platforms/posix/CMakeLists.txt b/platforms/posix/CMakeLists.txt
index 3d2b365365df38c7b171129aba4d4ae3dae6e188..bd0263a246f56d348e937b138649273fe5f3a301 100644
--- a/platforms/posix/CMakeLists.txt
+++ b/platforms/posix/CMakeLists.txt
@@ -1,5 +1,7 @@
 include (common/px4_upload)
 
+add_subdirectory(src)
+
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 get_property(module_libraries GLOBAL PROPERTY PX4_LIBRARIES)
@@ -10,7 +12,7 @@ px4_posix_generate_builtin_commands(
 
 # Define build target
 set(APP_NAME px4)
-set(MAIN_SRC ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp)
+set(MAIN_SRC src/main.cpp)
 set(UPLOAD_NAME upload)
 
 if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
diff --git a/platforms/posix/cmake/px4_impl_os.cmake b/platforms/posix/cmake/px4_impl_os.cmake
index d4d8479f6ff890ddb64961b0771a7824ab6740d2..b33acb225de7a9be32a2a81bcc23534b4ea1ea3d 100644
--- a/platforms/posix/cmake/px4_impl_os.cmake
+++ b/platforms/posix/cmake/px4_impl_os.cmake
@@ -165,9 +165,7 @@ function(px4_os_add_flags)
 		DEFINITIONS ${DEFINITIONS})
 
         set(added_include_dirs
-		src/modules/systemlib
-		src/platforms/posix/include
-		mavlink/include/mavlink
+		platforms/posix/include
 		)
 
 	# This block sets added_definitions and added_cxx_flags.
diff --git a/platforms/posix/cmake/sitl_target.cmake b/platforms/posix/cmake/sitl_target.cmake
index ca116e83995a7af1da0e73359feb1e058c7dcc3b..bc772b0730ad51b7ac1559956089603b64e5b888 100644
--- a/platforms/posix/cmake/sitl_target.cmake
+++ b/platforms/posix/cmake/sitl_target.cmake
@@ -32,7 +32,7 @@ endfunction()
 # sitl run targets
 #
 
-set(SITL_RUNNER_MAIN_CPP ${PX4_SOURCE_DIR}/src/platforms/posix/main.cpp)
+set(SITL_RUNNER_MAIN_CPP src/main.cpp)
 px4_add_sitl_app(APP_NAME px4
 		UPLOAD_NAME upload
 		MAIN_SRC ${SITL_RUNNER_MAIN_CPP}
@@ -111,7 +111,7 @@ foreach(viewer ${viewers})
 				set(SITL_RUNNER_MODEL_FILE ${PX4_SOURCE_DIR}/${config_sitl_rcS_dir}/${model})
 				set(SITL_RUNNER_WORKING_DIRECTORY ${SITL_WORKING_DIR})
 
-				configure_file(${PX4_SOURCE_DIR}/src/platforms/posix/sitl_runner_main.cpp.in sitl_runner_main_${model}.cpp @ONLY)
+				configure_file(src/sitl_runner_main.cpp.in sitl_runner_main_${model}.cpp @ONLY)
 
 				px4_add_sitl_app(APP_NAME px4_${model}
 						UPLOAD_NAME upload_${model}
diff --git a/src/platforms/posix/include/arch/board/board.h b/platforms/posix/include/arch/board/board.h
similarity index 100%
rename from src/platforms/posix/include/arch/board/board.h
rename to platforms/posix/include/arch/board/board.h
diff --git a/src/platforms/posix/include/crc32.h b/platforms/posix/include/crc32.h
similarity index 100%
rename from src/platforms/posix/include/crc32.h
rename to platforms/posix/include/crc32.h
diff --git a/src/platforms/posix/include/hrt_work.h b/platforms/posix/include/hrt_work.h
similarity index 100%
rename from src/platforms/posix/include/hrt_work.h
rename to platforms/posix/include/hrt_work.h
diff --git a/src/platforms/posix/include/px4_platform_types.h b/platforms/posix/include/px4_platform_types.h
similarity index 100%
rename from src/platforms/posix/include/px4_platform_types.h
rename to platforms/posix/include/px4_platform_types.h
diff --git a/src/platforms/posix/include/queue.h b/platforms/posix/include/queue.h
similarity index 100%
rename from src/platforms/posix/include/queue.h
rename to platforms/posix/include/queue.h
diff --git a/src/platforms/posix/include/system_config.h b/platforms/posix/include/system_config.h
similarity index 100%
rename from src/platforms/posix/include/system_config.h
rename to platforms/posix/include/system_config.h
diff --git a/platforms/posix/src/CMakeLists.txt b/platforms/posix/src/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..602b1b710744f71f932377fcc0f524e855cf4cd6
--- /dev/null
+++ b/platforms/posix/src/CMakeLists.txt
@@ -0,0 +1,34 @@
+############################################################################
+#
+#   Copyright (c) 2017 PX4 Development Team. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name PX4 nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+add_subdirectory(px4_layer)
diff --git a/src/platforms/posix/main.cpp b/platforms/posix/src/main.cpp
similarity index 100%
rename from src/platforms/posix/main.cpp
rename to platforms/posix/src/main.cpp
diff --git a/src/platforms/posix/px4_layer/CMakeLists.txt b/platforms/posix/src/px4_layer/CMakeLists.txt
similarity index 99%
rename from src/platforms/posix/px4_layer/CMakeLists.txt
rename to platforms/posix/src/px4_layer/CMakeLists.txt
index b0eaad3b4ef8b7e6d7e48fdce815f3728bfb0e65..6dadaa1e744a013e07bf78727b18d944a880bfba 100644
--- a/src/platforms/posix/px4_layer/CMakeLists.txt
+++ b/platforms/posix/src/px4_layer/CMakeLists.txt
@@ -54,7 +54,6 @@ px4_add_module(
 		px4_sem.cpp
 		lib_crc32.c
 		drv_hrt.c
-		px4_log.c
 		${SHMEM_SRCS}
 	DEPENDS
 		platforms__common
diff --git a/src/platforms/posix/px4_layer/drv_hrt.c b/platforms/posix/src/px4_layer/drv_hrt.c
similarity index 100%
rename from src/platforms/posix/px4_layer/drv_hrt.c
rename to platforms/posix/src/px4_layer/drv_hrt.c
diff --git a/src/platforms/posix/px4_layer/lib_crc32.c b/platforms/posix/src/px4_layer/lib_crc32.c
similarity index 100%
rename from src/platforms/posix/px4_layer/lib_crc32.c
rename to platforms/posix/src/px4_layer/lib_crc32.c
diff --git a/src/platforms/posix/px4_layer/px4_posix_impl.cpp b/platforms/posix/src/px4_layer/px4_posix_impl.cpp
similarity index 100%
rename from src/platforms/posix/px4_layer/px4_posix_impl.cpp
rename to platforms/posix/src/px4_layer/px4_posix_impl.cpp
diff --git a/src/platforms/posix/px4_layer/px4_posix_tasks.cpp b/platforms/posix/src/px4_layer/px4_posix_tasks.cpp
similarity index 100%
rename from src/platforms/posix/px4_layer/px4_posix_tasks.cpp
rename to platforms/posix/src/px4_layer/px4_posix_tasks.cpp
diff --git a/src/platforms/posix/px4_layer/px4_sem.cpp b/platforms/posix/src/px4_layer/px4_sem.cpp
similarity index 100%
rename from src/platforms/posix/px4_layer/px4_sem.cpp
rename to platforms/posix/src/px4_layer/px4_sem.cpp
diff --git a/src/platforms/posix/px4_layer/shmem_posix.c b/platforms/posix/src/px4_layer/shmem_posix.c
similarity index 100%
rename from src/platforms/posix/px4_layer/shmem_posix.c
rename to platforms/posix/src/px4_layer/shmem_posix.c
diff --git a/src/platforms/posix/sitl_runner_main.cpp.in b/platforms/posix/src/sitl_runner_main.cpp.in
similarity index 100%
rename from src/platforms/posix/sitl_runner_main.cpp.in
rename to platforms/posix/src/sitl_runner_main.cpp.in
diff --git a/platforms/qurt/CMakeLists.txt b/platforms/qurt/CMakeLists.txt
index b9923e4940404915a94e2242f240e8708835a6dd..6af56aef713b27dd1e935ff7862ae11cd2662cd2 100644
--- a/platforms/qurt/CMakeLists.txt
+++ b/platforms/qurt/CMakeLists.txt
@@ -5,6 +5,8 @@ include(fastrpc)
 include(qurt_lib)
 include(qurt_flags)
 
+add_subdirectory(src)
+
 include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes")
diff --git a/platforms/qurt/cmake/px4_impl_os.cmake b/platforms/qurt/cmake/px4_impl_os.cmake
index 06ce660f0b68744fee99e0b8d0bf7b17228ced67..47754c3120b00f9d9e2739c15533c23baeae0237 100644
--- a/platforms/qurt/cmake/px4_impl_os.cmake
+++ b/platforms/qurt/cmake/px4_impl_os.cmake
@@ -168,8 +168,9 @@ function(px4_os_add_flags)
 		${DSPAL_ROOT}/sys
 		${DSPAL_ROOT}/sys/sys
 		${DSPAL_ROOT}/uart_esc/inc
-		src/platforms/posix/include
-		src/platforms/qurt/include
+
+		platforms/posix/include
+		platforms/qurt/include
 		)
 
 	set(added_definitions
diff --git a/src/platforms/qurt/include/arch/board/board.h b/platforms/qurt/include/arch/board/board.h
similarity index 100%
rename from src/platforms/qurt/include/arch/board/board.h
rename to platforms/qurt/include/arch/board/board.h
diff --git a/src/platforms/qurt/include/board_config.h b/platforms/qurt/include/board_config.h
similarity index 100%
rename from src/platforms/qurt/include/board_config.h
rename to platforms/qurt/include/board_config.h
diff --git a/src/platforms/qurt/include/crc32.h b/platforms/qurt/include/crc32.h
similarity index 100%
rename from src/platforms/qurt/include/crc32.h
rename to platforms/qurt/include/crc32.h
diff --git a/src/platforms/qurt/include/hrt_work.h b/platforms/qurt/include/hrt_work.h
similarity index 100%
rename from src/platforms/qurt/include/hrt_work.h
rename to platforms/qurt/include/hrt_work.h
diff --git a/src/platforms/qurt/include/i2c.h b/platforms/qurt/include/i2c.h
similarity index 100%
rename from src/platforms/qurt/include/i2c.h
rename to platforms/qurt/include/i2c.h
diff --git a/src/platforms/qurt/include/poll.h b/platforms/qurt/include/poll.h
similarity index 100%
rename from src/platforms/qurt/include/poll.h
rename to platforms/qurt/include/poll.h
diff --git a/src/platforms/qurt/include/queue.h b/platforms/qurt/include/queue.h
similarity index 100%
rename from src/platforms/qurt/include/queue.h
rename to platforms/qurt/include/queue.h
diff --git a/src/platforms/qurt/include/qurt_log.h b/platforms/qurt/include/qurt_log.h
similarity index 100%
rename from src/platforms/qurt/include/qurt_log.h
rename to platforms/qurt/include/qurt_log.h
diff --git a/src/platforms/qurt/include/sys/ioctl.h b/platforms/qurt/include/sys/ioctl.h
similarity index 100%
rename from src/platforms/qurt/include/sys/ioctl.h
rename to platforms/qurt/include/sys/ioctl.h
diff --git a/platforms/qurt/src/CMakeLists.txt b/platforms/qurt/src/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..602b1b710744f71f932377fcc0f524e855cf4cd6
--- /dev/null
+++ b/platforms/qurt/src/CMakeLists.txt
@@ -0,0 +1,34 @@
+############################################################################
+#
+#   Copyright (c) 2017 PX4 Development Team. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in
+#    the documentation and/or other materials provided with the
+#    distribution.
+# 3. Neither the name PX4 nor the names of its contributors may be
+#    used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+add_subdirectory(px4_layer)
diff --git a/src/platforms/qurt/px4_layer/CMakeLists.txt b/platforms/qurt/src/px4_layer/CMakeLists.txt
similarity index 95%
rename from src/platforms/qurt/px4_layer/CMakeLists.txt
rename to platforms/qurt/src/px4_layer/CMakeLists.txt
index 7b913cfdbf4fc8e9a4042d8aba8b033ecec465ea..b7cf471c949a3e496f49d32c5037b16be8b67dd4 100644
--- a/src/platforms/qurt/px4_layer/CMakeLists.txt
+++ b/platforms/qurt/src/px4_layer/CMakeLists.txt
@@ -39,11 +39,12 @@ set(QURT_LAYER_SRCS
 	px4_qurt_impl.cpp
 	px4_qurt_tasks.cpp
 	lib_crc32.c
-	../../posix/px4_layer/drv_hrt.c
+	../../../posix/src/px4_layer/drv_hrt.c
 	qurt_stubs.c
 	main.cpp
 	shmem_qurt.c
 	)
+
 if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
 	list(APPEND QURT_LAYER_SRCS
 		../stubs/stubs_posix.c
@@ -51,9 +52,8 @@ if ("${QURT_ENABLE_STUBS}" STREQUAL "1")
 		)
 endif()
 
-
 px4_add_module(
-	MODULE platforms__qurt__px4_layer
+	MODULE platforms_px4_layer
 	COMPILE_FLAGS
 	SRCS
 		${QURT_LAYER_SRCS}
@@ -61,4 +61,3 @@ px4_add_module(
 	DEPENDS
 		platforms__common
 	)
-# vim: set noet ft=cmake fenc=utf-8 ff=unix :
diff --git a/src/platforms/qurt/px4_layer/commands_hil.c b/platforms/qurt/src/px4_layer/commands_hil.c
similarity index 100%
rename from src/platforms/qurt/px4_layer/commands_hil.c
rename to platforms/qurt/src/px4_layer/commands_hil.c
diff --git a/src/platforms/qurt/px4_layer/drv_hrt.c b/platforms/qurt/src/px4_layer/drv_hrt.c
similarity index 100%
rename from src/platforms/qurt/px4_layer/drv_hrt.c
rename to platforms/qurt/src/px4_layer/drv_hrt.c
diff --git a/src/platforms/qurt/px4_layer/get_commands.h b/platforms/qurt/src/px4_layer/get_commands.h
similarity index 100%
rename from src/platforms/qurt/px4_layer/get_commands.h
rename to platforms/qurt/src/px4_layer/get_commands.h
diff --git a/src/platforms/qurt/px4_layer/lib_crc32.c b/platforms/qurt/src/px4_layer/lib_crc32.c
similarity index 100%
rename from src/platforms/qurt/px4_layer/lib_crc32.c
rename to platforms/qurt/src/px4_layer/lib_crc32.c
diff --git a/src/platforms/qurt/px4_layer/main.cpp b/platforms/qurt/src/px4_layer/main.cpp
similarity index 100%
rename from src/platforms/qurt/px4_layer/main.cpp
rename to platforms/qurt/src/px4_layer/main.cpp
diff --git a/src/platforms/qurt/px4_layer/px4_qurt_impl.cpp b/platforms/qurt/src/px4_layer/px4_qurt_impl.cpp
similarity index 100%
rename from src/platforms/qurt/px4_layer/px4_qurt_impl.cpp
rename to platforms/qurt/src/px4_layer/px4_qurt_impl.cpp
diff --git a/src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp b/platforms/qurt/src/px4_layer/px4_qurt_tasks.cpp
similarity index 100%
rename from src/platforms/qurt/px4_layer/px4_qurt_tasks.cpp
rename to platforms/qurt/src/px4_layer/px4_qurt_tasks.cpp
diff --git a/src/platforms/qurt/px4_layer/qurt_stubs.c b/platforms/qurt/src/px4_layer/qurt_stubs.c
similarity index 100%
rename from src/platforms/qurt/px4_layer/qurt_stubs.c
rename to platforms/qurt/src/px4_layer/qurt_stubs.c
diff --git a/src/platforms/qurt/px4_layer/shmem_qurt.c b/platforms/qurt/src/px4_layer/shmem_qurt.c
similarity index 100%
rename from src/platforms/qurt/px4_layer/shmem_qurt.c
rename to platforms/qurt/src/px4_layer/shmem_qurt.c
diff --git a/src/drivers/snapdragon_pwm_out/CMakeLists.txt b/src/drivers/snapdragon_pwm_out/CMakeLists.txt
index 74b2ba9b849f3adc8378b012e5b324f827271053..ed7a2111c7add2d946a456a37dac1f675e9d11fd 100644
--- a/src/drivers/snapdragon_pwm_out/CMakeLists.txt
+++ b/src/drivers/snapdragon_pwm_out/CMakeLists.txt
@@ -38,5 +38,5 @@ px4_add_module(
 		snapdragon_pwm_out.cpp
 	DEPENDS
 		platforms__common
+		mixer_gen
 	)
-# vim: set noet ft=cmake fenc=utf-8 ff=unix :
diff --git a/src/lib/DriverFramework b/src/lib/DriverFramework
index 843ad727f2e9c310563dcd70173d6c859a246c07..29f386628af2c9dd6a95cb873d0624c0c0c58381 160000
--- a/src/lib/DriverFramework
+++ b/src/lib/DriverFramework
@@ -1 +1 @@
-Subproject commit 843ad727f2e9c310563dcd70173d6c859a246c07
+Subproject commit 29f386628af2c9dd6a95cb873d0624c0c0c58381
diff --git a/src/modules/uavcanesc/CMakeLists.txt b/src/modules/uavcanesc/CMakeLists.txt
index 695e425d6a56a03b1cc4df4cadc627878e0fe800..e9e0efff3ca1cdc1129ab9f5e4cb2771b55e1dce 100644
--- a/src/modules/uavcanesc/CMakeLists.txt
+++ b/src/modules/uavcanesc/CMakeLists.txt
@@ -53,7 +53,7 @@ add_definitions(
 set(LIBUAVCAN_DIR ${PX4_SOURCE_DIR}/src/modules/uavcan/libuavcan)
 
 add_subdirectory(${LIBUAVCAN_DIR} uavcanesc_libuavcan)
-add_dependencies(uavcan platforms__nuttx)
+add_dependencies(uavcan prebuild_targets)
 
 include_directories(${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams)
 include_directories(${LIBUAVCAN_DIR}/libuavcan/include)
diff --git a/src/modules/uavcannode/CMakeLists.txt b/src/modules/uavcannode/CMakeLists.txt
index c4fae3be5baf330046bb0c239cf9cd206eb34418..933a23fb80ecd7b5ffceb334a906735fac670a86 100644
--- a/src/modules/uavcannode/CMakeLists.txt
+++ b/src/modules/uavcannode/CMakeLists.txt
@@ -53,7 +53,7 @@ add_definitions(
 set(LIBUAVCAN_DIR ${PX4_SOURCE_DIR}/src/modules/uavcan/libuavcan)
 
 add_subdirectory(${LIBUAVCAN_DIR} uavcannode_libuavcan)
-add_dependencies(uavcan platforms__nuttx)
+add_dependencies(uavcan prebuild_targets)
 
 include_directories(${LIBUAVCAN_DIR}/libuavcan/include)
 include_directories(${LIBUAVCAN_DIR}/libuavcan/include/dsdlc_generated)
@@ -79,7 +79,7 @@ px4_add_module(
 		uavcannode_params.c
 
 	DEPENDS
-		platforms__common
+		prebuild_targets
 		uavcan
 	)
 
diff --git a/src/platforms/common/CMakeLists.txt b/src/platforms/common/CMakeLists.txt
index 837f27bec6e8f4d6d177c6f3bd3d4a91aeaa7e87..9e061c728553b47f5a253c5023848f39292d10f2 100644
--- a/src/platforms/common/CMakeLists.txt
+++ b/src/platforms/common/CMakeLists.txt
@@ -31,15 +31,25 @@
 #
 ############################################################################
 
+set(SRCS)
+
+if (NOT "${OS}" MATCHES "qurt")
+	list(APPEND SRCS
+		px4_log.c
+		)
+endif()
+
 px4_add_module(
 	MODULE platforms__common
 	SRCS
 		module.cpp
 		px4_getopt.c
 		shutdown.cpp
+		${SRCS}
 	DEPENDS
 		prebuild_targets
 		uorb_headers
 		uorb_msgs
 	)
-# vim: set noet ft=cmake fenc=utf-8 ff=unix : 
+	
+add_subdirectory(work_queue)
\ No newline at end of file
diff --git a/src/platforms/posix/px4_layer/px4_log.c b/src/platforms/common/px4_log.c
similarity index 61%
rename from src/platforms/posix/px4_layer/px4_log.c
rename to src/platforms/common/px4_log.c
index cf1599a01ff009858a8d3d622054205d9e03f6f5..0e1d50d4adda8441fa4a674a9f33ccfbe12b3e53 100644
--- a/src/platforms/posix/px4_layer/px4_log.c
+++ b/src/platforms/common/px4_log.c
@@ -1,9 +1,45 @@
+/****************************************************************************
+ *
+ * Copyright (C) 2017 PX4 Development Team. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ * 3. Neither the name PX4 nor the names of its contributors may be
+ *    used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#include <px4_log.h>
+
 #include <stdlib.h>
 #include <string.h>
-#include <px4_log.h>
+
 #if defined(__PX4_POSIX) && !defined(__PX4_CYGWIN)
 #include <execinfo.h>
 #endif
+
 #include <uORB/uORB.h>
 #include <uORB/topics/log_message.h>
 #include <drivers/drv_hrt.h>
@@ -92,7 +128,5 @@ __EXPORT void px4_log_modulename(int level, const char *moduleName, const char *
 		log_message.text[max_length - 1] = 0; //ensure 0-termination
 
 		orb_publish(ORB_ID(log_message), orb_log_message_pub, &log_message);
-
 	}
 }
-
diff --git a/src/platforms/posix/work_queue/CMakeLists.txt b/src/platforms/common/work_queue/CMakeLists.txt
similarity index 80%
rename from src/platforms/posix/work_queue/CMakeLists.txt
rename to src/platforms/common/work_queue/CMakeLists.txt
index 76d303e4c29bb3e2ae82c5ed2a1084ff3ca87ca9..6a6dd1b7351fb5a7f4c21cacf848aa2aeb5707fd 100644
--- a/src/platforms/posix/work_queue/CMakeLists.txt
+++ b/src/platforms/common/work_queue/CMakeLists.txt
@@ -30,25 +30,28 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 ############################################################################
-px4_add_module(
-	MODULE platforms__posix__work_queue
-	COMPILE_FLAGS
-	SRCS
-		hrt_thread.c
-		hrt_queue.c
-		hrt_work_cancel.c
-		work_thread.c
-		work_lock.c
-		work_queue.c
-		work_cancel.c
-		queue.c
-		dq_addlast.c
-		dq_remfirst.c
-		sq_addlast.c
-		sq_remfirst.c
-		sq_addafter.c
-		dq_rem.c
-	DEPENDS
-		platforms__common
-	)
-# vim: set noet ft=cmake fenc=utf-8 ff=unix :
+
+# nuttx uses internal work queue currently
+if (NOT "${OS}" MATCHES "nuttx")
+	px4_add_module(
+		MODULE platforms__posix__work_queue
+		COMPILE_FLAGS
+		SRCS
+			hrt_thread.c
+			hrt_queue.c
+			hrt_work_cancel.c
+			work_thread.c
+			work_lock.c
+			work_queue.c
+			work_cancel.c
+			queue.c
+			dq_addlast.c
+			dq_remfirst.c
+			sq_addlast.c
+			sq_remfirst.c
+			sq_addafter.c
+			dq_rem.c
+		DEPENDS
+			platforms__common
+		)
+endif()
diff --git a/src/platforms/posix/work_queue/dq_addlast.c b/src/platforms/common/work_queue/dq_addlast.c
similarity index 100%
rename from src/platforms/posix/work_queue/dq_addlast.c
rename to src/platforms/common/work_queue/dq_addlast.c
diff --git a/src/platforms/posix/work_queue/dq_rem.c b/src/platforms/common/work_queue/dq_rem.c
similarity index 100%
rename from src/platforms/posix/work_queue/dq_rem.c
rename to src/platforms/common/work_queue/dq_rem.c
diff --git a/src/platforms/posix/work_queue/dq_remfirst.c b/src/platforms/common/work_queue/dq_remfirst.c
similarity index 100%
rename from src/platforms/posix/work_queue/dq_remfirst.c
rename to src/platforms/common/work_queue/dq_remfirst.c
diff --git a/src/platforms/posix/work_queue/hrt_queue.c b/src/platforms/common/work_queue/hrt_queue.c
similarity index 100%
rename from src/platforms/posix/work_queue/hrt_queue.c
rename to src/platforms/common/work_queue/hrt_queue.c
diff --git a/src/platforms/posix/work_queue/hrt_thread.c b/src/platforms/common/work_queue/hrt_thread.c
similarity index 100%
rename from src/platforms/posix/work_queue/hrt_thread.c
rename to src/platforms/common/work_queue/hrt_thread.c
diff --git a/src/platforms/posix/work_queue/hrt_work_cancel.c b/src/platforms/common/work_queue/hrt_work_cancel.c
similarity index 100%
rename from src/platforms/posix/work_queue/hrt_work_cancel.c
rename to src/platforms/common/work_queue/hrt_work_cancel.c
diff --git a/src/platforms/posix/work_queue/queue.c b/src/platforms/common/work_queue/queue.c
similarity index 98%
rename from src/platforms/posix/work_queue/queue.c
rename to src/platforms/common/work_queue/queue.c
index 6f9d5b7bde3e0dc66a0d78cbe7aa9be354930cb2..1b0d73c9905aafcfd7344c519e737db93d5a42c3 100644
--- a/src/platforms/posix/work_queue/queue.c
+++ b/src/platforms/common/work_queue/queue.c
@@ -35,7 +35,7 @@
  ************************************************************************/
 
 // FIXME - need px4_queue
-#include <platforms/posix/include/queue.h>
+#include <queue.h>
 #include <stddef.h>
 
 __EXPORT void sq_rem(sq_entry_t *node, sq_queue_t *queue);
diff --git a/src/platforms/posix/work_queue/sq_addafter.c b/src/platforms/common/work_queue/sq_addafter.c
similarity index 100%
rename from src/platforms/posix/work_queue/sq_addafter.c
rename to src/platforms/common/work_queue/sq_addafter.c
diff --git a/src/platforms/posix/work_queue/sq_addlast.c b/src/platforms/common/work_queue/sq_addlast.c
similarity index 100%
rename from src/platforms/posix/work_queue/sq_addlast.c
rename to src/platforms/common/work_queue/sq_addlast.c
diff --git a/src/platforms/posix/work_queue/sq_remfirst.c b/src/platforms/common/work_queue/sq_remfirst.c
similarity index 100%
rename from src/platforms/posix/work_queue/sq_remfirst.c
rename to src/platforms/common/work_queue/sq_remfirst.c
diff --git a/src/platforms/posix/work_queue/work_cancel.c b/src/platforms/common/work_queue/work_cancel.c
similarity index 100%
rename from src/platforms/posix/work_queue/work_cancel.c
rename to src/platforms/common/work_queue/work_cancel.c
diff --git a/src/platforms/posix/work_queue/work_lock.c b/src/platforms/common/work_queue/work_lock.c
similarity index 100%
rename from src/platforms/posix/work_queue/work_lock.c
rename to src/platforms/common/work_queue/work_lock.c
diff --git a/src/platforms/posix/work_queue/work_lock.h b/src/platforms/common/work_queue/work_lock.h
similarity index 100%
rename from src/platforms/posix/work_queue/work_lock.h
rename to src/platforms/common/work_queue/work_lock.h
diff --git a/src/platforms/posix/work_queue/work_queue.c b/src/platforms/common/work_queue/work_queue.c
similarity index 100%
rename from src/platforms/posix/work_queue/work_queue.c
rename to src/platforms/common/work_queue/work_queue.c
diff --git a/src/platforms/posix/work_queue/work_thread.c b/src/platforms/common/work_queue/work_thread.c
similarity index 100%
rename from src/platforms/posix/work_queue/work_thread.c
rename to src/platforms/common/work_queue/work_thread.c
diff --git a/src/platforms/posix/tests/wqueue/CMakeLists.txt b/src/platforms/common/work_queue/wqueue_test/CMakeLists.txt
similarity index 100%
rename from src/platforms/posix/tests/wqueue/CMakeLists.txt
rename to src/platforms/common/work_queue/wqueue_test/CMakeLists.txt
diff --git a/src/platforms/posix/tests/wqueue/wqueue_main.cpp b/src/platforms/common/work_queue/wqueue_test/wqueue_main.cpp
similarity index 99%
rename from src/platforms/posix/tests/wqueue/wqueue_main.cpp
rename to src/platforms/common/work_queue/wqueue_test/wqueue_main.cpp
index 8dd5cc9707d6fa6502ea63e40d689f8ac38df06e..9f693c62a922ab50edd13547eeb9d7ba944494f2 100644
--- a/src/platforms/posix/tests/wqueue/wqueue_main.cpp
+++ b/src/platforms/common/work_queue/wqueue_test/wqueue_main.cpp
@@ -37,10 +37,11 @@
  *
  * @author Mark Charlebois <charlebm@gmail.com>
  */
+#include "wqueue_test.h"
+
 #include <px4_log.h>
 #include <px4_middleware.h>
 #include <px4_app.h>
-#include "wqueue_test.h"
 #include <stdio.h>
 
 int PX4_MAIN(int argc, char **argv)
diff --git a/src/platforms/posix/tests/wqueue/wqueue_start_posix.cpp b/src/platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp
similarity index 99%
rename from src/platforms/posix/tests/wqueue/wqueue_start_posix.cpp
rename to src/platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp
index 126a57fbc925192790b2952174a60096b9452a1f..d428e67ba730ff074a061d1d0fb565ab59e1bbf1 100644
--- a/src/platforms/posix/tests/wqueue/wqueue_start_posix.cpp
+++ b/src/platforms/common/work_queue/wqueue_test/wqueue_start_posix.cpp
@@ -38,6 +38,7 @@
  * @author Mark Charlebois <mcharleb@gmail.com>
  */
 #include "wqueue_test.h"
+
 #include <px4_app.h>
 #include <px4_log.h>
 #include <px4_tasks.h>
diff --git a/src/platforms/posix/tests/wqueue/wqueue_test.cpp b/src/platforms/common/work_queue/wqueue_test/wqueue_test.cpp
similarity index 99%
rename from src/platforms/posix/tests/wqueue/wqueue_test.cpp
rename to src/platforms/common/work_queue/wqueue_test/wqueue_test.cpp
index aec10269b8bd5aaaf346dc75c8f61cb208ac65a4..6f1ec62b2c61afdec5a4ce7ecd758e4d0f65f8bb 100644
--- a/src/platforms/posix/tests/wqueue/wqueue_test.cpp
+++ b/src/platforms/common/work_queue/wqueue_test/wqueue_test.cpp
@@ -39,9 +39,10 @@
  * @author Mark Charlebois <charlebm@gmail.com>
  */
 
+#include "wqueue_test.h"
+
 #include <px4_time.h>
 #include <px4_workqueue.h>
-#include "wqueue_test.h"
 #include <unistd.h>
 #include <stdio.h>
 
diff --git a/src/platforms/posix/tests/wqueue/wqueue_test.h b/src/platforms/common/work_queue/wqueue_test/wqueue_test.h
similarity index 100%
rename from src/platforms/posix/tests/wqueue/wqueue_test.h
rename to src/platforms/common/work_queue/wqueue_test/wqueue_test.h
diff --git a/src/platforms/px4_tasks.h b/src/platforms/px4_tasks.h
index 104593735b6d7696e2dca847c3a68bfd6833636b..e2e9d5f7a391595706d0dbcb28049a9904764708 100644
--- a/src/platforms/px4_tasks.h
+++ b/src/platforms/px4_tasks.h
@@ -64,19 +64,25 @@ typedef int px4_task_t;
 #define px4_task_exit(x) _exit(x)
 
 #elif defined(__PX4_POSIX) || defined(__PX4_QURT)
+
 #include <pthread.h>
 #include <sched.h>
 
 /** Default scheduler type */
 #define SCHED_DEFAULT	SCHED_FIFO
+
 #if defined(__PX4_LINUX) || defined(__PX4_DARWIN) || defined(__PX4_CYGWIN)
+
 #define SCHED_PRIORITY_MAX sched_get_priority_max(SCHED_FIFO)
 #define SCHED_PRIORITY_MIN sched_get_priority_min(SCHED_FIFO)
 #define SCHED_PRIORITY_DEFAULT (((sched_get_priority_max(SCHED_FIFO) - sched_get_priority_min(SCHED_FIFO)) / 2) + sched_get_priority_min(SCHED_FIFO))
+
 #elif defined(__PX4_QURT)
+
 #define SCHED_PRIORITY_MAX 255
 #define SCHED_PRIORITY_MIN 0
 #define SCHED_PRIORITY_DEFAULT 20
+
 #else
 #error "No target OS defined"
 #endif
@@ -93,6 +99,7 @@ typedef struct {
 	int argc;
 	char **argv;
 } px4_task_args_t;
+
 #else
 #error "No target OS defined"
 #endif