{"id":13830727,"url":"https://github.com/devanlai/dapboot","last_synced_at":"2025-07-09T12:31:15.823Z","repository":{"id":43330751,"uuid":"57870079","full_name":"devanlai/dapboot","owner":"devanlai","description":"DFU Bootloader for STM32 chips","archived":false,"fork":false,"pushed_at":"2024-01-28T17:07:53.000Z","size":148,"stargazers_count":327,"open_issues_count":12,"forks_count":109,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-08-04T10:03:49.226Z","etag":null,"topics":["bootloader","dfu","stm32"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devanlai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-02T06:30:00.000Z","updated_at":"2024-08-04T10:03:54.602Z","dependencies_parsed_at":"2024-01-06T23:57:24.581Z","dependency_job_id":"8056598d-1e33-46ce-b33e-595e0830d025","html_url":"https://github.com/devanlai/dapboot","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devanlai%2Fdapboot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devanlai%2Fdapboot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devanlai%2Fdapboot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devanlai%2Fdapboot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devanlai","download_url":"https://codeload.github.com/devanlai/dapboot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225539508,"owners_count":17485342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bootloader","dfu","stm32"],"created_at":"2024-08-04T10:01:06.772Z","updated_at":"2024-11-20T11:31:14.338Z","avatar_url":"https://github.com/devanlai.png","language":"C","funding_links":[],"categories":["MCU programming","C"],"sub_categories":["STM32"],"readme":"# dapboot\nThe dapboot project is an open-source USB [Device Firmware Upgrade](http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf) (DFU) bootloader for STM32 devices.\n\nCurrently, the only targets officially supported are the STM32F103x series.\n\n## Build instructions\nThe default target is a generic STM32F103 dev board with an LED on PC13, commonly referred to as a \"bluepill\" board.\n\nTo build other targets, you can override the\n`TARGET` variable when invoking `make`.\n\n    cd src/\n    make clean\n    make TARGET=STLINK\n\n### Targets\n\n| Target Name | Description | Link |\n| ----------- | ----------- |----- |\n|`BLUEPILL`   | Cheap dev board | https://stm32duinoforum.com/forum/wiki_subdomain/index_title_Blue_Pill.html |\n|`MAPLEMINI`  | LeafLabs Maple Mini board and clone derivatives | https://stm32duinoforum.com/forum/wiki_subdomain/index_title_Maple_Mini.html |\n|`STLINK`     | STLink/v2 hardware clones | https://wiki.paparazziuav.org/wiki/STLink#Clones |\n|`OLIMEXSTM32H103` | Olimex STM32-H103 | https://www.olimex.com/Products/ARM/ST/STM32-H103/ |\n|`BLUEPILLPLUSSTM32` | Bluepill with USB C | https://github.com/WeActTC/BluePill-Plus/ |\n|`BTTSKRMINIE3V2` | BigTreeTech SKR MINI E3 V2.0 (3D printer motherboard) | https://github.com/bigtreetech/BIGTREETECH-SKR-mini-E3 |\n\nFor the above targets there are some potential variants that can be added to the target name based on what the target supports:\n\n| Target Variant | Description                                             |\n| -------------- | ------------------------------------------------------- |\n|` `             | Standard bootloader, using first 8 KiB of flash         |\n|`_HIGH`         | High memory bootloader for 64 KiB chips  (experimental) |\n|`_HIGH_128`     | High memory bootloader for 128 KiB chips (experimental) |\n|`_HIGH_256`     | High memory bootloader for 256 KiB chips (experimental) |\n\nThe high memory bootloader is a variation that doesn't require the application to be at an offset, the bootloader resides in the top 7 KiB of ROM and hides its reset and stack vectors inside unused entries of the application vector table. As an example, to compile for a Bluepill board with 128 KiB flash, use:\n\n    make clean\n    make TARGET=BLUEPILL_HIGH_128\n\n\n## Flash instructions\nThe `make flash` target will use openocd to upload the bootloader to an attached board. By default, the Makefile assumes you're using a [CMSIS-DAP](http://www.arm.com/products/processors/cortex-m/cortex-microcontroller-software-interface-standard.php) based probe, but you can override this by overriding `OOCD_INTERFACE` variable. For example:\n\n    make OOCD_INTERFACE=interface/stlink-v2.cfg flash\n\n## Overriding defaults\nLocal makefile settings can be set by creating a `local.mk`, which is automatically included.\n\nHere is an example `local.mk` that changes the default target to the STLink/v2 and uses an unmodified STLink/v2 to flash it.\n\n    TARGET ?= STLINK\n    OOCD_INTERFACE ?= interface/stlink-v2.cfg\n\nYou can also use the env variable `DEFS` to override default configuration for a target, like:\n\n    # Disable LED on BluePill\n    DEFS=\"-DHAVE_LED=0\" make TARGET=BLUEPILL\n\n    # Allow access to all Flash on MapleMini and change the app base address\n    DEFS=\"-DFLASH_SIZE_OVERRIDE=0x20000 -DAPP_BASE_ADDRESS=0x08004000\" make TARGET=MAPLEMINI LDSCRIPT=\"/some/folder/stm32f103x8-16kb-boot.ld\"\n\n## Using the bootloader\n### Building for the bootloader\nThe standard bootloader occupies the lower 8KiB of flash, so your application must offset its flash contents by 8KiB. This can be done by modifying your linker script or flags as appropriate.\n\nThe high memory bootloaders do not use the lower part of the flash, so you only need to make sure your application leaves 7 KiB of flash free.\n\n\n### Switching to the bootloader\nThe bootloader can be built to look for arbitrary patterns, but the default looks for a magic value stored in the RTC backup registers. Writing the magic value and then resetting will run the bootloader instead of the main application.\n\nIn version v1.11 and earlier, the bootloader for STM32F103 targets looks for `0x544F` in RTC backup register 2 and `0x4F42` in RTC backup register 1 (together they spell \"BOOT\" in ASCII). From v1.20 on, the bootloader will only use RTC backup register 1 and check for `0x4F42` on targets with 16-bit backup registers and `0x544F4F42` on targets with 32-bit backup registers.\n\nThe backup register and bootloader command word can be customized with the `REG_BOOT` and `CMD_BOOT` defines respectively.\n\nYou can also use a button to stay in bootloader while booting. It's configured using `HAVE_BUTTON` define. If your button has a debounce capacitor, you can use `BUTTON_SAMPLE_DELAY_CYCLES` define to specify how many cycles to wait before sampling the I/O pin, by default it is approximately 20ms in a 72Mhz MCU.\n\nOn the bluepill boards, the default is using the BOOT1 input (available on jumper in the board) to enter the bootloader.\n\n### WebUSB\nThis bootloader implements the draft [WebUSB](https://wicg.github.io/webusb/) specification, which allows web pages to access the bootloader (after presenting the user with a device picker dialog).\n\nFor a demo implementing dfu-util features in the browser, see https://devanlai.github.io/webdfu/dfu-util/\n\nTo customize the WebUSB landing page, you can use the `LANDING_PAGE_URL` define. To set it from the command line, you can use the `DEFS` environment variable:\n\n    DEFS='-DLANDING_PAGE_URL=\\\"example.com/dfu-util/\\\"' make\n\nNote that the URL scheme shoul not be part of the `LANDING_PAGE_URL` string. As of this writing, it is hardcoded to HTTPS. \n\n### Manifestation behavior\nThere are two different manifestation behaviors that can be selected using the `DFU_WILL_DETACH` define. By default, `DFU_WILL_DETACH` is set to 1 for backwards compatibility with existing behavior.\n\nWhen `DFU_WILL_DETACH` is enabled, the bootloader autonomously reboot into the new firmware after it has been successfully downloaded and passes the basic validation check. This can be helpful on platforms such as Windows where it is not possible to generate a USB bus reset to signal that the bootloader should switch to the application.\n\nWhen `DFU_WILL_DETACH` is disabled, the bootloader will return to the idle state after validating the firmware. The DFU host application can then perform other operations or reboot the target into the new firmware by issuing a DFU detach request or generating a USB bus reset. (This can be done with `dfu-util` by passing the `-R` flag).\n\n## USB VID/PID\nThe default USB VID/PID pair ([1209/DB42](http://pid.codes/1209/DB42/)) is allocated through the [pid.codes](http://pid.codes/) open-source USB PID program.\n\nTo use a custom VID/PID pair, you need to set the macros `USB_VID` and `USB_PID`. One way to do this is by setting the `DEFS` environment variable when compiling:\n\n     DEFS=\"-DUSB_VID=0x1209 -DUSB_PID=0xCAFE\" make\n\n\n## USB Vendor, Product, and Interface strings\n\nTo customize the USB vendor, product, and interface strings that DAPBoot reports to the USB host, you may set the macros `USB_VENDOR_STRING`, `USB_PRODUCT_STRING`, and `USB_INTERFACE_STRING`, respectively. You can do this by setting the `DEFS` environment variable or including these macros in your board's `config.h`\n\n\n## Licensing\nAll contents of the dapboot project are licensed under terms that are compatible with the terms of the GNU Lesser General Public License version 3.\n\nNon-libopencm3 related portions of the dapboot project are licensed under the less restrictive ISC license, except where otherwise specified in the headers of specific files.\n\nSee the LICENSE file for full details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevanlai%2Fdapboot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevanlai%2Fdapboot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevanlai%2Fdapboot/lists"}