Skip to content

Commit

Permalink
[rpi4b] add new bsp for qemu-rpi4b
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuzhuzhus committed Nov 7, 2024
1 parent 5010c17 commit 24daad9
Show file tree
Hide file tree
Showing 31 changed files with 8,821 additions and 0 deletions.
1,541 changes: 1,541 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/.config

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mainmenu "RT-Thread Project Configuration"

BSP_DIR := .

RTT_DIR := ../../..

PKGS_DIR := packages

source "$(RTT_DIR)/Kconfig"
osource "$PKGS_DIR/Kconfig"

config BCM2711_SOC
bool
select ARCH_ARMV8
select ARCH_ARM_MMU
select RT_USING_CACHE
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
select ARCH_CPU_64BIT
default y

rsource "drivers/Kconfig"
33 changes: 33 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Raspberry PI 4-dm2.0BSP说明

## 1. 简介

树莓派4B的核心处理器为博通BCM2711(四核1.5GHz,Cortex A72架构,树莓派3是四核A53)。LPDDR4内存,由5V/3A USB-C供电或GPIO 5V。

外设支持上,引入了双频Wi-Fi,蓝牙5.0,千兆网卡,MIPI CSI相机接口,两个USB口,40个扩展帧。

这份RT-Thread BSP是针对 Raspberry Pi 4的一份移植,树莓派价格便宜, 使用者甚众,是研究和运行RT-Thread的可选平台之一。


## 2. 编译说明

推荐使用[env工具](https://www.rt-thread.org/download.html#download-rt-thread-env-tool),可以在console下进入到`bsp\raspberry-pi\raspi4-64`目录中,运行以下命令:

```
scons
```

来编译这个板级支持包。如果编译正确无误,会产生 `rtthread.elf`, `rtthread.bin` 文件。

## 3. 支持情况

| 驱动 | 支持情况 | 备注 |
| ------ | ---- | :------: |
| UART | 支持 | pl011驱动 |
| GPIO | 尚未支持 | 等待dm2.0相关代码合入主线 |
| SPI | 尚未支持 | 等待gpio合入主线 |
| WATCHDOG | 尚未支持 | 等待gpio合入主线 |
| HDMI | 尚未支持 | 等待gpio合入主线 |
| SDIO | 支持 | 能够正常运行在qemu,但是qemu对于raspi目前只支持pio传输,后续需要硬件进行详细测试 |
| ETH | 尚未支持 | 等待gpio合入主线 |

14 changes: 14 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# for module compiling
import os
from building import *

cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)

for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))

Return('objs')
30 changes: 30 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import sys
import rtconfig

from rtconfig import RTT_ROOT

sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *

TARGET = 'rtthread.' + rtconfig.TARGET_EXT

DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
CPP = rtconfig.CPP, CXXFLAGS = rtconfig.CXXFLAGS,
AR = rtconfig.AR, ARFLAGS = '-rc',
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
env['ASCOM'] = env['ASPPCOM']
env['LINKCOM'] = '$LINK -o $TARGET $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS -Wl,--start-group $_LIBFLAGS -Wl,--end-group'

Export('RTT_ROOT')
Export('rtconfig')

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT)

# make a building
DoBuilding(TARGET, objs)
14 changes: 14 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/applications/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from building import *

cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd, str(Dir('#'))]

group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

list = os.listdir(cwd)
for item in list:
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
group = group + SConscript(os.path.join(item, 'SConscript'))

Return('group')
19 changes: 19 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/applications/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2020-04-16 bigmagic first version
*/

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

int main(int argc, char** argv)
{
rt_kprintf("Hi, this is RT-Thread!!\n");
return 0;
}
Binary file added bsp/raspberry-pi/raspi-dm2.0/bcm2711-rpi-4-b.dtb
Binary file not shown.
13 changes: 13 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/drivers/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


menu "Hardware Drivers Config"
config BSP_USING_PL011
bool "Enable pl011 for uart"
default n

config BSP_USING_SDHCI
bool "Enable sdhci driver"
select RT_USING_SDHCI
default y
rsource sdhci/Kconfig
endmenu
25 changes: 25 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/drivers/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from building import *

cwd = GetCurrentDir()
src = ["board.c"]
CPPPATH = [cwd, str(Dir('#'))]

if GetDepend(['BSP_USING_PL011']):
src = src + ['drv_uart.c']

if GetDepend(['BSP_USING_SDHCI']):
src = src + ['drv_sd.c']

group = DefineGroup('driver', src, depend = [''], CPPPATH = CPPPATH)

# build for sub-directory
list = os.listdir(cwd)
objs = []

for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
group = group + objs

Return('group')
32 changes: 32 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/drivers/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-10-28 zhujiale The first version
*/

#define DBG_TAG "board"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>

#include <rthw.h>
#include <rtthread.h>
#include <mm_aspace.h>
#include <setup.h>
#include "board.h"
#include "drv_uart.h"

#include "cp15.h"
#include "mmu.h"
#include <mm_page.h>

#ifdef RT_USING_SMART
#include <lwp_arch.h>
#endif
void rt_hw_board_init(void)
{
rt_hw_common_setup();
}
35 changes: 35 additions & 0 deletions bsp/raspberry-pi/raspi-dm2.0/drivers/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-10-28 zhujiale The first version
*/

#ifndef BOARD_H__
#define BOARD_H__

#include <stdint.h>
#include "mmu.h"
#include "ioremap.h"

extern int __bss_end;
#define HEAP_BEGIN ((void*)&__bss_end)

#ifdef RT_USING_SMART
#define HEAP_END ((size_t)KERNEL_VADDR_START + 32 * 1024 * 1024)
#define PAGE_START HEAP_END
#define PAGE_END ((size_t)KERNEL_VADDR_START + 128 * 1024 * 1024)
#else
#define KERNEL_VADDR_START 0x0

#define HEAP_END (KERNEL_VADDR_START + 32 * 1024 * 1024)
#define PAGE_START HEAP_END
#define PAGE_END ((size_t)PAGE_START + 128 * 1024 * 1024)
#endif

void rt_hw_board_init(void);

#endif
Loading

0 comments on commit 24daad9

Please sign in to comment.