<p>Kévin Redon has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/12910">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add specific board support, including sysmoOCTSIM<br><br>the board specific definitions should be coded when particular<br>environment variable/marco is defined.<br>this macro name is provided by the makefile in the BOARD variable.<br>this allows to compile the bootloader for specific devices.<br>see README for more information.<br>the board definition for the sysmoOCTSIM is also added.<br><br>Change-Id: Ie51a3af7c77ba76ac40570b871f31fd527fb255b<br>---<br>M README.md<br>M atmel_start_pins.h<br>M config/usbd_config.h<br>M driver_init.c<br>M driver_init.h<br>M gcc/Makefile<br>M usb_dfu_main.c<br>M usb_start.c<br>8 files changed, 109 insertions(+), 14 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-asf4-dfu refs/changes/10/12910/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/README.md b/README.md</span><br><span>index 031bc27..58833aa 100644</span><br><span>--- a/README.md</span><br><span>+++ b/README.md</span><br><span>@@ -1,11 +1,22 @@</span><br><span> This is an implementation of the DFU mode of the [USB DFU Device Class Specification](https://usb.org/document-library/device-firmware-upgrade-11-new-version-31-aug-2004) for the Microchip SAM D5x/E5x micro-controller.</span><br><span> It is meant to be used as bootloader to allow flashing the main application over USB.</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-The code has been developed for the Microchip [SAM E54 Xplained Pro](https://www.microchip.com/DevelopmentTools/ProductDetails/PartNo/ATSAME54-XPRO) development board using a [SAM E54](https://www.microchip.com/wwwproducts/en/ATSAME54P20A) micro-controller.</span><br><span style="color: hsl(120, 100%, 40%);">+The code has been developed using a [SAM E54](https://www.microchip.com/wwwproducts/en/ATSAME54P20A) micro-controller.</span><br><span> It should work on any chip of the SAM D5x/E5x device family by replacing the corresponding device-specific definitions (usually including the chip name in the file name).</span><br><span> </span><br><span> The code uses the [Atmel START](https://start.atmel.com/) ASFv4 library.</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+Board</span><br><span style="color: hsl(120, 100%, 40%);">+=====</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The code can be compiled for specific boards:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+- Microchip [SAM E54 Xplained Pro](https://www.microchip.com/DevelopmentTools/ProductDetails/PartNo/ATSAME54-XPRO) development board, named *SAME54_XPLAINED_PRO*</span><br><span style="color: hsl(120, 100%, 40%);">+- sysmocom sysmoOCTSIM, name *SYSMOOCTSIM*</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The board name can be set in 'gcc/Makefile' *BOARD* variable, or provided while compiling (e.g. `make BOARD=SAME54_XPLAINED_PRO`).</span><br><span style="color: hsl(120, 100%, 40%);">+*SAME54_XPLAINED_PRO* is the default value.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> USB DFU</span><br><span> =======</span><br><span> </span><br><span>@@ -26,13 +37,14 @@</span><br><span> make</span><br><span> ```</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+The board name can be set in 'gcc/Makefile' *BOARD* variable, or provided while compiling (e.g. `make BOARD=SAME54_XPLAINED_PRO`).</span><br><span style="color: hsl(120, 100%, 40%);">+*SAME54_XPLAINED_PRO* is the default value.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> The resulting firmware binary is `AtmelStart.bin`.</span><br><span> </span><br><span> Flashing</span><br><span> ========</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-To flash the bootloader you can either use the [edbg tool](https://github.com/ataradov/edbg) over the EDBG interface of the SAM E54 Xplained Pro development board, or OpenICD with any SWJ adapter.</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> The USB DFU bootloader should be flashed in a protected area of the flash memory to prevent for erasing it, as specified in data sheet section 25.6.2 Memory Organization.</span><br><span> The bootloader size is configured in the NVM user configuration BOOTPROT field, as specified in data sheet section 25.6.9 NVM User Configuration.</span><br><span> The bit position of the BOOTPROT field is documented in data sheet section 9.4 NVM User Page Mapping.</span><br><span>@@ -43,8 +55,26 @@</span><br><span> EDBG</span><br><span> ----</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+To flash the bootloader using the [edbg tool](https://github.com/ataradov/edbg) over the EDBG interface of the SAM E54 Xplained Pro development board.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> To flash the USB DFU bootloader, perform the following actions:</span><br><span> * remove reserved bootloader space so we can erase it: `edbg --target atmel_cm4v2 --fuse wv,29:26,15`</span><br><span> * erase the whole flash: `edbg --target atmel_cm4v2 --fuse v,29:26,15 --erase`</span><br><span> * program the bootloader: `edbg --target atmel_cm4v2 --fuse v,29:26,15 --program --verify --file AtmelStart.bin`</span><br><span> * reserve bootloader space: `edbg --target atmel_cm4v2 --fuse wv,29:26,13`</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+SWJ</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The bootloader can also be flashed over SWJ (e.g. JTAG or SWD).</span><br><span style="color: hsl(120, 100%, 40%);">+You need to perform the following actions:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* remove reserved bootloader space so we can erase it (and reset MCU for change to be effective)</span><br><span style="color: hsl(120, 100%, 40%);">+* erase the whole flash</span><br><span style="color: hsl(120, 100%, 40%);">+* program the bootloader</span><br><span style="color: hsl(120, 100%, 40%);">+* reserve bootloader space</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Using OpenOCD (with the [SAM E54 patch](http://openocd.zylin.com/#/c/4272/)) and a ST-LINK/V2 SWD adapter, run the following command:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+`openocd --file interface/stlink.cfg --command "transport select hla_swd" --command "set CHIPNAME same54" --command "set CPUTAPID 0x2ba01477" --file target/atsame5x.cfg --command "init" --command "reset halt" --command "atsame5 bootloader 0" --command "flash erase_sector 0 0 last" --command "reset halt" --command "program ./AtmelStart.bin" --command "atsame5 bootloader 16384"  --command "reset run" --command "shutdown"`</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/atmel_start_pins.h b/atmel_start_pins.h</span><br><span>index 86e1dfb..220a7b5 100644</span><br><span>--- a/atmel_start_pins.h</span><br><span>+++ b/atmel_start_pins.h</span><br><span>@@ -27,11 +27,19 @@</span><br><span> #define GPIO_PIN_FUNCTION_M 12</span><br><span> #define GPIO_PIN_FUNCTION_N 13</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/** LED pin to indicate system state (pull low to switch on) */</span><br><span style="color: hsl(120, 100%, 40%);">+/** LED pin to indicate system state */</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SAME54_XPLAINED_PRO)</span><br><span> #define LED_SYSTEM GPIO(GPIO_PORTC, 18)</span><br><span style="color: hsl(120, 100%, 40%);">+#elif defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define LED_SYSTEM GPIO(GPIO_PORTC, 26)</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/** User button to force DFu bootloader (connected to ground when pressed) */</span><br><span style="color: hsl(120, 100%, 40%);">+/** User button to force DFU bootloader (connected to ground when pressed) */</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SAME54_XPLAINED_PRO)</span><br><span> #define BUTTON_FORCE_DFU GPIO(GPIO_PORTB, 31)</span><br><span style="color: hsl(120, 100%, 40%);">+#elif defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define BUTTON_FORCE_DFU GPIO(GPIO_PORTC, 14)</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> /** USB D+/D- pins */</span><br><span> #define PA24 GPIO(GPIO_PORTA, 24)</span><br><span>diff --git a/config/usbd_config.h b/config/usbd_config.h</span><br><span>index c20dfb2..6133596 100644</span><br><span>--- a/config/usbd_config.h</span><br><span>+++ b/config/usbd_config.h</span><br><span>@@ -85,8 +85,12 @@</span><br><span> // <0x6140=> osmo-ASF4-DFU</span><br><span> // <id> usb_dfud_idproduct</span><br><span> #ifndef CONF_USB_OSMOASF4DFU_IDPRODUCT</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_OSMOASF4DFU_IDPRODUCT 0x6141</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span> #define CONF_USB_OSMOASF4DFU_IDPRODUCT 0x6140</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> // <o> bcdDevice <0x0000-0xFFFF></span><br><span> // <id> usb_dfud_bcddevice</span><br><span>@@ -107,12 +111,20 @@</span><br><span> // <s> Unicode string of iManufact</span><br><span> // <id> usb_dfud_imanufact_str</span><br><span> #ifndef CONF_USB_DFUD_IMANUFACT_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IMANUFACT_STR "sysmocom"</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span> #define CONF_USB_DFUD_IMANUFACT_STR "osmocom"</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> #ifndef CONF_USB_DFUD_IMANUFACT_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IMANUFACT_STR_DESC 18, 0x03, 's', 0x00, 'y', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, 'c', 0x00, 'o', 0x00, 'm', 0x00,</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span> #define CONF_USB_DFUD_IMANUFACT_STR_DESC 16, 0x03, 'o', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, 'c', 0x00, 'o', 0x00, 'm', 0x00,</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> // </e></span><br><span> </span><br><span>@@ -130,12 +142,20 @@</span><br><span> // <s> Unicode string of iProduct</span><br><span> // <id> usb_dfud_iproduct_str</span><br><span> #ifndef CONF_USB_DFUD_IPRODUCT_STR</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IPRODUCT_STR "sysmoOCTSIM (osmo-ASF4-DFU)"</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span> #define CONF_USB_DFUD_IPRODUCT_STR "osmo-ASF4-DFU"</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> #ifndef CONF_USB_DFUD_IPRODUCT_STR_DESC</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+#define CONF_USB_DFUD_IPRODUCT_STR_DESC 56, 0x03, 's', 0x00, 'y', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, 'O', 0x00, 'C', 0x00, 'T', 0x00, 'S', 0x00, 'I', 0x00, 'M', 0x00, ' ', 0x00, '(', 0x00, 'o', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, '-', 0x00, 'A', 0x00, 'S', 0x00, 'F', 0x00, '4', 0x00, '-', 0x00, 'D', 0x00, 'F', 0x00, 'U', 0x00, ')', 0x00,</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span> #define CONF_USB_DFUD_IPRODUCT_STR_DESC 28, 0x03, 'o', 0x00, 's', 0x00, 'm', 0x00, 'o', 0x00, '-', 0x00, 'A', 0x00, 'S', 0x00, 'F', 0x00, '4', 0x00, '-', 0x00, 'D', 0x00, 'F', 0x00, 'U', 0x00,</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span> </span><br><span> // </e></span><br><span> </span><br><span>diff --git a/driver_init.c b/driver_init.c</span><br><span>index a91b0eb..d873230 100644</span><br><span>--- a/driver_init.c</span><br><span>+++ b/driver_init.c</span><br><span>@@ -139,18 +139,38 @@</span><br><span>      flash_init(&FLASH_0, NVMCTRL);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+void LED_SYSTEM_on(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+    gpio_set_pin_level(LED_SYSTEM, true);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+  gpio_set_pin_level(LED_SYSTEM, false);</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void LED_SYSTEM_off(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+#if defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+   gpio_set_pin_level(LED_SYSTEM, false);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+ gpio_set_pin_level(LED_SYSTEM, true);</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void system_init(void)</span><br><span> {</span><br><span>    init_mcu();</span><br><span> </span><br><span>      // configure system LED</span><br><span style="color: hsl(0, 100%, 40%);">- gpio_set_pin_level(LED_SYSTEM, true); // switch off LED</span><br><span style="color: hsl(120, 100%, 40%);">+       LED_SYSTEM_off();</span><br><span>    gpio_set_pin_direction(LED_SYSTEM, GPIO_DIRECTION_OUT);</span><br><span>      gpio_set_pin_function(LED_SYSTEM, GPIO_PIN_FUNCTION_OFF);</span><br><span> </span><br><span>        // configure force DFU user button</span><br><span>   gpio_set_pin_direction(BUTTON_FORCE_DFU, GPIO_DIRECTION_IN);</span><br><span style="color: hsl(0, 100%, 40%);">-    gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP);</span><br><span style="color: hsl(120, 100%, 40%);">+#if !defined(SYSMOOCTSIM)</span><br><span style="color: hsl(120, 100%, 40%);">+    gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP); // use internal pull-up resistor</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span>     gpio_set_pin_function(BUTTON_FORCE_DFU, GPIO_PIN_FUNCTION_OFF);</span><br><span> </span><br><span>  USB_DEVICE_INSTANCE_init();</span><br><span>diff --git a/driver_init.h b/driver_init.h</span><br><span>index 0d440d4..8d8a30b 100644</span><br><span>--- a/driver_init.h</span><br><span>+++ b/driver_init.h</span><br><span>@@ -34,6 +34,15 @@</span><br><span> void FLASH_0_CLOCK_init(void);</span><br><span> </span><br><span> /**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Switch system LED on</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void LED_SYSTEM_on(void);</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Switch system LED off</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void LED_SYSTEM_off(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/**</span><br><span>  * \brief Perform system initialization, initialize pins and clocks for</span><br><span>  * peripherals</span><br><span>  */</span><br><span>diff --git a/gcc/Makefile b/gcc/Makefile</span><br><span>index 16c7858..7ad24b1 100644</span><br><span>--- a/gcc/Makefile</span><br><span>+++ b/gcc/Makefile</span><br><span>@@ -1,4 +1,13 @@</span><br><span> ################################################################################</span><br><span style="color: hsl(120, 100%, 40%);">+# User configuration. Can be edited</span><br><span style="color: hsl(120, 100%, 40%);">+################################################################################</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Set for which board the bootloader should be compiled</span><br><span style="color: hsl(120, 100%, 40%);">+# run `make clean` for the change to be effective</span><br><span style="color: hsl(120, 100%, 40%);">+# possible values: SAME54_XPLAINED_PRO, SYSMOOCTSIM </span><br><span style="color: hsl(120, 100%, 40%);">+BOARD ?= SAME54_XPLAINED_PRO</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+################################################################################</span><br><span> # Automatically-generated file. Do not edit!</span><br><span> ################################################################################</span><br><span> </span><br><span>@@ -202,7 +211,7 @@</span><br><span>      @echo Building file: $<</span><br><span>   @echo ARM/GNU C Compiler</span><br><span>     $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span style="color: hsl(0, 100%, 40%);">--D__SAME54P20A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(120, 100%, 40%);">+-D__SAME54P20A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span> -I"../" -I"../config" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/nvmctrl" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>      @echo Finished building: $<</span><br><span>@@ -211,7 +220,7 @@</span><br><span>         @echo Building file: $<</span><br><span>   @echo ARM/GNU Assembler</span><br><span>      $(QUOTE)arm-none-eabi-as$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span style="color: hsl(0, 100%, 40%);">--D__SAME54P20A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(120, 100%, 40%);">+-D__SAME54P20A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span> -I"../" -I"../config" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/nvmctrl" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>       @echo Finished building: $<</span><br><span>@@ -220,7 +229,7 @@</span><br><span>         @echo Building file: $<</span><br><span>   @echo ARM/GNU Preprocessing Assembler</span><br><span>        $(QUOTE)arm-none-eabi-gcc$(QUOTE) -x c -mthumb -DDEBUG -Os -ffunction-sections -mlong-calls -g3 -Wall -c -std=gnu99 \</span><br><span style="color: hsl(0, 100%, 40%);">--D__SAME54P20A__ -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span style="color: hsl(120, 100%, 40%);">+-D__SAME54P20A__ -D$(BOARD) -mcpu=cortex-m4 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 \</span><br><span> -I"../" -I"../config" -I"../hal/include" -I"../hal/utils/include" -I"../hpl/cmcc" -I"../hpl/core" -I"../hpl/dmac" -I"../hpl/gclk" -I"../hpl/mclk" -I"../hpl/nvmctrl" -I"../hpl/osc32kctrl" -I"../hpl/oscctrl" -I"../hpl/pm" -I"../hpl/port" -I"../hpl/ramecc" -I"../hpl/usb" -I"../hri" -I"../" -I"../config" -I"../usb" -I"../usb/class/dfu" -I"../usb/class/dfu/device" -I"../usb/device" -I"../" -I"../CMSIS/Include" -I"../include"  \</span><br><span> -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"  -o "$@" "$<"</span><br><span>      @echo Finished building: $<</span><br><span>diff --git a/usb_dfu_main.c b/usb_dfu_main.c</span><br><span>index 449b311..96032c5 100644</span><br><span>--- a/usb_dfu_main.c</span><br><span>+++ b/usb_dfu_main.c</span><br><span>@@ -48,7 +48,6 @@</span><br><span>  */</span><br><span> static bool check_force_dfu(void)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-        gpio_set_pin_pull_mode(BUTTON_FORCE_DFU, GPIO_PULL_UP); // pull button high</span><br><span>  return (0 == gpio_get_pin_level(BUTTON_FORCE_DFU)); // signal is low when button is pressed</span><br><span> }</span><br><span> </span><br><span>diff --git a/usb_start.c b/usb_start.c</span><br><span>index ad91840..93059ad 100644</span><br><span>--- a/usb_start.c</span><br><span>+++ b/usb_start.c</span><br><span>@@ -80,7 +80,7 @@</span><br><span> void usb_dfu(void)</span><br><span> {</span><br><span>         while (!dfudf_is_enabled()); // wait for DFU to be installed</span><br><span style="color: hsl(0, 100%, 40%);">-    gpio_set_pin_level(LED_SYSTEM, false); // switch LED on to indicate USB DFU stack is ready</span><br><span style="color: hsl(120, 100%, 40%);">+    LED_SYSTEM_on(); // switch LED on to indicate USB DFU stack is ready</span><br><span> </span><br><span>     ASSERT(hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw) <= 15);</span><br><span>        uint32_t application_start_address = (15 - hri_nvmctrl_read_STATUS_BOOTPROT_bf(FLASH_0.dev.hw)) * 8192; // calculate bootloader size to know where we should write the application firmware</span><br><span>@@ -89,7 +89,7 @@</span><br><span>      while (true) { // main DFU infinite loop</span><br><span>             // run the second part of the USB DFU state machine handling non-USB aspects</span><br><span>                 if (USB_DFU_STATE_DFU_DNLOAD_SYNC == dfu_state || USB_DFU_STATE_DFU_DNBUSY == dfu_state) { // there is some data to be flashed</span><br><span style="color: hsl(0, 100%, 40%);">-                  gpio_set_pin_level(LED_SYSTEM, true); // switch LED off to indicate we are flashing</span><br><span style="color: hsl(120, 100%, 40%);">+                   LED_SYSTEM_off(); // switch LED off to indicate we are flashing</span><br><span>                      if (dfu_download_length > 0) { // there is some data to be flashed</span><br><span>                                int32_t rc = flash_write(&FLASH_0, application_start_address + dfu_download_offset, dfu_download_data, dfu_download_length); // write downloaded data chunk to flash</span><br><span>                             if (ERR_NONE == rc) {</span><br><span>@@ -108,7 +108,7 @@</span><br><span>                          // this case should not happen, but it's not a critical error</span><br><span>                            dfu_state = USB_DFU_STATE_DFU_DNLOAD_IDLE; // indicate flashing can continue</span><br><span>                         }</span><br><span style="color: hsl(0, 100%, 40%);">-                       gpio_set_pin_level(LED_SYSTEM, false); // switch LED on to indicate USB DFU can resume</span><br><span style="color: hsl(120, 100%, 40%);">+                        LED_SYSTEM_on(); // switch LED on to indicate USB DFU can resume</span><br><span>             }</span><br><span>            if (USB_DFU_STATE_DFU_MANIFEST == dfu_state) { // we can start manifestation (finish flashing)</span><br><span>                       // in theory every DFU files should have a suffix to with a CRC to check the data</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/12910">change 12910</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/12910"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-asf4-dfu </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ie51a3af7c77ba76ac40570b871f31fd527fb255b </div>
<div style="display:none"> Gerrit-Change-Number: 12910 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Kévin Redon <kredon@sysmocom.de> </div>