Demo of the usage USBDevice library with Blue Pill STM32F103C8T6 board.
STM32F103C8T6 USBSerial Demo
This project contains demo of the USB serial usage for a cheap developer board Blue Pill with STM32F103C8T6 mcu.
The USB serial port provides a good communication channel between PC and microcontroller. Especially it can be useful for a debug purposes.
Notes
- by the specifications this board has only 64KB of the flash, but actually it can have 128KB, that will be useful for a debug builds as it requires about 100KB of the flash for this demo.
- the board can have some problems with an USB because it has wrong value of the pull-up resistor
- for steady reading of data from a serial port, the project contains python script serial_reader.py (it requires PySerial and six python libraries), that is steady to the board reloading
- the project depends on the fork of the USBDevice library. This fork contains some fixes and support of the BLUE_PILL_STM32F103C8 target.
- the mbed-os now contains correct code for a clock initialization of the BLUE_PILL_STM32F103C8 target, so you don't need to adjust the board clocks separately
patches/STM32F103C8T6_128KB.ld@0:24604e97c40c, 2017-08-04 (annotated)
- Committer:
- Konstantin Kochin
- Date:
- Fri Aug 04 18:41:22 2017 +0300
- Revision:
- 0:24604e97c40c
Initial release
The project contains autogenerated makefile for a debug build,
the program itself (main.cpp) and the helper python script
'serial_reader.py' to read a data from a serial port.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Konstantin Kochin |
0:24604e97c40c | 1 | /* Linker script for Blue Pill STM32F103C8T6 with 128KB flash memory. */ |
Konstantin Kochin |
0:24604e97c40c | 2 | /* Linker script to configure memory regions. */ |
Konstantin Kochin |
0:24604e97c40c | 3 | MEMORY |
Konstantin Kochin |
0:24604e97c40c | 4 | { |
Konstantin Kochin |
0:24604e97c40c | 5 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K |
Konstantin Kochin |
0:24604e97c40c | 6 | RAM (rwx) : ORIGIN = 0x200000EC, LENGTH = 20K - 0xEC |
Konstantin Kochin |
0:24604e97c40c | 7 | } |
Konstantin Kochin |
0:24604e97c40c | 8 | |
Konstantin Kochin |
0:24604e97c40c | 9 | /* Linker script to place sections and symbol values. Should be used together |
Konstantin Kochin |
0:24604e97c40c | 10 | * with other linker script that defines memory regions FLASH and RAM. |
Konstantin Kochin |
0:24604e97c40c | 11 | * It references following symbols, which must be defined in code: |
Konstantin Kochin |
0:24604e97c40c | 12 | * Reset_Handler : Entry of reset handler |
Konstantin Kochin |
0:24604e97c40c | 13 | * |
Konstantin Kochin |
0:24604e97c40c | 14 | * It defines following symbols, which code can use without definition: |
Konstantin Kochin |
0:24604e97c40c | 15 | * __exidx_start |
Konstantin Kochin |
0:24604e97c40c | 16 | * __exidx_end |
Konstantin Kochin |
0:24604e97c40c | 17 | * __etext |
Konstantin Kochin |
0:24604e97c40c | 18 | * __data_start__ |
Konstantin Kochin |
0:24604e97c40c | 19 | * __preinit_array_start |
Konstantin Kochin |
0:24604e97c40c | 20 | * __preinit_array_end |
Konstantin Kochin |
0:24604e97c40c | 21 | * __init_array_start |
Konstantin Kochin |
0:24604e97c40c | 22 | * __init_array_end |
Konstantin Kochin |
0:24604e97c40c | 23 | * __fini_array_start |
Konstantin Kochin |
0:24604e97c40c | 24 | * __fini_array_end |
Konstantin Kochin |
0:24604e97c40c | 25 | * __data_end__ |
Konstantin Kochin |
0:24604e97c40c | 26 | * __bss_start__ |
Konstantin Kochin |
0:24604e97c40c | 27 | * __bss_end__ |
Konstantin Kochin |
0:24604e97c40c | 28 | * __end__ |
Konstantin Kochin |
0:24604e97c40c | 29 | * end |
Konstantin Kochin |
0:24604e97c40c | 30 | * __HeapLimit |
Konstantin Kochin |
0:24604e97c40c | 31 | * __StackLimit |
Konstantin Kochin |
0:24604e97c40c | 32 | * __StackTop |
Konstantin Kochin |
0:24604e97c40c | 33 | * __stack |
Konstantin Kochin |
0:24604e97c40c | 34 | * _estack |
Konstantin Kochin |
0:24604e97c40c | 35 | */ |
Konstantin Kochin |
0:24604e97c40c | 36 | ENTRY(Reset_Handler) |
Konstantin Kochin |
0:24604e97c40c | 37 | |
Konstantin Kochin |
0:24604e97c40c | 38 | SECTIONS |
Konstantin Kochin |
0:24604e97c40c | 39 | { |
Konstantin Kochin |
0:24604e97c40c | 40 | .text : |
Konstantin Kochin |
0:24604e97c40c | 41 | { |
Konstantin Kochin |
0:24604e97c40c | 42 | KEEP(*(.isr_vector)) |
Konstantin Kochin |
0:24604e97c40c | 43 | *(.text*) |
Konstantin Kochin |
0:24604e97c40c | 44 | KEEP(*(.init)) |
Konstantin Kochin |
0:24604e97c40c | 45 | KEEP(*(.fini)) |
Konstantin Kochin |
0:24604e97c40c | 46 | |
Konstantin Kochin |
0:24604e97c40c | 47 | /* .ctors */ |
Konstantin Kochin |
0:24604e97c40c | 48 | *crtbegin.o(.ctors) |
Konstantin Kochin |
0:24604e97c40c | 49 | *crtbegin?.o(.ctors) |
Konstantin Kochin |
0:24604e97c40c | 50 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) |
Konstantin Kochin |
0:24604e97c40c | 51 | *(SORT(.ctors.*)) |
Konstantin Kochin |
0:24604e97c40c | 52 | *(.ctors) |
Konstantin Kochin |
0:24604e97c40c | 53 | |
Konstantin Kochin |
0:24604e97c40c | 54 | /* .dtors */ |
Konstantin Kochin |
0:24604e97c40c | 55 | *crtbegin.o(.dtors) |
Konstantin Kochin |
0:24604e97c40c | 56 | *crtbegin?.o(.dtors) |
Konstantin Kochin |
0:24604e97c40c | 57 | *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) |
Konstantin Kochin |
0:24604e97c40c | 58 | *(SORT(.dtors.*)) |
Konstantin Kochin |
0:24604e97c40c | 59 | *(.dtors) |
Konstantin Kochin |
0:24604e97c40c | 60 | |
Konstantin Kochin |
0:24604e97c40c | 61 | *(.rodata*) |
Konstantin Kochin |
0:24604e97c40c | 62 | |
Konstantin Kochin |
0:24604e97c40c | 63 | KEEP(*(.eh_frame*)) |
Konstantin Kochin |
0:24604e97c40c | 64 | } > FLASH |
Konstantin Kochin |
0:24604e97c40c | 65 | |
Konstantin Kochin |
0:24604e97c40c | 66 | .ARM.extab : |
Konstantin Kochin |
0:24604e97c40c | 67 | { |
Konstantin Kochin |
0:24604e97c40c | 68 | *(.ARM.extab* .gnu.linkonce.armextab.*) |
Konstantin Kochin |
0:24604e97c40c | 69 | } > FLASH |
Konstantin Kochin |
0:24604e97c40c | 70 | |
Konstantin Kochin |
0:24604e97c40c | 71 | __exidx_start = .; |
Konstantin Kochin |
0:24604e97c40c | 72 | .ARM.exidx : |
Konstantin Kochin |
0:24604e97c40c | 73 | { |
Konstantin Kochin |
0:24604e97c40c | 74 | *(.ARM.exidx* .gnu.linkonce.armexidx.*) |
Konstantin Kochin |
0:24604e97c40c | 75 | } > FLASH |
Konstantin Kochin |
0:24604e97c40c | 76 | __exidx_end = .; |
Konstantin Kochin |
0:24604e97c40c | 77 | |
Konstantin Kochin |
0:24604e97c40c | 78 | __etext = .; |
Konstantin Kochin |
0:24604e97c40c | 79 | _sidata = .; |
Konstantin Kochin |
0:24604e97c40c | 80 | |
Konstantin Kochin |
0:24604e97c40c | 81 | .data : AT (__etext) |
Konstantin Kochin |
0:24604e97c40c | 82 | { |
Konstantin Kochin |
0:24604e97c40c | 83 | __data_start__ = .; |
Konstantin Kochin |
0:24604e97c40c | 84 | _sdata = .; |
Konstantin Kochin |
0:24604e97c40c | 85 | *(vtable) |
Konstantin Kochin |
0:24604e97c40c | 86 | *(.data*) |
Konstantin Kochin |
0:24604e97c40c | 87 | |
Konstantin Kochin |
0:24604e97c40c | 88 | . = ALIGN(4); |
Konstantin Kochin |
0:24604e97c40c | 89 | /* preinit data */ |
Konstantin Kochin |
0:24604e97c40c | 90 | PROVIDE_HIDDEN (__preinit_array_start = .); |
Konstantin Kochin |
0:24604e97c40c | 91 | KEEP(*(.preinit_array)) |
Konstantin Kochin |
0:24604e97c40c | 92 | PROVIDE_HIDDEN (__preinit_array_end = .); |
Konstantin Kochin |
0:24604e97c40c | 93 | |
Konstantin Kochin |
0:24604e97c40c | 94 | . = ALIGN(4); |
Konstantin Kochin |
0:24604e97c40c | 95 | /* init data */ |
Konstantin Kochin |
0:24604e97c40c | 96 | PROVIDE_HIDDEN (__init_array_start = .); |
Konstantin Kochin |
0:24604e97c40c | 97 | KEEP(*(SORT(.init_array.*))) |
Konstantin Kochin |
0:24604e97c40c | 98 | KEEP(*(.init_array)) |
Konstantin Kochin |
0:24604e97c40c | 99 | PROVIDE_HIDDEN (__init_array_end = .); |
Konstantin Kochin |
0:24604e97c40c | 100 | |
Konstantin Kochin |
0:24604e97c40c | 101 | |
Konstantin Kochin |
0:24604e97c40c | 102 | . = ALIGN(4); |
Konstantin Kochin |
0:24604e97c40c | 103 | /* finit data */ |
Konstantin Kochin |
0:24604e97c40c | 104 | PROVIDE_HIDDEN (__fini_array_start = .); |
Konstantin Kochin |
0:24604e97c40c | 105 | KEEP(*(SORT(.fini_array.*))) |
Konstantin Kochin |
0:24604e97c40c | 106 | KEEP(*(.fini_array)) |
Konstantin Kochin |
0:24604e97c40c | 107 | PROVIDE_HIDDEN (__fini_array_end = .); |
Konstantin Kochin |
0:24604e97c40c | 108 | |
Konstantin Kochin |
0:24604e97c40c | 109 | KEEP(*(.jcr*)) |
Konstantin Kochin |
0:24604e97c40c | 110 | . = ALIGN(4); |
Konstantin Kochin |
0:24604e97c40c | 111 | /* All data end */ |
Konstantin Kochin |
0:24604e97c40c | 112 | __data_end__ = .; |
Konstantin Kochin |
0:24604e97c40c | 113 | _edata = .; |
Konstantin Kochin |
0:24604e97c40c | 114 | |
Konstantin Kochin |
0:24604e97c40c | 115 | } > RAM |
Konstantin Kochin |
0:24604e97c40c | 116 | |
Konstantin Kochin |
0:24604e97c40c | 117 | .bss : |
Konstantin Kochin |
0:24604e97c40c | 118 | { |
Konstantin Kochin |
0:24604e97c40c | 119 | . = ALIGN(4); |
Konstantin Kochin |
0:24604e97c40c | 120 | __bss_start__ = .; |
Konstantin Kochin |
0:24604e97c40c | 121 | _sbss = .; |
Konstantin Kochin |
0:24604e97c40c | 122 | *(.bss*) |
Konstantin Kochin |
0:24604e97c40c | 123 | *(COMMON) |
Konstantin Kochin |
0:24604e97c40c | 124 | . = ALIGN(4); |
Konstantin Kochin |
0:24604e97c40c | 125 | __bss_end__ = .; |
Konstantin Kochin |
0:24604e97c40c | 126 | _ebss = .; |
Konstantin Kochin |
0:24604e97c40c | 127 | } > RAM |
Konstantin Kochin |
0:24604e97c40c | 128 | |
Konstantin Kochin |
0:24604e97c40c | 129 | .heap (COPY): |
Konstantin Kochin |
0:24604e97c40c | 130 | { |
Konstantin Kochin |
0:24604e97c40c | 131 | __end__ = .; |
Konstantin Kochin |
0:24604e97c40c | 132 | end = __end__; |
Konstantin Kochin |
0:24604e97c40c | 133 | *(.heap*) |
Konstantin Kochin |
0:24604e97c40c | 134 | __HeapLimit = .; |
Konstantin Kochin |
0:24604e97c40c | 135 | } > RAM |
Konstantin Kochin |
0:24604e97c40c | 136 | |
Konstantin Kochin |
0:24604e97c40c | 137 | /* .stack_dummy section doesn't contains any symbols. It is only |
Konstantin Kochin |
0:24604e97c40c | 138 | * used for linker to calculate size of stack sections, and assign |
Konstantin Kochin |
0:24604e97c40c | 139 | * values to stack symbols later */ |
Konstantin Kochin |
0:24604e97c40c | 140 | .stack_dummy (COPY): |
Konstantin Kochin |
0:24604e97c40c | 141 | { |
Konstantin Kochin |
0:24604e97c40c | 142 | *(.stack*) |
Konstantin Kochin |
0:24604e97c40c | 143 | } > RAM |
Konstantin Kochin |
0:24604e97c40c | 144 | |
Konstantin Kochin |
0:24604e97c40c | 145 | /* Set stack top to end of RAM, and stack limit move down by |
Konstantin Kochin |
0:24604e97c40c | 146 | * size of stack_dummy section */ |
Konstantin Kochin |
0:24604e97c40c | 147 | __StackTop = ORIGIN(RAM) + LENGTH(RAM); |
Konstantin Kochin |
0:24604e97c40c | 148 | _estack = __StackTop; |
Konstantin Kochin |
0:24604e97c40c | 149 | __StackLimit = __StackTop - SIZEOF(.stack_dummy); |
Konstantin Kochin |
0:24604e97c40c | 150 | PROVIDE(__stack = __StackTop); |
Konstantin Kochin |
0:24604e97c40c | 151 | |
Konstantin Kochin |
0:24604e97c40c | 152 | /* Check if data + heap + stack exceeds RAM limit */ |
Konstantin Kochin |
0:24604e97c40c | 153 | ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack") |
Konstantin Kochin |
0:24604e97c40c | 154 | } |
Konstantin Kochin |
0:24604e97c40c | 155 |