Skip to content

Commit a193547

Browse files
authored
Merge pull request #4595 from supperthomas/nrf5x_nrf
[bsp/nrfx]add the templete of nrfx
2 parents 7831353 + b2a2da7 commit a193547

Some content is hidden

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

63 files changed

+37389
-13755
lines changed
20.2 KB
Loading
22.1 KB
Loading
142 KB
Loading
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Nordic 系列 BSP 制作教程
2+
3+
为了让广大开发者更好、更方便地使用 BSP 进行开发,重新整理了现有的 Nordic 系列的 BSP,推出了新的 BSP 框架。新的 BSP 框架在易用性、移植便利性、驱动完整性、代码规范性等方面都有较大提升,在新的 BSP 框架下进行开发,可以大大提高应用的开发效率。
4+
5+
这边参考了官方stm32的相关制作流程,熟悉STM32的可以参考[STM32](https://github.com/RT-Thread/rt-thread/blob/master/bsp/stm32/docs/STM32%E7%B3%BB%E5%88%97BSP%E5%88%B6%E4%BD%9C%E6%95%99%E7%A8%8B.md)
6+
7+
## 1. 知识准备
8+
9+
制作一个 BSP 的过程就是构建一个新系统的过程,因此想要制作出好用的 BSP,要对 RT-Thread 系统的构建过程有一定了解,需要的知识准备如下所示:
10+
11+
- 掌握 Nordic系列 BSP 的使用方法
12+
13+
了解 BSP 的使用方法,可以阅读 [Nordic 说明文档](../README.md) 中使用教程表格内的文档。
14+
15+
- 了解 scons 工程构建方法
16+
17+
RT-Thread 使用 scons 作为系统的构建工具,因此了解 scons 的常用命令对制作新 BSP 是基本要求。
18+
19+
- 了解设备驱动框架
20+
21+
在 RT-Thread 系统中,应用程序通过设备驱动框架来操作硬件,因此了解设备驱动框架,对添加 BSP 驱动是很重要的。
22+
23+
- 了解 kconfig 语法
24+
25+
RT-Thread 系统通过 menuconfig 的方式进行配置,而 menuconfig 中的选项是由 kconfig 文件决定的,因此想要对 RT-Thread 系统进行配置,需要对 kconfig 语法有一定了解。
26+
27+
28+
## BSP 制作方法
29+
30+
本节以制作microbit添加 BSP。在接下来的章节中将会详细介绍具体步骤,帮助开发者快速创建所需要的 BSP。
31+
32+
### 复制通用模板
33+
制作新 BSP 的第一步是复制一份同系列的 BSP 模板作为基础,通过对 BSP 模板的修改来获得新 BSP。目前提供的 BSP 模板系列如下表所示:
34+
35+
| 工程模板 | 说明 |
36+
| ------- | ---- |
37+
| libraries/templates/nrfx | nrfx系列 BSP 模板 |
38+
39+
### 修改芯片类型
40+
41+
打开board/Kconfig找到SOC_NRF52840
42+
43+
SOC_NRF52840 要改成你对应的芯片类型,例如SOC_NRF51822 这个时候要确认[nrfx](https://github.com/xckhmf/nrfx)软件包中的SConscript中有对应的配置选项,没用的话,可以pr到对应的软件包
44+
45+
```
46+
elif GetDepend('SOC_NRF51822') == True:
47+
define += ['NRF51822_XXAA']
48+
src += ['./mdk/system_nrf51.c']
49+
50+
if rtconfig.PLATFORM == 'armcc':
51+
src += ['./mdk/arm_startup_nrf51.s']
52+
53+
if rtconfig.PLATFORM == 'gcc':
54+
src += ['./mdk/gcc_startup_nrf51.S']
55+
56+
if rtconfig.PLATFORM == 'iar':
57+
D_SRC += ['./mdk/iar_startup_nrf51.s']
58+
```
59+
60+
### 修改templete.uvprojx模板
61+
62+
修改template.uvprojx中的soc和jlink等配置选项,这个可以参考官方SDK sample的keil配置
63+
64+
这边如果要配置jlink的话,要注意flash download算法是否需要修改。
65+
66+
### 检查rtconfig.py
67+
68+
检查rtconfig.py中的CPU类型,nrf52是`cortex-m4` 如果是nrf51需要改成`cortex-m0`
69+
70+
### 修改menuconfig中的相关配置
71+
72+
menuconfig中修改RAM size大小。并且修改link.sct文件,这个可以参考官方sample
73+
74+
![image-20210403182242202](images/image-20210403182242202.png)
75+
76+
配置UART0相关的的引脚配置, 选中对应的UART0 TX RX引脚
77+
78+
![image-20210403182031505](images/image-20210403182031505.png)
79+
80+
最后调试`scons --target=mdk5`
81+
82+
### 修改整理readme.md
83+
84+
修改readme.md, 将你的开发板常用的链接信息整理到readme.md中
85+
86+
87+
88+
## FAQ:
89+
90+
1. 编译keil遇到 `No section matches selector - no section to be FIRST`
91+
92+
这个因为package里面的nrfx中的Sconscript未添加好对应的芯片,没有加载arm_startup_nrf51.s等文件导致

bsp/nrf5x/libraries/cmsis/include/arm_common_tables.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
33
*
44
* $Date: 19. October 2015
5-
* $Revision: V.1.4.5 a
5+
* $Revision: V.1.4.5 a
66
*
7-
* Project: CMSIS DSP Library
8-
* Title: arm_common_tables.h
7+
* Project: CMSIS DSP Library
8+
* Title: arm_common_tables.h
99
*
10-
* Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
10+
* Description: This file has extern declaration for common tables like Bitreverse, reciprocal etc which are used across different functions
1111
*
1212
* Target Processor: Cortex-M4/Cortex-M3
1313
*

bsp/nrf5x/libraries/cmsis/include/arm_const_structs.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
33
*
44
* $Date: 19. March 2015
5-
* $Revision: V.1.4.5
5+
* $Revision: V.1.4.5
66
*
7-
* Project: CMSIS DSP Library
8-
* Title: arm_const_structs.h
7+
* Project: CMSIS DSP Library
8+
* Title: arm_const_structs.h
99
*
10-
* Description: This file has constant structs that are initialized for
10+
* Description: This file has constant structs that are initialized for
1111
* user convenience. For example, some can be given as
1212
* arguments to the arm_cfft_f32() function.
1313
*

bsp/nrf5x/libraries/cmsis/include/cmsis_armcc_V6.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ __attribute__((always_inline)) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t v
464464
/**
465465
\brief Set Base Priority with condition (non_secure)
466466
\details Assigns the given value to the non-secure Base Priority register when in secure state only if BASEPRI masking is disabled,
467-
or the new value increases the BASEPRI priority level.
467+
or the new value increases the BASEPRI priority level.
468468
\param [in] basePri Base Priority value to set
469469
*/
470470
__attribute__((always_inline)) __STATIC_INLINE void __TZ_set_BASEPRI_MAX_NS(uint32_t value)

bsp/nrf5x/libraries/templates/nrf52x/applications/application.c

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)