[BSP][stm32f411-nucleo] Add GCC support.

This commit is contained in:
Bernard Xiong 2018-05-29 10:19:27 +08:00
parent eaef195911
commit f1d0cb872d
11 changed files with 4521 additions and 1191 deletions

View File

@ -8,17 +8,18 @@
#
CONFIG_RT_NAME_MAX=8
CONFIG_RT_ALIGN_SIZE=4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
CONFIG_RT_THREAD_PRIORITY_32=y
# CONFIG_RT_THREAD_PRIORITY_256 is not set
CONFIG_RT_THREAD_PRIORITY_MAX=32
CONFIG_RT_TICK_PER_SECOND=100
CONFIG_RT_DEBUG=y
CONFIG_RT_USING_OVERFLOW_CHECK=y
CONFIG_RT_DEBUG_INIT=0
# CONFIG_RT_DEBUG_THREAD is not set
CONFIG_RT_DEBUG_THREAD=0
CONFIG_RT_USING_HOOK=y
CONFIG_IDLE_THREAD_STACK_SIZE=256
CONFIG_RT_USING_TIMER_SOFT=y
CONFIG_RT_TIMER_THREAD_PRIO=4
CONFIG_RT_TIMER_THREAD_STACK_SIZE=512
CONFIG_IDLE_THREAD_STACK_SIZE=512
# CONFIG_RT_USING_TIMER_SOFT is not set
#
# Inter-Thread communication
@ -35,14 +36,17 @@ CONFIG_RT_USING_MESSAGEQUEUE=y
#
CONFIG_RT_USING_MEMPOOL=y
# CONFIG_RT_USING_MEMHEAP is not set
CONFIG_RT_USING_HEAP=y
# CONFIG_RT_USING_NOHEAP is not set
CONFIG_RT_USING_SMALL_MEM=y
# CONFIG_RT_USING_SLAB is not set
# CONFIG_RT_USING_MEMTRACE is not set
CONFIG_RT_USING_HEAP=y
#
# Kernel Device Object
#
CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart2"
@ -53,6 +57,7 @@ CONFIG_RT_CONSOLE_DEVICE_NAME="uart2"
#
CONFIG_RT_USING_COMPONENTS_INIT=y
CONFIG_RT_USING_USER_MAIN=y
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
#
# C++ features
@ -63,14 +68,19 @@ CONFIG_RT_USING_USER_MAIN=y
# Command shell
#
CONFIG_RT_USING_FINSH=y
CONFIG_FINSH_THREAD_NAME="tshell"
CONFIG_FINSH_USING_HISTORY=y
CONFIG_FINSH_HISTORY_LINES=5
CONFIG_FINSH_USING_SYMTAB=y
CONFIG_FINSH_USING_DESCRIPTION=y
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
CONFIG_FINSH_THREAD_PRIORITY=20
CONFIG_FINSH_THREAD_STACK_SIZE=4096
CONFIG_FINSH_CMD_SIZE=80
# CONFIG_FINSH_USING_AUTH is not set
# CONFIG_FINSH_USING_MSH is not set
CONFIG_FINSH_USING_MSH=y
CONFIG_FINSH_USING_MSH_DEFAULT=y
CONFIG_FINSH_USING_MSH_ONLY=y
#
# Device virtual file system
@ -84,6 +94,7 @@ CONFIG_RT_USING_DEVICE_IPC=y
CONFIG_RT_USING_SERIAL=y
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_MTD_NOR is not set
@ -92,6 +103,11 @@ CONFIG_RT_USING_SERIAL=y
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_WIFI is not set
#
# Using USB
#
# CONFIG_RT_USING_USB_HOST is not set
# CONFIG_RT_USING_USB_DEVICE is not set
@ -116,20 +132,20 @@ CONFIG_RT_USING_SERIAL=y
# CONFIG_RT_USING_MODBUS is not set
#
# RT-Thread UI Engine
# VBUS(Virtual Software BUS)
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_RT_USING_VBUS is not set
#
# Utilities
#
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_RYM is not set
#
# RT-Thread online packages
#
#
# system packages
#
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_SQLITE is not set
#
# IoT - internet of things
#
@ -138,39 +154,94 @@ CONFIG_RT_USING_SERIAL=y
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
#
# Wi-Fi
#
#
# Marvell WiFi
#
# CONFIG_PKG_USING_MARVELLWIFI is not set
# CONFIG_PKG_USING_WLANMARVELL is not set
#
# Wiced WiFi
#
# CONFIG_PKG_USING_WLAN_WICED is not set
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_ONENET is not set
#
# security packages
#
# CONFIG_PKG_USING_MBEDTLS is not set
# CONFIG_PKG_USING_libsodium is not set
# CONFIG_PKG_USING_TINYCRYPT is not set
#
# language packages
#
# CONFIG_PKG_USING_JERRYSCRIPT is not set
# CONFIG_PKG_USING_MICROPYTHON is not set
#
# multimedia packages
#
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
#
# tools packages
#
# CONFIG_PKG_USING_CMBACKTRACE is not set
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
#
# system packages
#
#
# RT-Thread GUI Engine
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
#
# peripheral libraries and drivers
#
# CONFIG_PKG_USING_STM32F4_HAL is not set
# CONFIG_PKG_USING_STM32F4_DRIVERS is not set
#
# miscellaneous packages
#
# CONFIG_PKG_USING_HELLO is not set
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
#
# BSP_SPECIAL CONFIG
# sample package
#
# CONFIG_PKG_USING_SAMPLES is not set
#
# example package: hello
#
# CONFIG_PKG_USING_HELLO is not set
CONFIG_RT_USING_UART2=y

View File

@ -19,6 +19,5 @@ source "$RTT_DIR/Kconfig"
source "$PKGS_DIR/Kconfig"
config RT_USING_UART2
bool "Using RT_USING_UART2"
bool "Using UART2"
default y

View File

@ -0,0 +1,104 @@
/**
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
* @file gcc_startup.s
* @author MCD Application Team
* @version V4.2.0
* @date 31-March-2017
* @brief Based on STM32F103xE's startup file.
* This module performs:
* - Set the initial SP
* - Set the initial PC == Reset_Handler,
* - Set the vector table entries with the exceptions ISR address
* - Configure the clock system
* - Configure external SRAM mounted on STM3210E-EVAL board
* to be used as data memory (optional, to be enabled by user)
* - Branches to entry in the C library (which eventually
* calls main(), but entry() in RT-Thread).
* After Reset the Cortex-M3 processor is in Thread mode,
* priority is Privileged, and the Stack is set to Main.
******************************************************************************
*
* <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
.syntax unified
.cpu cortex-m3
.fpu softvfp
.thumb
/**
* @brief This is the code that gets called when the processor first
* starts execution following a reset event. Only the absolutely
* necessary set is performed, after which the application
* supplied main() routine is called.
* @param None
* @retval : None
*/
.global Reset_Handler
.section .text.Reset_Handler
.type Reset_Handler, %function
Reset_Handler:
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
CopyDataInit:
ldr r3, =_sidata
ldr r3, [r3, r1]
str r3, [r0, r1]
adds r1, r1, #4
LoopCopyDataInit:
ldr r0, =_sdata
ldr r3, =_edata
adds r2, r0, r1
cmp r2, r3
bcc CopyDataInit
ldr r2, =_sbss
b LoopFillZerobss
/* Zero fill the bss segment. */
FillZerobss:
movs r3, #0
str r3, [r2], #4
LoopFillZerobss:
ldr r3, = _ebss
cmp r2, r3
bcc FillZerobss
/* Call the clock system intitialization function.*/
bl SystemInit
/* Call static constructors */
/* bl __libc_init_array */
/* Call the application's entry point.*/
bl entry
bx lr
.size Reset_Handler, .-Reset_Handler

View File

@ -13,10 +13,12 @@ CPPDEFINES = [rtconfig.PART_TYPE] #stm32f411xe
# add for startup script
if rtconfig.CROSS_TOOL == 'gcc':
folder = 'gcc'
src += ['Device/ST/STM32F4xx/Source/Templates/gcc/gcc_startup.s']
elif rtconfig.CROSS_TOOL == 'keil':
folder = 'arm'
elif rtconfig.CROSS_TOOL == 'iar':
folder = 'iar'
#Device/ST/STM32F4xx/Source/Templates/iar/startup_stm32f411xe.s
src += ['Device/ST/STM32F4xx/Source/Templates/' + folder + '/startup_' + rtconfig.PART_TYPE.lower() + '.s']

View File

@ -0,0 +1,133 @@
# STM32L476-nucleo 板级支持包
## 1. 简介
STM32F411-nucleo 是由意法半导体推出的搭载Cortex-M4内核的高性能微控制器开发板包括如下硬件特性
| 硬件 | 描述 |
| -- | -- |
|芯片型号| STM32F411RE |
|CPU | Cortex-M4 |
|主频 | 100MHz |
|Flash| 512kB |
|SRAM | 128KB |
## 2. 编译说明
| 环境 | 说明 |
| ------------ | ------------------------------------------------------------ |
| PC操作系统 | Linux/MacOS/Windows |
| 编译器 | arm-none-eabi-gcc version 6.3.1 20170620 (release)/armcc/ |
| 构建工具 | scons/mdk5 |
| 依赖软件环境 | Env工具/(MDK或arm-none-eabi-gcc)/git/调试器驱动 |
1) 下载源码
```bash
git clone https://github.com/RT-Thread/rt-thread.git
```
2) 配置工程并准备env
* Windows
>在[RT-Thread官网][1]下载ENV工具包
* Linux/Mac
```bash
cd rt-thread/bsp/stm32l476-nucleo
scons --menuconfig
source ~/.env/env.sh
pkgs --upgrade
```
3) 生成工程(Mac/Linux下请跳过此步骤)
* Windows MDK5
```bash
scons --target=mdk5 -s
```
4) 编译
* Windows
使用MDK或IAR请参见对应教程。Windows下使用ENV工具已经携带GNU GCC工具链只需要在console下在`bsp/stm32f411-nucleo`目录下使用
```bash
scons
```
即可编译成功。
* Linux/MAC
请使用以下指令设置gcc路径
```bash
export RTT_EXEC_PATH=[GCC路径]
```
而后在`rt-thread/bsp/stm32f411-nucleo`目录下使用
```bash
scons
```
即可编译成功。
GNU GCC编译成功会在最后有如下类似信息显示
```bash
LINK rtthread-stm32f411.elf
arm-none-eabi-objcopy -O binary rtthread-stm32f411.elf rtthread.bin
arm-none-eabi-size rtthread-stm32f411.elf
text data bss dec hex filename
55916 208 2456 58580 e4d4 rtthread-stm32f411.elf
scons: done building targets.
```
并产生rtthread-stm32f411.elf、rtthread.bin文件。其中rtthread.bin为二进制固件
## 3. 烧写及执行
对于STM32F411-Nucleo开发板在Windows上可以直接把rtthread.bin文件拖到U盘中实现烧写。在Linux下请查找Linux下如何使用 ST-Link 的教程。
**注:**
如果需要使用Keil MDK来调试GNU GCC编译后的映像文件可以在编译出`rt-thread/bsp/stm32f411-nucleo/rtthread-stm32f411.elf`后,把这个文件改名成`rtthread-stm32f4xx.axf`
并放置于build目录下。然后在Keil MDK工程配置的Debug页中把`Run to main()`选项拿掉,然后直接点击下载或调试即可进行调试(千万别再编译这个工程)。
### 3.1 运行结果
如果编译 & 烧写无误会在串口2上看到RT-Thread的启动logo信息
```bash
\ | /
- RT - Thread Operating System
/ | \ 3.0.4 build May 29 2018
2006 - 2018 Copyright by rt-thread team
msh >
```
## 4. 驱动支持情况及计划
| 驱动 | 支持情况 | 备注 |
| ---------- | :------: | :--------------------------: |
| UART | 支持 | UART2 |
### 4.1 IO在板级支持包中的映射情况
| IO号 | 板级包中的定义 |
| -- | -- |
| PA2 | USART2 TX |
| PA3 | USART2 RX |
## 5. menuconfig Bsp菜单详解
| 选项 | 解释 |
| -- | -- |
| Using UART2 | 开启串口2设备名为"uart2" |
[1]: https://www.rt-thread.org/page/download.html

View File

@ -19,9 +19,8 @@
#include <stm32f4xx.h>
#include <stm32f4xx_hal.h>
// <o> Internal SRAM memory size[Kbytes] <8-64>
// <i>Default: 64
#define STM32_SRAM_SIZE 64
#define STM32_SRAM_SIZE 128
#define STM32_SRAM_END (0x20000000 + STM32_SRAM_SIZE * 1024)
#ifdef __CC_ARM
@ -36,6 +35,6 @@ extern int __bss_end;
#endif
#define HEAP_END STM32_SRAM_END
void rt_hw_board_init(void);
#endif
extern void rt_hw_board_init(void);
// <<< Use Configuration Wizard in Context Menu >>>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,17 +8,15 @@
#define RT_NAME_MAX 8
#define RT_ALIGN_SIZE 4
#define RT_THREAD_PRIORITY_32
#define RT_THREAD_PRIORITY_MAX 32
#define RT_TICK_PER_SECOND 100
#define RT_DEBUG
#define RT_USING_OVERFLOW_CHECK
#define RT_DEBUG_INIT 0
/* RT_DEBUG_THREAD is not set */
#define RT_DEBUG_THREAD 0
#define RT_USING_HOOK
#define IDLE_THREAD_STACK_SIZE 256
#define RT_USING_TIMER_SOFT
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define IDLE_THREAD_STACK_SIZE 512
/* Inter-Thread communication */
@ -27,15 +25,12 @@
#define RT_USING_EVENT
#define RT_USING_MAILBOX
#define RT_USING_MESSAGEQUEUE
/* RT_USING_SIGNALS is not set */
/* Memory Management */
#define RT_USING_MEMPOOL
/* RT_USING_MEMHEAP is not set */
#define RT_USING_HEAP
#define RT_USING_SMALL_MEM
/* RT_USING_SLAB is not set */
#define RT_USING_HEAP
/* Kernel Device Object */
@ -43,109 +38,99 @@
#define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart2"
/* RT_USING_MODULE is not set */
/* RT-Thread Components */
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
/* C++ features */
/* RT_USING_CPLUSPLUS is not set */
/* Command shell */
#define RT_USING_FINSH
#define FINSH_THREAD_NAME "tshell"
#define FINSH_USING_HISTORY
#define FINSH_HISTORY_LINES 5
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION
#define FINSH_THREAD_PRIORITY 20
#define FINSH_THREAD_STACK_SIZE 4096
#define FINSH_CMD_SIZE 80
/* FINSH_USING_AUTH is not set */
/* FINSH_USING_MSH is not set */
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_ONLY
/* Device virtual file system */
/* RT_USING_DFS is not set */
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_USING_SERIAL
/* RT_USING_CAN is not set */
/* RT_USING_HWTIMER is not set */
/* RT_USING_I2C is not set */
/* RT_USING_PIN is not set */
/* RT_USING_MTD_NOR is not set */
/* RT_USING_MTD_NAND is not set */
/* RT_USING_RTC is not set */
/* RT_USING_SDIO is not set */
/* RT_USING_SPI is not set */
/* RT_USING_WDT is not set */
/* RT_USING_USB_HOST is not set */
/* RT_USING_USB_DEVICE is not set */
/* Using USB */
/* POSIX layer and C standard library */
/* RT_USING_LIBC is not set */
/* RT_USING_PTHREADS is not set */
/* Network stack */
/* light weight TCP/IP stack */
/* RT_USING_LWIP is not set */
/* Modbus master and slave stack */
/* RT_USING_MODBUS is not set */
/* RT-Thread UI Engine */
/* VBUS(Virtual Software BUS) */
/* Utilities */
/* PKG_USING_GUIENGINE is not set */
/* RT-Thread online packages */
/* system packages */
/* PKG_USING_PARTITION is not set */
/* PKG_USING_SQLITE is not set */
/* IoT - internet of things */
/* PKG_USING_PAHOMQTT is not set */
/* PKG_USING_WEBCLIENT is not set */
/* PKG_USING_MONGOOSE is not set */
/* PKG_USING_WEBTERMINAL is not set */
/* PKG_USING_CJSON is not set */
/* PKG_USING_EZXML is not set */
/* Wi-Fi */
/* Marvell WiFi */
/* PKG_USING_MARVELLWIFI is not set */
/* Wiced WiFi */
/* security packages */
/* PKG_USING_MBEDTLS is not set */
/* language packages */
/* PKG_USING_JERRYSCRIPT is not set */
/* multimedia packages */
/* tools packages */
/* PKG_USING_CMBACKTRACE is not set */
/* PKG_USING_EASYLOGGER is not set */
/* system packages */
/* RT-Thread GUI Engine */
/* peripheral libraries and drivers */
/* miscellaneous packages */
/* PKG_USING_HELLO is not set */
/* BSP_SPECIAL CONFIG */
/* sample package */
/* example package: hello */
#define RT_USING_UART2

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff