README.md
1# Raspberry PI 3B 32 BSP (Board Support Package) Execution Instruction
2
3[中文页](README_zh.md) |
4
5## Introduction
6
7This document records the execution instruction of the BSP (board support package) provided by the RT-Thread development team for the Raspberry PI 3B 32 development board.
8
9[](https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi3-32/figures/raspi3_f.jpg)
10
11[](https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi3-32/figures/raspi3_b.jpg)
12
13## Hardware Features
14
15| Hardware | Description |
16| -------------- | ----------------------------------------- |
17| CPU | quad-core ARM Cortex A53(ARMv8) |
18| Main Frequency | 1.2 GHz |
19| GPU | VideoCore IV |
20| GPU Frequency | 400MHz |
21| Memory | 1GB (0x0000000 - 0x40000000) |
22| | 0x3f000000 - 0x40000000 is for peripheral |
23
24**The description of functional pins is as shown as follow:**
25
26[](https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi3-32/figures/GPIO-Pinout-Diagram-2.png)
27
28## **Compilation Instruction**
29
30The [env](https://www.rt-thread.io/download.html?download=Env) tool is recommended for compiling in Windows environments.
31
32The cross-compiler gcc-arm-none-eabi-4_8-2014q1_linux is recommended in Linux environment. If you don’t have compiling tool, please uncompress the downloaded package like this:
33
34```
35tar vxf gcc-arm-none-eabi-4_8-2014q1_linux.tar.bz2
36```
37
38In Linux environment, you need to modify the settings of the compiler directory, and modify the actual directory of the compiling tool in bsp/raspi3-32/rtconfig. py, remember to add the suffix /bin here.
39
40```
41EXEC_PATH = r'/opt/gcc-arm-none-eabi-4_8-2014q1_gri/bin'
42```
43
44Enter the rt-thread/bsp/raspi3-32 directory and run the following command to compile this BSP:
45
46```
47scons
48```
49
50If everything goes well, a new 'rtthread.elf' and 'kernel7.img' file will be generated. ‘kernel7.img' is what we need to put into the root directory of the Raspberry PI 3B SD card.
51
52### **Eclipse compiling environment**
53
54- Step 1: Install the eclipse plugin 'cdt'.
55- Step 2: Open eclipse cdt and set workspace, and set the workspace to 'rt-thread/bsp/raspberry-pi/raspi3-32'.
56- Step 3: Import the project by selecting 'General->Existing Projects into Workspace' and then 'Browse ...'. Noted that the compiling only supports scons now.
57
58
59## **Running**
60
61### **Prepare the [Raspbian](https://downloads.raspberrypi.org/raspbian_lite_latest) SD card**
62
63Download the raspbian image, for example, "2018-06-27-raspbian-stretch-lite.zip". Unpack it.
64
65**Burn the SD card on Windows**
66
67On Windows, download the burning tool " [etcher.io](https://www.balena.io/etcher/) ", run it and choose the unpacked image "2018-06-27-raspbian-stretch-lite.img".
68
69When the burning process is completed, put "kernel8.img" into the boot partition to replace the file wit the same name.
70
71**Burn the SD card on Linux**
72
73Prepare an empty SD card, plug it in the computer and then execute the command below:
74
75"sudo dd if=2018-06-27-raspbian-stretch-lite.img of=/dev/xxx bs=32M conv=fsync"
76
77Note that the device file "/dev/xxx" should be replaced with the real SD card.
78
79### **Prepare the serial port wire**
80
81The BSP uses GPIO 14 & GPIO 15 of raspi 3 as the communication ports, as shown in the following image:
82
83
84
85[](https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi3-32/figures/raspberrypi-console.png)
86
87The serial port parameters: 115200 8N1, hardware and software flow control is off.
88
89## **Running Result**
90
91Insert the burned SD card into Raspberry Pi, power up, the output information on the serial port should be like this:
92
93```
94heap: 0x0005d784 - 0x0045d784
95
96 \ | /
97- RT - Thread Operating System
98 / | \ 4.0.2 build Jan 9 2020
99 2006 - 2019 Copyright by rt-thread team
100[I/I2C] I2C bus [i2c0] registered
101[I/I2C] I2C bus [i2c1] registered
102[I/SDIO] SD card capacity 15558144 KB.
103found part[0], begin: 1048576, size: 63.0MB
104found part[1], begin: 67108864, size: 14.793GB
105file system initialization done!
106boot cpu:3
107msh />cpu = 0x00000003
108cpu 3 startup.
109start OK: CPU 3
110boot cpu:2
111cpu = 0x00000002
112cpu 2 startup.
113start OK: CPU 2
114boot cpu:1
115cpu = 0x00000001
116cpu 1 startup.
117start OK: CPU 1
118Hello RT-Thread!
119
120msh />
121```
122
123## **Peripheral Condition**
124
125| Drive | Support | Remark |
126| -------------- | ------- | ------ |
127| UART | Support | UART0 |
128| GPIO | Support | - |
129| IIC | Support | - |
130| SPI | Support | - |
131| CPU Timer | Support | - |
132| SD card driver | Support | - |
133| RTC | Support | - |
134| WDT | Support | - |
135| MAILBOX | Support | - |
136| SMP | Support | - |
137| FRAMEBUFFER | Support | HDMI |
138
README_zh.md
1# Raspberry PI 3B(32位)板级支持包说明
2
3## 1. 简介
4
5树莓派由注册于英国的慈善组织“Raspberry Pi 基金会”开发,莓派3采用4核Broadcom BCM2837 (ARMv8)芯片、双核VideoCore IV GPU和1GB内存。
6
7这份RT-Thread BSP是针对 Raspberry Pi 3B (32位)的一份移植,树莓派价格便宜, 使用者甚众,是研究和运行RT-Thread的可选平台之一。
8
9随着RT-Thread的发展,它越来越多的向一些Cortex-A等AP类处理器提供支持,例如全志的ARM9、Cortex-A处理器,Xilinx的Zynq处理器等。
10
11而RT-Thread也是一套高度社区化发展的操作系统,所以在一些方向推进上希望以社区化方式,大家一起来推动的方式向前发展,在这个过程中RT-Thread得到了不同开发者、不同领域的应用,一步步把RT-Thread推向成熟。而在Cortex-A平台上,目前最流行的硬件平台是树莓派,分树莓派[2B](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/)、[3B](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)以及最新的[4B](https://www.raspberrypi.org/products/raspberry-pi-4-model-b/)等。
12
13RT-Thread对树莓派的支持主要从树莓派2B开始,它是一个四核Cortex-A7的平台,以32位单核的模式运行。后续将推动着RT-Thread向树莓派3,四核Cortex-A53 64位模式发展(中间当然也可能出现四核Cortex-A7模式执行的过渡性版本)。
14
15
16
17
18
19当前Raspberry Pi 3B对应的硬件特性:
20
21| 硬件 | 描述 |
22|------- | ------------------------------- |
23| CPU | quad-core ARM Cortex A53(ARMv8) |
24| 主频 | 1.2 GHz |
25| GPU | VideoCore IV |
26| GPU频率 | 400MHz |
27| Memory | 1GB (0x0000000 - 0x40000000) |
28| | 其中0x3f000000 - 0x40000000为peripheral |
29
30硬件引脚分布情况
31
32
33
34## 2. 编译说明
35
36Windows环境下推荐使用[env工具][1]进行编译。
37
38Linux下推荐使用gcc工具 gcc-arm-none-eabi-5_4-2016q3,如果还没有编译工具,下载后,解开文件。
39
40```
41tar vxf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
42```
43
44Linux环境下需要修改编译器目录设置,修改`bsp/raspi3-32/rtconfig.py`中的
45
46```
47EXEC_PATH = r'/opt/gcc-arm-none-eabi-5_4-2016q3/bin'
48```
49
50为编译工具的实际所在目录,这里注意要加上后缀 `/bin`
51
52进入到`rt-thread/bsp/raspi3-32`目录中,运行以下命令:
53
54```
55scons
56```
57
58来编译这个板级支持包。如果编译正确无误,会产生rtthread.elf、kernel7.img文件。
59kernel7.img即是要cp到raspberry SD卡中根目录的文件
60
61### 2.1 eclipse 编码环境 ###
62第一步: 安装 eclipse cdt
63第二步: 打开 eclipse cdt 设置workspace ,推荐设置于xxx\xxx\rt-thread\bsp
64第三步: Import 工程 General-> Existing Peojects into Workspace 然后 Browse.. 你的raspi3目录,点击Finish
65
66btw:编译依旧使用scons,目前不支持qemu debug,后期如果有大佬实现ARM JTAG调试
67
68## 3. 执行
69
70### 3.1 下载[raspbian镜像][3],生成可以运行的raspbian SD卡
71
72Windows下,去[etcher.io][4]下载etcher,这是个可以烧写img的工具
73
74解开下载的镜像文件, linux下使用如下的命令
75
76```
77unzip 2018-06-27-raspbian-stretch-lite.zip
78```
79
80准备一张空SD卡,linux环境下,插入电脑并执行
81
82```
83sudo dd if=2018-06-27-raspbian-stretch-lite.img of=/dev/xxx bs=32M conv=fsync
84```
85
86**注意: /dev/xxx 要换成真实环境中的SD卡所在设置,千万不要弄错。**
87
88Windows环境下,执行etcher选择解压后的2018-06-27-raspbian-stretch-lite.img文件和SD卡就可以开始烧写了。
89
90最后把kernel7.img放入SD boot分区,覆盖原来的文件。
91
92### 3.2 准备好串口线
93
94目前版本是使用raspi3的 GPIO 14, GPIO 15来作路口输出,连线情况如下图所示:
95
96
97
98
99
100串口参数: 115200 8N1 ,硬件和软件流控为关。
101
102按上面的方法做好SD卡后,插入树莓派3B,通电可以在串口上看到如下所示的输出信息:
103
104```text
105heap: 0x0005d784 - 0x0045d784
106
107 \ | /
108- RT - Thread Operating System
109 / | \ 4.0.2 build Jan 9 2020
110 2006 - 2019 Copyright by rt-thread team
111[I/I2C] I2C bus [i2c0] registered
112[I/I2C] I2C bus [i2c1] registered
113[I/SDIO] SD card capacity 15558144 KB.
114found part[0], begin: 1048576, size: 63.0MB
115found part[1], begin: 67108864, size: 14.793GB
116file system initialization done!
117boot cpu:3
118msh />cpu = 0x00000003
119cpu 3 startup.
120start OK: CPU 3
121boot cpu:2
122cpu = 0x00000002
123cpu 2 startup.
124start OK: CPU 2
125boot cpu:1
126cpu = 0x00000001
127cpu 1 startup.
128start OK: CPU 1
129Hello RT-Thread!
130
131msh />
132```
133
134## 4. 支持情况
135
136| 驱动 | 支持情况 | 备注 |
137| ------ | ---- | :------: |
138| UART | 支持 | UART0|
139| GPIO | 支持 | - |
140| IIC | 支持 | - |
141| SPI | 支持 | - |
142| CPU Timer | 支持 | - |
143| SD卡驱动 | 支持 | - |
144| RTC | 支持 | - |
145| WDT | 支持 | - |
146| MAILBOX | 支持 | - |
147| SMP | 支持 | - |
148| FRAMEBUFFER | 支持 | HDMI |
149
150## 5. 联系人信息
151
152维护人:[bernard][5]
153
154[1]: https://www.rt-thread.org/download.html#download-rt-thread-env-tool
155[2]: https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
156[3]: https://downloads.raspberrypi.org/raspbian_lite_latest
157[4]: https://etcher.io
158[5]: https://github.com/BernardXiong
159