Skip to content

Commit

Permalink
Added support to High Density F103 devices such as STM32F103RCT6
Browse files Browse the repository at this point in the history
High density F103 devices have a 2kB page size, while LOW and MEDIUM F103 devices have a 1kB page size.
  • Loading branch information
Serasidis committed Aug 30, 2019
1 parent b27e6d1 commit 161fb7d
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 178 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ You might need to reboot or run ```udevadm control --reload-rules``` and replug

### Windows examples:

```D:\STM32_HID_bootloader\cli>make clean``` Clears the previous generated files
```D:\STM32_HID_bootloader\cli>make``` Creates the **hid-flash.exe** file
```[YOUR_HDD_PATH]\STM32_HID_bootloader\cli>make clean``` Clears the previous generated files
```[YOUR_HDD_PATH]\STM32_HID_bootloader\cli>make``` Creates the **hid-flash.exe** file


## Bootloader folder
Expand All @@ -88,19 +88,24 @@ You might need to reboot or run ```udevadm control --reload-rules``` and replug
### Examples:
***STM32F10x***

```D:\STM32_HID_bootloader\bootloader\F1>make clean``` Clears the previous generated files
```D:\STM32_HID_bootloader\bootloader\F1>make``` Creates the **hid_bootloader.bin** file
```[YOUR_HDD_PATH]\STM32_HID_bootloader\bootloader\F1>make clean``` Clears the previous generated files
```[YOUR_HDD_PATH]\STM32_HID_bootloader\bootloader\F1>make generic-pc13``` Creates the **hid_bootloader.bin** file, assigning the LED to pin PC13. Edit the ***make_all.bat*** file to see all supported pin options.


If you want to use a ***High Density Device*** such as ***STM32F103RCT6**, then you have to add an extra argument to the ```make``` command.

**Example:** ```[YOUR_HDD_PATH]\STM32_HID_bootloader\bootloader\F1>make generic-pd2 PAGE_SIZE=2048``` Creates the **hid_bootloader.bin** file, assigning the LED to pin PD2. Edit the ***make_all_hd.bat*** file to see all supported pin options.



***STM32F4xx***

```D:\STM32_HID_bootloader\bootloader\F4>make clean``` Clears the previous generated files
```D:\STM32_HID_bootloader\bootloader\F4>make``` Creates the **hid_bootloader.bin** file
```[YOUR_HDD_PATH]\STM32_HID_bootloader\bootloader\F4>make clean``` Clears the previous generated files
```[YOUR_HDD_PATH]\STM32_HID_bootloader\bootloader\F4>make``` Creates the **hid_bootloader.bin** file

The binary file can be found in:
After compiling, the binary file can be found in:

```D:\STM32_HID_bootloader\bootloader\F4\build\hid_bootloader.bin```
```[YOUR_HDD_PATH]\STM32_HID_bootloader\bootloader\F4\build\hid_bootloader.bin```

### Screenshot

Expand Down
7 changes: 6 additions & 1 deletion bootloader/F1/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ DEVICE = STM32F10X_MD

VECTOR_TABLE_OFFSET = 0x0000

# The default Flash Page size (Sector size) for LOW and MEDIUM STM32F103 devices is 1024 bytes
# High Density STM32F103 devices have 2 kB Flash Page size
PAGE_SIZE = 1024

C_SRCS = Src/main.c Src/usb.c Src/hid.c Src/led.c Src/flash.c

# Be silent per default, but 'make V=1' will show all compiler calls.
Expand Down Expand Up @@ -33,6 +37,7 @@ CFLAGS += -D$(DEVICE)
CFLAGS += -DVECTOR_TABLE_OFFSET=$(VECTOR_TABLE_OFFSET)
CFLAGS += -nostdlib
CFLAGS += $(TARGETFLAGS)
CFLAGS += -DPAGE_SIZE=$(PAGE_SIZE)

LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref
LDFLAGS += -Wl,--gc-sections
Expand Down Expand Up @@ -80,7 +85,7 @@ generic-pb12: $(SRCS) clean gccversion build_generic-pb12 copy_generic-pb12 info
mini-stm32v3: $(SRCS) clean gccversion build_mini-stm32v3 copy_mini-stm32v3 info size

build_maple-mini: TARGETFLAGS= -DTARGET_MAPLE_MINI
build_maple-mini: LINKER_SCRIPT=STM32F103CBT6.ld
build_maple-mini: LINKER_SCRIPT=STM32F103C8T6.ld
build_maple-mini: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin
copy_maple_mini: $(BIN_DIR)
$(ECHO) "COPY $(BIN_DIR)/hid_maple_mini.bin"
Expand Down
139 changes: 0 additions & 139 deletions bootloader/F1/STM32F103CBT6.ld

This file was deleted.

23 changes: 17 additions & 6 deletions bootloader/F1/Src/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,26 @@
/* Flash memory base address */
#define FLASH_BASE_ADDRESS 0x08000000

/* This should be the last page taken by the bootloader */
/* *
* PAGE_SIZE : Flash Page size
* Low and MEDIUM Density F103 devices have 1 kB Flash page
* High Density F103 devices have 2 kB Flash page
*
* PAGEMIN : This should be the last page taken by the bootloader
* (2 * 1024) or (1 * 2048) In any case, the bootloader size is 2048 bytes
*/
#if (PAGE_SIZE == 2048)
#define MIN_PAGE 1
#else
#define MIN_PAGE 2
#endif

/* Maximum packet size */
#define MAX_PACKET_SIZE 8

/* Command size */
#define COMMAND_SIZE 64

/* Page size */
#define PAGE_SIZE 1024

/* Buffer table offsset in PMA memory */
#define BTABLE_OFFSET (0x00)

Expand Down Expand Up @@ -276,10 +284,13 @@ static void HIDUSB_HandleData(uint8_t *data)
PAGE_SIZE / 2);
CurrentPage++;
CurrentPageOffset = 0;
USB_SendData(ENDP1, (uint16_t *) Command,
sizeof (Command));
LED1_OFF;
}

if((CurrentPageOffset == 0)||(CurrentPageOffset == 1024)){
USB_SendData(ENDP1, (uint16_t *) Command,
sizeof (Command));
}
}

void USB_Reset(void)
Expand Down
11 changes: 11 additions & 0 deletions bootloader/F1/make_all_hd.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
make generic-pc13 PAGE_SIZE=2048
make generic-pd2 PAGE_SIZE=2048
make generic-pd1 PAGE_SIZE=2048
make generic-pa1 PAGE_SIZE=2048
make generic-pb9 PAGE_SIZE=2048
make generic-pe2 PAGE_SIZE=2048
make generic-pa9 PAGE_SIZE=2048
make generic-pe5 PAGE_SIZE=2048
make generic-pb7 PAGE_SIZE=2048
make generic-pb0 PAGE_SIZE=2048
make generic-pb12 PAGE_SIZE=2048
24 changes: 0 additions & 24 deletions bootloader/F4/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,33 +169,9 @@ int main(void)

/* USER CODE BEGIN 2 */









static volatile uint32_t current_Page = (USER_CODE_OFFSET / 1024);
static volatile uint16_t currentPageOffset = 0;

















/* USER CODE END 2 */

/* Infinite loop */
Expand Down

0 comments on commit 161fb7d

Please sign in to comment.