summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Polyudov <apolyudov@google.com>2016-07-12 18:45:05 -0700
committerAlexey Polyudov <apolyudov@google.com>2016-07-13 08:50:58 -0700
commitf805306b53d82eef67d8891a5dd5c32d3794a3ab (patch)
tree1ec3999680cf7649704b0337e189d4b4b6baf4a2
parenta2a09914775591691046341c06d1286a303ec0a9 (diff)
downloadcontexthub-f805306b53d82eef67d8891a5dd5c32d3794a3ab.tar.gz
build: restructure nanohub tree
1. rearrange tree so that soft links are no longer necessary 2. decouple OS variants build from app build 3. add support for output directory Bug: 29635686 Change-Id: I273b823c29582a85c632e43c23b10fa44123d8af
-rw-r--r--firmware/Makefile129
-rw-r--r--firmware/README17
-rw-r--r--firmware/app/Android.mk0
-rw-r--r--firmware/app/app.mk267
-rw-r--r--firmware/app/common.mk38
-rw-r--r--firmware/app/external.app/Makefile26
-rw-r--r--firmware/app/test0.app/Makefile27
-rw-r--r--firmware/app/test1.app/Makefile29
-rw-r--r--firmware/external/arm/arm_common_tables.c2
-rw-r--r--firmware/external/freebsd/lib/msun/src/e_atan2f.c2
-rw-r--r--firmware/external/freebsd/lib/msun/src/e_expf.c2
-rw-r--r--firmware/external/freebsd/lib/msun/src/s_atanf.c2
-rw-r--r--firmware/firmware.mk108
-rw-r--r--firmware/lib/lib.mk43
-rw-r--r--firmware/lib/libc/acle-compat.h (renamed from lib/libc/acle-compat.h)0
-rw-r--r--firmware/lib/libc/arm_asm.h (renamed from lib/libc/arm_asm.h)0
-rw-r--r--firmware/lib/libc/bcopy.c (renamed from lib/libc/bcopy.c)0
-rw-r--r--firmware/lib/libc/memcmp.c (renamed from lib/libc/memcmp.c)0
-rw-r--r--firmware/lib/libc/memcpy-armv7m.S (renamed from lib/libc/memcpy-armv7m.S)0
-rw-r--r--firmware/lib/libc/memcpy.c (renamed from lib/libc/memcpy.c)0
-rw-r--r--firmware/lib/libc/memmove.c (renamed from lib/libc/memmove.c)0
-rw-r--r--firmware/lib/libc/memset.c (renamed from lib/libc/memset.c)0
-rw-r--r--firmware/lib/libc/strcasecmp.c (renamed from lib/libc/strcasecmp.c)0
-rw-r--r--firmware/lib/libc/strlen.c (renamed from lib/libc/strlen.c)1
-rw-r--r--firmware/lib/libc/strncpy.c (renamed from lib/libc/strncpy.c)0
-rw-r--r--firmware/lib/libm/ef_asin.c (renamed from lib/libm/ef_asin.c)0
-rw-r--r--firmware/lib/libm/ef_atan2.c (renamed from lib/libm/ef_atan2.c)0
-rw-r--r--firmware/lib/libm/ef_fmod.c (renamed from lib/libm/ef_fmod.c)0
-rw-r--r--firmware/lib/libm/ef_rem_pio2.c (renamed from lib/libm/ef_rem_pio2.c)0
-rw-r--r--firmware/lib/libm/ef_sqrt.c (renamed from lib/libm/ef_sqrt.c)0
-rw-r--r--firmware/lib/libm/fdlibm.h (renamed from lib/libm/fdlibm.h)0
-rw-r--r--firmware/lib/libm/kf_cos.c (renamed from lib/libm/kf_cos.c)0
-rw-r--r--firmware/lib/libm/kf_rem_pio2.c (renamed from lib/libm/kf_rem_pio2.c)0
-rw-r--r--firmware/lib/libm/kf_sin.c (renamed from lib/libm/kf_sin.c)0
-rw-r--r--firmware/lib/libm/sf_atan.c (renamed from lib/libm/sf_atan.c)0
-rw-r--r--firmware/lib/libm/sf_cos.c (renamed from lib/libm/sf_cos.c)0
-rw-r--r--firmware/lib/libm/sf_floor.c (renamed from lib/libm/sf_floor.c)0
-rw-r--r--firmware/lib/libm/sf_fpclassify.c (renamed from lib/libm/sf_fpclassify.c)0
-rw-r--r--firmware/lib/libm/sf_round.c (renamed from lib/libm/sf_round.c)0
-rw-r--r--firmware/lib/libm/sf_scalbn.c (renamed from lib/libm/sf_scalbn.c)0
-rw-r--r--firmware/lib/libm/sf_sin.c (renamed from lib/libm/sf_sin.c)0
-rw-r--r--firmware/lib/libm/wf_asin.c (renamed from lib/libm/wf_asin.c)0
-rw-r--r--firmware/lib/libm/wf_atan2.c (renamed from lib/libm/wf_atan2.c)0
-rw-r--r--firmware/lib/libm/wf_fmod.c (renamed from lib/libm/wf_fmod.c)0
-rw-r--r--firmware/misc/platform/stm32f4xx/Makefile80
-rw-r--r--firmware/os/algos/accel_cal.c (renamed from firmware/src/algos/accel_cal.c)0
-rw-r--r--firmware/os/algos/fusion.c (renamed from firmware/src/algos/fusion.c)0
-rw-r--r--firmware/os/algos/gyro_cal.c (renamed from firmware/src/algos/gyro_cal.c)0
-rw-r--r--firmware/os/algos/gyro_stillness_detect.c (renamed from firmware/src/algos/gyro_stillness_detect.c)0
-rw-r--r--firmware/os/algos/mag_cal.c (renamed from firmware/src/algos/mag_cal.c)0
-rw-r--r--firmware/os/algos/mat.c (renamed from firmware/src/algos/mat.c)0
-rw-r--r--firmware/os/algos/quat.c (renamed from firmware/src/algos/quat.c)0
-rw-r--r--firmware/os/algos/time_sync.c (renamed from firmware/src/algos/time_sync.c)0
-rw-r--r--firmware/os/algos/vec.c (renamed from firmware/src/algos/vec.c)0
-rw-r--r--firmware/os/core/appSec.c (renamed from firmware/src/appSec.c)2
-rw-r--r--firmware/os/core/eventQ.c (renamed from firmware/src/eventQ.c)4
-rw-r--r--firmware/os/core/floatRt.c (renamed from firmware/src/floatRt.c)0
-rw-r--r--firmware/os/core/heap.c (renamed from firmware/src/heap.c)0
-rw-r--r--firmware/os/core/hostIntf.c (renamed from firmware/src/hostIntf.c)4
-rw-r--r--firmware/os/core/hostIntfI2c.c (renamed from firmware/src/hostIntfI2c.c)0
-rw-r--r--firmware/os/core/hostIntfSpi.c (renamed from firmware/src/hostIntfSpi.c)0
-rw-r--r--firmware/os/core/nanohubCommand.c (renamed from firmware/src/nanohubCommand.c)8
-rw-r--r--firmware/os/core/osApi.c (renamed from firmware/src/osApi.c)4
-rw-r--r--firmware/os/core/printf.c (renamed from firmware/src/printf.c)2
-rw-r--r--firmware/os/core/sensors.c (renamed from firmware/src/sensors.c)6
-rw-r--r--firmware/os/core/seos.c (renamed from firmware/src/seos.c)10
-rw-r--r--firmware/os/core/simpleQ.c (renamed from firmware/src/simpleQ.c)0
-rw-r--r--firmware/os/core/slab.c (renamed from firmware/src/slab.c)0
-rw-r--r--firmware/os/core/spi.c (renamed from firmware/src/spi.c)0
-rw-r--r--firmware/os/core/syscall.c (renamed from firmware/src/syscall.c)0
-rw-r--r--firmware/os/core/timer.c (renamed from firmware/src/timer.c)4
-rw-r--r--firmware/os/core/trylock.c (renamed from firmware/src/trylock.c)0
-rw-r--r--firmware/os/cpu/cortexm4/appSupport.c (renamed from firmware/src/cpu/cortexm4f/appSupport.c)0
-rw-r--r--firmware/os/cpu/cortexm4/atomic.c (renamed from firmware/src/cpu/cortexm4f/atomic.c)0
-rw-r--r--firmware/os/cpu/cortexm4/atomicBitset.c (renamed from firmware/src/cpu/cortexm4f/atomicBitset.c)0
-rw-r--r--firmware/os/cpu/cortexm4/cortexm4.mk (renamed from firmware/misc/cpu/cortexm4f/Makefile)39
-rw-r--r--firmware/os/cpu/cortexm4/cpu.c (renamed from firmware/src/cpu/cortexm4f/cpu.c)8
-rw-r--r--firmware/os/cpu/cortexm4/cpuMath.c (renamed from firmware/src/cpu/cortexm4f/cpuMath.c)2
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/atomic.h (renamed from firmware/inc/cpu/cortexm4f/atomic.h)3
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/atomicBitset.h (renamed from firmware/inc/cpu/cortexm4f/atomicBitset.h)0
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/barrier.h (renamed from firmware/inc/cpu/cortexm4f/barrier.h)0
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/cpuMath.h (renamed from firmware/inc/cpu/cortexm4f/cpuMath.h)0
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/nanohub_math.h (renamed from firmware/inc/cpu/cortexm4f/nanohub_math.h)1
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/pendsv.h (renamed from firmware/inc/cpu/cortexm4f/pendsv.h)0
-rw-r--r--firmware/os/cpu/cortexm4/inc/cpu/syscallDo.h (renamed from firmware/inc/cpu/cortexm4f/syscallDo.h)0
-rw-r--r--firmware/os/cpu/cortexm4/pendsv.c (renamed from firmware/src/cpu/cortexm4f/pendsv.c)4
-rw-r--r--firmware/os/cpu/x86/atomic.c (renamed from firmware/src/cpu/x86/atomic.c)0
-rw-r--r--firmware/os/cpu/x86/atomicBitset.c (renamed from firmware/src/cpu/x86/atomicBitset.c)0
-rw-r--r--firmware/os/cpu/x86/cpu.c (renamed from firmware/src/cpu/x86/cpu.c)0
-rw-r--r--firmware/os/cpu/x86/inc/cpu/atomicBitset.h (renamed from firmware/inc/cpu/x86/atomicBitset.h)0
-rw-r--r--firmware/os/cpu/x86/inc/cpu/barrier.h (renamed from firmware/inc/cpu/x86/barrier.h)0
-rw-r--r--firmware/os/cpu/x86/x86.mk (renamed from firmware/misc/cpu/x86/Makefile)9
-rw-r--r--firmware/os/drivers/ams_tmd2772/ams_tmd2772.c (renamed from firmware/src/drivers/ams_tmd2772/ams_tmd2772.c)0
-rw-r--r--firmware/os/drivers/ams_tmd4903/ams_tmd4903.c (renamed from firmware/src/drivers/ams_tmd4903/ams_tmd4903.c)8
-rw-r--r--firmware/os/drivers/bosch_bmi160/akm_ak09915_slave.c (renamed from firmware/src/drivers/bosch_bmi160/akm_ak09915_slave.c)0
-rw-r--r--firmware/os/drivers/bosch_bmi160/akm_ak09915_slave.h (renamed from firmware/src/drivers/bosch_bmi160/akm_ak09915_slave.h)0
-rw-r--r--firmware/os/drivers/bosch_bmi160/bosch_bmi160.c (renamed from firmware/src/drivers/bosch_bmi160/bosch_bmi160.c)14
-rw-r--r--firmware/os/drivers/bosch_bmi160/bosch_bmm150_slave.c (renamed from firmware/src/drivers/bosch_bmi160/bosch_bmm150_slave.c)0
-rw-r--r--firmware/os/drivers/bosch_bmi160/bosch_bmm150_slave.h (renamed from firmware/src/drivers/bosch_bmi160/bosch_bmm150_slave.h)0
-rw-r--r--firmware/os/drivers/bosch_bmp280/bosch_bmp280.c (renamed from firmware/src/drivers/bosch_bmp280/bosch_bmp280.c)0
-rw-r--r--firmware/os/drivers/hall/hall.c (renamed from firmware/src/drivers/hall/hall.c)8
-rw-r--r--firmware/os/drivers/hall_twopole/hall_twopole.c (renamed from firmware/src/drivers/hall_twopole/hall_twopole.c)8
-rw-r--r--firmware/os/drivers/orientation/orientation.c (renamed from firmware/src/drivers/orientation/orientation.c)4
-rw-r--r--firmware/os/drivers/rohm_rpr0521/rohm_rpr0521.c (renamed from firmware/src/drivers/rohm_rpr0521/rohm_rpr0521.c)8
-rw-r--r--firmware/os/drivers/tilt_detection/tilt_detection.c (renamed from firmware/src/drivers/tilt_detection/tilt_detection.c)4
-rw-r--r--firmware/os/drivers/vsync/vsync.c (renamed from firmware/src/drivers/vsync/vsync.c)8
-rw-r--r--firmware/os/drivers/window_orientation/window_orientation.c (renamed from firmware/src/drivers/window_orientation/window_orientation.c)4
-rw-r--r--firmware/os/inc/algos/accel_cal.h (renamed from firmware/inc/algos/accel_cal.h)0
-rw-r--r--firmware/os/inc/algos/fusion.h (renamed from firmware/inc/algos/fusion.h)0
-rw-r--r--firmware/os/inc/algos/gyro_cal.h (renamed from firmware/inc/algos/gyro_cal.h)0
-rw-r--r--firmware/os/inc/algos/gyro_stillness_detect.h (renamed from firmware/inc/algos/gyro_stillness_detect.h)0
-rw-r--r--firmware/os/inc/algos/mag_cal.h (renamed from firmware/inc/algos/mag_cal.h)0
-rw-r--r--firmware/os/inc/algos/mat.h (renamed from firmware/inc/algos/mat.h)0
-rw-r--r--firmware/os/inc/algos/quat.h (renamed from firmware/inc/algos/quat.h)0
-rw-r--r--firmware/os/inc/algos/time_sync.h (renamed from firmware/inc/algos/time_sync.h)0
-rw-r--r--firmware/os/inc/algos/vec.h (renamed from firmware/inc/algos/vec.h)0
-rw-r--r--firmware/os/inc/apInt.h (renamed from firmware/inc/apInt.h)0
-rw-r--r--firmware/os/inc/appSec.h (renamed from firmware/inc/appSec.h)0
-rw-r--r--firmware/os/inc/atomic.h (renamed from firmware/inc/atomic.h)6
-rw-r--r--firmware/os/inc/atomicBitset.h (renamed from firmware/inc/atomicBitset.h)2
-rw-r--r--firmware/os/inc/console.h (renamed from firmware/inc/console.h)0
-rw-r--r--firmware/os/inc/cpu.h (renamed from firmware/inc/cpu.h)2
-rw-r--r--firmware/os/inc/crc.h2
-rw-r--r--firmware/os/inc/eeData.h (renamed from firmware/inc/eeData.h)0
-rw-r--r--firmware/os/inc/eventQ.h (renamed from firmware/inc/eventQ.h)2
-rw-r--r--firmware/os/inc/eventnums.h (renamed from firmware/inc/eventnums.h)0
-rw-r--r--firmware/os/inc/floatRt.h (renamed from firmware/inc/floatRt.h)0
-rw-r--r--firmware/os/inc/gpio.h (renamed from firmware/inc/gpio.h)0
-rw-r--r--firmware/os/inc/heap.h (renamed from firmware/inc/heap.h)0
-rw-r--r--firmware/os/inc/hostIntf.h (renamed from firmware/inc/hostIntf.h)0
-rw-r--r--firmware/os/inc/hostIntf_priv.h (renamed from firmware/inc/hostIntf_priv.h)0
-rw-r--r--firmware/os/inc/i2c.h (renamed from firmware/inc/i2c.h)0
-rw-r--r--firmware/os/inc/isr.h (renamed from firmware/inc/isr.h)0
-rw-r--r--firmware/os/inc/list.h (renamed from firmware/inc/list.h)0
-rw-r--r--firmware/os/inc/mpu.h (renamed from firmware/inc/mpu.h)0
-rw-r--r--firmware/os/inc/nanohubCommand.h (renamed from firmware/inc/nanohubCommand.h)0
-rw-r--r--firmware/os/inc/nanohubPacket.h (renamed from firmware/inc/nanohubPacket.h)0
-rw-r--r--firmware/os/inc/nanohub_math.h (renamed from firmware/inc/nanohub_math.h)2
-rw-r--r--firmware/os/inc/osApi.h (renamed from firmware/inc/osApi.h)0
-rw-r--r--firmware/os/inc/platform.h (renamed from firmware/inc/platform.h)0
-rw-r--r--firmware/os/inc/printf.h (renamed from firmware/inc/printf.h)0
-rw-r--r--firmware/os/inc/reset.h (renamed from firmware/inc/reset.h)0
-rw-r--r--firmware/os/inc/sensType.h (renamed from firmware/inc/sensType.h)0
-rw-r--r--firmware/os/inc/sensors.h (renamed from firmware/inc/sensors.h)4
-rw-r--r--firmware/os/inc/seos.h (renamed from firmware/inc/seos.h)6
-rw-r--r--firmware/os/inc/simpleQ.h (renamed from firmware/inc/simpleQ.h)0
-rw-r--r--firmware/os/inc/slab.h (renamed from firmware/inc/slab.h)0
-rw-r--r--firmware/os/inc/spi.h (renamed from firmware/inc/spi.h)0
-rw-r--r--firmware/os/inc/spi_priv.h (renamed from firmware/inc/spi_priv.h)0
-rw-r--r--firmware/os/inc/syscall.h (renamed from firmware/inc/syscall.h)0
-rw-r--r--firmware/os/inc/syscallDo.h (renamed from firmware/inc/syscallDo.h)2
-rw-r--r--firmware/os/inc/timer.h (renamed from firmware/inc/timer.h)0
-rw-r--r--firmware/os/inc/toolchain.h (renamed from firmware/inc/toolchain.h)0
-rw-r--r--firmware/os/inc/trylock.h (renamed from firmware/inc/trylock.h)2
-rw-r--r--firmware/os/inc/usart.h (renamed from firmware/inc/usart.h)0
-rw-r--r--firmware/os/inc/util.h (renamed from firmware/inc/util.h)2
-rw-r--r--firmware/os/platform/native/hostIntf.c (renamed from firmware/src/platform/linux/hostIntf.c)0
-rw-r--r--firmware/os/platform/native/i2c.c (renamed from firmware/src/platform/linux/i2c.c)0
-rw-r--r--firmware/os/platform/native/inc/plat/app.h (renamed from firmware/inc/platform/linux/app.h)0
-rw-r--r--firmware/os/platform/native/inc/plat/crc.h3
-rw-r--r--firmware/os/platform/native/inc/plat/plat.h (renamed from firmware/inc/platform/linux/plat.h)0
-rw-r--r--firmware/os/platform/native/inc/plat/pwr.h (renamed from firmware/inc/platform/linux/pwr.h)0
-rw-r--r--firmware/os/platform/native/inc/plat/rtc.h (renamed from firmware/inc/platform/linux/rtc.h)0
-rw-r--r--firmware/os/platform/native/inc/plat/usart.h (renamed from firmware/inc/platform/linux/usart.h)0
-rw-r--r--firmware/os/platform/native/inc/plat/wdt.h (renamed from firmware/inc/platform/linux/wdt.h)0
-rw-r--r--firmware/os/platform/native/lkr/app.lkr15
-rw-r--r--firmware/os/platform/native/lkr/native.extra.lkr (renamed from firmware/misc/platform/linux/linux.extra.lkr)0
-rw-r--r--firmware/os/platform/native/native.mk (renamed from firmware/misc/platform/linux/Makefile)17
-rw-r--r--firmware/os/platform/native/platform.c (renamed from firmware/src/platform/linux/platform.c)2
-rw-r--r--firmware/os/platform/native/rtc.c (renamed from firmware/src/platform/linux/rtc.c)4
-rw-r--r--firmware/os/platform/native/spi.c (renamed from firmware/src/platform/linux/spi.c)0
-rw-r--r--firmware/os/platform/stm32/apInt.c (renamed from firmware/src/platform/stm32f4xx/apInt.c)6
-rw-r--r--firmware/os/platform/stm32/bl.c (renamed from firmware/src/platform/stm32f4xx/bl.c)10
-rw-r--r--firmware/os/platform/stm32/crc.c (renamed from firmware/src/platform/stm32f4xx/crc.c)2
-rw-r--r--firmware/os/platform/stm32/crt_stm32.c (renamed from firmware/src/platform/stm32f4xx/crt_stm32f4xx.c)0
-rw-r--r--firmware/os/platform/stm32/dma.c (renamed from firmware/src/platform/stm32f4xx/dma.c)6
-rw-r--r--firmware/os/platform/stm32/eeData.c (renamed from firmware/src/platform/stm32f4xx/eeData.c)2
-rw-r--r--firmware/os/platform/stm32/exti.c (renamed from firmware/src/platform/stm32f4xx/exti.c)6
-rw-r--r--firmware/os/platform/stm32/flash_script/Makefile (renamed from firmware/misc/platform/stm32f4xx/flash_script/Makefile)0
-rw-r--r--firmware/os/platform/stm32/flash_script/tool.c (renamed from firmware/misc/platform/stm32f4xx/flash_script/tool.c)0
-rw-r--r--firmware/os/platform/stm32/gpio.c (renamed from firmware/src/platform/stm32f4xx/gpio.c)4
-rw-r--r--firmware/os/platform/stm32/hostIntf.c (renamed from firmware/src/platform/stm32f4xx/hostIntf.c)8
-rw-r--r--firmware/os/platform/stm32/i2c.c (renamed from firmware/src/platform/stm32f4xx/i2c.c)16
-rw-r--r--firmware/os/platform/stm32/inc/plat/app.h (renamed from firmware/inc/platform/stm32f4xx/app.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/bl.h (renamed from firmware/inc/platform/stm32f4xx/bl.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis.h (renamed from firmware/inc/platform/stm32f4xx/cmsis.h)2
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/arm_common_tables.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/arm_common_tables.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/arm_const_structs.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/arm_const_structs.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/arm_math.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/arm_math.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cm0.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cm0.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cm0plus.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cm0plus.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cm3.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cm3.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cm4.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cm4.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cm7.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cm7.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cmFunc.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cmFunc.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cmInstr.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cmInstr.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_cmSimd.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_cmSimd.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_sc000.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_sc000.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/cmsis/core_sc300.h (renamed from firmware/inc/platform/stm32f4xx/cmsis/core_sc300.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/crc.h1
-rw-r--r--firmware/os/platform/stm32/inc/plat/dma.h (renamed from firmware/inc/platform/stm32f4xx/dma.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/eeData.h (renamed from firmware/inc/platform/stm32f4xx/eeData.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/exti.h (renamed from firmware/inc/platform/stm32f4xx/exti.h)4
-rw-r--r--firmware/os/platform/stm32/inc/plat/gpio.h (renamed from firmware/inc/platform/stm32f4xx/gpio.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/i2c.h (renamed from firmware/inc/platform/stm32f4xx/i2c.h)6
-rw-r--r--firmware/os/platform/stm32/inc/plat/plat.h (renamed from firmware/inc/platform/stm32f4xx/plat.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/pwr.h (renamed from firmware/inc/platform/stm32f4xx/pwr.h)2
-rw-r--r--firmware/os/platform/stm32/inc/plat/rtc.h (renamed from firmware/inc/platform/stm32f4xx/rtc.h)2
-rw-r--r--firmware/os/platform/stm32/inc/plat/spi.h (renamed from firmware/inc/platform/stm32f4xx/spi.h)6
-rw-r--r--firmware/os/platform/stm32/inc/plat/syscfg.h (renamed from firmware/inc/platform/stm32f4xx/syscfg.h)2
-rw-r--r--firmware/os/platform/stm32/inc/plat/taggedPtr.h (renamed from firmware/inc/platform/stm32f4xx/taggedPtr.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/usart.h (renamed from firmware/inc/platform/stm32f4xx/usart.h)0
-rw-r--r--firmware/os/platform/stm32/inc/plat/wdt.h (renamed from firmware/inc/platform/stm32f4xx/wdt.h)0
-rw-r--r--firmware/os/platform/stm32/lkr/app.lkr (renamed from firmware/misc/cpu/cortexm4f/app.lkr)12
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f401.bl.lkr (renamed from firmware/misc/variant/common/stm32f401.bl.lkr)6
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f401.map.lkr (renamed from firmware/misc/variant/common/stm32f401.map.lkr)3
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f401.os.lkr (renamed from firmware/misc/variant/common/stm32f401.os.lkr)6
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f411.bl.lkr (renamed from firmware/misc/variant/common/stm32f411.bl.lkr)6
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f411.map.lkr (renamed from firmware/misc/variant/common/stm32f411.map.lkr)0
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f411.os.lkr (renamed from firmware/misc/variant/common/stm32f411.os.lkr)6
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f412.bl.lkr20
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f412.map.lkr24
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f412.os.lkr20
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f4xx.bl.lkr (renamed from firmware/misc/variant/common/stm32f4xx.bl.lkr)3
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f4xx.common.lkr (renamed from firmware/misc/variant/common/stm32f4xx.common.lkr)3
-rw-r--r--firmware/os/platform/stm32/lkr/stm32f4xx.os.lkr (renamed from firmware/misc/variant/common/stm32f4xx.os.lkr)3
-rw-r--r--firmware/os/platform/stm32/misc/debug.privkey (renamed from firmware/misc/debug.privkey)0
-rw-r--r--firmware/os/platform/stm32/misc/debug.pubkey (renamed from firmware/misc/debug.pubkey)bin256 -> 256 bytes
-rw-r--r--firmware/os/platform/stm32/misc/m3debug.script (renamed from firmware/misc/platform/stm32f4xx/m3debug.script)0
-rwxr-xr-xfirmware/os/platform/stm32/misc/showsizes.sh (renamed from firmware/misc/platform/stm32f4xx/showsizes.sh)0
-rw-r--r--firmware/os/platform/stm32/mpu.c (renamed from firmware/src/platform/stm32f4xx/mpu.c)2
-rw-r--r--firmware/os/platform/stm32/platform.c (renamed from firmware/src/platform/stm32f4xx/platform.c)24
-rw-r--r--firmware/os/platform/stm32/pwr.c (renamed from firmware/src/platform/stm32f4xx/pwr.c)8
-rw-r--r--firmware/os/platform/stm32/rtc.c (renamed from firmware/src/platform/stm32f4xx/rtc.c)18
-rw-r--r--firmware/os/platform/stm32/spi.c (renamed from firmware/src/platform/stm32f4xx/spi.c)16
-rw-r--r--firmware/os/platform/stm32/stm32.mk86
-rw-r--r--firmware/os/platform/stm32/syscfg.c (renamed from firmware/src/platform/stm32f4xx/syscfg.c)4
-rw-r--r--firmware/os/platform/stm32/usart.c (renamed from firmware/src/platform/stm32f4xx/usart.c)6
-rw-r--r--firmware/os/platform/stm32/wdt.c (renamed from firmware/src/platform/stm32f4xx/wdt.c)6
-rw-r--r--firmware/variant/Android.mk0
-rw-r--r--firmware/variant/README2
-rw-r--r--firmware/variant/linux/Makefile5
-rw-r--r--firmware/variant/linux/inc/variant/variant.h (renamed from firmware/inc/variant/linux/variant.h)5
-rw-r--r--firmware/variant/linux/linux.mk (renamed from firmware/misc/variant/linux/Makefile)0
-rw-r--r--firmware/variant/lunchbox/Makefile5
-rw-r--r--firmware/variant/lunchbox/inc/variant/sensType.h (renamed from firmware/inc/variant/lunchbox/sensType.h)0
-rw-r--r--firmware/variant/lunchbox/inc/variant/variant.h (renamed from firmware/inc/variant/lunchbox/variant.h)3
-rw-r--r--firmware/variant/lunchbox/lunchbox.mk (renamed from firmware/misc/variant/lunchbox/Makefile)43
-rw-r--r--firmware/variant/lunchbox/src/os/i2c.c (renamed from firmware/src/variant/nucleo/i2c.c)2
-rw-r--r--firmware/variant/lunchbox/src/os/spi.c (renamed from firmware/src/variant/lunchbox/spi.c)2
-rw-r--r--firmware/variant/nucleo/Makefile5
-rw-r--r--firmware/variant/nucleo/inc/variant/sensType.h (renamed from firmware/inc/variant/nucleo/sensType.h)0
-rw-r--r--firmware/variant/nucleo/inc/variant/variant.h (renamed from firmware/inc/variant/nucleo/variant.h)0
-rw-r--r--firmware/variant/nucleo/nucleo.mk (renamed from firmware/misc/variant/nucleo/Makefile)48
-rw-r--r--firmware/variant/nucleo/src/os/i2c.c (renamed from firmware/src/variant/lunchbox/i2c.c)2
-rw-r--r--firmware/variant/nucleo/src/os/spi.c (renamed from firmware/src/variant/nucleo/spi.c)2
-rw-r--r--firmware/variant/variant.mk22
-rw-r--r--lib/Android.mk53
-rw-r--r--lib/include/nanohub/crc.h4
-rw-r--r--lib/nanohub/softcrc.c7
-rw-r--r--sensorhal/Android.mk6
-rw-r--r--util/nanoapp_cmd/Android.mk2
-rw-r--r--util/nanoapp_encr/Android.mk7
-rw-r--r--util/nanoapp_postprocess/Android.mk11
-rw-r--r--util/nanoapp_sign/Android.mk9
265 files changed, 1059 insertions, 575 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
deleted file mode 100644
index 81b8febe..00000000
--- a/firmware/Makefile
+++ /dev/null
@@ -1,129 +0,0 @@
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#find build target
-PLATFORM ?= stm32f4xx
-CPU ?= cortexm4f
-VARIANT ?= lunchbox
-DEBUG ?= -DDEBUG
-
-#bad words
-BADWORDS += strcpy strcat atoi
-BADWORDS += "rsaPrivOp=RSA private ops must never be compiled into firmware."
-
-#find makefiles
-MAKE_PLAT = misc/platform/$(PLATFORM)/Makefile
-MAKE_CPU = misc/cpu/$(CPU)/Makefile
-
-#link paths
-ifdef VARIANT_PATH
-LINK_PATH_MISC = $(VARIANT_PATH)/misc
-LINK_PATH_SRC = $(VARIANT_PATH)/src
-LINK_PATH_INC = $(VARIANT_PATH)/inc
-else
-LINK_PATH_MISC = misc/variant/$(VARIANT)
-LINK_PATH_SRC = src/variant/$(VARIANT)
-LINK_PATH_INC = inc/variant/$(VARIANT)
-endif
-
-#variant makefile
-MAKE_VAR = $(LINK_PATH_MISC)/Makefile
-
-#top make target
-SRCS_os :=
-SRCS_bl :=
-DELIVERABLES :=
-real: all
-
-#include makefiles for plat and cpu
-include $(MAKE_PLAT)
-include $(MAKE_CPU)
-include $(MAKE_VAR)
-
-FLAGS += -Wall -Werror -Iinc -Ilinks -Iexternal/freebsd/inc -I../lib/include -fshort-double
-#help avoid commmon embedded C mistakes
-FLAGS += -Wmissing-declarations -Wlogical-op -Waddress -Wempty-body -Wpointer-arith -Wenum-compare -Wdouble-promotion -Wfloat-equal -Wshadow -fno-strict-aliasing
-
-OSFLAGS += -g -ggdb3 -D_OS_BUILD_ -O2
-APPFLAGS += -Os
-
-#debug mode
-FLAGS += $(DEBUG)
-
-#bootloader pieces
-SRCS_bl += ../lib/nanohub/sha2.c ../lib/nanohub/rsa.c ../lib/nanohub/aes.c src/seos.c
-
-#frameworks
-SRCS_os += src/printf.c src/timer.c src/seos.c src/heap.c src/slab.c src/spi.c src/trylock.c
-SRCS_os += src/hostIntf.c src/hostIntfI2c.c src/hostIntfSpi.c src/nanohubCommand.c src/sensors.c src/syscall.c
-SRCS_os += src/eventQ.c src/osApi.c src/appSec.c src/simpleQ.c src/floatRt.c
-
-#some help for bootloader
-SRCS_bl += src/printf.c
-
-ifndef PLATFORM_HAS_HARDWARE_CRC
-SRCS_os += ../lib/nanohub/softcrc.c
-endif
-
-#app code
-include $(wildcard app/*/Makefile)
-
-
-#extra deps
-DEPS += $(wildcard app/*.h)
-DEPS += $(wildcard inc/*.h)
-DEPS += Makefile $(MAKE_PLAT) $(MAKE_CPU) $(MAKE_VAR)
-
-all: symlinks $(DELIVERABLES)
-
-symlinks: links/p_$(PLATFORM) links/c_$(CPU) links/v_$(VARIANT)
-
-links/p_$(PLATFORM):
- rm -rf links/plat links/p_*
- mkdir -p links/plat
- ln -s ../../misc/platform/$(PLATFORM) links/plat/misc
- ln -s ../../src/platform/$(PLATFORM) links/plat/src
- ln -s ../../inc/platform/$(PLATFORM) links/plat/inc
- touch links/p_$(PLATFORM)
-
-links/c_$(CPU):
- rm -rf links/cpu links/c_*
- mkdir -p links/cpu
- ln -s ../../misc/cpu/$(CPU) links/cpu/misc
- ln -s ../../src/cpu/$(CPU) links/cpu/src
- ln -s ../../inc/cpu/$(CPU) links/cpu/inc
- touch links/c_$(CPU)
-
-links/v_$(VARIANT):
- rm -rf links/variant links/v_*
- mkdir -p links/variant
- ln -s ../../$(LINK_PATH_MISC) links/variant/misc
- ln -s ../../$(LINK_PATH_SRC) links/variant/src
- ln -s ../../$(LINK_PATH_INC) links/variant/inc
- touch links/v_$(VARIANT)
-
-%.unchecked.elf: symlinks $(SRCS_$*) $(DEPS)
- $(GCC) -o $@ $(SRCS_$*) $(OSFLAGS) $(OSFLAGS_$*) $(FLAGS) -lgcc -nostdlib
-
-%.checked.elf : %.unchecked.elf symcheck.sh
- ./symcheck.sh $< $@ $(BADWORDS)
-
-full.bin: $(BL_FILE) $(OS_FILE)
- cat $(BL_FILE) $(OS_FILE) > $@
-
-clean:
- rm -rf $(DELIVERABLES) os.elf bootloader.elf links $(CLEANFILES)
-
diff --git a/firmware/README b/firmware/README
new file mode 100644
index 00000000..2bdb6242
--- /dev/null
+++ b/firmware/README
@@ -0,0 +1,17 @@
+Define and export CROSS_COMPILE env var for your toolchain
+
+1. to build any OS variant, run
+
+make -C <variant_path>
+
+where <variant_path> is relative path to OS variant dir;
+or simply "cd <variant_path>" and run "make".
+for local variants, variant_path is variant/<variant_name>
+
+2. to build nanoapp, run
+
+make -C <nanapp_path>
+
+where <nanoapp_path> is relative path to nanoapp;
+or simply "cd <nanoapp_path>" and run "make".
+for local nanoapps, nanoapp_path is app/<app_name>
diff --git a/firmware/app/Android.mk b/firmware/app/Android.mk
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/firmware/app/Android.mk
diff --git a/firmware/app/app.mk b/firmware/app/app.mk
new file mode 100644
index 00000000..2ace2d23
--- /dev/null
+++ b/firmware/app/app.mk
@@ -0,0 +1,267 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+################################################################################
+#
+# NanoApp C/C++ Makefile Utils
+#
+################################################################################
+
+# Configuration ################################################################
+
+# Toolchain Prefix
+ifndef CROSS_COMPILE
+ $(error Please set the environment variable CROSS_COMPILE to the complete \
+ path to the toolchain directory plus the binary prefix, e.g. export \
+ CROSS_COMPILE=~/bin/gcc-arm-none-eabi-4_8-2014q3/bin/arm-none-eabi-)
+endif
+
+PREFIX = $(CROSS_COMPILE)
+TOOLCHAIN_DIR = $(shell dirname `which $(CROSS_COMPILE)gcc`)/..
+
+NANOAPP_POSTPROCESS := $(NANOHUB_DIR)/../util/nanoapp_postprocess/nanoapp_postprocess
+NANOAPP_SIGN := $(NANOHUB_DIR)/../util/nanoapp_sign/nanoapp_sign
+
+VARIANT ?= lunchbox
+PLATFORM ?= stm32
+CHIP ?= stm32f411
+CPU ?= cortexm4
+
+VARIANT_PATH ?= device/google/contexthub/firmware/variant/$(VARIANT)
+VARIANT_PATH := $(NANOHUB_DIR)/../../../../$(VARIANT_PATH)
+
+# all output goes here
+OUT ?= out/$(VARIANT)/app/$(BIN)
+
+################################################################################
+#
+# Nanoapp Libc/Libm Utils
+#
+################################################################################
+
+include $(NANOHUB_DIR)/lib/lib.mk
+
+# Tools ########################################################################
+
+AS := $(PREFIX)gcc
+CC := $(PREFIX)gcc
+CXX := $(PREFIX)g++
+OBJCOPY := $(PREFIX)objcopy
+OBJDUMP := $(PREFIX)objdump
+
+# Assembly Flags ###############################################################
+
+AS_FLAGS +=
+
+# C++ Flags ####################################################################
+
+CXX_CFLAGS += -std=c++11
+CXX_CFLAGS += -fno-exceptions
+CXX_CFLAGS += -fno-rtti
+
+# C Flags ######################################################################
+
+C_CFLAGS +=
+
+# Common Flags #################################################################
+
+# Defines
+CFLAGS += -DAPP_ID=$(APP_ID)
+CFLAGS += -DAPP_VERSION=$(APP_VERSION)
+CFLAGS += -D__NANOHUB__
+
+# Optimization/debug
+CFLAGS += -Os
+CFLAGS += -g
+
+# Include paths
+CFLAGS += -I$(NANOHUB_DIR)/os/inc
+CFLAGS += -I$(NANOHUB_DIR)/os/platform/$(PLATFORM)/inc
+CFLAGS += -I$(NANOHUB_DIR)/os/cpu/$(CPU)/inc
+CFLAGS += -I$(VARIANT_PATH)/inc
+CFLAGS += -I$(NANOHUB_DIR)/../lib/include
+
+# Warnings/error configuration.
+CFLAGS += -Wall
+CFLAGS += -Werror
+CFLAGS += -Wmissing-declarations
+CFLAGS += -Wlogical-op
+CFLAGS += -Waddress
+CFLAGS += -Wempty-body
+CFLAGS += -Wpointer-arith
+CFLAGS += -Wenum-compare
+CFLAGS += -Wdouble-promotion
+CFLAGS += -Wshadow
+CFLAGS += -Wno-attributes
+
+# Produce position independent code.
+CFLAGS += -fpic
+CFLAGS += -mno-pic-data-is-text-relative
+CFLAGS += -msingle-pic-base
+CFLAGS += -mpic-register=r9
+
+# Code generation options for Cortex-M4F
+CFLAGS += -mthumb
+CFLAGS += -mcpu=cortex-m4
+CFLAGS += -march=armv7e-m
+CFLAGS += -mfloat-abi=softfp
+CFLAGS += -mfpu=fpv4-sp-d16
+CFLAGS += -mno-thumb-interwork
+CFLAGS += -ffast-math
+CFLAGS += -fsingle-precision-constant
+
+# Platform defines
+CFLAGS += -DARM
+CFLAGS += -DUSE_NANOHUB_FLOAT_RUNTIME
+CFLAGS += -DARM_MATH_CM4
+CFLAGS += -D__FPU_PRESENT
+
+# Miscellaneous
+CFLAGS += -fno-strict-aliasing
+CFLAGS += -fshort-double
+CFLAGS += -fvisibility=hidden
+CFLAGS += -fno-unwind-tables
+CFLAGS += -fstack-reuse=all
+CFLAGS += -ffunction-sections
+CFLAGS += -fdata-sections
+
+# Linker Configuration #########################################################
+
+LD := $(PREFIX)ld
+
+LDFLAGS := -T $(NANOHUB_DIR)/os/platform/$(PLATFORM)/lkr/app.lkr
+LDFLAGS += -nostartfiles
+LDFLAGS += --gc-sections
+LDFLAGS += -Map $(OUT)/$(BIN).map
+LDFLAGS += --cref
+ifeq ($(BIN_MODE),static)
+LDFLAGS += -static
+LDFLAGS += --emit-relocs
+LDFLAGS += -L$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/arm-none-eabi/*/armv7e-m/softfp)
+STATIC_LIBS += -lgcc
+else
+LDFLAGS += -shared
+LDFLAGS += --no-undefined
+LDFLAGS += --no-allow-shlib-undefined
+LDFLAGS += -L$(wildcard $(TOOLCHAIN_DIR)/lib/gcc/arm-none-eabi/*/armv7e-m/softfp)
+STATIC_LIBS += -lgcc
+endif
+
+# Build Rules ##################################################################
+
+AS_SRCS := $(filter %.S, $(SRCS))
+C_SRCS := $(filter %.c, $(SRCS))
+CXX_SRCS := $(filter %.cc, $(SRCS))
+
+OBJS := $(patsubst %.S, $(OUT)/%.o, $(AS_SRCS))
+OBJS += $(patsubst %.c, $(OUT)/%.o, $(C_SRCS))
+OBJS += $(patsubst %.cc, $(OUT)/%.o, $(CXX_SRCS))
+
+UNSIGNED_BIN := $(BIN).unsigned.napp
+
+NANOHUB_KEY_PATH := $(NANOHUB_DIR)/os/platform/$(PLATFORM)/misc
+
+
+.PHONY: all
+all: $(OUT)/$(BIN).S $(OUT)/$(BIN).napp
+
+$(OUT)/$(BIN).napp : $(OUT)/$(UNSIGNED_BIN) $(NANOAPP_SIGN)
+ @mkdir -p $(dir $@)
+ $(NANOAPP_SIGN) -e $(NANOHUB_KEY_PATH)/debug.privkey \
+ -m $(NANOHUB_KEY_PATH)/debug.pubkey -s $< $@
+
+ifeq ($(BIN_MODE),static)
+$(OUT)/$(UNSIGNED_BIN) : $(OUT)/$(BIN).elf $(NANOAPP_POSTPROCESS)
+ @mkdir -p $(dir $@)
+ $(NANOAPP_POSTPROCESS) -s -a $(APP_ID) -v $< $@
+else
+$(OUT)/$(UNSIGNED_BIN) : $(OUT)/$(BIN).bin $(NANOAPP_POSTPROCESS)
+ @mkdir -p $(dir $@)
+ $(NANOAPP_POSTPROCESS) -a $(APP_ID) -v $< $@
+
+$(OUT)/$(BIN).bin : $(OUT)/$(BIN).elf
+ @mkdir -p $(dir $@)
+ $(OBJCOPY) -j.relocs -j.flash -j.data -j.dynsym -O binary $< $@
+endif
+
+$(OUT)/$(BIN).S : $(OUT)/$(BIN).elf
+ @mkdir -p $(dir $@)
+ $(OBJDUMP) $< -DS > $@
+
+$(OUT)/$(BIN).elf : $(OBJS)
+ @mkdir -p $(dir $@)
+ $(LD) $(LDFLAGS) $(OBJS) $(STATIC_LIBS) -o $@
+
+$(OUT)/%.o : %.S
+ @mkdir -p $(dir $@)
+ $(AS) $(AS_FLAGS) $(CFLAGS) -c $< -o $@
+
+$(OUT)/%.o : %.c
+ @mkdir -p $(dir $@)
+ $(CC) $(C_CFLAGS) $(CFLAGS) -c $< -o $@
+
+$(OUT)/%.o : %.cc
+ @mkdir -p $(dir $@)
+ $(CXX) $(CXX_CFLAGS) $(CFLAGS) -c $< -o $@
+
+# Automatic dependency resolution ##############################################
+
+DEPS_AS = $(OUT)/deps_as
+DEPS_C = $(OUT)/deps_c
+DEPS_CXX = $(OUT)/deps_cxx
+
+$(DEPS_AS) : $(AS_SRCS)
+ @mkdir -p $(dir $@)
+ $(AS) $(AS_CFLAGS) $(CFLAGS) -MM $^ > $@
+
+$(DEPS_C) : $(C_SRCS)
+ @mkdir -p $(dir $@)
+ $(CC) $(C_CFLAGS) $(CFLAGS) -MM $^ > $@
+
+$(DEPS_CXX) : $(CXX_SRCS)
+ @mkdir -p $(dir $@)
+ $(CXX) $(CXX_CFLAGS) $(CFLAGS) -MM $^ > $@
+
+NOAUTODEPTARGETS = clean
+
+ifeq ($(words $(findstring $(MAKECMDGOALS), $(NOAUTODEPTARGETS))), 0)
+
+ifneq ($(AS_SRCS), )
+-include $(DEPS_AS)
+endif
+
+ifneq ($(C_SRCS), )
+-include $(DEPS_C)
+endif
+
+ifneq ($(CXX_SRCS), )
+-include $(DEPS_CXX)
+endif
+
+endif
+
+$(NANOAPP_POSTPROCESS): $(wildcard $(dir $(NANOAPP_POSTPROCESS))/*.c* $(dir $(NANOAPP_POSTPROCESS))/*.h)
+ echo DEPS [$@]: $^
+ make -C $(dir $@)
+
+$(NANOAPP_SIGN): $(wildcard $(dir $(NANOAPP_SIGN))/*.c* $(dir $(NANOAPP_SIGN))/*.h)
+ echo DEPS [$@]: $^
+ make -C $(dir $@)
+
+# Clean targets ################################################################
+
+.PHONY: clean
+clean :
+ rm -rf $(OUT)
diff --git a/firmware/app/common.mk b/firmware/app/common.mk
deleted file mode 100644
index 81a96240..00000000
--- a/firmware/app/common.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-SELF_DIR := $(SELF_MKFILE:Makefile=)
-SELF_FILES := $(wildcard $(SELF_DIR)*.c)
-APP_NM := $(SELF_DIR)app
-CLEANFILES := $(CLEANFILES) $(APP_NM).elf $(APP_NM).bin
-DELIVERABLES := $(DELIVERABLES) $(APP_NM).napp
-APP_ELF := $(APP_NM).elf
-APP_BIN := $(APP_NM).bin
-APP_APP := $(APP_NM).napp
-APPFLAGS += $(EXTRA_FLAGS) -Wall -Werror
-
-define APPRULE
-$(APP_APP): $(APP_BIN)
- nanoapp_postprocess -v -a $(APP_ID) $(APP_BIN) $(APP_APP)
-
-$(APP_BIN): $(APP_ELF)
- $(OBJCOPY) -j.relocs -j.flash -j.data -j.dynsym -O binary $(APP_ELF) $(APP_BIN)
-
-$(APP_ELF): $(SELF_FILES) symlinks
- $(GCC) -o $(APP_ELF) $(FLAGS) $(APPFLAGS) -fvisibility=hidden $(SELF_FILES)
-endef
-
-$(eval $(APPRULE))
diff --git a/firmware/app/external.app/Makefile b/firmware/app/external.app/Makefile
deleted file mode 100644
index 7b3ae790..00000000
--- a/firmware/app/external.app/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#makefile for all extrernal appspop app
-
-EXTRA_FLAGS ?=
-
-ifneq ($(EXTERNAL_APP_BUILD),)
- SELF_MKFILE := $(EXTERNAL_APP_MAKEFILE)
- APP_ID := $(EXTERNAL_APP_ID)
- include app/common.mk
-endif
-
diff --git a/firmware/app/test0.app/Makefile b/firmware/app/test0.app/Makefile
index 0303b64e..b5931d1a 100644
--- a/firmware/app/test0.app/Makefile
+++ b/firmware/app/test0.app/Makefile
@@ -14,10 +14,29 @@
# limitations under the License.
#
-#makefile for test0 app
+################################################################################
+#
+# test NanoApp Makefile
+#
+################################################################################
-SELF_MKFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
-# Googl + T + 0x8000
+
+SRCS := test_app0.c
+BIN := test0
APP_ID := 476f6f676c548000
+APP_VERSION := 0
+
+# Nanohub relative path
+NANOHUB_DIR := ../..
+
+# Device configuration #########################################################
+
+# select device variant for this app
+VARIANT_PATH = device/google/contexthub/firmware/variant/nucleo
+VARIANT = nucleo
+
+# setup variant parameters
+# PLATFORM, CPU, CHIP must match variant Makefile (located under VARIANT_PATH);
+# if not defined there, there is not need to specify them here either
-include app/common.mk
+include $(NANOHUB_DIR)/app/app.mk
diff --git a/firmware/app/test1.app/Makefile b/firmware/app/test1.app/Makefile
index 8cade3f9..b21c4ba5 100644
--- a/firmware/app/test1.app/Makefile
+++ b/firmware/app/test1.app/Makefile
@@ -14,10 +14,31 @@
# limitations under the License.
#
-#makefile for test1 app
+################################################################################
+#
+# test1 NanoApp Makefile
+#
+################################################################################
+
+# Device configuration #########################################################
+
+SRCS := test_app1.c
+BIN := test1
-SELF_MKFILE := $(abspath $(lastword $(MAKEFILE_LIST)))
-# Googl + T + 0x8001
APP_ID := 476f6f676c548001
+APP_VERSION := 0
+
+# Nanohub relative path
+NANOHUB_DIR := ../..
+
+# Device configuration #########################################################
+
+# select device variant for this app
+VARIANT_PATH = device/google/contexthub/firmware/variant/nucleo
+VARIANT = nucleo
+
+# setup variant parameters
+# PLATFORM, CPU, CHIP must match variant Makefile (located under VARIANT_PATH);
+# if not defined there, there is not need to specify them here either
-include app/common.mk
+include $(NANOHUB_DIR)/app/app.mk
diff --git a/firmware/external/arm/arm_common_tables.c b/firmware/external/arm/arm_common_tables.c
index 7f1ac845..148d9855 100644
--- a/firmware/external/arm/arm_common_tables.c
+++ b/firmware/external/arm/arm_common_tables.c
@@ -40,7 +40,7 @@
#include <arm_math.h>
-#include <plat/inc/cmsis/arm_common_tables.h>
+#include <plat/cmsis/arm_common_tables.h>
/**
* @ingroup groupTransforms
diff --git a/firmware/external/freebsd/lib/msun/src/e_atan2f.c b/firmware/external/freebsd/lib/msun/src/e_atan2f.c
index fc77bffa..90883233 100644
--- a/firmware/external/freebsd/lib/msun/src/e_atan2f.c
+++ b/firmware/external/freebsd/lib/msun/src/e_atan2f.c
@@ -17,7 +17,7 @@
__FBSDID("$FreeBSD$");
#include "math.h"
-#include "math_private.h"
+#include <math_private.h>
static volatile float
tiny = 1.0e-30;
diff --git a/firmware/external/freebsd/lib/msun/src/e_expf.c b/firmware/external/freebsd/lib/msun/src/e_expf.c
index b1fe2c53..19931da8 100644
--- a/firmware/external/freebsd/lib/msun/src/e_expf.c
+++ b/firmware/external/freebsd/lib/msun/src/e_expf.c
@@ -19,7 +19,7 @@ __FBSDID("$FreeBSD$");
#include <float.h>
#include "math.h"
-#include "math_private.h"
+#include <math_private.h>
static const float
one = 1.0,
diff --git a/firmware/external/freebsd/lib/msun/src/s_atanf.c b/firmware/external/freebsd/lib/msun/src/s_atanf.c
index b3a371f3..965fea50 100644
--- a/firmware/external/freebsd/lib/msun/src/s_atanf.c
+++ b/firmware/external/freebsd/lib/msun/src/s_atanf.c
@@ -17,7 +17,7 @@
__FBSDID("$FreeBSD$");
#include "math.h"
-#include "math_private.h"
+#include <math_private.h>
static const float atanhi[] = {
4.6364760399e-01, /* atan(0.5)hi 0x3eed6338 */
diff --git a/firmware/firmware.mk b/firmware/firmware.mk
new file mode 100644
index 00000000..fbb13a23
--- /dev/null
+++ b/firmware/firmware.mk
@@ -0,0 +1,108 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#find build target
+PLATFORM ?= stm32
+CHIP ?= stm32f411
+CPU ?= cortexm4
+VARIANT ?= lunchbox
+DEBUG ?= -DDEBUG
+OUT := out/nanohub/$(VARIANT)
+
+#bad words
+BADWORDS += strcpy strcat atoi
+BADWORDS += "rsaPrivOp=RSA private ops must never be compiled into firmware."
+
+#find makefiles
+MAKE_PLAT = os/platform/$(PLATFORM)/$(PLATFORM).mk
+MAKE_CPU = os/cpu/$(CPU)/$(CPU).mk
+
+ifndef VARIANT_PATH
+VARIANT_PATH := variant/$(VARIANT)
+endif
+
+MAKE_VAR = $(VARIANT_PATH)/$(VARIANT).mk
+
+#top make target
+SRCS_os :=
+SRCS_bl :=
+DELIVERABLES :=
+
+.PHONY: real all
+real: all
+
+#include makefiles for plat and cpu
+include $(MAKE_PLAT)
+include $(MAKE_CPU)
+include $(MAKE_VAR)
+
+FLAGS += -Ios/inc
+FLAGS += -Ios/platform/$(PLATFORM)/inc
+FLAGS += -Ios/platform/$(PLATFORM)/inc/plat/cmsis
+FLAGS += -Ios/cpu/$(CPU)/inc
+FLAGS += -I$(VARIANT_PATH)/inc
+FLAGS += -Iexternal/freebsd/inc
+FLAGS += -I../lib/include
+
+FLAGS += -Wall -Werror -fshort-double
+#help avoid commmon embedded C mistakes
+FLAGS += -Wmissing-declarations -Wlogical-op -Waddress -Wempty-body -Wpointer-arith -Wenum-compare -Wdouble-promotion -Wfloat-equal -Wshadow -fno-strict-aliasing
+
+OSFLAGS += -g -ggdb3 -D_OS_BUILD_ -O2
+
+#debug mode
+FLAGS += $(DEBUG)
+
+#bootloader pieces
+SRCS_bl += ../lib/nanohub/sha2.c ../lib/nanohub/rsa.c ../lib/nanohub/aes.c os/core/seos.c
+
+#frameworks
+SRCS_os += os/core/printf.c os/core/timer.c os/core/seos.c os/core/heap.c os/core/slab.c os/core/spi.c os/core/trylock.c
+SRCS_os += os/core/hostIntf.c os/core/hostIntfI2c.c os/core/hostIntfSpi.c os/core/nanohubCommand.c os/core/sensors.c os/core/syscall.c
+SRCS_os += os/core/eventQ.c os/core/osApi.c os/core/appSec.c os/core/simpleQ.c os/core/floatRt.c
+
+#some help for bootloader
+SRCS_bl += os/core/printf.c
+
+ifndef PLATFORM_HAS_HARDWARE_CRC
+SRCS_os += ../lib/nanohub/softcrc.c
+endif
+
+#extra deps
+DEPS += $(wildcard inc/*.h)
+DEPS += firmware.mk $(MAKE_PLAT) $(MAKE_CPU) $(MAKE_VAR)
+DELIVERABLES += $(OUT)/full.bin
+
+all: $(DELIVERABLES)
+
+$(OUT)/bl.unchecked.elf: $(SRCS_bl) $(DEPS)
+ mkdir -p $(dir $@)
+ $(GCC) -o $@ $(SRCS_bl) $(OSFLAGS) $(OSFLAGS_bl) $(FLAGS)
+
+$(OUT)/os.unchecked.elf: $(SRCS_os) $(DEPS)
+ mkdir -p $(dir $@)
+ $(GCC) -o $@ $(SRCS_os) $(OSFLAGS) $(OSFLAGS_os) $(FLAGS)
+
+$(OUT)/%.checked.elf : $(OUT)/%.unchecked.elf symcheck.sh
+ mkdir -p $(dir $@)
+ ./symcheck.sh $< $@ $(BADWORDS)
+
+$(OUT)/full.bin: $(BL_FILE) $(OS_FILE)
+ mkdir -p $(dir $@)
+ cat $(BL_FILE) $(OS_FILE) > $@
+
+clean:
+ rm -rf $(OUT)
diff --git a/firmware/lib/lib.mk b/firmware/lib/lib.mk
new file mode 100644
index 00000000..d8c6b70c
--- /dev/null
+++ b/firmware/lib/lib.mk
@@ -0,0 +1,43 @@
+################################################################################
+#
+# Nanoapp Libc/Libm build helper script
+#
+################################################################################
+
+# Libm #########################################################################
+
+LIBM_PATH := $(NANOHUB_DIR)/lib/libm
+
+CFLAGS += -D_IEEE_LIBM
+
+SRCS += $(LIBM_PATH)/ef_atan2.c
+SRCS += $(LIBM_PATH)/ef_asin.c
+SRCS += $(LIBM_PATH)/ef_fmod.c
+SRCS += $(LIBM_PATH)/ef_rem_pio2.c
+SRCS += $(LIBM_PATH)/ef_sqrt.c
+SRCS += $(LIBM_PATH)/kf_cos.c
+SRCS += $(LIBM_PATH)/kf_rem_pio2.c
+SRCS += $(LIBM_PATH)/kf_sin.c
+SRCS += $(LIBM_PATH)/sf_atan.c
+SRCS += $(LIBM_PATH)/sf_cos.c
+SRCS += $(LIBM_PATH)/sf_floor.c
+SRCS += $(LIBM_PATH)/sf_fpclassify.c
+SRCS += $(LIBM_PATH)/sf_round.c
+SRCS += $(LIBM_PATH)/sf_scalbn.c
+SRCS += $(LIBM_PATH)/sf_sin.c
+SRCS += $(LIBM_PATH)/wf_atan2.c
+SRCS += $(LIBM_PATH)/wf_asin.c
+SRCS += $(LIBM_PATH)/wf_fmod.c
+
+# Libc #########################################################################
+
+LIBC_PATH := $(NANOHUB_DIR)/lib/libc
+
+SRCS += $(LIBC_PATH)/bcopy.c
+SRCS += $(LIBC_PATH)/memcmp.c
+#SRCS += $(LIBC_PATH)/memcpy-armv7m.S
+SRCS += $(LIBC_PATH)/memcpy.c
+SRCS += $(LIBC_PATH)/memmove.c
+SRCS += $(LIBC_PATH)/memset.c
+SRCS += $(LIBC_PATH)/strcasecmp.c
+SRCS += $(LIBC_PATH)/strlen.c
diff --git a/lib/libc/acle-compat.h b/firmware/lib/libc/acle-compat.h
index 888ae2ea..888ae2ea 100644
--- a/lib/libc/acle-compat.h
+++ b/firmware/lib/libc/acle-compat.h
diff --git a/lib/libc/arm_asm.h b/firmware/lib/libc/arm_asm.h
index 1bb5edb2..1bb5edb2 100644
--- a/lib/libc/arm_asm.h
+++ b/firmware/lib/libc/arm_asm.h
diff --git a/lib/libc/bcopy.c b/firmware/lib/libc/bcopy.c
index 854e9649..854e9649 100644
--- a/lib/libc/bcopy.c
+++ b/firmware/lib/libc/bcopy.c
diff --git a/lib/libc/memcmp.c b/firmware/lib/libc/memcmp.c
index 9e6a575f..9e6a575f 100644
--- a/lib/libc/memcmp.c
+++ b/firmware/lib/libc/memcmp.c
diff --git a/lib/libc/memcpy-armv7m.S b/firmware/lib/libc/memcpy-armv7m.S
index 8a70c7d7..8a70c7d7 100644
--- a/lib/libc/memcpy-armv7m.S
+++ b/firmware/lib/libc/memcpy-armv7m.S
diff --git a/lib/libc/memcpy.c b/firmware/lib/libc/memcpy.c
index 72b8e339..72b8e339 100644
--- a/lib/libc/memcpy.c
+++ b/firmware/lib/libc/memcpy.c
diff --git a/lib/libc/memmove.c b/firmware/lib/libc/memmove.c
index cdfededc..cdfededc 100644
--- a/lib/libc/memmove.c
+++ b/firmware/lib/libc/memmove.c
diff --git a/lib/libc/memset.c b/firmware/lib/libc/memset.c
index 0f3ba012..0f3ba012 100644
--- a/lib/libc/memset.c
+++ b/firmware/lib/libc/memset.c
diff --git a/lib/libc/strcasecmp.c b/firmware/lib/libc/strcasecmp.c
index 2be09136..2be09136 100644
--- a/lib/libc/strcasecmp.c
+++ b/firmware/lib/libc/strcasecmp.c
diff --git a/lib/libc/strlen.c b/firmware/lib/libc/strlen.c
index 7e59e755..bf56ed66 100644
--- a/lib/libc/strlen.c
+++ b/firmware/lib/libc/strlen.c
@@ -84,6 +84,7 @@ strlen (const char* str)
size_t __attribute__((naked))
strlen (const char* str)
{
+ (void)str; /* disable unused argument warning */
asm ("len .req r0\n\t"
"data .req r3\n\t"
"addr .req r1\n\t"
diff --git a/lib/libc/strncpy.c b/firmware/lib/libc/strncpy.c
index 5003a199..5003a199 100644
--- a/lib/libc/strncpy.c
+++ b/firmware/lib/libc/strncpy.c
diff --git a/lib/libm/ef_asin.c b/firmware/lib/libm/ef_asin.c
index c49dcbbc..c49dcbbc 100644
--- a/lib/libm/ef_asin.c
+++ b/firmware/lib/libm/ef_asin.c
diff --git a/lib/libm/ef_atan2.c b/firmware/lib/libm/ef_atan2.c
index d57480b0..d57480b0 100644
--- a/lib/libm/ef_atan2.c
+++ b/firmware/lib/libm/ef_atan2.c
diff --git a/lib/libm/ef_fmod.c b/firmware/lib/libm/ef_fmod.c
index 53c1ba28..53c1ba28 100644
--- a/lib/libm/ef_fmod.c
+++ b/firmware/lib/libm/ef_fmod.c
diff --git a/lib/libm/ef_rem_pio2.c b/firmware/lib/libm/ef_rem_pio2.c
index f1191d09..f1191d09 100644
--- a/lib/libm/ef_rem_pio2.c
+++ b/firmware/lib/libm/ef_rem_pio2.c
diff --git a/lib/libm/ef_sqrt.c b/firmware/lib/libm/ef_sqrt.c
index 80e7f360..80e7f360 100644
--- a/lib/libm/ef_sqrt.c
+++ b/firmware/lib/libm/ef_sqrt.c
diff --git a/lib/libm/fdlibm.h b/firmware/lib/libm/fdlibm.h
index a4b7fffe..a4b7fffe 100644
--- a/lib/libm/fdlibm.h
+++ b/firmware/lib/libm/fdlibm.h
diff --git a/lib/libm/kf_cos.c b/firmware/lib/libm/kf_cos.c
index 4f71af23..4f71af23 100644
--- a/lib/libm/kf_cos.c
+++ b/firmware/lib/libm/kf_cos.c
diff --git a/lib/libm/kf_rem_pio2.c b/firmware/lib/libm/kf_rem_pio2.c
index 261c4812..261c4812 100644
--- a/lib/libm/kf_rem_pio2.c
+++ b/firmware/lib/libm/kf_rem_pio2.c
diff --git a/lib/libm/kf_sin.c b/firmware/lib/libm/kf_sin.c
index e81fa0bd..e81fa0bd 100644
--- a/lib/libm/kf_sin.c
+++ b/firmware/lib/libm/kf_sin.c
diff --git a/lib/libm/sf_atan.c b/firmware/lib/libm/sf_atan.c
index 6edf05fe..6edf05fe 100644
--- a/lib/libm/sf_atan.c
+++ b/firmware/lib/libm/sf_atan.c
diff --git a/lib/libm/sf_cos.c b/firmware/lib/libm/sf_cos.c
index 4c0a9a53..4c0a9a53 100644
--- a/lib/libm/sf_cos.c
+++ b/firmware/lib/libm/sf_cos.c
diff --git a/lib/libm/sf_floor.c b/firmware/lib/libm/sf_floor.c
index 9264d81e..9264d81e 100644
--- a/lib/libm/sf_floor.c
+++ b/firmware/lib/libm/sf_floor.c
diff --git a/lib/libm/sf_fpclassify.c b/firmware/lib/libm/sf_fpclassify.c
index 878457f3..878457f3 100644
--- a/lib/libm/sf_fpclassify.c
+++ b/firmware/lib/libm/sf_fpclassify.c
diff --git a/lib/libm/sf_round.c b/firmware/lib/libm/sf_round.c
index c8f1d773..c8f1d773 100644
--- a/lib/libm/sf_round.c
+++ b/firmware/lib/libm/sf_round.c
diff --git a/lib/libm/sf_scalbn.c b/firmware/lib/libm/sf_scalbn.c
index 70006001..70006001 100644
--- a/lib/libm/sf_scalbn.c
+++ b/firmware/lib/libm/sf_scalbn.c
diff --git a/lib/libm/sf_sin.c b/firmware/lib/libm/sf_sin.c
index da81845d..da81845d 100644
--- a/lib/libm/sf_sin.c
+++ b/firmware/lib/libm/sf_sin.c
diff --git a/lib/libm/wf_asin.c b/firmware/lib/libm/wf_asin.c
index 385de549..385de549 100644
--- a/lib/libm/wf_asin.c
+++ b/firmware/lib/libm/wf_asin.c
diff --git a/lib/libm/wf_atan2.c b/firmware/lib/libm/wf_atan2.c
index eb2a76b1..eb2a76b1 100644
--- a/lib/libm/wf_atan2.c
+++ b/firmware/lib/libm/wf_atan2.c
diff --git a/lib/libm/wf_fmod.c b/firmware/lib/libm/wf_fmod.c
index 030ca3e7..030ca3e7 100644
--- a/lib/libm/wf_fmod.c
+++ b/firmware/lib/libm/wf_fmod.c
diff --git a/firmware/misc/platform/stm32f4xx/Makefile b/firmware/misc/platform/stm32f4xx/Makefile
deleted file mode 100644
index c21fd8f3..00000000
--- a/firmware/misc/platform/stm32f4xx/Makefile
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# Copyright (C) 2016 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-M3DEBUG ?= m3debug
-
-ifneq ($(CPU),cortexm4f)
- $(error "stm32f4xx cplatform only supports Cortex-M4F CPUs")
-endif
-
-DELIVERABLES = os.checked.bin bl.unchecked.bin full.bin showsizes
-BL_FILE = bl.unchecked.bin
-OS_FILE = os.checked.bin
-
-FLAGS += -I. -fno-unwind-tables -fstack-reuse=all -ffunction-sections -fdata-sections
-FLAGS += -Wl,--gc-sections
-FLAGS += -Iinc/platform/$(PLATFORM)/cmsis
-
-APPFLAGS += -msingle-pic-base -mpic-register=r9 -nostartfiles -fpic -shared
-
-#platform bootloader
-SRCS_bl += src/platform/$(PLATFORM)/bl.c
-
-#platform runtime
-SRCS_os += src/platform/$(PLATFORM)/crt_$(PLATFORM).c
-
-#platform drivers
-SRCS_os += src/platform/$(PLATFORM)/platform.c \
- src/platform/$(PLATFORM)/usart.c \
- src/platform/$(PLATFORM)/gpio.c \
- src/platform/$(PLATFORM)/pwr.c \
- src/platform/$(PLATFORM)/wdt.c \
- src/platform/$(PLATFORM)/i2c.c \
- src/platform/$(PLATFORM)/exti.c \
- src/platform/$(PLATFORM)/syscfg.c \
- src/platform/$(PLATFORM)/spi.c \
- src/platform/$(PLATFORM)/rtc.c \
- src/platform/$(PLATFORM)/mpu.c \
- src/platform/$(PLATFORM)/dma.c \
- src/platform/$(PLATFORM)/crc.c \
- src/platform/$(PLATFORM)/hostIntf.c \
- src/platform/$(PLATFORM)/apInt.c \
- src/platform/$(PLATFORM)/eeData.c
-
-
-#platform drivers for bootloader
-SRCS_bl += src/platform/$(PLATFORM)/pwr.c src/platform/$(PLATFORM)/gpio.c
-
-#extra deps
-DEPS += $(wildcard inc/platform/$(PLATFORM)/*.h)
-DEPS += $(wildcard inc/platform/$(PLATFORM)/cmsis/*.h)
-
-#platform flags
-PLATFORM_HAS_HARDWARE_CRC = true
-FLAGS += -DPLATFORM_HW_VER=0
-
-#platform-specific rules
-OBJCOPY_PARAMS = -I elf32-littlearm -O binary
-
-bl.%.bin : bl.%.elf
- $(OBJCOPY) -j .bl -j .blrodata -j .eedata $(OBJCOPY_PARAMS) $< $@
-
-os.%.bin : os.%.elf
- $(OBJCOPY) -j .data -j .text $(OBJCOPY_PARAMS) $< $@
-
-showsizes: os.unchecked.elf
- misc/platform/$(PLATFORM)/showsizes.sh $<
-
diff --git a/firmware/src/algos/accel_cal.c b/firmware/os/algos/accel_cal.c
index 953074fe..953074fe 100644
--- a/firmware/src/algos/accel_cal.c
+++ b/firmware/os/algos/accel_cal.c
diff --git a/firmware/src/algos/fusion.c b/firmware/os/algos/fusion.c
index 537af511..537af511 100644
--- a/firmware/src/algos/fusion.c
+++ b/firmware/os/algos/fusion.c
diff --git a/firmware/src/algos/gyro_cal.c b/firmware/os/algos/gyro_cal.c
index 0b30fc32..0b30fc32 100644
--- a/firmware/src/algos/gyro_cal.c
+++ b/firmware/os/algos/gyro_cal.c
diff --git a/firmware/src/algos/gyro_stillness_detect.c b/firmware/os/algos/gyro_stillness_detect.c
index 89f4ab81..89f4ab81 100644
--- a/firmware/src/algos/gyro_stillness_detect.c
+++ b/firmware/os/algos/gyro_stillness_detect.c
diff --git a/firmware/src/algos/mag_cal.c b/firmware/os/algos/mag_cal.c
index e8b27ea7..e8b27ea7 100644
--- a/firmware/src/algos/mag_cal.c
+++ b/firmware/os/algos/mag_cal.c
diff --git a/firmware/src/algos/mat.c b/firmware/os/algos/mat.c
index d5ae315a..d5ae315a 100644
--- a/firmware/src/algos/mat.c
+++ b/firmware/os/algos/mat.c
diff --git a/firmware/src/algos/quat.c b/firmware/os/algos/quat.c
index b7be5a5d..b7be5a5d 100644
--- a/firmware/src/algos/quat.c
+++ b/firmware/os/algos/quat.c
diff --git a/firmware/src/algos/time_sync.c b/firmware/os/algos/time_sync.c
index 830fe7f3..830fe7f3 100644
--- a/firmware/src/algos/time_sync.c
+++ b/firmware/os/algos/time_sync.c
diff --git a/firmware/src/algos/vec.c b/firmware/os/algos/vec.c
index 3f7493ce..3f7493ce 100644
--- a/firmware/src/algos/vec.c
+++ b/firmware/os/algos/vec.c
diff --git a/firmware/src/appSec.c b/firmware/os/core/appSec.c
index de7421ac..6d4aec89 100644
--- a/firmware/src/appSec.c
+++ b/firmware/os/core/appSec.c
@@ -16,7 +16,7 @@
#include <stdint.h>
-#include <plat/inc/bl.h>
+#include <plat/bl.h>
#include <nanohub/sha2.h>
#include <nanohub/rsa.h>
diff --git a/firmware/src/eventQ.c b/firmware/os/core/eventQ.c
index 6c77b09f..60a8c4fc 100644
--- a/firmware/src/eventQ.c
+++ b/firmware/os/core/eventQ.c
@@ -23,8 +23,8 @@
#include <slab.h>
#include <cpu.h>
#include <util.h>
-#include <plat/inc/plat.h>
-#include <plat/inc/taggedPtr.h>
+#include <plat/plat.h>
+#include <plat/taggedPtr.h>
struct EvtRecord {
diff --git a/firmware/src/floatRt.c b/firmware/os/core/floatRt.c
index f5a10d9f..f5a10d9f 100644
--- a/firmware/src/floatRt.c
+++ b/firmware/os/core/floatRt.c
diff --git a/firmware/src/heap.c b/firmware/os/core/heap.c
index b172c708..b172c708 100644
--- a/firmware/src/heap.c
+++ b/firmware/os/core/heap.c
diff --git a/firmware/src/hostIntf.c b/firmware/os/core/hostIntf.c
index f08f1a90..35b6d985 100644
--- a/firmware/src/hostIntf.c
+++ b/firmware/os/core/hostIntf.c
@@ -20,10 +20,10 @@
#include <string.h>
#include <alloca.h>
-#include <variant/inc/variant.h>
+#include <variant/variant.h>
#include <eventnums.h>
-#include <plat/inc/pwr.h>
+#include <plat/pwr.h>
#include <nanohub/crc.h>
diff --git a/firmware/src/hostIntfI2c.c b/firmware/os/core/hostIntfI2c.c
index 36763768..36763768 100644
--- a/firmware/src/hostIntfI2c.c
+++ b/firmware/os/core/hostIntfI2c.c
diff --git a/firmware/src/hostIntfSpi.c b/firmware/os/core/hostIntfSpi.c
index 761325cf..761325cf 100644
--- a/firmware/src/hostIntfSpi.c
+++ b/firmware/os/core/hostIntfSpi.c
diff --git a/firmware/src/nanohubCommand.c b/firmware/os/core/nanohubCommand.c
index e70477d6..79387d66 100644
--- a/firmware/src/nanohubCommand.c
+++ b/firmware/os/core/nanohubCommand.c
@@ -19,12 +19,12 @@
#include <stdint.h>
#include <sys/endian.h>
-#include <variant/inc/variant.h>
+#include <variant/variant.h>
#include <eventnums.h>
-#include <plat/inc/taggedPtr.h>
-#include <plat/inc/bl.h>
-#include <plat/inc/plat.h>
+#include <plat/taggedPtr.h>
+#include <plat/bl.h>
+#include <plat/plat.h>
#include <nanohub/crc.h>
#include <nanohub/rsa.h>
diff --git a/firmware/src/osApi.c b/firmware/os/core/osApi.c
index 1e1ec7b9..77ffe7a8 100644
--- a/firmware/src/osApi.c
+++ b/firmware/os/core/osApi.c
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <plat/inc/taggedPtr.h>
-#include <plat/inc/rtc.h>
+#include <plat/taggedPtr.h>
+#include <plat/rtc.h>
#include <syscall.h>
#include <sensors.h>
#include <errno.h>
diff --git a/firmware/src/printf.c b/firmware/os/core/printf.c
index 6f3d94a8..9c10dc3d 100644
--- a/firmware/src/printf.c
+++ b/firmware/os/core/printf.c
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <printf.h>
-#include <cpu/inc/cpuMath.h>
+#include <cpu/cpuMath.h>
static uint32_t StrPrvPrintfEx_number(printf_write_c putc_, void* userData, uint64_t number, bool base10, bool zeroExtend, bool isSigned, uint32_t padToLength, bool caps, bool* bail)
diff --git a/firmware/src/sensors.c b/firmware/os/core/sensors.c
index b5f6cc67..46583518 100644
--- a/firmware/src/sensors.c
+++ b/firmware/os/core/sensors.c
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include <plat/inc/taggedPtr.h>
-#include <plat/inc/rtc.h>
-#include <cpu/inc/barrier.h>
+#include <plat/taggedPtr.h>
+#include <plat/rtc.h>
+#include <cpu/barrier.h>
#include <atomicBitset.h>
#include <inttypes.h>
#include <sensors.h>
diff --git a/firmware/src/seos.c b/firmware/os/core/seos.c
index 6d36337a..e1570f81 100644
--- a/firmware/src/seos.c
+++ b/firmware/os/core/seos.c
@@ -14,11 +14,12 @@
* limitations under the License.
*/
-#include <plat/inc/eeData.h>
-#include <plat/inc/plat.h>
-#include <plat/inc/bl.h>
-#include <plat/inc/wdt.h>
+#include <plat/eeData.h>
+#include <plat/plat.h>
+#include <plat/bl.h>
+#include <plat/wdt.h>
#include <platform.h>
+#include <crc.h>
#include <hostIntf.h>
#include <inttypes.h>
#include <syscall.h>
@@ -41,7 +42,6 @@
#include <atomic.h>
#include <nanohub/nanohub.h>
-#include <nanohub/crc.h>
#define NO_NODE (TaskIndex)(-1)
#define for_each_task(listHead, task) for (task = osTaskByIdx((listHead)->next); task; task = osTaskByIdx(task->list.next))
diff --git a/firmware/src/simpleQ.c b/firmware/os/core/simpleQ.c
index 3b897121..3b897121 100644
--- a/firmware/src/simpleQ.c
+++ b/firmware/os/core/simpleQ.c
diff --git a/firmware/src/slab.c b/firmware/os/core/slab.c
index 13400e5f..13400e5f 100644
--- a/firmware/src/slab.c
+++ b/firmware/os/core/slab.c
diff --git a/firmware/src/spi.c b/firmware/os/core/spi.c
index afa58a3e..afa58a3e 100644
--- a/firmware/src/spi.c
+++ b/firmware/os/core/spi.c
diff --git a/firmware/src/syscall.c b/firmware/os/core/syscall.c
index 2bd9169e..2bd9169e 100644
--- a/firmware/src/syscall.c
+++ b/firmware/os/core/syscall.c
diff --git a/firmware/src/timer.c b/firmware/os/core/timer.c
index e64c5579..df9c2124 100644
--- a/firmware/src/timer.c
+++ b/firmware/os/core/timer.c
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <cpu/inc/atomicBitset.h>
-#include <plat/inc/rtc.h>
+#include <cpu/atomicBitset.h>
+#include <plat/rtc.h>
#include <atomicBitset.h>
#include <platform.h>
#include <atomic.h>
diff --git a/firmware/src/trylock.c b/firmware/os/core/trylock.c
index 62b3a10e..62b3a10e 100644
--- a/firmware/src/trylock.c
+++ b/firmware/os/core/trylock.c
diff --git a/firmware/src/cpu/cortexm4f/appSupport.c b/firmware/os/cpu/cortexm4/appSupport.c
index 927fc905..927fc905 100644
--- a/firmware/src/cpu/cortexm4f/appSupport.c
+++ b/firmware/os/cpu/cortexm4/appSupport.c
diff --git a/firmware/src/cpu/cortexm4f/atomic.c b/firmware/os/cpu/cortexm4/atomic.c
index 15963cd1..15963cd1 100644
--- a/firmware/src/cpu/cortexm4f/atomic.c
+++ b/firmware/os/cpu/cortexm4/atomic.c
diff --git a/firmware/src/cpu/cortexm4f/atomicBitset.c b/firmware/os/cpu/cortexm4/atomicBitset.c
index 9e5ce09e..9e5ce09e 100644
--- a/firmware/src/cpu/cortexm4f/atomicBitset.c
+++ b/firmware/os/cpu/cortexm4/atomicBitset.c
diff --git a/firmware/misc/cpu/cortexm4f/Makefile b/firmware/os/cpu/cortexm4/cortexm4.mk
index e81465c1..8e3b78ba 100644
--- a/firmware/misc/cpu/cortexm4f/Makefile
+++ b/firmware/os/cpu/cortexm4/cortexm4.mk
@@ -18,33 +18,52 @@ GCC = $(CROSS_COMPILE)gcc
OBJCOPY = $(CROSS_COMPILE)objcopy
FLAGS += -mthumb -mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -mno-thumb-interwork -ffast-math -fsingle-precision-constant -DARM -DUSE_NANOHUB_FLOAT_RUNTIME
-APPFLAGS += -Wl,-T misc/cpu/$(CPU)/app.lkr -mno-pic-data-is-text-relative
+
+LIB_PATH := lib
#defines
FLAGS += -DCPU_NUM_PERSISTENT_RAM_BITS=32
#cpu runtime
-SRCS_os += src/cpu/$(CPU)/atomicBitset.c src/cpu/$(CPU)/cpu.c src/cpu/$(CPU)/pendsv.c src/cpu/$(CPU)/atomic.c src/cpu/$(CPU)/appSupport.c src/cpu/$(CPU)/cpuMath.c
+SRCS_os += \
+ os/cpu/$(CPU)/atomicBitset.c \
+ os/cpu/$(CPU)/cpu.c \
+ os/cpu/$(CPU)/pendsv.c \
+ os/cpu/$(CPU)/atomic.c \
+ os/cpu/$(CPU)/appSupport.c \
+ os/cpu/$(CPU)/cpuMath.c \
#cpu runtime for bootloader
-SRCS_bl += src/cpu/$(CPU)/cpu.c
+SRCS_bl += os/cpu/$(CPU)/cpu.c
#c runtime
-SRCS_os += ../lib/libc/memcpy-armv7m.S ../lib/libc/memset.c ../lib/libc/memcmp.c ../lib/libc/memmove.c
+SRCS_os += \
+ $(LIB_PATH)/libc/memcpy-armv7m.S \
+ $(LIB_PATH)/libc/memset.c \
+ $(LIB_PATH)/libc/memcmp.c \
+ $(LIB_PATH)/libc/memmove.c \
#c runtime for bootloader
-SRCS_bl += ../lib/libc/memcpy-armv7m.S ../lib/libc/memset.c ../lib/libc/memcmp.c ../lib/libc/memmove.c
+SRCS_bl += \
+ $(LIB_PATH)/libc/memcpy-armv7m.S \
+ $(LIB_PATH)/libc/memset.c \
+ $(LIB_PATH)/libc/memcmp.c \
+ $(LIB_PATH)/libc/memmove.c \
#floating point runtime (ARM)
SRCS_os += external/arm/arm_sin_cos_f32.c
FLAGS += -DARM_MATH_CM4 -D__FPU_PRESENT
#floating point runtime (FreeBSD)
-SRCS_os += external/freebsd/lib/msun/src/e_atan2f.c external/freebsd/lib/msun/src/e_expf.c external/freebsd/lib/msun/src/s_atanf.c
-FLAGS += -DFLT_EVAL_METHOD
+SRCS_os += \
+ external/freebsd/lib/msun/src/e_atan2f.c \
+ external/freebsd/lib/msun/src/e_expf.c \
+ external/freebsd/lib/msun/src/s_atanf.c \
+
+FLAGS += -DFLT_EVAL_METHOD -Iexternal/freebsd/lib/msun/src
#extra deps
-DEPS += $(wildcard inc/cpu/$(CPU)/*.h)
+DEPS += $(wildcard os/cpu/$(CPU)/inc/cpu/*.h)
#bad words for C-M4F
BADWORDS += "__floatundisf=When casting a uint64_t to float, use floatFromUint64"
@@ -60,6 +79,4 @@ BADWORDS += "asinf=include nanhub_math.h before using asinf()"
#all softfloat double funcs are forbidden
BADWORDS += __muldf3 __divdf3 __subdf3 __adddf3 __truncdfsf2
-
-
-
+$(info Included CORTEX-M4 CPU)
diff --git a/firmware/src/cpu/cortexm4f/cpu.c b/firmware/os/cpu/cortexm4/cpu.c
index 3aea26a3..2c887e9e 100644
--- a/firmware/src/cpu/cortexm4f/cpu.c
+++ b/firmware/os/cpu/cortexm4/cpu.c
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#include <plat/inc/cmsis.h>
-#include <plat/inc/plat.h>
-#include <plat/inc/pwr.h>
-#include <plat/inc/wdt.h>
+#include <plat/cmsis.h>
+#include <plat/plat.h>
+#include <plat/pwr.h>
+#include <plat/wdt.h>
#include <syscall.h>
#include <string.h>
#include <seos.h>
diff --git a/firmware/src/cpu/cortexm4f/cpuMath.c b/firmware/os/cpu/cortexm4/cpuMath.c
index f7e3970c..af2df53d 100644
--- a/firmware/src/cpu/cortexm4f/cpuMath.c
+++ b/firmware/os/cpu/cortexm4/cpuMath.c
@@ -1,4 +1,4 @@
-#include <cpu/inc/cpuMath.h>
+#include <cpu/cpuMath.h>
uint32_t cpuMathUint44Div1000ToUint32_slow_path(uint64_t val)
{
diff --git a/firmware/inc/cpu/cortexm4f/atomic.h b/firmware/os/cpu/cortexm4/inc/cpu/atomic.h
index b9423401..3eb66c2a 100644
--- a/firmware/inc/cpu/cortexm4f/atomic.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/atomic.h
@@ -17,9 +17,6 @@
#ifndef _CM4F_ATOMIC_H_
#define _CM4F_ATOMIC_H_
-// real definition available in CPU-independent header file
-extern bool atomicCmpXchg32bits(volatile uint32_t *word, uint32_t prevVal, uint32_t newVal);
-
static inline bool atomicCmpXchgPtr(volatile uintptr_t *word, uintptr_t prevVal, uintptr_t newVal) {
// 32-bit CPU architecture so fall back appropriately
return atomicCmpXchg32bits((volatile uint32_t *) word, (uint32_t) prevVal, (uint32_t) newVal);
diff --git a/firmware/inc/cpu/cortexm4f/atomicBitset.h b/firmware/os/cpu/cortexm4/inc/cpu/atomicBitset.h
index 75a12fe6..75a12fe6 100644
--- a/firmware/inc/cpu/cortexm4f/atomicBitset.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/atomicBitset.h
diff --git a/firmware/inc/cpu/cortexm4f/barrier.h b/firmware/os/cpu/cortexm4/inc/cpu/barrier.h
index 2c70ff88..2c70ff88 100644
--- a/firmware/inc/cpu/cortexm4f/barrier.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/barrier.h
diff --git a/firmware/inc/cpu/cortexm4f/cpuMath.h b/firmware/os/cpu/cortexm4/inc/cpu/cpuMath.h
index 70fb98a0..70fb98a0 100644
--- a/firmware/inc/cpu/cortexm4f/cpuMath.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/cpuMath.h
diff --git a/firmware/inc/cpu/cortexm4f/nanohub_math.h b/firmware/os/cpu/cortexm4/inc/cpu/nanohub_math.h
index 320154fb..d353c455 100644
--- a/firmware/inc/cpu/cortexm4f/nanohub_math.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/nanohub_math.h
@@ -17,6 +17,7 @@
#ifndef _CPU_NANOHUB_MATH_H_
#define _CPU_NANOHUB_MATH_H_
+#include <arm_math.h>
#define asinf arm_asinf
#define sinf arm_sin_f32
diff --git a/firmware/inc/cpu/cortexm4f/pendsv.h b/firmware/os/cpu/cortexm4/inc/cpu/pendsv.h
index 4020a9fa..4020a9fa 100644
--- a/firmware/inc/cpu/cortexm4f/pendsv.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/pendsv.h
diff --git a/firmware/inc/cpu/cortexm4f/syscallDo.h b/firmware/os/cpu/cortexm4/inc/cpu/syscallDo.h
index 45cfdbab..45cfdbab 100644
--- a/firmware/inc/cpu/cortexm4f/syscallDo.h
+++ b/firmware/os/cpu/cortexm4/inc/cpu/syscallDo.h
diff --git a/firmware/src/cpu/cortexm4f/pendsv.c b/firmware/os/cpu/cortexm4/pendsv.c
index 1112de49..ef37c10a 100644
--- a/firmware/src/cpu/cortexm4f/pendsv.c
+++ b/firmware/os/cpu/cortexm4/pendsv.c
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <plat/inc/cmsis.h>
-#include <cpu/inc/pendsv.h>
+#include <plat/cmsis.h>
+#include <cpu/pendsv.h>
#include <stdio.h>
diff --git a/firmware/src/cpu/x86/atomic.c b/firmware/os/cpu/x86/atomic.c
index 20cd2489..20cd2489 100644
--- a/firmware/src/cpu/x86/atomic.c
+++ b/firmware/os/cpu/x86/atomic.c
diff --git a/firmware/src/cpu/x86/atomicBitset.c b/firmware/os/cpu/x86/atomicBitset.c
index 98f25360..98f25360 100644
--- a/firmware/src/cpu/x86/atomicBitset.c
+++ b/firmware/os/cpu/x86/atomicBitset.c
diff --git a/firmware/src/cpu/x86/cpu.c b/firmware/os/cpu/x86/cpu.c
index af74873e..af74873e 100644
--- a/firmware/src/cpu/x86/cpu.c
+++ b/firmware/os/cpu/x86/cpu.c
diff --git a/firmware/inc/cpu/x86/atomicBitset.h b/firmware/os/cpu/x86/inc/cpu/atomicBitset.h
index d9d3d1d9..d9d3d1d9 100644
--- a/firmware/inc/cpu/x86/atomicBitset.h
+++ b/firmware/os/cpu/x86/inc/cpu/atomicBitset.h
diff --git a/firmware/inc/cpu/x86/barrier.h b/firmware/os/cpu/x86/inc/cpu/barrier.h
index 7411bf87..7411bf87 100644
--- a/firmware/inc/cpu/x86/barrier.h
+++ b/firmware/os/cpu/x86/inc/cpu/barrier.h
diff --git a/firmware/misc/cpu/x86/Makefile b/firmware/os/cpu/x86/x86.mk
index dcc9295c..352e91c3 100644
--- a/firmware/misc/cpu/x86/Makefile
+++ b/firmware/os/cpu/x86/x86.mk
@@ -20,9 +20,12 @@ OBJCOPY = objcopy
FLAGS += -march=core2 -msse2 -DSYSCALL_VARARGS_PARAMS_PASSED_AS_PTRS
#cpu runtime
-SRCS += src/cpu/$(CPU)/atomicBitset.c src/cpu/$(CPU)/cpu.c src/cpu/$(CPU)/atomic.c
+SRCS += \
+ os/cpu/$(CPU)/atomicBitset.c \
+ os/cpu/$(CPU)/cpu.c \
+ os/cpu/$(CPU)/atomic.c \
#extra deps
-DEPS += $(wildcard inc/cpu/$(CPU)/*.h)
-
+DEPS += $(wildcard os/cpu/$(CPU)/inc/cpu/*.h)
+$(info Included x86 CPU)
diff --git a/firmware/src/drivers/ams_tmd2772/ams_tmd2772.c b/firmware/os/drivers/ams_tmd2772/ams_tmd2772.c
index f37ff594..f37ff594 100644
--- a/firmware/src/drivers/ams_tmd2772/ams_tmd2772.c
+++ b/firmware/os/drivers/ams_tmd2772/ams_tmd2772.c
diff --git a/firmware/src/drivers/ams_tmd4903/ams_tmd4903.c b/firmware/os/drivers/ams_tmd4903/ams_tmd4903.c
index 104393cf..a74e0404 100644
--- a/firmware/src/drivers/ams_tmd4903/ams_tmd4903.c
+++ b/firmware/os/drivers/ams_tmd4903/ams_tmd4903.c
@@ -30,10 +30,10 @@
#include <sensors.h>
#include <seos.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/syscfg.h>
-#include <variant/inc/variant.h>
+#include <plat/exti.h>
+#include <plat/gpio.h>
+#include <plat/syscfg.h>
+#include <variant/variant.h>
#define AMS_TMD4903_APP_ID APP_ID_MAKE(APP_ID_VENDOR_GOOGLE, 12)
#define AMS_TMD4903_APP_VERSION 10
diff --git a/firmware/src/drivers/bosch_bmi160/akm_ak09915_slave.c b/firmware/os/drivers/bosch_bmi160/akm_ak09915_slave.c
index 371f997b..371f997b 100644
--- a/firmware/src/drivers/bosch_bmi160/akm_ak09915_slave.c
+++ b/firmware/os/drivers/bosch_bmi160/akm_ak09915_slave.c
diff --git a/firmware/src/drivers/bosch_bmi160/akm_ak09915_slave.h b/firmware/os/drivers/bosch_bmi160/akm_ak09915_slave.h
index d7bb12e9..d7bb12e9 100644
--- a/firmware/src/drivers/bosch_bmi160/akm_ak09915_slave.h
+++ b/firmware/os/drivers/bosch_bmi160/akm_ak09915_slave.h
diff --git a/firmware/src/drivers/bosch_bmi160/bosch_bmi160.c b/firmware/os/drivers/bosch_bmi160/bosch_bmi160.c
index ced8f0ff..8283c5bc 100644
--- a/firmware/src/drivers/bosch_bmi160/bosch_bmi160.c
+++ b/firmware/os/drivers/bosch_bmi160/bosch_bmi160.c
@@ -16,25 +16,25 @@
#include <algos/time_sync.h>
#include <atomic.h>
-#include <cpu/inc/cpuMath.h>
+#include <cpu/cpuMath.h>
#include <gpio.h>
#include <heap.h>
#include <hostIntf.h>
#include <isr.h>
#include <nanohub_math.h>
#include <nanohubPacket.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/syscfg.h>
-#include <plat/inc/rtc.h>
#include <printf.h>
+#include <plat/exti.h>
+#include <plat/gpio.h>
+#include <plat/syscfg.h>
+#include <plat/rtc.h>
#include <sensors.h>
#include <seos.h>
#include <slab.h>
#include <spi.h>
#include <timer.h>
-#include <variant/inc/sensType.h>
-#include <variant/inc/variant.h>
+#include <variant/sensType.h>
+#include <variant/variant.h>
#ifdef MAG_SLAVE_PRESENT
#include <algos/mag_cal.h>
diff --git a/firmware/src/drivers/bosch_bmi160/bosch_bmm150_slave.c b/firmware/os/drivers/bosch_bmi160/bosch_bmm150_slave.c
index 4a223fbd..4a223fbd 100644
--- a/firmware/src/drivers/bosch_bmi160/bosch_bmm150_slave.c
+++ b/firmware/os/drivers/bosch_bmi160/bosch_bmm150_slave.c
diff --git a/firmware/src/drivers/bosch_bmi160/bosch_bmm150_slave.h b/firmware/os/drivers/bosch_bmi160/bosch_bmm150_slave.h
index 59e53fba..59e53fba 100644
--- a/firmware/src/drivers/bosch_bmi160/bosch_bmm150_slave.h
+++ b/firmware/os/drivers/bosch_bmi160/bosch_bmm150_slave.h
diff --git a/firmware/src/drivers/bosch_bmp280/bosch_bmp280.c b/firmware/os/drivers/bosch_bmp280/bosch_bmp280.c
index 4dd623da..4dd623da 100644
--- a/firmware/src/drivers/bosch_bmp280/bosch_bmp280.c
+++ b/firmware/os/drivers/bosch_bmp280/bosch_bmp280.c
diff --git a/firmware/src/drivers/hall/hall.c b/firmware/os/drivers/hall/hall.c
index 01e8c8a2..6469177c 100644
--- a/firmware/src/drivers/hall/hall.c
+++ b/firmware/os/drivers/hall/hall.c
@@ -27,10 +27,10 @@
#include <sensors.h>
#include <seos.h>
#include <timer.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/syscfg.h>
-#include <variant/inc/variant.h>
+#include <plat/gpio.h>
+#include <plat/exti.h>
+#include <plat/syscfg.h>
+#include <variant/variant.h>
#define APP_VERSION 2
diff --git a/firmware/src/drivers/hall_twopole/hall_twopole.c b/firmware/os/drivers/hall_twopole/hall_twopole.c
index 11c77e53..847071f2 100644
--- a/firmware/src/drivers/hall_twopole/hall_twopole.c
+++ b/firmware/os/drivers/hall_twopole/hall_twopole.c
@@ -27,10 +27,10 @@
#include <sensors.h>
#include <seos.h>
#include <timer.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/syscfg.h>
-#include <variant/inc/variant.h>
+#include <plat/gpio.h>
+#include <plat/exti.h>
+#include <plat/syscfg.h>
+#include <variant/variant.h>
#define APP_ID APP_ID_MAKE(APP_ID_VENDOR_GOOGLE, 11)
#define APP_VERSION 2
diff --git a/firmware/src/drivers/orientation/orientation.c b/firmware/os/drivers/orientation/orientation.c
index 7bb06eff..03fe0c80 100644
--- a/firmware/src/drivers/orientation/orientation.c
+++ b/firmware/os/drivers/orientation/orientation.c
@@ -18,8 +18,8 @@
#include <string.h>
#include <timer.h>
#include <heap.h>
-#include <plat/inc/rtc.h>
-#include <plat/inc/syscfg.h>
+#include <plat/rtc.h>
+#include <plat/syscfg.h>
#include <hostIntf.h>
#include <nanohubPacket.h>
#include <floatRt.h>
diff --git a/firmware/src/drivers/rohm_rpr0521/rohm_rpr0521.c b/firmware/os/drivers/rohm_rpr0521/rohm_rpr0521.c
index 79978207..c0ba6253 100644
--- a/firmware/src/drivers/rohm_rpr0521/rohm_rpr0521.c
+++ b/firmware/os/drivers/rohm_rpr0521/rohm_rpr0521.c
@@ -30,10 +30,10 @@
#include <sensors.h>
#include <seos.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/syscfg.h>
-#include <variant/inc/variant.h>
+#include <plat/exti.h>
+#include <plat/gpio.h>
+#include <plat/syscfg.h>
+#include <variant/variant.h>
#ifndef PROX_INT_PIN
#error "PROX_INT_PIN is not defined; please define in variant.h"
diff --git a/firmware/src/drivers/tilt_detection/tilt_detection.c b/firmware/os/drivers/tilt_detection/tilt_detection.c
index c21d5b05..7ed4de03 100644
--- a/firmware/src/drivers/tilt_detection/tilt_detection.c
+++ b/firmware/os/drivers/tilt_detection/tilt_detection.c
@@ -18,8 +18,8 @@
#include <string.h>
#include <timer.h>
#include <heap.h>
-#include <plat/inc/rtc.h>
-#include <plat/inc/syscfg.h>
+#include <plat/rtc.h>
+#include <plat/syscfg.h>
#include <hostIntf.h>
#include <nanohubPacket.h>
diff --git a/firmware/src/drivers/vsync/vsync.c b/firmware/os/drivers/vsync/vsync.c
index c6d55aab..b541ee1a 100644
--- a/firmware/src/drivers/vsync/vsync.c
+++ b/firmware/os/drivers/vsync/vsync.c
@@ -28,10 +28,10 @@
#include <seos.h>
#include <slab.h>
#include <timer.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/syscfg.h>
-#include <variant/inc/variant.h>
+#include <plat/gpio.h>
+#include <plat/exti.h>
+#include <plat/syscfg.h>
+#include <variant/variant.h>
#define VSYNC_APP_ID APP_ID_MAKE(APP_ID_VENDOR_GOOGLE, 7)
#define VSYNC_APP_VERSION 2
diff --git a/firmware/src/drivers/window_orientation/window_orientation.c b/firmware/os/drivers/window_orientation/window_orientation.c
index e5cab76c..2c6c94a2 100644
--- a/firmware/src/drivers/window_orientation/window_orientation.c
+++ b/firmware/os/drivers/window_orientation/window_orientation.c
@@ -18,8 +18,8 @@
#include <string.h>
#include <timer.h>
#include <heap.h>
-#include <plat/inc/rtc.h>
-#include <plat/inc/syscfg.h>
+#include <plat/rtc.h>
+#include <plat/syscfg.h>
#include <hostIntf.h>
#include <nanohubPacket.h>
#include <floatRt.h>
diff --git a/firmware/inc/algos/accel_cal.h b/firmware/os/inc/algos/accel_cal.h
index b2f818c7..b2f818c7 100644
--- a/firmware/inc/algos/accel_cal.h
+++ b/firmware/os/inc/algos/accel_cal.h
diff --git a/firmware/inc/algos/fusion.h b/firmware/os/inc/algos/fusion.h
index 506cd1ce..506cd1ce 100644
--- a/firmware/inc/algos/fusion.h
+++ b/firmware/os/inc/algos/fusion.h
diff --git a/firmware/inc/algos/gyro_cal.h b/firmware/os/inc/algos/gyro_cal.h
index 59e9736d..59e9736d 100644
--- a/firmware/inc/algos/gyro_cal.h
+++ b/firmware/os/inc/algos/gyro_cal.h
diff --git a/firmware/inc/algos/gyro_stillness_detect.h b/firmware/os/inc/algos/gyro_stillness_detect.h
index 93516115..93516115 100644
--- a/firmware/inc/algos/gyro_stillness_detect.h
+++ b/firmware/os/inc/algos/gyro_stillness_detect.h
diff --git a/firmware/inc/algos/mag_cal.h b/firmware/os/inc/algos/mag_cal.h
index 425844d7..425844d7 100644
--- a/firmware/inc/algos/mag_cal.h
+++ b/firmware/os/inc/algos/mag_cal.h
diff --git a/firmware/inc/algos/mat.h b/firmware/os/inc/algos/mat.h
index c6f4705e..c6f4705e 100644
--- a/firmware/inc/algos/mat.h
+++ b/firmware/os/inc/algos/mat.h
diff --git a/firmware/inc/algos/quat.h b/firmware/os/inc/algos/quat.h
index b0f6fc55..b0f6fc55 100644
--- a/firmware/inc/algos/quat.h
+++ b/firmware/os/inc/algos/quat.h
diff --git a/firmware/inc/algos/time_sync.h b/firmware/os/inc/algos/time_sync.h
index ce497fc9..ce497fc9 100644
--- a/firmware/inc/algos/time_sync.h
+++ b/firmware/os/inc/algos/time_sync.h
diff --git a/firmware/inc/algos/vec.h b/firmware/os/inc/algos/vec.h
index ac7f139c..ac7f139c 100644
--- a/firmware/inc/algos/vec.h
+++ b/firmware/os/inc/algos/vec.h
diff --git a/firmware/inc/apInt.h b/firmware/os/inc/apInt.h
index 169e5938..169e5938 100644
--- a/firmware/inc/apInt.h
+++ b/firmware/os/inc/apInt.h
diff --git a/firmware/inc/appSec.h b/firmware/os/inc/appSec.h
index 8847a2a7..8847a2a7 100644
--- a/firmware/inc/appSec.h
+++ b/firmware/os/inc/appSec.h
diff --git a/firmware/inc/atomic.h b/firmware/os/inc/atomic.h
index 5a446243..129b8616 100644
--- a/firmware/inc/atomic.h
+++ b/firmware/os/inc/atomic.h
@@ -23,8 +23,6 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
-#include <cpu/inc/atomic.h>
-#include <cpu/inc/barrier.h>
/* almost all platforms support byte and 32-bit operations of this sort. please do not add other sizes here */
uint32_t atomicXchgByte(volatile uint8_t *byte, uint32_t newVal);
@@ -36,6 +34,10 @@ bool atomicCmpXchg32bits(volatile uint32_t *word, uint32_t prevVal, uint32_t new
uint32_t atomicAddByte(volatile uint8_t *byte, uint32_t addend);
uint32_t atomicAdd32bits(volatile uint32_t *word, uint32_t addend);
+// pull in inline cpu-specific implementations, if any
+#include <cpu/atomic.h>
+#include <cpu/barrier.h>
+
//writes with barriers
static inline uint32_t atomicReadByte(volatile uint8_t *byte)
{
diff --git a/firmware/inc/atomicBitset.h b/firmware/os/inc/atomicBitset.h
index 34374bfe..c7521769 100644
--- a/firmware/inc/atomicBitset.h
+++ b/firmware/os/inc/atomicBitset.h
@@ -19,7 +19,7 @@
#include <stdint.h>
#include <stdbool.h>
-#include <cpu/inc/atomicBitset.h>
+#include <cpu/atomicBitset.h>
struct AtomicBitset;
diff --git a/firmware/inc/console.h b/firmware/os/inc/console.h
index c0c59582..c0c59582 100644
--- a/firmware/inc/console.h
+++ b/firmware/os/inc/console.h
diff --git a/firmware/inc/cpu.h b/firmware/os/inc/cpu.h
index 2cf44455..22416e3f 100644
--- a/firmware/inc/cpu.h
+++ b/firmware/os/inc/cpu.h
@@ -24,7 +24,7 @@ extern "C" {
#include <seos.h>
#include <stdint.h>
-#include <plat/inc/app.h>
+#include <plat/app.h>
void cpuInit(void);
diff --git a/firmware/os/inc/crc.h b/firmware/os/inc/crc.h
new file mode 100644
index 00000000..2c88d465
--- /dev/null
+++ b/firmware/os/inc/crc.h
@@ -0,0 +1,2 @@
+#include <nanohub/crc.h>
+#include <plat/crc.h>
diff --git a/firmware/inc/eeData.h b/firmware/os/inc/eeData.h
index 9b313eed..9b313eed 100644
--- a/firmware/inc/eeData.h
+++ b/firmware/os/inc/eeData.h
diff --git a/firmware/inc/eventQ.h b/firmware/os/inc/eventQ.h
index 2d4d417a..b15e3497 100644
--- a/firmware/inc/eventQ.h
+++ b/firmware/os/inc/eventQ.h
@@ -20,7 +20,7 @@
#include <stdbool.h>
#include <stdint.h>
-#include <plat/inc/taggedPtr.h>
+#include <plat/taggedPtr.h>
#define EVENT_TYPE_BIT_DISCARDABLE_COMPAT 0x80000000 /* some external apps are using this one */
diff --git a/firmware/inc/eventnums.h b/firmware/os/inc/eventnums.h
index 88c2e5a5..88c2e5a5 100644
--- a/firmware/inc/eventnums.h
+++ b/firmware/os/inc/eventnums.h
diff --git a/firmware/inc/floatRt.h b/firmware/os/inc/floatRt.h
index 050cf54c..050cf54c 100644
--- a/firmware/inc/floatRt.h
+++ b/firmware/os/inc/floatRt.h
diff --git a/firmware/inc/gpio.h b/firmware/os/inc/gpio.h
index 7eb24b7f..7eb24b7f 100644
--- a/firmware/inc/gpio.h
+++ b/firmware/os/inc/gpio.h
diff --git a/firmware/inc/heap.h b/firmware/os/inc/heap.h
index c5bea591..c5bea591 100644
--- a/firmware/inc/heap.h
+++ b/firmware/os/inc/heap.h
diff --git a/firmware/inc/hostIntf.h b/firmware/os/inc/hostIntf.h
index 66ed7e4f..66ed7e4f 100644
--- a/firmware/inc/hostIntf.h
+++ b/firmware/os/inc/hostIntf.h
diff --git a/firmware/inc/hostIntf_priv.h b/firmware/os/inc/hostIntf_priv.h
index a5bfc689..a5bfc689 100644
--- a/firmware/inc/hostIntf_priv.h
+++ b/firmware/os/inc/hostIntf_priv.h
diff --git a/firmware/inc/i2c.h b/firmware/os/inc/i2c.h
index aae0d0c7..aae0d0c7 100644
--- a/firmware/inc/i2c.h
+++ b/firmware/os/inc/i2c.h
diff --git a/firmware/inc/isr.h b/firmware/os/inc/isr.h
index 2ce9d2ca..2ce9d2ca 100644
--- a/firmware/inc/isr.h
+++ b/firmware/os/inc/isr.h
diff --git a/firmware/inc/list.h b/firmware/os/inc/list.h
index c892e421..c892e421 100644
--- a/firmware/inc/list.h
+++ b/firmware/os/inc/list.h
diff --git a/firmware/inc/mpu.h b/firmware/os/inc/mpu.h
index 45bf7a9a..45bf7a9a 100644
--- a/firmware/inc/mpu.h
+++ b/firmware/os/inc/mpu.h
diff --git a/firmware/inc/nanohubCommand.h b/firmware/os/inc/nanohubCommand.h
index 0c4c5220..0c4c5220 100644
--- a/firmware/inc/nanohubCommand.h
+++ b/firmware/os/inc/nanohubCommand.h
diff --git a/firmware/inc/nanohubPacket.h b/firmware/os/inc/nanohubPacket.h
index ad962ea7..ad962ea7 100644
--- a/firmware/inc/nanohubPacket.h
+++ b/firmware/os/inc/nanohubPacket.h
diff --git a/firmware/inc/nanohub_math.h b/firmware/os/inc/nanohub_math.h
index 6257c764..27de6acd 100644
--- a/firmware/inc/nanohub_math.h
+++ b/firmware/os/inc/nanohub_math.h
@@ -14,5 +14,5 @@
* limitations under the License.
*/
-#include <cpu/inc/nanohub_math.h>
+#include <cpu/nanohub_math.h>
#include <math.h>
diff --git a/firmware/inc/osApi.h b/firmware/os/inc/osApi.h
index 20b2158b..20b2158b 100644
--- a/firmware/inc/osApi.h
+++ b/firmware/os/inc/osApi.h
diff --git a/firmware/inc/platform.h b/firmware/os/inc/platform.h
index c589b5b1..c589b5b1 100644
--- a/firmware/inc/platform.h
+++ b/firmware/os/inc/platform.h
diff --git a/firmware/inc/printf.h b/firmware/os/inc/printf.h
index f3c26cdc..f3c26cdc 100644
--- a/firmware/inc/printf.h
+++ b/firmware/os/inc/printf.h
diff --git a/firmware/inc/reset.h b/firmware/os/inc/reset.h
index 1e79d2ed..1e79d2ed 100644
--- a/firmware/inc/reset.h
+++ b/firmware/os/inc/reset.h
diff --git a/firmware/inc/sensType.h b/firmware/os/inc/sensType.h
index 4fdb1776..4fdb1776 100644
--- a/firmware/inc/sensType.h
+++ b/firmware/os/inc/sensType.h
diff --git a/firmware/inc/sensors.h b/firmware/os/inc/sensors.h
index 8ff9bf8d..dc1d5ad0 100644
--- a/firmware/inc/sensors.h
+++ b/firmware/os/inc/sensors.h
@@ -20,8 +20,8 @@
#ifdef __cplusplus
extern "C" {
#endif
-#include <plat/inc/taggedPtr.h>
-#include <variant/inc/variant.h>
+#include <plat/taggedPtr.h>
+#include <variant/variant.h>
#include <eventnums.h>
#include <sensType.h>
#include <stdbool.h>
diff --git a/firmware/inc/seos.h b/firmware/os/inc/seos.h
index f417e576..9cc8afb3 100644
--- a/firmware/inc/seos.h
+++ b/firmware/os/inc/seos.h
@@ -21,15 +21,15 @@
extern "C" {
#endif
-#include <plat/inc/taggedPtr.h>
+#include <plat/taggedPtr.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include <stddef.h>
#include <eventQ.h>
-#include <plat/inc/app.h>
+#include <plat/app.h>
#include <eventnums.h>
-#include <variant/inc/variant.h>
+#include <variant/variant.h>
#include "toolchain.h"
#include <nanohub/nanohub.h>
diff --git a/firmware/inc/simpleQ.h b/firmware/os/inc/simpleQ.h
index 62294d76..62294d76 100644
--- a/firmware/inc/simpleQ.h
+++ b/firmware/os/inc/simpleQ.h
diff --git a/firmware/inc/slab.h b/firmware/os/inc/slab.h
index a807ad62..a807ad62 100644
--- a/firmware/inc/slab.h
+++ b/firmware/os/inc/slab.h
diff --git a/firmware/inc/spi.h b/firmware/os/inc/spi.h
index 2647959d..2647959d 100644
--- a/firmware/inc/spi.h
+++ b/firmware/os/inc/spi.h
diff --git a/firmware/inc/spi_priv.h b/firmware/os/inc/spi_priv.h
index 97eb1cac..97eb1cac 100644
--- a/firmware/inc/spi_priv.h
+++ b/firmware/os/inc/spi_priv.h
diff --git a/firmware/inc/syscall.h b/firmware/os/inc/syscall.h
index 5970982a..5970982a 100644
--- a/firmware/inc/syscall.h
+++ b/firmware/os/inc/syscall.h
diff --git a/firmware/inc/syscallDo.h b/firmware/os/inc/syscallDo.h
index 7dba269e..f41e5e24 100644
--- a/firmware/inc/syscallDo.h
+++ b/firmware/os/inc/syscallDo.h
@@ -26,7 +26,7 @@ extern "C" {
#error "Syscalls should not be called from OS code"
#endif
-#include <cpu/inc/syscallDo.h>
+#include <cpu/syscallDo.h>
#include <sensors.h>
#include <syscall.h>
#include <stdarg.h>
diff --git a/firmware/inc/timer.h b/firmware/os/inc/timer.h
index 18ea8153..18ea8153 100644
--- a/firmware/inc/timer.h
+++ b/firmware/os/inc/timer.h
diff --git a/firmware/inc/toolchain.h b/firmware/os/inc/toolchain.h
index d6829581..d6829581 100644
--- a/firmware/inc/toolchain.h
+++ b/firmware/os/inc/toolchain.h
diff --git a/firmware/inc/trylock.h b/firmware/os/inc/trylock.h
index 63a726db..e6eec911 100644
--- a/firmware/inc/trylock.h
+++ b/firmware/os/inc/trylock.h
@@ -21,7 +21,7 @@
#include <stdbool.h>
#ifdef PLATFORM_HAS_OWN_TRYLOCK
-#include <plat/inc/trylock.h>
+#include <plat/trylock.h>
#else
struct TryLock {
diff --git a/firmware/inc/usart.h b/firmware/os/inc/usart.h
index ab7a477d..ab7a477d 100644
--- a/firmware/inc/usart.h
+++ b/firmware/os/inc/usart.h
diff --git a/firmware/inc/util.h b/firmware/os/inc/util.h
index c29345d3..ed3e6568 100644
--- a/firmware/inc/util.h
+++ b/firmware/os/inc/util.h
@@ -16,7 +16,7 @@
#ifndef __UTIL_H
#define __UTIL_H
-#include <plat/inc/plat.h>
+#include <plat/plat.h>
#include "toolchain.h"
#include <limits.h>
#include <stdbool.h>
diff --git a/firmware/src/platform/linux/hostIntf.c b/firmware/os/platform/native/hostIntf.c
index 1320e8e2..1320e8e2 100644
--- a/firmware/src/platform/linux/hostIntf.c
+++ b/firmware/os/platform/native/hostIntf.c
diff --git a/firmware/src/platform/linux/i2c.c b/firmware/os/platform/native/i2c.c
index f58b454a..f58b454a 100644
--- a/firmware/src/platform/linux/i2c.c
+++ b/firmware/os/platform/native/i2c.c
diff --git a/firmware/inc/platform/linux/app.h b/firmware/os/platform/native/inc/plat/app.h
index 5617672c..5617672c 100644
--- a/firmware/inc/platform/linux/app.h
+++ b/firmware/os/platform/native/inc/plat/app.h
diff --git a/firmware/os/platform/native/inc/plat/crc.h b/firmware/os/platform/native/inc/plat/crc.h
new file mode 100644
index 00000000..2c846cbb
--- /dev/null
+++ b/firmware/os/platform/native/inc/plat/crc.h
@@ -0,0 +1,3 @@
+#include <nanohub/crc.h>
+
+#define crc32 soft_crc32
diff --git a/firmware/inc/platform/linux/plat.h b/firmware/os/platform/native/inc/plat/plat.h
index 5cda58f9..5cda58f9 100644
--- a/firmware/inc/platform/linux/plat.h
+++ b/firmware/os/platform/native/inc/plat/plat.h
diff --git a/firmware/inc/platform/linux/pwr.h b/firmware/os/platform/native/inc/plat/pwr.h
index 8ef4131e..8ef4131e 100644
--- a/firmware/inc/platform/linux/pwr.h
+++ b/firmware/os/platform/native/inc/plat/pwr.h
diff --git a/firmware/inc/platform/linux/rtc.h b/firmware/os/platform/native/inc/plat/rtc.h
index 38b698aa..38b698aa 100644
--- a/firmware/inc/platform/linux/rtc.h
+++ b/firmware/os/platform/native/inc/plat/rtc.h
diff --git a/firmware/inc/platform/linux/usart.h b/firmware/os/platform/native/inc/plat/usart.h
index 40516d46..40516d46 100644
--- a/firmware/inc/platform/linux/usart.h
+++ b/firmware/os/platform/native/inc/plat/usart.h
diff --git a/firmware/inc/platform/linux/wdt.h b/firmware/os/platform/native/inc/plat/wdt.h
index 430a385f..430a385f 100644
--- a/firmware/inc/platform/linux/wdt.h
+++ b/firmware/os/platform/native/inc/plat/wdt.h
diff --git a/firmware/os/platform/native/lkr/app.lkr b/firmware/os/platform/native/lkr/app.lkr
new file mode 100644
index 00000000..37766bde
--- /dev/null
+++ b/firmware/os/platform/native/lkr/app.lkr
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
diff --git a/firmware/misc/platform/linux/linux.extra.lkr b/firmware/os/platform/native/lkr/native.extra.lkr
index 94f3cd72..94f3cd72 100644
--- a/firmware/misc/platform/linux/linux.extra.lkr
+++ b/firmware/os/platform/native/lkr/native.extra.lkr
diff --git a/firmware/misc/platform/linux/Makefile b/firmware/os/platform/native/native.mk
index ad14dbfb..f113061d 100644
--- a/firmware/misc/platform/linux/Makefile
+++ b/firmware/os/platform/native/native.mk
@@ -15,21 +15,21 @@
#
DELIVERABLES = $(APP).bin
-LKR = misc/platform/$(PLATFORM)/linux.extra.lkr
+LKR = os/platform/$(PLATFORM)/lkr/native.extra.lkr
FLAGS += -I. -fno-unwind-tables -fstack-reuse=all -ffunction-sections -fdata-sections -m32
FLAGS += -Wl,-T $(LKR) -Wl,--gc-sections
#platform drivers
-SRCS += src/platform/$(PLATFORM)/platform.c \
- src/platform/$(PLATFORM)/i2c.c \
- src/platform/$(PLATFORM)/spi.c \
- src/platform/$(PLATFORM)/rtc.c \
- src/platform/$(PLATFORM)/hostIntf.c
+SRCS += os/platform/$(PLATFORM)/platform.c \
+ os/platform/$(PLATFORM)/i2c.c \
+ os/platform/$(PLATFORM)/spi.c \
+ os/platform/$(PLATFORM)/rtc.c \
+ os/platform/$(PLATFORM)/hostIntf.c
#extra deps
-DEPS += $(wildcard inc/platform/$(PLATFORM)/*.h)
+DEPS += $(wildcard os/platform/$(PLATFORM)/inc/plat/*.h)
DEPS += $(LKR)
#platform flags
@@ -40,5 +40,6 @@ FLAGS += -DPLAT_HAS_NO_U_TYPES_H
#platform-specific rules
%.bin : %.elf
- mv $< $@
+ cp $< $@
+$(info Included NATIVE platfrom)
diff --git a/firmware/src/platform/linux/platform.c b/firmware/os/platform/native/platform.c
index 735f295b..ceac5a6d 100644
--- a/firmware/src/platform/linux/platform.c
+++ b/firmware/os/platform/native/platform.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/rtc.h>
+#include <plat/rtc.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
diff --git a/firmware/src/platform/linux/rtc.c b/firmware/os/platform/native/rtc.c
index e262f466..075f5e26 100644
--- a/firmware/src/platform/linux/rtc.c
+++ b/firmware/os/platform/native/rtc.c
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <cpu/inc/barrier.h>
-#include <plat/inc/rtc.h>
+#include <cpu/barrier.h>
+#include <plat/rtc.h>
#include <timer.h>
#include <platform.h>
diff --git a/firmware/src/platform/linux/spi.c b/firmware/os/platform/native/spi.c
index efc41eaa..efc41eaa 100644
--- a/firmware/src/platform/linux/spi.c
+++ b/firmware/os/platform/native/spi.c
diff --git a/firmware/src/platform/stm32f4xx/apInt.c b/firmware/os/platform/stm32/apInt.c
index b8a1c016..d8521d13 100644
--- a/firmware/src/platform/stm32f4xx/apInt.c
+++ b/firmware/os/platform/stm32/apInt.c
@@ -16,11 +16,11 @@
#include <apInt.h>
#include <gpio.h>
-#include <variant/inc/variant.h>
-#include <plat/inc/gpio.h>
+#include <variant/variant.h>
+#include <plat/gpio.h>
#include <seos.h>
#include <platform.h>
-#include <plat/inc/plat.h>
+#include <plat/plat.h>
static struct Gpio *apIntWkup;
#ifdef AP_INT_NONWAKEUP
diff --git a/firmware/src/platform/stm32f4xx/bl.c b/firmware/os/platform/stm32/bl.c
index 2786c365..9d634e93 100644
--- a/firmware/src/platform/stm32f4xx/bl.c
+++ b/firmware/os/platform/stm32/bl.c
@@ -15,12 +15,12 @@
*/
-#include <variant/inc/variant.h>
+#include <variant/variant.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/pwr.h>
-#include <plat/inc/bl.h>
+#include <plat/cmsis.h>
+#include <plat/gpio.h>
+#include <plat/pwr.h>
+#include <plat/bl.h>
#include <nanohub/sha2.h>
#include <nanohub/aes.h>
diff --git a/firmware/src/platform/stm32f4xx/crc.c b/firmware/os/platform/stm32/crc.c
index 771703d2..ece90e73 100644
--- a/firmware/src/platform/stm32f4xx/crc.c
+++ b/firmware/os/platform/stm32/crc.c
@@ -19,7 +19,7 @@
#include <nanohub/crc.h>
#include <seos.h>
-#include <plat/inc/pwr.h>
+#include <plat/pwr.h>
struct StmCrcRegs {
volatile uint32_t DR;
diff --git a/firmware/src/platform/stm32f4xx/crt_stm32f4xx.c b/firmware/os/platform/stm32/crt_stm32.c
index 52e3f7c5..52e3f7c5 100644
--- a/firmware/src/platform/stm32f4xx/crt_stm32f4xx.c
+++ b/firmware/os/platform/stm32/crt_stm32.c
diff --git a/firmware/src/platform/stm32f4xx/dma.c b/firmware/os/platform/stm32/dma.c
index 226bb989..6813b256 100644
--- a/firmware/src/platform/stm32f4xx/dma.c
+++ b/firmware/os/platform/stm32/dma.c
@@ -20,9 +20,9 @@
#include <seos.h>
#include <util.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/dma.h>
-#include <plat/inc/pwr.h>
+#include <plat/cmsis.h>
+#include <plat/dma.h>
+#include <plat/pwr.h>
#define DMA_VERBOSE_DEBUG 0
diff --git a/firmware/src/platform/stm32f4xx/eeData.c b/firmware/os/platform/stm32/eeData.c
index 906b9f38..8ce47747 100644
--- a/firmware/src/platform/stm32f4xx/eeData.c
+++ b/firmware/os/platform/stm32/eeData.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/bl.h>
+#include <plat/bl.h>
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
diff --git a/firmware/src/platform/stm32f4xx/exti.c b/firmware/os/platform/stm32/exti.c
index 30e91db5..ababe3c1 100644
--- a/firmware/src/platform/stm32f4xx/exti.c
+++ b/firmware/os/platform/stm32/exti.c
@@ -17,9 +17,9 @@
#include <errno.h>
#include <isr.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/pwr.h>
+#include <plat/cmsis.h>
+#include <plat/exti.h>
+#include <plat/pwr.h>
struct StmExti
{
diff --git a/firmware/misc/platform/stm32f4xx/flash_script/Makefile b/firmware/os/platform/stm32/flash_script/Makefile
index ca5d0ef4..ca5d0ef4 100644
--- a/firmware/misc/platform/stm32f4xx/flash_script/Makefile
+++ b/firmware/os/platform/stm32/flash_script/Makefile
diff --git a/firmware/misc/platform/stm32f4xx/flash_script/tool.c b/firmware/os/platform/stm32/flash_script/tool.c
index 2b607d09..2b607d09 100644
--- a/firmware/misc/platform/stm32f4xx/flash_script/tool.c
+++ b/firmware/os/platform/stm32/flash_script/tool.c
diff --git a/firmware/src/platform/stm32f4xx/gpio.c b/firmware/os/platform/stm32/gpio.c
index ff17c79c..648ca098 100644
--- a/firmware/src/platform/stm32f4xx/gpio.c
+++ b/firmware/os/platform/stm32/gpio.c
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <plat/inc/gpio.h>
-#include <plat/inc/pwr.h>
+#include <plat/gpio.h>
+#include <plat/pwr.h>
#include <gpio.h>
#include <cpu.h>
diff --git a/firmware/src/platform/stm32f4xx/hostIntf.c b/firmware/os/platform/stm32/hostIntf.c
index c561d9a0..8993f565 100644
--- a/firmware/src/platform/stm32f4xx/hostIntf.c
+++ b/firmware/os/platform/stm32/hostIntf.c
@@ -16,10 +16,10 @@
#include <hostIntf.h>
#include <hostIntf_priv.h>
-#include <variant/inc/variant.h>
-#include <plat/inc/bl.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/spi.h>
+#include <variant/variant.h>
+#include <plat/bl.h>
+#include <plat/cmsis.h>
+#include <plat/spi.h>
const struct HostIntfComm *platHostIntfInit()
diff --git a/firmware/src/platform/stm32f4xx/i2c.c b/firmware/os/platform/stm32/i2c.c
index dd911c10..32b39853 100644
--- a/firmware/src/platform/stm32f4xx/i2c.c
+++ b/firmware/os/platform/stm32/i2c.c
@@ -27,14 +27,14 @@
#include <atomic.h>
#include <platform.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/dma.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/i2c.h>
-#include <plat/inc/pwr.h>
-#include <plat/inc/plat.h>
-
-#include <cpu/inc/barrier.h>
+#include <plat/cmsis.h>
+#include <plat/dma.h>
+#include <plat/gpio.h>
+#include <plat/i2c.h>
+#include <plat/pwr.h>
+#include <plat/plat.h>
+
+#include <cpu/barrier.h>
#define I2C_VERBOSE_DEBUG 0
#define I2C_MAX_QUEUE_DEPTH 5
diff --git a/firmware/inc/platform/stm32f4xx/app.h b/firmware/os/platform/stm32/inc/plat/app.h
index 98c61bd7..98c61bd7 100644
--- a/firmware/inc/platform/stm32f4xx/app.h
+++ b/firmware/os/platform/stm32/inc/plat/app.h
diff --git a/firmware/inc/platform/stm32f4xx/bl.h b/firmware/os/platform/stm32/inc/plat/bl.h
index 34f08bd5..34f08bd5 100644
--- a/firmware/inc/platform/stm32f4xx/bl.h
+++ b/firmware/os/platform/stm32/inc/plat/bl.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis.h b/firmware/os/platform/stm32/inc/plat/cmsis.h
index efac7cd4..07f0798c 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis.h
@@ -126,7 +126,7 @@ typedef enum IRQn
NUM_INTERRUPTS
} IRQn_Type;
-#include "core_cm4.h"
+#include <core_cm4.h>
#ifdef __cplusplus
}
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/arm_common_tables.h b/firmware/os/platform/stm32/inc/plat/cmsis/arm_common_tables.h
index 06a63487..06a63487 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/arm_common_tables.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/arm_common_tables.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/arm_const_structs.h b/firmware/os/platform/stm32/inc/plat/cmsis/arm_const_structs.h
index 21c79d69..21c79d69 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/arm_const_structs.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/arm_const_structs.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/arm_math.h b/firmware/os/platform/stm32/inc/plat/cmsis/arm_math.h
index 422ec13e..422ec13e 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/arm_math.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/arm_math.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cm0.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm0.h
index dbc4e22d..dbc4e22d 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cm0.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm0.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cm0plus.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm0plus.h
index 4d7facfa..4d7facfa 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cm0plus.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm0plus.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cm3.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm3.h
index d41ac3f0..d41ac3f0 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cm3.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm3.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cm4.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm4.h
index 827dc384..827dc384 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cm4.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm4.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cm7.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm7.h
index 64436103..64436103 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cm7.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cm7.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cmFunc.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cmFunc.h
index a1bd88c2..a1bd88c2 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cmFunc.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cmFunc.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cmInstr.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cmInstr.h
index cabf4a02..cabf4a02 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cmInstr.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cmInstr.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_cmSimd.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_cmSimd.h
index 04665617..04665617 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_cmSimd.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_cmSimd.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_sc000.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_sc000.h
index 5a0635d2..5a0635d2 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_sc000.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_sc000.h
diff --git a/firmware/inc/platform/stm32f4xx/cmsis/core_sc300.h b/firmware/os/platform/stm32/inc/plat/cmsis/core_sc300.h
index d82eab97..d82eab97 100644
--- a/firmware/inc/platform/stm32f4xx/cmsis/core_sc300.h
+++ b/firmware/os/platform/stm32/inc/plat/cmsis/core_sc300.h
diff --git a/firmware/os/platform/stm32/inc/plat/crc.h b/firmware/os/platform/stm32/inc/plat/crc.h
new file mode 100644
index 00000000..40a8c178
--- /dev/null
+++ b/firmware/os/platform/stm32/inc/plat/crc.h
@@ -0,0 +1 @@
+/* empty */
diff --git a/firmware/inc/platform/stm32f4xx/dma.h b/firmware/os/platform/stm32/inc/plat/dma.h
index a4ef66a2..a4ef66a2 100644
--- a/firmware/inc/platform/stm32f4xx/dma.h
+++ b/firmware/os/platform/stm32/inc/plat/dma.h
diff --git a/firmware/inc/platform/stm32f4xx/eeData.h b/firmware/os/platform/stm32/inc/plat/eeData.h
index 6cba1503..6cba1503 100644
--- a/firmware/inc/platform/stm32f4xx/eeData.h
+++ b/firmware/os/platform/stm32/inc/plat/eeData.h
diff --git a/firmware/inc/platform/stm32f4xx/exti.h b/firmware/os/platform/stm32/inc/plat/exti.h
index 84fcd396..5d32a210 100644
--- a/firmware/inc/platform/stm32f4xx/exti.h
+++ b/firmware/os/platform/stm32/inc/plat/exti.h
@@ -19,8 +19,8 @@
#include <isr.h>
#include <stdbool.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/gpio.h>
+#include <plat/cmsis.h>
+#include <plat/gpio.h>
#include <gpio.h>
#ifdef __cplusplus
diff --git a/firmware/inc/platform/stm32f4xx/gpio.h b/firmware/os/platform/stm32/inc/plat/gpio.h
index a45110f6..a45110f6 100644
--- a/firmware/inc/platform/stm32f4xx/gpio.h
+++ b/firmware/os/platform/stm32/inc/plat/gpio.h
diff --git a/firmware/inc/platform/stm32f4xx/i2c.h b/firmware/os/platform/stm32/inc/plat/i2c.h
index f1f021fd..bf46f452 100644
--- a/firmware/inc/platform/stm32f4xx/i2c.h
+++ b/firmware/os/platform/stm32/inc/plat/i2c.h
@@ -19,9 +19,9 @@
#include <gpio.h>
#include <platform.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/plat.h>
+#include <plat/cmsis.h>
+#include <plat/gpio.h>
+#include <plat/plat.h>
struct StmI2cDmaCfg {
uint8_t channel;
diff --git a/firmware/inc/platform/stm32f4xx/plat.h b/firmware/os/platform/stm32/inc/plat/plat.h
index 253d9fac..253d9fac 100644
--- a/firmware/inc/platform/stm32f4xx/plat.h
+++ b/firmware/os/platform/stm32/inc/plat/plat.h
diff --git a/firmware/inc/platform/stm32f4xx/pwr.h b/firmware/os/platform/stm32/inc/plat/pwr.h
index fde926fc..e142c513 100644
--- a/firmware/inc/platform/stm32f4xx/pwr.h
+++ b/firmware/os/platform/stm32/inc/plat/pwr.h
@@ -23,7 +23,7 @@ extern "C" {
#include <stdint.h>
#include <stdbool.h>
-#include <plat/inc/rtc.h>
+#include <plat/rtc.h>
/* busses */
#define PERIPH_BUS_AHB1 0
diff --git a/firmware/inc/platform/stm32f4xx/rtc.h b/firmware/os/platform/stm32/inc/plat/rtc.h
index e807a1d1..5615356b 100644
--- a/firmware/inc/platform/stm32f4xx/rtc.h
+++ b/firmware/os/platform/stm32/inc/plat/rtc.h
@@ -22,7 +22,7 @@ extern "C" {
#endif
#include <stdint.h>
-#include <inc/seos.h>
+#include <seos.h>
enum RtcClock
{
diff --git a/firmware/inc/platform/stm32f4xx/spi.h b/firmware/os/platform/stm32/inc/plat/spi.h
index 79bc3c41..22c80708 100644
--- a/firmware/inc/platform/stm32f4xx/spi.h
+++ b/firmware/os/platform/stm32/inc/plat/spi.h
@@ -19,9 +19,9 @@
#include <gpio.h>
#include <platform.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/plat.h>
+#include <plat/cmsis.h>
+#include <plat/gpio.h>
+#include <plat/plat.h>
struct StmSpiDmaCfg {
uint8_t channel;
diff --git a/firmware/inc/platform/stm32f4xx/syscfg.h b/firmware/os/platform/stm32/inc/plat/syscfg.h
index de8bab19..464895e2 100644
--- a/firmware/inc/platform/stm32f4xx/syscfg.h
+++ b/firmware/os/platform/stm32/inc/plat/syscfg.h
@@ -17,7 +17,7 @@
#ifndef _STM32F4XX_SYSCFG_H_
#define _STM32F4XX_SYSCFG_H_
-#include <plat/inc/gpio.h>
+#include <plat/gpio.h>
#include <gpio.h>
#ifdef __cplusplus
diff --git a/firmware/inc/platform/stm32f4xx/taggedPtr.h b/firmware/os/platform/stm32/inc/plat/taggedPtr.h
index b4839775..b4839775 100644
--- a/firmware/inc/platform/stm32f4xx/taggedPtr.h
+++ b/firmware/os/platform/stm32/inc/plat/taggedPtr.h
diff --git a/firmware/inc/platform/stm32f4xx/usart.h b/firmware/os/platform/stm32/inc/plat/usart.h
index 62f249fc..62f249fc 100644
--- a/firmware/inc/platform/stm32f4xx/usart.h
+++ b/firmware/os/platform/stm32/inc/plat/usart.h
diff --git a/firmware/inc/platform/stm32f4xx/wdt.h b/firmware/os/platform/stm32/inc/plat/wdt.h
index afc8de2e..afc8de2e 100644
--- a/firmware/inc/platform/stm32f4xx/wdt.h
+++ b/firmware/os/platform/stm32/inc/plat/wdt.h
diff --git a/firmware/misc/cpu/cortexm4f/app.lkr b/firmware/os/platform/stm32/lkr/app.lkr
index 6766e291..c2196a90 100644
--- a/firmware/misc/cpu/cortexm4f/app.lkr
+++ b/firmware/os/platform/stm32/lkr/app.lkr
@@ -87,6 +87,18 @@ SECTIONS
__data_end = ABSOLUTE(.);
. = ALIGN(4);
+ __init_array_start = ABSOLUTE(.);
+ KEEP(*(SORT(.init_array.*)))
+ KEEP(*(.init_array))
+ __init_array_end = ABSOLUTE(.);
+
+ . = ALIGN(4);
+ __fini_array_start = ABSOLUTE(.);
+ KEEP(*(SORT(.fini_array.*)))
+ KEEP(*(.fini_array))
+ __fini_array_end = ABSOLUTE(.);
+
+ . = ALIGN(4);
__got_start = ABSOLUTE(.);
*(.got) *(.got.*) ;
__got_end = ABSOLUTE(.);
diff --git a/firmware/misc/variant/common/stm32f401.bl.lkr b/firmware/os/platform/stm32/lkr/stm32f401.bl.lkr
index bb187ea6..c903e152 100644
--- a/firmware/misc/variant/common/stm32f401.bl.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f401.bl.lkr
@@ -15,6 +15,6 @@
*/
-INCLUDE misc/variant/common/stm32f401.map.lkr
-INCLUDE misc/variant/common/stm32f4xx.bl.lkr
-INCLUDE misc/variant/common/stm32f4xx.common.lkr
+INCLUDE os/platform/stm32/lkr/stm32f401.map.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.bl.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.common.lkr
diff --git a/firmware/misc/variant/common/stm32f401.map.lkr b/firmware/os/platform/stm32/lkr/stm32f401.map.lkr
index f03ef569..b726f14e 100644
--- a/firmware/misc/variant/common/stm32f401.map.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f401.map.lkr
@@ -14,8 +14,6 @@
* limitations under the License.
*/
-
-
MEMORY
{
bl : ORIGIN = 0x08000000, LENGTH = 16K /* one block */
@@ -24,4 +22,3 @@ MEMORY
shared : ORIGIN = 0x08020000, LENGTH = 384K /* 3x 128K blocks */
ram : ORIGIN = 0x20000000, LENGTH = 96K
}
-
diff --git a/firmware/misc/variant/common/stm32f401.os.lkr b/firmware/os/platform/stm32/lkr/stm32f401.os.lkr
index b842ce97..aef5c61e 100644
--- a/firmware/misc/variant/common/stm32f401.os.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f401.os.lkr
@@ -15,6 +15,6 @@
*/
-INCLUDE misc/variant/common/stm32f401.map.lkr
-INCLUDE misc/variant/common/stm32f4xx.os.lkr
-INCLUDE misc/variant/common/stm32f4xx.common.lkr
+INCLUDE os/platform/stm32/lkr/stm32f401.map.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.os.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.common.lkr
diff --git a/firmware/misc/variant/common/stm32f411.bl.lkr b/firmware/os/platform/stm32/lkr/stm32f411.bl.lkr
index 0bb4e40f..09a21364 100644
--- a/firmware/misc/variant/common/stm32f411.bl.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f411.bl.lkr
@@ -15,6 +15,6 @@
*/
-INCLUDE misc/variant/common/stm32f411.map.lkr
-INCLUDE misc/variant/common/stm32f4xx.bl.lkr
-INCLUDE misc/variant/common/stm32f4xx.common.lkr
+INCLUDE os/platform/stm32/lkr/stm32f411.map.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.bl.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.common.lkr
diff --git a/firmware/misc/variant/common/stm32f411.map.lkr b/firmware/os/platform/stm32/lkr/stm32f411.map.lkr
index 4aa0be01..4aa0be01 100644
--- a/firmware/misc/variant/common/stm32f411.map.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f411.map.lkr
diff --git a/firmware/misc/variant/common/stm32f411.os.lkr b/firmware/os/platform/stm32/lkr/stm32f411.os.lkr
index 25534599..db0a6c82 100644
--- a/firmware/misc/variant/common/stm32f411.os.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f411.os.lkr
@@ -15,6 +15,6 @@
*/
-INCLUDE misc/variant/common/stm32f411.map.lkr
-INCLUDE misc/variant/common/stm32f4xx.os.lkr
-INCLUDE misc/variant/common/stm32f4xx.common.lkr
+INCLUDE os/platform/stm32/lkr/stm32f411.map.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.os.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.common.lkr
diff --git a/firmware/os/platform/stm32/lkr/stm32f412.bl.lkr b/firmware/os/platform/stm32/lkr/stm32f412.bl.lkr
new file mode 100644
index 00000000..1ae513d8
--- /dev/null
+++ b/firmware/os/platform/stm32/lkr/stm32f412.bl.lkr
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+INCLUDE os/platform/stm32/lkr/stm32f412.map.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.bl.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.common.lkr
diff --git a/firmware/os/platform/stm32/lkr/stm32f412.map.lkr b/firmware/os/platform/stm32/lkr/stm32f412.map.lkr
new file mode 100644
index 00000000..5e5f82a4
--- /dev/null
+++ b/firmware/os/platform/stm32/lkr/stm32f412.map.lkr
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+MEMORY
+{
+ bl : ORIGIN = 0x08000000, LENGTH = 16K /* one block */
+ eedata : ORIGIN = 0x08004000, LENGTH = 32K /* two 16K blocks */
+ code : ORIGIN = 0x0800C000, LENGTH = 208K /* 16K block + 64K block + 128K block */
+ shared : ORIGIN = 0x08040000, LENGTH = 768K /* 6x 128K blocks */
+ ram : ORIGIN = 0x20000000, LENGTH = 256K
+}
diff --git a/firmware/os/platform/stm32/lkr/stm32f412.os.lkr b/firmware/os/platform/stm32/lkr/stm32f412.os.lkr
new file mode 100644
index 00000000..0662cba8
--- /dev/null
+++ b/firmware/os/platform/stm32/lkr/stm32f412.os.lkr
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+INCLUDE os/platform/stm32/lkr/stm32f412.map.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.os.lkr
+INCLUDE os/platform/stm32/lkr/stm32f4xx.common.lkr
diff --git a/firmware/misc/variant/common/stm32f4xx.bl.lkr b/firmware/os/platform/stm32/lkr/stm32f4xx.bl.lkr
index d83b5291..b2940c5c 100644
--- a/firmware/misc/variant/common/stm32f4xx.bl.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f4xx.bl.lkr
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
SECTIONS
{
/* bootloader */
@@ -74,6 +73,4 @@ SECTIONS
} > ram
}
-
ENTRY(__BL_VECTORS)
-
diff --git a/firmware/misc/variant/common/stm32f4xx.common.lkr b/firmware/os/platform/stm32/lkr/stm32f4xx.common.lkr
index 30b2d7e5..8df1d051 100644
--- a/firmware/misc/variant/common/stm32f4xx.common.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f4xx.common.lkr
@@ -1,4 +1,3 @@
-
__ram_start = ORIGIN(ram);
__ram_end = ORIGIN(ram) + LENGTH(ram);
__eedata_start = ORIGIN(eedata);
@@ -8,5 +7,3 @@ __code_end = ORIGIN(code) + LENGTH(code);
__shared_start = ORIGIN(shared);
__shared_end = ORIGIN(shared) + LENGTH(shared);
__data_data = LOADADDR(.data);
-
-
diff --git a/firmware/misc/variant/common/stm32f4xx.os.lkr b/firmware/os/platform/stm32/lkr/stm32f4xx.os.lkr
index 153faeda..ac7a019f 100644
--- a/firmware/misc/variant/common/stm32f4xx.os.lkr
+++ b/firmware/os/platform/stm32/lkr/stm32f4xx.os.lkr
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-
SECTIONS
{
/* things that live in the main app image */
@@ -68,5 +67,3 @@ BL = ORIGIN(bl);
__app_start = __data_data + __data_end - __data_start;
__heap_end = ORIGIN(ram) + LENGTH(ram);
ENTRY(__VECTORS)
-
-
diff --git a/firmware/misc/debug.privkey b/firmware/os/platform/stm32/misc/debug.privkey
index 9a634276..9a634276 100644
--- a/firmware/misc/debug.privkey
+++ b/firmware/os/platform/stm32/misc/debug.privkey
diff --git a/firmware/misc/debug.pubkey b/firmware/os/platform/stm32/misc/debug.pubkey
index b4d49531..b4d49531 100644
--- a/firmware/misc/debug.pubkey
+++ b/firmware/os/platform/stm32/misc/debug.pubkey
Binary files differ
diff --git a/firmware/misc/platform/stm32f4xx/m3debug.script b/firmware/os/platform/stm32/misc/m3debug.script
index 3ad5912e..3ad5912e 100644
--- a/firmware/misc/platform/stm32f4xx/m3debug.script
+++ b/firmware/os/platform/stm32/misc/m3debug.script
diff --git a/firmware/misc/platform/stm32f4xx/showsizes.sh b/firmware/os/platform/stm32/misc/showsizes.sh
index e7401114..e7401114 100755
--- a/firmware/misc/platform/stm32f4xx/showsizes.sh
+++ b/firmware/os/platform/stm32/misc/showsizes.sh
diff --git a/firmware/src/platform/stm32f4xx/mpu.c b/firmware/os/platform/stm32/mpu.c
index 175657a7..9a3c94fd 100644
--- a/firmware/src/platform/stm32f4xx/mpu.c
+++ b/firmware/os/platform/stm32/mpu.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/bl.h>
+#include <plat/bl.h>
#include <platform.h>
#include <stdbool.h>
#include <stdint.h>
diff --git a/firmware/src/platform/stm32f4xx/platform.c b/firmware/os/platform/stm32/platform.c
index 5cbe5a72..4e22f107 100644
--- a/firmware/src/platform/stm32f4xx/platform.c
+++ b/firmware/os/platform/stm32/platform.c
@@ -14,17 +14,17 @@
* limitations under the License.
*/
-#include <cpu/inc/cpuMath.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/usart.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/pwr.h>
-#include <plat/inc/rtc.h>
-#include <plat/inc/plat.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/syscfg.h>
-#include <plat/inc/wdt.h>
-#include <plat/inc/dma.h>
+#include <cpu/cpuMath.h>
+#include <plat/gpio.h>
+#include <plat/usart.h>
+#include <plat/cmsis.h>
+#include <plat/pwr.h>
+#include <plat/rtc.h>
+#include <plat/plat.h>
+#include <plat/exti.h>
+#include <plat/syscfg.h>
+#include <plat/wdt.h>
+#include <plat/dma.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
@@ -43,7 +43,7 @@
#include <hostIntf.h>
#include <nanohubPacket.h>
#include <sensType.h>
-#include <variant/inc/variant.h>
+#include <variant/variant.h>
struct StmDbg {
diff --git a/firmware/src/platform/stm32f4xx/pwr.c b/firmware/os/platform/stm32/pwr.c
index e0e07cbd..39510a50 100644
--- a/firmware/src/platform/stm32f4xx/pwr.c
+++ b/firmware/os/platform/stm32/pwr.c
@@ -14,10 +14,10 @@
* limitations under the License.
*/
-#include <cpu/inc/barrier.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/pwr.h>
-#include <plat/inc/rtc.h>
+#include <cpu/barrier.h>
+#include <plat/cmsis.h>
+#include <plat/pwr.h>
+#include <plat/rtc.h>
#include <reset.h>
#include <stddef.h>
diff --git a/firmware/src/platform/stm32f4xx/rtc.c b/firmware/os/platform/stm32/rtc.c
index 33430a4f..28acde10 100644
--- a/firmware/src/platform/stm32f4xx/rtc.c
+++ b/firmware/os/platform/stm32/rtc.c
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-#include <cpu/inc/barrier.h>
-#include <cpu/inc/cpuMath.h>
-#include <plat/inc/rtc.h>
-#include <plat/inc/pwr.h>
-#include <inc/timer.h>
-#include <inc/platform.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/cmsis.h>
-#include <variant/inc/variant.h>
+#include <cpu/barrier.h>
+#include <cpu/cpuMath.h>
+#include <plat/rtc.h>
+#include <plat/pwr.h>
+#include <timer.h>
+#include <platform.h>
+#include <plat/exti.h>
+#include <plat/cmsis.h>
+#include <variant/variant.h>
#ifndef NS_PER_S
#define NS_PER_S 1000000000ULL
diff --git a/firmware/src/platform/stm32f4xx/spi.c b/firmware/os/platform/stm32/spi.c
index dc305a5a..5f1915b7 100644
--- a/firmware/src/platform/stm32f4xx/spi.c
+++ b/firmware/os/platform/stm32/spi.c
@@ -25,14 +25,14 @@
#include <atomic.h>
#include <platform.h>
-#include <plat/inc/cmsis.h>
-#include <plat/inc/dma.h>
-#include <plat/inc/gpio.h>
-#include <plat/inc/pwr.h>
-#include <plat/inc/exti.h>
-#include <plat/inc/syscfg.h>
-#include <plat/inc/spi.h>
-#include <plat/inc/plat.h>
+#include <plat/cmsis.h>
+#include <plat/dma.h>
+#include <plat/gpio.h>
+#include <plat/pwr.h>
+#include <plat/exti.h>
+#include <plat/syscfg.h>
+#include <plat/spi.h>
+#include <plat/plat.h>
#define SPI_CR1_CPHA (1 << 0)
#define SPI_CR1_CPOL (1 << 1)
diff --git a/firmware/os/platform/stm32/stm32.mk b/firmware/os/platform/stm32/stm32.mk
new file mode 100644
index 00000000..103ca3df
--- /dev/null
+++ b/firmware/os/platform/stm32/stm32.mk
@@ -0,0 +1,86 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+M3DEBUG ?= m3debug
+
+ifneq ($(CPU),cortexm4)
+ $(error "stm32 cplatform only supports Cortex-M4 CPUs")
+endif
+
+BL_FILE = $(OUT)/bl.unchecked.bin
+OS_FILE = $(OUT)/os.checked.bin
+
+DELIVERABLES += showsizes
+FLAGS += -I. -fno-unwind-tables -fstack-reuse=all -ffunction-sections -fdata-sections
+FLAGS += -Wl,--gc-sections -nostartfiles
+FLAGS_os += -nostdlib
+
+#platform bootloader
+SRCS_bl += os/platform/$(PLATFORM)/bl.c
+
+#platform runtime
+SRCS_os += os/platform/$(PLATFORM)/crt_$(PLATFORM).c
+
+#platform drivers
+SRCS_os += os/platform/$(PLATFORM)/platform.c \
+ os/platform/$(PLATFORM)/usart.c \
+ os/platform/$(PLATFORM)/gpio.c \
+ os/platform/$(PLATFORM)/pwr.c \
+ os/platform/$(PLATFORM)/wdt.c \
+ os/platform/$(PLATFORM)/i2c.c \
+ os/platform/$(PLATFORM)/exti.c \
+ os/platform/$(PLATFORM)/syscfg.c \
+ os/platform/$(PLATFORM)/spi.c \
+ os/platform/$(PLATFORM)/rtc.c \
+ os/platform/$(PLATFORM)/mpu.c \
+ os/platform/$(PLATFORM)/dma.c \
+ os/platform/$(PLATFORM)/crc.c \
+ os/platform/$(PLATFORM)/hostIntf.c \
+ os/platform/$(PLATFORM)/apInt.c \
+ os/platform/$(PLATFORM)/eeData.c
+
+
+#platform drivers for bootloader
+SRCS_bl += os/platform/$(PLATFORM)/pwr.c os/platform/$(PLATFORM)/gpio.c
+
+#extra deps
+DEPS += $(wildcard os/platform/$(PLATFORM)/inc/plat/*.h)
+DEPS += $(wildcard os/platform/$(PLATFORM)/inc/plat/cmsis/*.h)
+
+#linker script
+LKR_os = os/platform/$(PLATFORM)/lkr/$(CHIP).os.lkr
+LKR_bl = os/platform/$(PLATFORM)/lkr/$(CHIP).bl.lkr
+OSFLAGS_os += -Wl,-T $(LKR_os)
+OSFLAGS_bl += -Wl,-T $(LKR_bl)
+DEPS += $(LKR_os) $(LKR_bl)
+
+#platform flags
+PLATFORM_HAS_HARDWARE_CRC = true
+FLAGS += -DPLATFORM_HW_VER=0
+
+#platform-specific rules
+OBJCOPY_PARAMS = -I elf32-littlearm -O binary
+
+$(OUT)/bl.%.bin : $(OUT)/bl.%.elf
+ $(OBJCOPY) -j .bl -j .blrodata -j .eedata $(OBJCOPY_PARAMS) $< $@
+
+$(OUT)/os.%.bin : $(OUT)/os.%.elf
+ $(OBJCOPY) -j .data -j .text $(OBJCOPY_PARAMS) $< $@
+
+showsizes: $(OUT)/os.unchecked.elf
+ os/platform/$(PLATFORM)/misc/showsizes.sh $<
+
+$(info Included STM32 platfrom)
diff --git a/firmware/src/platform/stm32f4xx/syscfg.c b/firmware/os/platform/stm32/syscfg.c
index 27aa132d..845bf0d6 100644
--- a/firmware/src/platform/stm32f4xx/syscfg.c
+++ b/firmware/os/platform/stm32/syscfg.c
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#include <plat/inc/pwr.h>
-#include <plat/inc/syscfg.h>
+#include <plat/pwr.h>
+#include <plat/syscfg.h>
#define SYSCFG_REG_SHIFT 2
diff --git a/firmware/src/platform/stm32f4xx/usart.c b/firmware/os/platform/stm32/usart.c
index ae20f9c9..302cb852 100644
--- a/firmware/src/platform/stm32f4xx/usart.c
+++ b/firmware/os/platform/stm32/usart.c
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include <plat/inc/gpio.h>
-#include <plat/inc/usart.h>
-#include <plat/inc/pwr.h>
+#include <plat/gpio.h>
+#include <plat/usart.h>
+#include <plat/pwr.h>
#include <usart.h>
#include <gpio.h>
diff --git a/firmware/src/platform/stm32f4xx/wdt.c b/firmware/os/platform/stm32/wdt.c
index d29fcf11..b3c785f0 100644
--- a/firmware/src/platform/stm32f4xx/wdt.c
+++ b/firmware/os/platform/stm32/wdt.c
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-#include <plat/inc/pwr.h>
-#include <plat/inc/wdt.h>
-#include <plat/inc/cmsis.h>
+#include <plat/pwr.h>
+#include <plat/wdt.h>
+#include <plat/cmsis.h>
struct StmWwdg {
volatile uint16_t CR;
diff --git a/firmware/variant/Android.mk b/firmware/variant/Android.mk
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/firmware/variant/Android.mk
diff --git a/firmware/variant/README b/firmware/variant/README
new file mode 100644
index 00000000..3cece9db
--- /dev/null
+++ b/firmware/variant/README
@@ -0,0 +1,2 @@
+for ease of source browsing this directory may contain soft links to variant directories located elsewhere;
+build scripts fully support such layout, however this is not necessary in order to build such variants.
diff --git a/firmware/variant/linux/Makefile b/firmware/variant/linux/Makefile
new file mode 100644
index 00000000..4dec4069
--- /dev/null
+++ b/firmware/variant/linux/Makefile
@@ -0,0 +1,5 @@
+SRC_PATH=../..
+VARIANT_PATH=src/variant/linux
+VARIANT=linux
+
+include $(SRC_PATH)/src/variant/variant.mk
diff --git a/firmware/inc/variant/linux/variant.h b/firmware/variant/linux/inc/variant/variant.h
index 092ce1cb..2e6c280b 100644
--- a/firmware/inc/variant/linux/variant.h
+++ b/firmware/variant/linux/inc/variant/variant.h
@@ -21,6 +21,11 @@
extern "C" {
#endif
+#define PLATFORM_HOST_INTF_I2C_BUS 0
+#define PLATFORM_HW_TYPE 0x8086
+
+#define PLAT_HAS_NO_U_TYPES_H
+
//we have no LSE in linux
#define HAVE_LSE false
diff --git a/firmware/misc/variant/linux/Makefile b/firmware/variant/linux/linux.mk
index 9149d8cb..9149d8cb 100644
--- a/firmware/misc/variant/linux/Makefile
+++ b/firmware/variant/linux/linux.mk
diff --git a/firmware/variant/lunchbox/Makefile b/firmware/variant/lunchbox/Makefile
new file mode 100644
index 00000000..3079098c
--- /dev/null
+++ b/firmware/variant/lunchbox/Makefile
@@ -0,0 +1,5 @@
+SRC_PATH=../..
+VARIANT_PATH=src/variant/lunchbox
+VARIANT=lunchbox
+
+include $(SRC_PATH)/src/variant/variant.mk
diff --git a/firmware/inc/variant/lunchbox/sensType.h b/firmware/variant/lunchbox/inc/variant/sensType.h
index 23cd0ef4..23cd0ef4 100644
--- a/firmware/inc/variant/lunchbox/sensType.h
+++ b/firmware/variant/lunchbox/inc/variant/sensType.h
diff --git a/firmware/inc/variant/lunchbox/variant.h b/firmware/variant/lunchbox/inc/variant/variant.h
index dafe9f23..ae499f2e 100644
--- a/firmware/inc/variant/lunchbox/variant.h
+++ b/firmware/variant/lunchbox/inc/variant/variant.h
@@ -21,6 +21,9 @@
extern "C" {
#endif
+#define PLATFORM_HW_TYPE 0x4C75 // 'Lu' -> lunchbox
+//#define DEBUG_UART_PIN 16 // GPIOB0 is debug uart at 2MBps
+
#define VARIANT_VER 0x00000000
//we have LSE in lunchbox
diff --git a/firmware/misc/variant/lunchbox/Makefile b/firmware/variant/lunchbox/lunchbox.mk
index db18758c..59c8010e 100644
--- a/firmware/misc/variant/lunchbox/Makefile
+++ b/firmware/variant/lunchbox/lunchbox.mk
@@ -16,57 +16,50 @@
#variant makefile for lunchbox
-ifneq ($(PLATFORM),stm32f4xx)
- $(error "LUNCHBOX variant cannot be build on a platform that is not stm32f411")
+ifneq ($(PLATFORM),stm32)
+ $(error "LUNCHBOX variant cannot be build on a platform that is not stm32")
endif
FLAGS += -DPLATFORM_HW_TYPE=0x4C75 #'Lu' -> lunchbox
FLAGS += -DDEBUG_UART_PIN=16 #GPIOB0 is debug uart at 2MBps
+FLAGS += -I$(VARIANT_PATH)/inc
#board configuration shims
-SRCS_os += links/variant/src/i2c.c
-SRCS_os += links/variant/src/spi.c
-
+SRCS_os += $(VARIANT_PATH)/src/os/i2c.c
+SRCS_os += $(VARIANT_PATH)/src/os/spi.c
#keys
#drivers
# ROHM ALS/prox
-SRCS_os += src/drivers/rohm_rpr0521/rohm_rpr0521.c
+SRCS_os += os/drivers/rohm_rpr0521/rohm_rpr0521.c
# Fusion algorithms
-SRCS_os += src/algos/fusion.c src/algos/mat.c src/algos/quat.c src/algos/vec.c
+SRCS_os += os/algos/fusion.c os/algos/mat.c os/algos/quat.c os/algos/vec.c
# BMI160 accel and gyro, BMM150 mag drivers
FLAGS += -DUSE_BMM150 -DMAG_SLAVE_PRESENT
-SRCS_os += src/drivers/bosch_bmi160/bosch_bmi160.c \
- src/drivers/bosch_bmi160/bosch_bmm150_slave.c \
- src/algos/mag_cal.c \
- src/algos/time_sync.c
+SRCS_os += os/drivers/bosch_bmi160/bosch_bmi160.c \
+ os/drivers/bosch_bmi160/bosch_bmm150_slave.c \
+ os/algos/mag_cal.c \
+ os/algos/time_sync.c
# Orientation sensor driver
-SRCS_os += src/drivers/orientation/orientation.c
+SRCS_os += os/drivers/orientation/orientation.c
# Window orientation sensor driver
-SRCS_os += src/drivers/window_orientation/window_orientation.c
+SRCS_os += os/drivers/window_orientation/window_orientation.c
# Bosch BMP280 Barometer/Temperature
-SRCS_os += src/drivers/bosch_bmp280/bosch_bmp280.c
+SRCS_os += os/drivers/bosch_bmp280/bosch_bmp280.c
# Hall effect sensor driver
-SRCS_os += src/drivers/hall/hall.c
+SRCS_os += os/drivers/hall/hall.c
# Camera Vsync driver
-SRCS_os += src/drivers/vsync/vsync.c
+SRCS_os += os/drivers/vsync/vsync.c
# Tilt detection
-SRCS_os += src/drivers/tilt_detection/tilt_detection.c
-
-DEPS += $(wildcard links/variant/inc/*.h)
+SRCS_os += os/drivers/tilt_detection/tilt_detection.c
-#linker script
-LKR_os = misc/variant/common/stm32f411.os.lkr
-LKR_bl = misc/variant/common/stm32f411.bl.lkr
-OSFLAGS_os += -Wl,-T $(LKR_os)
-OSFLAGS_bl += -Wl,-T $(LKR_bl)
-DEPS += $(LKR_os) $(LKR_bl)
+$(info included LUNCHBOX variant)
diff --git a/firmware/src/variant/nucleo/i2c.c b/firmware/variant/lunchbox/src/os/i2c.c
index 87278a4e..ec4c899f 100644
--- a/firmware/src/variant/nucleo/i2c.c
+++ b/firmware/variant/lunchbox/src/os/i2c.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/i2c.h>
+#include <plat/i2c.h>
#include <util.h>
static const struct StmI2cBoardCfg mStmI2cBoardCfgs[] = {
diff --git a/firmware/src/variant/lunchbox/spi.c b/firmware/variant/lunchbox/src/os/spi.c
index bbe986d8..40457bd1 100644
--- a/firmware/src/variant/lunchbox/spi.c
+++ b/firmware/variant/lunchbox/src/os/spi.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/spi.h>
+#include <plat/spi.h>
#include <util.h>
static const struct StmSpiBoardCfg mStmSpiBoardCfgs[] = {
diff --git a/firmware/variant/nucleo/Makefile b/firmware/variant/nucleo/Makefile
new file mode 100644
index 00000000..872c73e9
--- /dev/null
+++ b/firmware/variant/nucleo/Makefile
@@ -0,0 +1,5 @@
+SRC_PATH=../..
+VARIANT_PATH=src/variant/nucleo
+VARIANT=nucleo
+
+include $(SRC_PATH)/src/variant/variant.mk
diff --git a/firmware/inc/variant/nucleo/sensType.h b/firmware/variant/nucleo/inc/variant/sensType.h
index 1a21b3cb..1a21b3cb 100644
--- a/firmware/inc/variant/nucleo/sensType.h
+++ b/firmware/variant/nucleo/inc/variant/sensType.h
diff --git a/firmware/inc/variant/nucleo/variant.h b/firmware/variant/nucleo/inc/variant/variant.h
index 4cefbeeb..4cefbeeb 100644
--- a/firmware/inc/variant/nucleo/variant.h
+++ b/firmware/variant/nucleo/inc/variant/variant.h
diff --git a/firmware/misc/variant/nucleo/Makefile b/firmware/variant/nucleo/nucleo.mk
index 12ba238c..af070ed7 100644
--- a/firmware/misc/variant/nucleo/Makefile
+++ b/firmware/variant/nucleo/nucleo.mk
@@ -17,58 +17,54 @@
#variant makefile for nucleo
-ifneq ($(PLATFORM),stm32f4xx)
- $(error "NUCLEO variant cannot be build on a platform that is not stm32f411")
+ifneq ($(PLATFORM),stm32)
+ $(error "NUCLEO variant cannot be build on a platform that is not stm32")
endif
FLAGS += -DPLATFORM_HW_TYPE=0x4E75 #'Nu' ->nucleo
FLAGS += -DDEBUG_SWD
+FLAGS += -I$(VARIANT_PATH)/inc
+
#board configuration shims
-SRCS_os += src/variant/$(VARIANT)/i2c.c
-SRCS_os += src/variant/$(VARIANT)/spi.c
+SRCS_os += $(VARIANT_PATH)/src/os/i2c.c
+SRCS_os += $(VARIANT_PATH)/src/os/spi.c
#keys
#drivers
# AMS ALS/prox
-SRCS_os += src/drivers/ams_tmd2772/ams_tmd2772.c
+SRCS_os += os/drivers/ams_tmd2772/ams_tmd2772.c
# ROHM ALS/prox
-SRCS_os += src/drivers/rohm_rpr0521/rohm_rpr0521.c
+SRCS_os += os/drivers/rohm_rpr0521/rohm_rpr0521.c
# Fusion algorithm
-SRCS_os += src/algos/fusion.c src/algos/mat.c src/algos/quat.c src/algos/vec.c
+SRCS_os += os/algos/fusion.c os/algos/mat.c os/algos/quat.c os/algos/vec.c
# BMI160 accel and gyro, BMM150 mag drivers
-FLAGS += -DUSE_BMM150
-SRCS_os += src/drivers/bosch_bmi160/bosch_bmi160.c \
- src/drivers/bosch_bmi160/bosch_bmm150_slave.c \
- src/algos/mag_cal.c \
- src/algos/time_sync.c
+FLAGS += -DUSE_BMM150 -DMAG_SLAVE_PRESENT
+SRCS_os += os/drivers/bosch_bmi160/bosch_bmi160.c \
+ os/drivers/bosch_bmi160/bosch_bmm150_slave.c \
+ os/algos/mag_cal.c \
+ os/algos/time_sync.c
# Orientation sensor driver
-SRCS_os += src/drivers/orientation/orientation.c
+SRCS_os += os/drivers/orientation/orientation.c
# Window orientation sensor driver
-SRCS_os += src/drivers/window_orientation/window_orientation.c
+SRCS_os += os/drivers/window_orientation/window_orientation.c
# Bosch BMP280 Barometer/Temperature
-SRCS_os += src/drivers/bosch_bmp280/bosch_bmp280.c
+SRCS_os += os/drivers/bosch_bmp280/bosch_bmp280.c
# Hall effect sensor driver
-SRCS_os += src/drivers/hall/hall.c
+SRCS_os += os/drivers/hall/hall.c
# Camera Vsync driver
-SRCS_os += src/drivers/vsync/vsync.c
+SRCS_os += os/drivers/vsync/vsync.c
# Tilt detection
-SRCS_os += src/drivers/tilt_detection/tilt_detection.c
-
-#linker script
-LKR_os = misc/variant/common/stm32f411.os.lkr
-LKR_bl = misc/variant/common/stm32f411.bl.lkr
-OSFLAGS_os += -Wl,-T $(LKR_os)
-OSFLAGS_bl += -Wl,-T $(LKR_bl)
-DEPS += $(LKR_os) $(LKR_bl)
-DEPS += $(LKR)
+SRCS_os += os/drivers/tilt_detection/tilt_detection.c
+
+$(info included NUCLEO variant)
diff --git a/firmware/src/variant/lunchbox/i2c.c b/firmware/variant/nucleo/src/os/i2c.c
index 87278a4e..ec4c899f 100644
--- a/firmware/src/variant/lunchbox/i2c.c
+++ b/firmware/variant/nucleo/src/os/i2c.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/i2c.h>
+#include <plat/i2c.h>
#include <util.h>
static const struct StmI2cBoardCfg mStmI2cBoardCfgs[] = {
diff --git a/firmware/src/variant/nucleo/spi.c b/firmware/variant/nucleo/src/os/spi.c
index 6a694522..d75824c5 100644
--- a/firmware/src/variant/nucleo/spi.c
+++ b/firmware/variant/nucleo/src/os/spi.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include <plat/inc/spi.h>
+#include <plat/spi.h>
#include <util.h>
static const struct StmSpiBoardCfg mStmSpiBoardCfgs[] = {
diff --git a/firmware/variant/variant.mk b/firmware/variant/variant.mk
new file mode 100644
index 00000000..340f91cc
--- /dev/null
+++ b/firmware/variant/variant.mk
@@ -0,0 +1,22 @@
+PLATFORM?=stm32
+CPU?=cortexm4
+CHIP?=stm32f411
+OUT?=out
+
+# SRC_PATH points to "firmware"; TOP_PATH is the abs path to top of andrlid tree
+TOP_RELPATH := ../../../..
+TOP_ABSPATH := $(realpath $(SRC_PATH)/$(TOP_RELPATH))
+VARIANT_ABSPATH := $(TOP_ABSPATH)/$(VARIANT_PATH)
+VARIANT_PATH := $(TOP_RELPATH)/$(VARIANT_PATH)
+
+all:
+ make -C $(SRC_PATH) -f firmware.mk VARIANT=$(VARIANT) VARIANT_PATH=$(VARIANT_PATH) OUT=$(VARIANT_PATH)/$(OUT) PLATFORM=$(PLATFORM) CPU=$(CPU) CHIP=$(CHIP) $(EXTRA_ARGS)
+ifdef IMAGE_OUT
+ cd $(VARIANT_ABSPATH) && cp $(OUT)/full.bin $(IMAGE_OUT)
+endif
+
+clean:
+ rm -rf $(OUT)
+ifdef IMAGE_OUT
+ rm $(IMAGE_OUT)
+endif
diff --git a/lib/Android.mk b/lib/Android.mk
new file mode 100644
index 00000000..a39d13f4
--- /dev/null
+++ b/lib/Android.mk
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+src_files := \
+ nanohub/aes.c \
+ nanohub/rsa.c \
+ nanohub/sha2.c \
+ nanohub/softcrc.c \
+
+src_includes := \
+ $(LOCAL_PATH)/include \
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libnanohub_common
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := \
+ $(src_files) \
+ nanohub/nanoapp.c \
+
+LOCAL_CFLAGS := \
+ -DHOST_BUILD \
+ -DRSA_SUPPORT_PRIV_OP_BIGRAM \
+
+LOCAL_C_INCLUDES := \
+ $(src_includes)
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+ $(src_includes)
+
+LOCAL_MULTILIB := both
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+include $(call first-makefiles-under, $(LOCAL_PATH))
+
+src_files :=
+src_includes :=
diff --git a/lib/include/nanohub/crc.h b/lib/include/nanohub/crc.h
index 96b7e4c4..35d716e4 100644
--- a/lib/include/nanohub/crc.h
+++ b/lib/include/nanohub/crc.h
@@ -38,4 +38,8 @@
*/
uint32_t crc32(const void *buf, size_t size, uint32_t crc);
+/* concrete public implementation of crc32() w/o HW acceleration */
+uint32_t soft_crc32(const void *buf, size_t size, uint32_t crc);
+
+
#endif /* _NANOHUB_CRC_H_ */
diff --git a/lib/nanohub/softcrc.c b/lib/nanohub/softcrc.c
index fb2b7119..286e36b4 100644
--- a/lib/nanohub/softcrc.c
+++ b/lib/nanohub/softcrc.c
@@ -29,7 +29,7 @@ static const uint32_t crctab[] =
static uint32_t crcOneWord(uint32_t crc, uint32_t data, int cnt)
{
- uint32_t i;
+ int i;
crc = crc ^ data;
for (i = 0; i < cnt; i++)
@@ -38,11 +38,12 @@ static uint32_t crcOneWord(uint32_t crc, uint32_t data, int cnt)
return crc;
}
-uint32_t crc32(const void *buf, size_t size, uint32_t crc)
+uint32_t soft_crc32(const void *buf, size_t size, uint32_t crc)
{
const uint32_t *data32 = (const uint32_t *)buf;
const uint8_t *data8;
- uint32_t word, i;
+ uint32_t word;
+ size_t i;
// word by word crc32
for (i = 0; i < size / 4; i++)
diff --git a/sensorhal/Android.mk b/sensorhal/Android.mk
index c34f0e9e..a2fb0a9b 100644
--- a/sensorhal/Android.mk
+++ b/sensorhal/Android.mk
@@ -56,7 +56,7 @@ LOCAL_MODULE_OWNER := google
LOCAL_CFLAGS += $(COMMON_CFLAGS)
LOCAL_C_INCLUDES += \
- device/google/contexthub/firmware/inc \
+ device/google/contexthub/firmware/os/inc \
device/google/contexthub/util/common
LOCAL_SRC_FILES := \
@@ -83,7 +83,7 @@ LOCAL_MODULE_OWNER := google
LOCAL_CFLAGS += $(COMMON_CFLAGS)
LOCAL_C_INCLUDES += \
- device/google/contexthub/firmware/inc \
+ device/google/contexthub/firmware/os/inc \
device/google/contexthub/util/common
LOCAL_SRC_FILES := \
@@ -121,7 +121,7 @@ LOCAL_CFLAGS += -DDOUBLE_TOUCH_ENABLED
endif
LOCAL_C_INCLUDES += \
- device/google/contexthub/firmware/inc \
+ device/google/contexthub/firmware/os/inc \
device/google/contexthub/util/common
LOCAL_SRC_FILES := \
diff --git a/util/nanoapp_cmd/Android.mk b/util/nanoapp_cmd/Android.mk
index b9eb4934..8dcd8ac5 100644
--- a/util/nanoapp_cmd/Android.mk
+++ b/util/nanoapp_cmd/Android.mk
@@ -19,7 +19,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= nanoapp_cmd.c
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../firmware/inc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../firmware/os/inc
LOCAL_CFLAGS := -Wall -Werror -Wextra
LOCAL_MODULE:= nanoapp_cmd
diff --git a/util/nanoapp_encr/Android.mk b/util/nanoapp_encr/Android.mk
index 4d64acc6..84444e12 100644
--- a/util/nanoapp_encr/Android.mk
+++ b/util/nanoapp_encr/Android.mk
@@ -20,9 +20,6 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../../lib/nanohub/aes.c \
- ../../lib/nanohub/sha2.c \
- ../../lib/nanohub/nanoapp.c \
nanoapp_encr.c \
@@ -34,9 +31,7 @@ LOCAL_CFLAGS := \
-DBOOTLOADER= \
-DBOOTLOADER_RO= \
-
-LOCAL_C_INCLUDES := \
- device/google/contexthub/lib/include \
+LOCAL_STATIC_LIBRARIES := libnanohub_common
LOCAL_MODULE := nanoapp_encr
diff --git a/util/nanoapp_postprocess/Android.mk b/util/nanoapp_postprocess/Android.mk
index b20deec2..dce17112 100644
--- a/util/nanoapp_postprocess/Android.mk
+++ b/util/nanoapp_postprocess/Android.mk
@@ -24,15 +24,20 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
postprocess.c \
- ../../lib/nanohub/nanoapp.c \
LOCAL_CFLAGS := -Wall -Werror -Wextra
-LOCAL_C_INCLUDES += \
- device/google/contexthub/lib/include \
+LOCAL_STATIC_LIBRARIES := libnanohub_common
LOCAL_MODULE := nanoapp_postprocess
+# libelf needed for ELF parsing support, libz required by libelf
+LOCAL_STATIC_LIBRARIES += libelf libz
+
+# Statically linking libc++ so this binary can be copied out of the tree and
+# still work (needed by dependencies)
+LOCAL_CXX_STL := libc++_static
+
LOCAL_MODULE_TAGS := optional
include $(BUILD_HOST_EXECUTABLE)
diff --git a/util/nanoapp_sign/Android.mk b/util/nanoapp_sign/Android.mk
index 81e204a7..7be51975 100644
--- a/util/nanoapp_sign/Android.mk
+++ b/util/nanoapp_sign/Android.mk
@@ -19,12 +19,8 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- ../../lib/nanohub/rsa.c \
- ../../lib/nanohub/sha2.c \
- ../../lib/nanohub/nanoapp.c \
nanoapp_sign.c \
-
LOCAL_CFLAGS := \
-Wall \
-Werror \
@@ -35,13 +31,12 @@ LOCAL_CFLAGS := \
-DBOOTLOADER_RO= \
-LOCAL_C_INCLUDES := \
- device/google/contexthub/lib/include \
-
ifneq ($(filter userdebug eng,$(TARGET_BUILD_VARIANT)),)
LOCAL_CFLAGS += -DDEBUG_KEYS
endif
+LOCAL_STATIC_LIBRARIES := libnanohub_common
+
LOCAL_MODULE := nanoapp_sign
LOCAL_MODULE_TAGS := optional