Skip to content

Commit d949f64

Browse files
committed
🎉 Init.
0 parents  commit d949f64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+127226
-0
lines changed

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CMakeLists.txt.user
2+
CMakeCache.txt
3+
CMakeFiles
4+
CMakeScripts
5+
Testing
6+
Makefile
7+
cmake_install.cmake
8+
install_manifest.txt
9+
compile_commands.json
10+
CTestTestfile.cmake
11+
_deps
12+
13+
build/

.gitmodules

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

.vscode/c_cpp_properties.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Win32",
5+
"includePath": [
6+
"${workspaceFolder}/**"
7+
],
8+
"windowsSdkVersion": "10.0.17763.0",
9+
"compilerPath": "E:\\Program Files (x86)\\GNU Arm Embedded Toolchain\\10 2020-q4-major\\bin\\arm-none-eabi-gcc.exe",
10+
"cStandard": "c17",
11+
"cppStandard": "c++17",
12+
"intelliSenseMode": "gcc-arm",
13+
"configurationProvider": "ms-vscode.cmake-tools"
14+
}
15+
],
16+
"version": 4
17+
}

.vscode/launch.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// 使用 IntelliSense 了解相关属性。
3+
// 悬停以查看现有属性的描述。
4+
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"cwd": "${workspaceRoot}/my-project",
9+
"executable": "test.elf",
10+
"name": "Debug Microcontroller",
11+
"request": "launch",
12+
"type": "cortex-debug",
13+
"servertype": "jlink",
14+
"device": "STM32F103RC",
15+
}
16+
17+
18+
]
19+
}

CMakeLists.txt

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
cmake_minimum_required(VERSION 3.7)
2+
3+
# specify cross compilers and tools
4+
set(CMAKE_C_COMPILER_WORKS 1)
5+
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
6+
set(CMAKE_CXX_COMPILER_WORKS 1)
7+
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
8+
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
9+
set(CMAKE_AR arm-none-eabi-ar)
10+
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
11+
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
12+
set(CMAKE_PYTHON python)
13+
14+
#Uncomment for hardware floating point
15+
#set(FPU_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
16+
#add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
17+
18+
#Uncomment for software floating point
19+
set(FPU_FLAGS "-mfloat-abi=soft")
20+
21+
set(COMMON_FLAGS
22+
"-mcpu=cortex-m3 ${FPU_FLAGS} -mthumb -mthumb-interwork -ffunction-sections -fdata-sections \
23+
-g -Os -fno-common -fmessage-length=0 -specs=nosys.specs")
24+
25+
set(CMAKE_CXX_FLAGS_INIT "${COMMON_FLAGS} -std=c++11")
26+
set(CMAKE_C_FLAGS_INIT "${COMMON_FLAGS} -std=gnu99")
27+
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-gc-sections,--print-memory-usage")
28+
29+
PROJECT(stm32f1_bootloader C CXX ASM)
30+
set(CMAKE_CXX_STANDARD 11)
31+
# 显示具体命令
32+
# set(CMAKE_VERBOSE_MAKEFILE ON)
33+
34+
if(${stm32f1_bootloader_SOURCE_DIR} STREQUAL ${stm32f1_bootloader_BINARY_DIR})
35+
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
36+
endif()
37+
38+
39+
#add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
40+
add_definitions(-DSTM32F103xE -DCFG_TUSB_MCU=OPT_MCU_STM32F1 -DSTM32F1)
41+
42+
file(GLOB_RECURSE C_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c"
43+
"${CMAKE_CURRENT_SOURCE_DIR}/lib/tinyusb/src/*.c")
44+
45+
46+
add_executable(${PROJECT_NAME}.elf ${C_SRCS})
47+
add_dependencies(${PROJECT_NAME}.elf libopencm3_stm32f1.a)
48+
49+
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/libopencm3.cmake)
50+
51+
set(LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/STM32F103RCTx_FLASH.ld)
52+
53+
target_include_directories(${PROJECT_NAME}.elf PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
54+
${CMAKE_CURRENT_SOURCE_DIR}/lib/tinyusb/src
55+
${CMAKE_CURRENT_SOURCE_DIR}/lib/libopencm3/include
56+
${CMAKE_CURRENT_SOURCE_DIR}/lib/tinyusb/hw/mcu/st/cmsis_device_f1/Include
57+
${CMAKE_CURRENT_SOURCE_DIR}/lib/libopencm3/include/libopencmsis
58+
${CMAKE_CURRENT_SOURCE_DIR}/lib/cmsis_device_f1/Include)
59+
60+
target_link_directories(${PROJECT_NAME}.elf PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
61+
target_link_libraries(${PROJECT_NAME}.elf opencm3_stm32f1)
62+
63+
64+
set(CMAKE_EXE_LINKER_FLAGS
65+
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map -T ${LINKER_SCRIPT}")
66+
67+
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
68+
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
69+
70+
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
71+
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
72+
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
73+
COMMENT "Building ${HEX_FILE}
74+
Building ${BIN_FILE}")

README.MD

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# STM32 BootLoader
2+

STM32F103RCTx_FLASH.ld

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
EXTERN(vector_table)
2+
ENTRY(reset_handler)
3+
MEMORY
4+
{
5+
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 48K
6+
rom (rx) : ORIGIN = 0x08000000, LENGTH = 256K
7+
}
8+
SECTIONS
9+
{
10+
.text : {
11+
*(.vectors)
12+
*(.text*)
13+
*(.eh_frame)
14+
. = ALIGN(4);
15+
*(.rodata*)
16+
. = ALIGN(4);
17+
} >rom
18+
.preinit_array : {
19+
. = ALIGN(4);
20+
__preinit_array_start = .;
21+
KEEP (*(.preinit_array))
22+
__preinit_array_end = .;
23+
} >rom
24+
.init_array : {
25+
. = ALIGN(4);
26+
__init_array_start = .;
27+
KEEP (*(SORT(.init_array.*)))
28+
KEEP (*(.init_array))
29+
__init_array_end = .;
30+
} >rom
31+
.fini_array : {
32+
. = ALIGN(4);
33+
__fini_array_start = .;
34+
KEEP (*(.fini_array))
35+
KEEP (*(SORT(.fini_array.*)))
36+
__fini_array_end = .;
37+
} >rom
38+
.ARM.extab : {
39+
*(.ARM.extab*)
40+
} >rom
41+
.ARM.exidx : {
42+
__exidx_start = .;
43+
*(.ARM.exidx*)
44+
__exidx_end = .;
45+
} >rom
46+
. = ALIGN(4);
47+
_etext = .;
48+
.noinit (NOLOAD) : {
49+
*(.noinit*)
50+
} >ram
51+
. = ALIGN(4);
52+
.data : {
53+
_data = .;
54+
*(.data*)
55+
*(.ramtext*)
56+
. = ALIGN(4);
57+
_edata = .;
58+
} >ram AT >rom
59+
_data_loadaddr = LOADADDR(.data);
60+
.bss : {
61+
*(.bss*)
62+
*(COMMON)
63+
. = ALIGN(4);
64+
_ebss = .;
65+
} >ram
66+
/DISCARD/ : { *(.eh_frame) }
67+
. = ALIGN(4);
68+
end = .;
69+
}
70+
PROVIDE(_stack = ORIGIN(ram) + LENGTH(ram));

cmake/libopencm3.cmake

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.7)
2+
set(OPENCM3_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/libopencm3)
3+
set(DEVICES_DATA ${OPENCM3_DIR}/ld/devices.data)
4+
set(DEVICE STM32F103RC)
5+
6+
add_custom_target(libopencm3_stm32f1.a
7+
make -C ${OPENCM3_DIR} TARGETS=stm32/f1 -j8
8+
COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/lib/libopencm3/lib/libopencm3_stm32f1.a ${CMAKE_CURRENT_BINARY_DIR}
9+
COMMENT "Building libopencm3"
10+
USES_TERMINAL)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Caution**
11+
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
12+
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the [ST Community/STM32 MCUs forum](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
13+
14+
**Describe the set-up**
15+
* The board (either ST RPN reference or your custom board)
16+
* IDE or at least the compiler and its version
17+
18+
**Describe the bug**
19+
A clear and concise description of what the bug is.
20+
21+
**How To Reproduce**
22+
1. Indicate the global behavior of your application project
23+
24+
2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...)
25+
26+
3. The use case that generates the problem
27+
28+
4. How we can reproduce the problem
29+
30+
31+
**Additional context**
32+
If you have a first analysis or patch correction, thank you to share your proposal.
33+
34+
**Screenshots**
35+
If applicable, add screenshots to help explain your problem.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: 'Other Issue '
3+
about: Generic issue description
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Caution**
11+
The Issues are strictly limited for the reporting of problem encountered with the software provided in this project.
12+
For any other problem related to the STM32 product, the performance, the hardware characteristics and boards, the tools the environment in general, please post a topic in the [ST Community/STM32 MCUs forum](https://community.st.com/s/group/0F90X000000AXsASAW/stm32-mcus).
13+
14+
**Describe the set-up**
15+
* The board (either ST RPN reference or your custom board)
16+
* IDE or at least the compiler and its version
17+
18+
**Additional context**
19+
If you have a first analysis or a patch proposal, thank you to share your proposal.
20+
21+
**Screenshots**
22+
If applicable, add screenshots to help explain your problem.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## IMPORTANT INFORMATION
2+
3+
### Contributor License Agreement (CLA)
4+
* The Pull Request feature will be considered by STMicroelectronics after the signature of a **Contributor License Agreement (CLA)** by the submiter.
5+
* If you have not signed such agreement, please follow the rules mentioned in the CONTRIBUTING.md file.
6+
7+
8+
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at https://www.st.com/content/st_com/en/contact-us.html. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

0 commit comments

Comments
 (0)