From ff15efb9c91540303622c3f9c48e22bbc9488ae0 Mon Sep 17 00:00:00 2001 From: px4dev Date: Fri, 26 Apr 2013 12:59:12 -0700 Subject: [PATCH 1/5] Build utility apps -Os to save ROM space. --- apps/examples/nsh/Makefile | 2 ++ apps/nshlib/Makefile | 2 ++ apps/px4/tests/Makefile | 2 ++ apps/system/i2c/Makefile | 1 + apps/systemcmds/bl_update/Makefile | 2 ++ apps/systemcmds/boardinfo/Makefile | 2 ++ apps/systemcmds/calibration/Makefile | 2 ++ apps/systemcmds/delay_test/Makefile | 2 ++ apps/systemcmds/eeprom/Makefile | 2 ++ apps/systemcmds/mixer/Makefile | 2 ++ apps/systemcmds/param/Makefile | 2 ++ apps/systemcmds/perf/Makefile | 2 ++ apps/systemcmds/preflight_check/Makefile | 2 ++ apps/systemcmds/reboot/Makefile | 2 ++ apps/systemcmds/top/Makefile | 2 ++ 15 files changed, 29 insertions(+) diff --git a/apps/examples/nsh/Makefile b/apps/examples/nsh/Makefile index c7d212fc2c..ad687958f6 100644 --- a/apps/examples/nsh/Makefile +++ b/apps/examples/nsh/Makefile @@ -64,6 +64,8 @@ ROOTDEPPATH = --dep-path . VPATH = +MAXOPTIMIZATION = -Os + all: .built .PHONY: clean depend distclean diff --git a/apps/nshlib/Makefile b/apps/nshlib/Makefile index 76cdac40d5..4256a10918 100644 --- a/apps/nshlib/Makefile +++ b/apps/nshlib/Makefile @@ -107,6 +107,8 @@ endif ROOTDEPPATH = --dep-path . VPATH = +MAXOPTIMIZATION = -Os + # Build targets all: .built diff --git a/apps/px4/tests/Makefile b/apps/px4/tests/Makefile index cb1c3c6185..34f058be44 100644 --- a/apps/px4/tests/Makefile +++ b/apps/px4/tests/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 12000 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/system/i2c/Makefile b/apps/system/i2c/Makefile index 1ed7a2faef..c98e2c0e2b 100644 --- a/apps/system/i2c/Makefile +++ b/apps/system/i2c/Makefile @@ -64,6 +64,7 @@ VPATH = APPNAME = i2c PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 2048 +MAXOPTIMIZATION = -Os # Build targets diff --git a/apps/systemcmds/bl_update/Makefile b/apps/systemcmds/bl_update/Makefile index 9d0e156f60..d05493577a 100644 --- a/apps/systemcmds/bl_update/Makefile +++ b/apps/systemcmds/bl_update/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 4096 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/boardinfo/Makefile b/apps/systemcmds/boardinfo/Makefile index 753a6843e5..6f1be149c6 100644 --- a/apps/systemcmds/boardinfo/Makefile +++ b/apps/systemcmds/boardinfo/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 2048 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/calibration/Makefile b/apps/systemcmds/calibration/Makefile index aa1aa77610..a1735962e1 100644 --- a/apps/systemcmds/calibration/Makefile +++ b/apps/systemcmds/calibration/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_MAX - 1 STACKSIZE = 4096 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/delay_test/Makefile b/apps/systemcmds/delay_test/Makefile index d30fcba27b..e54cf2f4e4 100644 --- a/apps/systemcmds/delay_test/Makefile +++ b/apps/systemcmds/delay_test/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 2048 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/eeprom/Makefile b/apps/systemcmds/eeprom/Makefile index 2f3db0fdce..79a05550ec 100644 --- a/apps/systemcmds/eeprom/Makefile +++ b/apps/systemcmds/eeprom/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 4096 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/mixer/Makefile b/apps/systemcmds/mixer/Makefile index b016ddc578..3d8ac38cb7 100644 --- a/apps/systemcmds/mixer/Makefile +++ b/apps/systemcmds/mixer/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 4096 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/param/Makefile b/apps/systemcmds/param/Makefile index 603746a206..f19cadbb60 100644 --- a/apps/systemcmds/param/Makefile +++ b/apps/systemcmds/param/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 4096 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/perf/Makefile b/apps/systemcmds/perf/Makefile index 0134c9948b..f8bab41b65 100644 --- a/apps/systemcmds/perf/Makefile +++ b/apps/systemcmds/perf/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 2048 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/preflight_check/Makefile b/apps/systemcmds/preflight_check/Makefile index f138e2640b..98aadaa86f 100644 --- a/apps/systemcmds/preflight_check/Makefile +++ b/apps/systemcmds/preflight_check/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 2048 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/reboot/Makefile b/apps/systemcmds/reboot/Makefile index 9609a24fd0..15dd199829 100644 --- a/apps/systemcmds/reboot/Makefile +++ b/apps/systemcmds/reboot/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 2048 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os diff --git a/apps/systemcmds/top/Makefile b/apps/systemcmds/top/Makefile index c45775f4be..f58f9212e7 100644 --- a/apps/systemcmds/top/Makefile +++ b/apps/systemcmds/top/Makefile @@ -40,3 +40,5 @@ PRIORITY = SCHED_PRIORITY_DEFAULT - 10 STACKSIZE = 3000 include $(APPDIR)/mk/app.mk + +MAXOPTIMIZATION = -Os From de412b6467378ea5d4e61928f5795f309012a081 Mon Sep 17 00:00:00 2001 From: px4dev Date: Fri, 26 Apr 2013 12:59:35 -0700 Subject: [PATCH 2/5] Pass -g to the link phase for PX4IO the same way we do for FMU --- nuttx/configs/px4io/common/Make.defs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nuttx/configs/px4io/common/Make.defs b/nuttx/configs/px4io/common/Make.defs index 4958f70926..7f782b5b22 100644 --- a/nuttx/configs/px4io/common/Make.defs +++ b/nuttx/configs/px4io/common/Make.defs @@ -112,7 +112,6 @@ ARCHOPTIMIZATION = $(MAXOPTIMIZATION) \ ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") ARCHOPTIMIZATION += -g -ARCHSCRIPT += -g endif ARCHCFLAGS = -std=gnu99 @@ -145,7 +144,7 @@ ARCHDEFINES = ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 # this seems to be the only way to add linker flags -ARCHSCRIPT += --warn-common \ +EXTRA_LIBS += --warn-common \ --gc-sections CFLAGS = $(ARCHCFLAGS) $(ARCHCWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(INSTRUMENTATIONDEFINES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe -fno-common From 74c62a131e34d416ef29436b12d78f961e14807a Mon Sep 17 00:00:00 2001 From: px4dev Date: Fri, 26 Apr 2013 13:00:12 -0700 Subject: [PATCH 3/5] Fix the way that we idle the tone_alarm pin so that the board defines what is the 'safe' state. --- apps/drivers/stm32/tone_alarm/tone_alarm.cpp | 8 ++++---- nuttx/configs/px4fmu/include/board.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/drivers/stm32/tone_alarm/tone_alarm.cpp b/apps/drivers/stm32/tone_alarm/tone_alarm.cpp index baa652d8ad..ac5511e60a 100644 --- a/apps/drivers/stm32/tone_alarm/tone_alarm.cpp +++ b/apps/drivers/stm32/tone_alarm/tone_alarm.cpp @@ -494,7 +494,7 @@ ToneAlarm::init() return ret; /* configure the GPIO to the idle state */ - stm32_configgpio(GPIO_TONE_ALARM); + stm32_configgpio(GPIO_TONE_ALARM_IDLE); /* clock/power on our timer */ modifyreg32(STM32_RCC_APB1ENR, 0, TONE_ALARM_CLOCK_ENABLE); @@ -606,6 +606,8 @@ ToneAlarm::start_note(unsigned note) rEGR = GTIM_EGR_UG; // force a reload of the period rCCER |= TONE_CCER; // enable the output + // configure the GPIO to enable timer output + stm32_configgpio(GPIO_TONE_ALARM); } void @@ -616,10 +618,8 @@ ToneAlarm::stop_note() /* * Make sure the GPIO is not driving the speaker. - * - * XXX this presumes PX4FMU and the onboard speaker driver FET. */ - stm32_gpiowrite(GPIO_TONE_ALARM, 0); + stm32_configgpio(GPIO_TONE_ALARM_IDLE); } void diff --git a/nuttx/configs/px4fmu/include/board.h b/nuttx/configs/px4fmu/include/board.h index 8ad56a4c6a..0bc0b30216 100755 --- a/nuttx/configs/px4fmu/include/board.h +++ b/nuttx/configs/px4fmu/include/board.h @@ -326,6 +326,7 @@ */ #define TONE_ALARM_TIMER 3 /* timer 3 */ #define TONE_ALARM_CHANNEL 3 /* channel 3 */ +#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN8) #define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF2|GPIO_SPEED_2MHz|GPIO_FLOAT|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN8) /************************************************************************************ From 264cf65d0f6b1259c64aad7d7bb45aff155a8e35 Mon Sep 17 00:00:00 2001 From: px4dev Date: Fri, 26 Apr 2013 13:00:27 -0700 Subject: [PATCH 4/5] Fix an error in a #error --- apps/drivers/stm32/drv_hrt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/drivers/stm32/drv_hrt.c b/apps/drivers/stm32/drv_hrt.c index bb67d5e6d2..cec0c49ffd 100644 --- a/apps/drivers/stm32/drv_hrt.c +++ b/apps/drivers/stm32/drv_hrt.c @@ -125,7 +125,7 @@ # define HRT_TIMER_VECTOR STM32_IRQ_TIM8CC # define HRT_TIMER_CLOCK STM32_APB2_TIM8_CLKIN # if CONFIG_STM32_TIM8 -# error must not set CONFIG_STM32_TIM8=y and HRT_TIMER=6 +# error must not set CONFIG_STM32_TIM8=y and HRT_TIMER=8 # endif #elif HRT_TIMER == 9 # define HRT_TIMER_BASE STM32_TIM9_BASE From 46085b43d14b1ea1237aa176460ff648e0ff2d2a Mon Sep 17 00:00:00 2001 From: px4dev Date: Fri, 26 Apr 2013 13:00:48 -0700 Subject: [PATCH 5/5] Use the I2C bus number from the board config, not a hardcoded value. --- apps/drivers/blinkm/blinkm.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/drivers/blinkm/blinkm.cpp b/apps/drivers/blinkm/blinkm.cpp index 56265995f3..3fabfd9a54 100644 --- a/apps/drivers/blinkm/blinkm.cpp +++ b/apps/drivers/blinkm/blinkm.cpp @@ -92,6 +92,7 @@ #include +#include #include #include @@ -841,7 +842,7 @@ int blinkm_main(int argc, char *argv[]) { - int i2cdevice = 3; + int i2cdevice = PX4_I2C_BUS_EXPANSION; int blinkmadr = 9; int x;