diff --git a/tests/gadget-zero/Makefile.stm32f3-disco b/tests/gadget-zero/Makefile.stm32f3-disco
new file mode 100644
index 00000000..3a60392e
--- /dev/null
+++ b/tests/gadget-zero/Makefile.stm32f3-disco
@@ -0,0 +1,44 @@
+##
+## This file is part of the libopencm3 project.
+##
+## This library is free software: you can redistribute it and/or modify
+## it under the terms of the GNU Lesser General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public License
+## along with this library. If not, see .
+##
+
+BOARD = stm32f3-disco
+PROJECT = usb-gadget0-$(BOARD)
+BUILD_DIR = bin-$(BOARD)
+
+SHARED_DIR = ../shared
+
+CFILES = main-$(BOARD).c
+CFILES += usb-gadget0.c trace.c trace_stdio.c
+CFILES += delay.c
+
+VPATH += $(SHARED_DIR)
+
+INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
+
+OPENCM3_DIR=../..
+
+### This section can go to an arch shared rules eventually...
+LDSCRIPT = ../../lib/stm32/f3/stm32f303xc.ld
+OPENCM3_LIB = opencm3_stm32f3
+OPENCM3_DEFS = -DSTM32F3
+FP_FLAGS ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16
+ARCH_FLAGS = -mthumb -mcpu=cortex-m4 $(FP_FLAGS)
+#OOCD_INTERFACE = stlink-v2
+#OOCD_TARGET = stm32f3x
+OOCD_FILE = openocd.stm32f3-disco.cfg
+
+include ../rules.mk
diff --git a/tests/gadget-zero/main-stm32f3-disco.c b/tests/gadget-zero/main-stm32f3-disco.c
new file mode 100644
index 00000000..53970b9f
--- /dev/null
+++ b/tests/gadget-zero/main-stm32f3-disco.c
@@ -0,0 +1,93 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2015 Karl Palsson
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
+ */
+
+/* "generic" could be any L1 board, but this file is pre-configured for the
+ * libopencm3-tests "hw1" board, with an stm32l151c8-A part.
+ */
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include "usb-gadget0.h"
+
+#define ER_DEBUG
+#ifdef ER_DEBUG
+#define ER_DPRINTF(fmt, ...) \
+ do { printf(fmt, ## __VA_ARGS__); } while (0)
+#else
+#define ER_DPRINTF(fmt, ...) \
+ do { } while (0)
+#endif
+
+const struct rcc_clock_scale this_clock_config = {
+ /* 72MHZ from 8MHZ external clock from stlink MCO */
+ .pllsrc = RCC_CFGR_PLLSRC_HSE_PREDIV,
+ .pllmul = RCC_CFGR_PLLMUL_MUL9,
+ .plldiv = RCC_CFGR2_PREDIV_NODIV,
+ .usbdiv1 = false,
+ .flash_waitstates = 2,
+ .hpre = RCC_CFGR_HPRE_DIV_NONE,
+ .ppre1 = RCC_CFGR_PPRE1_DIV_2,
+ .ppre2 = RCC_CFGR_PPRE2_DIV_NONE,
+ .ahb_frequency = 72e6,
+ .apb1_frequency = 32e6,
+ .apb2_frequency = 72e6,
+};
+
+
+int main(void)
+{
+ rcc_periph_clock_enable(RCC_GPIOE);
+ gpio_mode_setup(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO11|GPIO12);
+ gpio_set(GPIOE, GPIO12);
+ rcc_clock_setup_pll(&this_clock_config);
+
+ rcc_periph_clock_enable(RCC_GPIOA);
+ /*
+ * Vile hack to reenumerate, physically _drag_ d+ low.
+ * do NOT do this if you're board has proper usb pull up control!
+ * (need at least 2.5us to trigger usb disconnect)
+ */
+ gpio_mode_setup(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO12);
+ gpio_clear(GPIOA, GPIO12);
+ for (unsigned int i = 0; i < 800000; i++) {
+ __asm__("nop");
+ }
+ /* now return PA11/PA12 to usb AF */
+ gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO11|GPIO12);
+ gpio_set_af(GPIOA, GPIO_AF14, GPIO11|GPIO12);
+
+ usbd_device *usbd_dev = gadget0_init(&st_usbfs_v1_usb_driver,
+ "stm32f3-disco");
+
+ ER_DPRINTF("bootup complete\n");
+ gpio_clear(GPIOE, GPIO12);
+ static int i = 0;
+ while (1) {
+ gpio_toggle(GPIOE, GPIO12);
+ gadget0_run(usbd_dev);
+ ER_DPRINTF("loop %d\n", i++);
+ }
+
+}
+
diff --git a/tests/gadget-zero/openocd.stm32f3-disco.cfg b/tests/gadget-zero/openocd.stm32f3-disco.cfg
new file mode 100644
index 00000000..835d4669
--- /dev/null
+++ b/tests/gadget-zero/openocd.stm32f3-disco.cfg
@@ -0,0 +1,13 @@
+source [find interface/stlink-v2.cfg]
+set WORKAREASIZE 0x4000
+source [find target/stm32f3x.cfg]
+
+# serial of my f3 disco board.
+hla_serial "S?n\x06gePQ6G%g"
+
+tpiu config internal swodump.stm32f3-disco.log uart off 72000000
+
+# Uncomment to reset on connect, for grabbing under WFI et al
+reset_config srst_only srst_nogate
+# reset_config srst_only srst_nogate connect_assert_srst
+