diff --git a/conf/airframes/CDW/test/ChimuLisaFw.xml b/conf/airframes/CDW/test/ChimuLisaFw.xml
index 3c67cd6c68..0300ba4e4d 100644
--- a/conf/airframes/CDW/test/ChimuLisaFw.xml
+++ b/conf/airframes/CDW/test/ChimuLisaFw.xml
@@ -160,8 +160,9 @@
-
-
+
+
+
diff --git a/conf/airframes/examples/microjet.xml b/conf/airframes/examples/microjet.xml
index 276f927524..9daf3ec61e 100644
--- a/conf/airframes/examples/microjet.xml
+++ b/conf/airframes/examples/microjet.xml
@@ -212,8 +212,9 @@
-
-
+
+
+
diff --git a/conf/airframes/examples/setup_lisam2.xml b/conf/airframes/examples/setup_lisam2.xml
index 68c925c838..bfbc7e3d1a 100644
--- a/conf/airframes/examples/setup_lisam2.xml
+++ b/conf/airframes/examples/setup_lisam2.xml
@@ -6,6 +6,9 @@
+
+
+
diff --git a/conf/airframes/examples/twinjet.xml b/conf/airframes/examples/twinjet.xml
index 44de04e738..93fe181c06 100644
--- a/conf/airframes/examples/twinjet.xml
+++ b/conf/airframes/examples/twinjet.xml
@@ -31,8 +31,9 @@
-
-
+
+
+
diff --git a/conf/airframes/flixr_discovery.xml b/conf/airframes/flixr_discovery.xml
index 213b340795..778f71c1b8 100644
--- a/conf/airframes/flixr_discovery.xml
+++ b/conf/airframes/flixr_discovery.xml
@@ -55,7 +55,7 @@
-
+
diff --git a/conf/airframes/jsbsim.xml b/conf/airframes/jsbsim.xml
index 71557b7608..d13a3554a6 100644
--- a/conf/airframes/jsbsim.xml
+++ b/conf/airframes/jsbsim.xml
@@ -216,11 +216,4 @@
-
-
-
-
-
-
-
diff --git a/conf/airframes/usb_test.xml b/conf/airframes/usb_test.xml
index f0b73c12a2..238921cbbe 100644
--- a/conf/airframes/usb_test.xml
+++ b/conf/airframes/usb_test.xml
@@ -21,8 +21,9 @@
-
-
+
+
+
diff --git a/conf/firmwares/setup.makefile b/conf/firmwares/setup.makefile
index 978ea1d7a1..5ae6900fb3 100644
--- a/conf/firmwares/setup.makefile
+++ b/conf/firmwares/setup.makefile
@@ -3,65 +3,110 @@
#
#
+SRC_ARCH=arch/$(ARCH)
+SRC_BOARD=boards/$(BOARD)
+SRC_SUBSYSTEMS=subsystems
+SRC_MODULES=modules
CFG_SHARED=$(PAPARAZZI_SRC)/conf/firmwares/subsystems/shared
-#CFG_SETUP=$(PAPARAZZI_SRC)/conf/firmwares/subsystems/setup
-SRC_ARCH=arch/$(ARCH)
SRC_FIRMWARE=firmwares/setup
-SRC_LISA=lisa
-
-SETUP_INC = -I$(SRC_FIRMWARE)
-
-$(TARGET).CFLAGS += -DBOARD_CONFIG=$(BOARD_CFG)
-
-# a test program to tunnel between both uart
-tunnel.CFLAGS += -DUSE_LED
-tunnel.srcs += $(SRC_ARCH)/uart_tunnel.c
-tunnel.srcs += mcu.c $(SRC_ARCH)/mcu_arch.c
-ifeq ($(ARCH), stm32)
-tunnel.ARCHDIR = $(ARCH)
-tunnel.CFLAGS += -I$(ARCH) -DPERIPHERALS_AUTO_INIT
-tunnel.srcs += $(SRC_ARCH)/mcu_periph/gpio_arch.c $(SRC_ARCH)/led_hw.c
-ifneq ($(SYS_TIME_LED),none)
-tunnel.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
-endif
-tunnel.CFLAGS += -DPERIODIC_FREQUENCY='512.'
-tunnel.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c
-endif
-
-
-# for the usb_tunnel we need to set PCLK higher with the flag USE_USB_HIGH_PCLK
-
-# a configuration program to access both uart through usb
-ifeq ($(ARCH), lpc21)
-usb_tunnel_0.CFLAGS += -DUSE_UART0 -DUART0_BAUD=B115200 -DPERIPHERALS_AUTO_INIT
-usb_tunnel_0.CFLAGS += -DUSE_USB_LINE_CODING -DUSE_USB_SERIAL -DUSE_LED -DUSE_USB_HIGH_PCLK
-usb_tunnel_0.srcs += $(SRC_ARCH)/usb_tunnel.c $(SRC_ARCH)/usb_ser_hw.c mcu_periph/uart.c $(SRC_ARCH)/mcu_periph/uart_arch.c
-usb_tunnel_0.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbinit.c
-usb_tunnel_0.srcs += $(SRC_ARCH)/lpcusb/usbcontrol.c $(SRC_ARCH)/lpcusb/usbstdreq.c
-usb_tunnel_0.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c $(SRC_ARCH)/armVIC.c
-usb_tunnel_0.srcs += mcu.c $(SRC_ARCH)/mcu_arch.c
-
-usb_tunnel_1.CFLAGS += -DUSE_UART1 -DUART1_BAUD=B115200 -DPERIPHERALS_AUTO_INIT
-usb_tunnel_1.CFLAGS += -DUSE_USB_LINE_CODING -DUSE_USB_SERIAL -DUSE_LED -DUSE_USB_HIGH_PCLK
-usb_tunnel_1.srcs += $(SRC_ARCH)/usb_tunnel.c $(SRC_ARCH)/usb_ser_hw.c mcu_periph/uart.c $(SRC_ARCH)/mcu_periph/uart_arch.c
-usb_tunnel_1.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbinit.c
-usb_tunnel_1.srcs += $(SRC_ARCH)/lpcusb/usbcontrol.c $(SRC_ARCH)/lpcusb/usbstdreq.c
-usb_tunnel_1.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c $(SRC_ARCH)/armVIC.c
-usb_tunnel_1.srcs += mcu.c $(SRC_ARCH)/mcu_arch.c
-else
-ifeq ($(TARGET),usb_tunnel_0)
-$(error usb_tunnel_0 currently only implemented for the lpc21)
-else ifeq ($(TARGET),usb_tunnel_1)
-$(error usb_tunnel_1 currently only implemented for the lpc21)
-endif
-endif
-
-
+#
+# common setup
+#
+# configuration
+# SYS_TIME_LED
+# MODEM_PORT
+# MODEM_BAUD
+#
PERIODIC_FREQUENCY ?= 512
+COMMON_SETUP_CFLAGS = -I$(SRC_BOARD) -DBOARD_CONFIG=$(BOARD_CFG)
+COMMON_SETUP_CFLAGS += -DPERIPHERALS_AUTO_INIT
+COMMON_SETUP_SRCS = mcu.c $(SRC_ARCH)/mcu_arch.c
+ifneq ($(SYS_TIME_LED),none)
+ COMMON_SETUP_CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
+endif
+COMMON_SETUP_CFLAGS += -DPERIODIC_FREQUENCY=$(PERIODIC_FREQUENCY)
+COMMON_SETUP_SRCS += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c
+
+COMMON_SETUP_CFLAGS += -DUSE_LED
+
+ifeq ($(ARCH), lpc21)
+COMMON_SETUP_SRCS += $(SRC_ARCH)/armVIC.c
+else ifeq ($(ARCH), stm32)
+COMMON_SETUP_SRCS += $(SRC_ARCH)/led_hw.c
+COMMON_SETUP_SRCS += $(SRC_ARCH)/mcu_periph/gpio_arch.c
+endif
+
+
+
+#
+# a test program to tunnel between both uart
+#
+tunnel.ARCHDIR = $(ARCH)
+tunnel.CFLAGS += $(COMMON_SETUP_CFLAGS)
+tunnel.srcs += $(COMMON_SETUP_SRCS)
+tunnel.srcs += $(SRC_ARCH)/uart_tunnel.c
+
+
+#
+# usb tunnel
+#
+# a configuration program to access a uart through usb
+#
+# configuration:
+# TUNNEL_PORT (defaults to GPS_PORT)
+# TUNNEL_BAUD
+#
+usb_tunnel.ARCHDIR = $(ARCH)
+usb_tunnel.CFLAGS += $(COMMON_SETUP_CFLAGS)
+usb_tunnel.srcs += $(COMMON_SETUP_SRCS)
+usb_tunnel.srcs += mcu_periph/uart.c $(SRC_ARCH)/mcu_periph/uart_arch.c
+
+TUNNEL_PORT ?= GPS_PORT
+TUNNEL_PORT_LOWER=$(shell echo $(TUNNEL_PORT) | tr A-Z a-z)
+TUNNEL_PORT_UPPER=$(shell echo $(TUNNEL_PORT) | tr a-z A-Z)
+TUNNEL_BAUD ?= B115200
+
+usb_tunnel.CFLAGS += -DUSE_$(TUNNEL_PORT_UPPER) -D$(TUNNEL_PORT_UPPER)_BAUD=$(TUNNEL_BAUD)
+usb_tunnel.CFLAGS += -DUSB_TUNNEL_UART=$(TUNNEL_PORT_LOWER)
+usb_tunnel.CFLAGS += -DUSE_USB_LINE_CODING -DUSE_USB_SERIAL
+usb_tunnel.srcs += $(SRC_ARCH)/usb_tunnel.c $(SRC_ARCH)/usb_ser_hw.c
+
+ifeq ($(ARCH), lpc21)
+# for the usb_tunnel we need to set PCLK higher with the flag USE_USB_HIGH_PCLK
+usb_tunnel.CFLAGS += -DUSE_USB_HIGH_PCLK
+usb_tunnel.srcs += $(SRC_ARCH)/lpcusb/usbhw_lpc.c $(SRC_ARCH)/lpcusb/usbinit.c
+usb_tunnel.srcs += $(SRC_ARCH)/lpcusb/usbcontrol.c $(SRC_ARCH)/lpcusb/usbstdreq.c
+else ifeq($(ARCH), stm32)
+else
+ifeq ($(TARGET),usb_tunnel)
+$(error usb_tunnel is only implemented for lpc21 and stm32)
+endif
+endif
+
+
+
+#
+# setup actuators
+#
+setup_actuators.ARCHDIR = $(ARCH)
+setup_actuators.CFLAGS += $(COMMON_SETUP_CFLAGS)
+setup_actuators.srcs += $(COMMON_SETUP_SRCS)
+
+setup_actuators.srcs += mcu_periph/uart.c $(SRC_ARCH)/mcu_periph/uart_arch.c
+setup_actuators.CFLAGS += -DUSE_$(MODEM_PORT)
+setup_actuators.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
+SETUP_ACTUATORS_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z)
+setup_actuators.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(SETUP_ACTUATORS_MODEM_PORT_LOWER) -DPPRZ_UART=$(MODEM_PORT)
+setup_actuators.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ
+setup_actuators.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
+
+setup_actuators.srcs += subsystems/actuators.c
+setup_actuators.srcs += $(SRC_FIRMWARE)/setup_actuators.c
+
ifeq ($(TARGET), setup_actuators)
ifeq ($(ACTUATORS),)
$(error ACTUATORS not configured, if your board file has no default, configure in your airframe file)
@@ -69,38 +114,3 @@ ifeq ($(TARGET), setup_actuators)
include $(CFG_SHARED)/$(ACTUATORS).makefile
endif
endif
-
-# a test program to setup actuators
-setup_actuators.CFLAGS += -DUSE_LED -DPERIPHERALS_AUTO_INIT
-setup_actuators.srcs += mcu.c $(SRC_ARCH)/mcu_arch.c
-
-ifneq ($(SYS_TIME_LED),none)
-setup_actuators.CFLAGS += -DSYS_TIME_LED=$(SYS_TIME_LED)
-endif
-setup_actuators.srcs += mcu_periph/sys_time.c $(SRC_ARCH)/mcu_periph/sys_time_arch.c
-
-setup_actuators.CFLAGS += -DUSE_$(MODEM_PORT)
-setup_actuators.CFLAGS += -D$(MODEM_PORT)_BAUD=$(MODEM_BAUD)
-setup_actuators.srcs += mcu_periph/uart.c $(SRC_ARCH)/mcu_periph/uart_arch.c
-
-SETUP_ACTUATORS_MODEM_PORT_LOWER=$(shell echo $(MODEM_PORT) | tr A-Z a-z)
-setup_actuators.CFLAGS += -DDOWNLINK -DDOWNLINK_DEVICE=$(SETUP_ACTUATORS_MODEM_PORT_LOWER) -DPPRZ_UART=$(MODEM_PORT)
-setup_actuators.CFLAGS += -DDOWNLINK_TRANSPORT=pprz_tp -DDATALINK=PPRZ
-setup_actuators.srcs += subsystems/datalink/downlink.c subsystems/datalink/pprz_transport.c
-# we actually don't really use the generated periodic telemetry in this firmware,
-# but still needed to register e.g. the UART_ERRORS message #if DOWNLINK
-setup_actuators.CFLAGS += -DDefaultPeriodic='&telemetry_Main'
-setup_actuators.srcs += subsystems/datalink/telemetry.c
-
-setup_actuators.CFLAGS += -DPERIODIC_FREQUENCY=$(PERIODIC_FREQUENCY)
-setup_actuators.srcs += subsystems/actuators.c
-setup_actuators.srcs += $(SRC_FIRMWARE)/setup_actuators.c
-
-ifeq ($(ARCH), lpc21)
-setup_actuators.srcs += $(SRC_ARCH)/armVIC.c
-else ifeq ($(ARCH), stm32)
-setup_actuators.ARCHDIR = $(ARCH)
-setup_actuators.CFLAGS += -I$(ARCH)
-setup_actuators.srcs += $(SRC_ARCH)/led_hw.c
-setup_actuators.srcs += $(SRC_ARCH)/mcu_periph/gpio_arch.c
-endif
diff --git a/sw/airborne/arch/lpc21/usb_tunnel.c b/sw/airborne/arch/lpc21/usb_tunnel.c
index cf689f6c71..beb35901fe 100644
--- a/sw/airborne/arch/lpc21/usb_tunnel.c
+++ b/sw/airborne/arch/lpc21/usb_tunnel.c
@@ -46,6 +46,8 @@
#endif
#endif
+INFO_VAR(USB_TUNNEL_UART)
+
int main( void ) {
unsigned char inc;
unsigned int rx_time=0, tx_time=0;
diff --git a/sw/airborne/arch/stm32/usb_ser_hw.c b/sw/airborne/arch/stm32/usb_ser_hw.c
index 33865267bf..38995c8f3d 100644
--- a/sw/airborne/arch/stm32/usb_ser_hw.c
+++ b/sw/airborne/arch/stm32/usb_ser_hw.c
@@ -483,8 +483,8 @@ void VCOM_transmit_message()
* USE_USB_LINE_CODING is not used in case of example1, example2 and telemetry
*/
#ifdef USE_USB_LINE_CODING
-void VCOM_allow_linecoding(uint8_t mode) {}
-void VCOM_set_linecoding(uint8_t mode) {}
+void VCOM_allow_linecoding(uint8_t mode __attribute__((unused))) {}
+void VCOM_set_linecoding(uint8_t mode __attribute__((unused))) {}
#endif
/*
diff --git a/sw/airborne/arch/stm32/usb_tunnel.c b/sw/airborne/arch/stm32/usb_tunnel.c
new file mode 100644
index 0000000000..d94c25340e
--- /dev/null
+++ b/sw/airborne/arch/stm32/usb_tunnel.c
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2009 Martin Mueller
+ * 2014 Felix Ruess
+#endif
+
+INFO_VAR(USB_TUNNEL_UART)
+
+
+static void tunnel_event(void)
+{
+ static unsigned char inc;
+
+ if (uart_char_available(&USB_TUNNEL_UART) && VCOM_check_free_space(1)) {
+ inc = uart_getch(&USB_TUNNEL_UART);
+ VCOM_putchar(inc);
+ }
+ if (VCOM_check_available() && uart_check_free_space(&USB_TUNNEL_UART, 1)) {
+ inc = VCOM_getchar();
+ uart_transmit(&USB_TUNNEL_UART, inc);
+ }
+}
+
+int main(void)
+{
+ mcu_init();
+ sys_time_init();
+ led_init();
+
+ VCOM_allow_linecoding(1);
+
+ VCOM_init();
+
+ mcu_int_enable();
+
+ while(1) {
+ VCOM_event();
+ tunnel_event();
+ }
+
+ return 0;
+}