|
| 1 | +/* |
| 2 | + * Copyright (c) 2021, Dennis Marttinen |
| 3 | + * |
| 4 | + * Permission to use, copy, modify, and/or distribute this software |
| 5 | + * for any purpose with or without fee is hereby granted, provided |
| 6 | + * that the above copyright notice and this permission notice |
| 7 | + * appear in all copies. |
| 8 | + * |
| 9 | + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR |
| 13 | + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 14 | + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
| 15 | + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
| 16 | + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 17 | + */ |
| 18 | + |
| 19 | +/* |
| 20 | + * ATTENTION! Using the USBMOD target requires hardware modifications to your BTT SKR MINI E3 V2.0. These modifications |
| 21 | + * aim to restore the broken SWD debugging support of this board by removing "unnecessary" components attached to the |
| 22 | + * SWDIO and SWDCLK pins. Read the comments carefully, and proceed at your own risk! Flashing this firmware on an |
| 23 | + * unmodified SKR MINI will not harm it, but USB will not work in the bootloader. Here's the schematic for the board for |
| 24 | + * looking up the component identifiers mentioned in the comments: |
| 25 | + * https://github.com/bigtreetech/BIGTREETECH-SKR-mini-E3/blob/master/hardware/BTT%20SKR%20MINI%20E3%20V2.0/Hardware/BTT%20SKR%20MINI%20E3%20V2.0SCHpdf.PDF |
| 26 | + */ |
| 27 | + |
| 28 | +#ifndef CONFIG_H_INCLUDED |
| 29 | +#define CONFIG_H_INCLUDED |
| 30 | + |
| 31 | +#ifndef APP_BASE_ADDRESS |
| 32 | +#define APP_BASE_ADDRESS (0x08000000 + BOOTLOADER_OFFSET) |
| 33 | +#endif |
| 34 | +#ifndef FLASH_PAGE_SIZE |
| 35 | +/* The BTT SKR MINI E3 V2.0 uses an STM32F103RC with 256 KiB of flash and 2 KiB pages */ |
| 36 | +#define FLASH_PAGE_SIZE 2048 |
| 37 | +#endif |
| 38 | +#ifndef DFU_UPLOAD_AVAILABLE |
| 39 | +#define DFU_UPLOAD_AVAILABLE 1 |
| 40 | +#endif |
| 41 | +#ifndef DFU_DOWNLOAD_AVAILABLE |
| 42 | +#define DFU_DOWNLOAD_AVAILABLE 1 |
| 43 | +#endif |
| 44 | +#ifndef DFU_WILL_DETACH |
| 45 | +#define DFU_WILL_DETACH 0 |
| 46 | +#endif |
| 47 | + |
| 48 | +/* There is a PCB-mounted status LED, but it's unreadable when the board is installed, and additionally it's wired to |
| 49 | + * SWDIO so toggling it manually is a bad idea. To restore reliable SWD communication, desolder either the status LED |
| 50 | + * itself (D16) or the resistor for it (R90). */ |
| 51 | +#ifndef HAVE_LED |
| 52 | +#define HAVE_LED 0 |
| 53 | +#endif |
| 54 | + |
| 55 | +/* Display encoder button (BTN-ENC) on PA15, no external pullup */ |
| 56 | +#ifndef HAVE_BUTTON |
| 57 | +#define HAVE_BUTTON 1 |
| 58 | +#endif |
| 59 | +#ifndef BUTTON_ACTIVE_HIGH |
| 60 | +#define BUTTON_ACTIVE_HIGH 0 |
| 61 | +#endif |
| 62 | +#ifndef BUTTON_GPIO_PORT |
| 63 | +#define BUTTON_GPIO_PORT GPIOA |
| 64 | +#endif |
| 65 | +#ifndef BUTTON_GPIO_PIN |
| 66 | +#define BUTTON_GPIO_PIN GPIO15 |
| 67 | +#endif |
| 68 | +#ifndef BUTTON_USES_PULL |
| 69 | +#define BUTTON_USES_PULL 1 |
| 70 | +#endif |
| 71 | +#ifndef BUTTON_SAMPLE_DELAY_CYCLES |
| 72 | +#define BUTTON_SAMPLE_DELAY_CYCLES 1440000 |
| 73 | +#endif |
| 74 | + |
| 75 | +/* The USB pullup MOSFET (U7) with its pullup resistor (R43) is wired to SWCLK on this board which makes attaching a |
| 76 | + * debug probe nearly impossible. It is however possible to desolder these two components and bridge the source and |
| 77 | + * drain contact pads for the MOSFET to gain debugger support. The [datasheet] for the MCU suggests that the pullup |
| 78 | + * resistor for the USB D+ pin (R44) is enough on its own, as the MCU itself can pull the pin down to initiate a USB |
| 79 | + * reset without an external MOSFET controlling that resistor. This does indeed work without any configuration in |
| 80 | + * dapboot as well as both the Klipper and Marlin 3D printer firmwares. There were no problems during testing when |
| 81 | + * performing software resets or using the reset button, the USB reset works seamlessly even when transitioning from |
| 82 | + * dapboot to a freshly flashed firmware. |
| 83 | + * [datasheet]: https://www.st.com/resource/en/datasheet/stm32f103rc.pdf */ |
| 84 | +#ifndef HAVE_USB_PULLUP_CONTROL |
| 85 | +#define HAVE_USB_PULLUP_CONTROL 0 |
| 86 | +#endif |
| 87 | + |
| 88 | +#ifndef USES_GPIOA |
| 89 | +#define USES_GPIOA 1 |
| 90 | +#endif |
| 91 | + |
| 92 | +/* For stm32duino bootloader compatibility, the following options enable |
| 93 | + * bootloader flashing using KIAUH: https://github.com/th33xitus/kiauh */ |
| 94 | +#ifndef REG_BOOT |
| 95 | +#define REG_BOOT BKP10 |
| 96 | +#endif |
| 97 | + |
| 98 | +#ifndef CMD_BOOT |
| 99 | +#define CMD_BOOT 1 |
| 100 | +#endif |
| 101 | + |
| 102 | +#ifndef USB_DFU_ALTN |
| 103 | +#define USB_DFU_ALTN 2 |
| 104 | +#endif |
| 105 | + |
| 106 | +#endif |
0 commit comments