Skip to content

Commit 45d4eec

Browse files
committed
Fix peripheral access failed
1 parent e441264 commit 45d4eec

File tree

18 files changed

+340
-108
lines changed

18 files changed

+340
-108
lines changed

.github/ALL_BSP_COMPILE.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
"nxp/lpc/lpc176x",
235235
"nxp/imx/imx6sx/cortex-a9",
236236
"nxp/imx/imx6ul",
237+
"nxp/imx/imx91",
237238
"nxp/imx/imxrt/imxrt1052-atk-commander",
238239
"nxp/imx/imxrt/imxrt1052-fire-pro",
239240
"nxp/imx/imxrt/imxrt1052-nxp-evk",

bsp/Copyright_Notice.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,17 @@ Path:
325325

326326
- bsp/imx6ul/platform
327327

328+
### imx91
329+
330+
License: bsd-new
331+
332+
Copyright: Copyright 2014-2016 Freescale Semiconductor, Inc.
333+
Copyright 2016-2025 NXP
334+
335+
Path:
336+
337+
- bsp/imx91/platform
338+
328339
### imxrt
329340

330341
License: clear-bsd

bsp/nxp/imx/imx91/.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ CONFIG_SOC_MIMX91X1D=y
14691469
#
14701470
# Hardware Drivers Config
14711471
#
1472-
# CONFIG_BSP_USING_EARLY_CONSOLE is not set
1472+
CONFIG_BSP_USING_EARLY_CONSOLE=y
14731473
CONFIG_BSP_USING_UART1=y
14741474
CONFIG_BSP_USING_GIC=y
14751475
CONFIG_BSP_USING_GICV3=y
73 KB
Loading
10.8 KB
Loading

bsp/nxp/imx/imx91/README.md

Lines changed: 195 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,212 @@
1-
# FRDM-IMX91 RT-Thread BSP
1+
# FRDM-IMX91 板级支持包 使用说明
22

3-
This folder contains the RT-Thread BSP for the NXP FRDM-IMX91 development board.
3+
本目录包含NXP FRDM-IMX91 开发板的板级支持包代码。
44

5-
## Board Overview
5+
## 1. 简介
66

7-
## Build and Run
7+
### 1.1 i.MX91系列处理器简介
88

9-
### Setup RT-Thread Development Environment
9+
i.MX 91系列采用了可扩展的Arm® Cortex®-A55内核,其主频高达1.4GHz,支持新一代LPDDR4内存以延长平台寿命,支持双千兆以太网和双USB端口,以及面向医疗、工业和消费物联网市场细分领域的丰富外设。
1010

11-
### Setup Network and TFTP Server for FRDM-IMX91
1211

13-
### Build RT-Thread BSP for FRDM-IMX91
1412

15-
1. Clone the RT-Thread repository:
16-
```
17-
git clone https://github.com/RT-Thread/rt-thread.git
18-
```
13+
### 1.2 FRDM-i.MX91开发板简介
1914

20-
2. Navigate to the BSP folder:
21-
```
22-
cd rt-thread/bsp/nxp/imx/imx91
23-
```
15+
FRDM i.MX 91开发板是一款低成本、紧凑型开发板,采用i.MX 91应用处理器。该板配备板载IW610模块,集成了恩智浦的三频解决方案,支持Wi-Fi 6、BLE 5.4和802.15.4,适用于开发现代工业和物联网应用。该开发板包含LPDDR4、用于快速启动的eMMC存储、PMIC以及扩展功能。
2416

25-
3. Build the BSP:
26-
```
27-
scons -j 8
28-
```
17+
FRDM i.MX 91开发板是一款入门级紧凑型开发板,采用i.MX 91应用处理器。
2918

30-
4. copy the `rtthread.bin` to the TFTP server working directory:
31-
```
32-
cp rtthread.bin /path/to/tftp_work_dir/
33-
```
19+
![GS-FRDM-IMX91-IMG1](README.assets/GS-FRDM-IMX91-IMG1.webp)
3420

35-
### Run RT-Thread on FRDM-IMX91 with u-boot
21+
22+
23+
| 处理器 | * i.MX 91应用处理器<br />* [email protected]<br />* EdgeLock®安全区域 |
24+
| ------------------ | ------------------------------------------------------------ |
25+
| 存储器 | 1GB LPDDR4<br />8GB eMMC5.1<br />MicroSD插槽<br />EEPROM |
26+
| 显示器和摄像头接口 | 并行RGB LCD接口(40引脚扩展接口)<br />并行摄像头接口(40引脚扩展接口) |
27+
| 无线 | u-blox MAYA-W476-00B三频Wi-Fi 6/BLE 5.4/802.15.4模块 |
28+
| 音频 | 3.5mm耳机插孔 |
29+
| 连接 | USB2.0 Type-C连接器<br /> USB2.0 type A连接器 <br />两个GbE RJ45 <br />CAN(HDR) <br />40引脚(2x20) <br />扩展接口 <br />I²C HDR <br />ADC HDR |
30+
| 调试 | SWD连接器 <br />通过USB Type C的UART |
31+
32+
33+
34+
### 1.3 开发板和PC之间的连接
35+
36+
在FRDM i.MX 91开发板上调测RT-Thread的过程中,需要使用到的接口有:
37+
38+
1. POWER(P1),USB供电接口,用于向开发板供电;
39+
2. DEBUG(P16),带有USB转串口芯片,用于U-Boot和RT-Thread日志输出、命令行交互;
40+
3. ENET1(P4)或者ENET2(P3),以太网口,用于网络下载编译生成的RT-Thread固件;
41+
42+
43+
44+
## 2. 编译
45+
46+
### 2.1 下载AArch64工具链
47+
48+
从ARM开发者网站下载AArch64裸机工具链,
49+
50+
下载页面: [Arm GNU Toolchain Downloads – Arm Developer](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)
51+
52+
例如,64位Windows主机上下载: https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-mingw-w64-x86_64-aarch64-none-elf.zip
53+
54+
例如,下载后解压到本地路径:`D:\ARM\arm-gnu-toolchain-14.3.rel1-mingw-w64-x86_64-aarch64-none-elf`
55+
56+
57+
58+
### 2.2 下载RT-Thread Env工具
59+
60+
下载页面:[rt-thread.org/download.html#download-rt-thread-env-tool](https://www.rt-thread.org/download.html#download-rt-thread-env-tool)
61+
62+
63+
64+
### 2.3 下载RT-Thread源代码
65+
66+
在Env环境中,使用git命令下载RT-Thread源代码,例如:
67+
68+
```sh
69+
git clone https://github.com/RT-Thread/rt-thread.git
70+
```
71+
72+
73+
74+
### 2.4 编译FRDM-i.MX 91目标
75+
76+
在Env环境中,转到`i.MX 91`的BSP目录:
77+
78+
```sh
79+
cd bsp/nxp/imx/imx91/
80+
```
81+
82+
然后,设置工具链路径(Windows Env环境):
83+
84+
```bat
85+
set RTT_EXEC_PATH=D:\ARM\arm-gnu-toolchain-14.3.rel1-mingw-w64-x86_64-aarch64-none-elf\bin
86+
```
87+
88+
或者(bash):
89+
90+
```sh''
91+
export RTT_EXEC_PATH=/path/to/aarch64-none-elf/bin
92+
```
93+
94+
接着,执行`scons`命令开始编译:
3695

3796
```sh
97+
scons -j 8
98+
```
99+
100+
101+
102+
## 3.下载
103+
104+
开发板默认固件带有U-Boot启动加载器,开机3秒内通过串口发送换行符,可以进入U-Boot命令行界面。
105+
106+
### 3.1 准备U-Boot网络环境
107+
108+
将开发板和PC连接到同一个路由器。
109+
110+
例如,PC的IP地址为:`192.168.0.101`
111+
112+
在开发板的U-Boot命令行界面内,设置FRDM-i.MX为静态IP:
113+
114+
```sh
115+
setenv ipaddr 192.168.0.120
116+
```
117+
118+
或者从路由器动态获取IP:
119+
120+
```sh
121+
dhcp
122+
```
123+
124+
成功后,可以使用ping命令测试是否可以访问PC:
125+
126+
```sh
127+
ping 192.168.0.101
128+
```
129+
130+
成功则表示网络环境正常,可以执行后续步骤。
131+
132+
133+
134+
### 3.2 安装TFTP服务
135+
136+
Windows系统可以使用Tftpd,下载链接: [Releases · PJO2/tftpd64](https://github.com/PJO2/tftpd64/releases/)
137+
138+
例如,下载portable免安装版本: https://github.com/PJO2/tftpd64/releases/download/v4.74/tftpd64_portable_v4.74.zip
139+
140+
启动后,设置TFTP工作目录:
141+
142+
![image-20251210021421740](README.assets/image-20251210021421740.png)
143+
144+
145+
146+
### 3.3 拷贝rtthread.bin到TFTP工作目录
147+
148+
在PC的Env环境中,将 `rtthread.bin` 拷贝到TFTP工作目录:
149+
```bat
150+
copy /Y rtthread.bin D:\PortableSoftwareApps\tftpd64_portable_v4.74\work\
151+
```
152+
153+
或者:
154+
155+
```sh
156+
cp rtthread.bin /path/to/tftp_work_dir/
157+
```
158+
159+
160+
161+
### 3.4 下载rtthread.bin到开发板内存中
162+
163+
在开发板的U-Boot命令行界面中,首先执行如下命令,设置TFTP服务地址(PC的IP地址):
164+
165+
```sh
166+
setenv serverip 192.168.0.101
167+
```
168+
169+
然后,继续在开发板的U-Boot命令行界面中,执行如下命令,将`rtthread.bin`下载到内存中:
170+
171+
```sh
172+
tftp 0x80000000 rtthread.bin
173+
```
174+
175+
下载的目标内存地址为:`0x80000000`
176+
177+
178+
179+
## 4. 运行
180+
181+
完成前面步骤后,继续在开发板的U-Boot命令行界面中,执行如下命令,跳转到`0x80000000`并开始执行:
182+
183+
```sh
184+
dcache flush
185+
icache flush
186+
go 0x80000000
187+
```
188+
189+
190+
191+
可以将以上三条命令设置到U-Boot的启动命令变量`bootcmd`中,实现下次开机自动执行。所有U-Boot命令如下:
192+
193+
```sh
194+
setenv ipaddr 192.168.0.120
195+
setenv serverip 192.168.0.101
38196
setenv bootcmd "tftp 0x80000000 rtthread.bin; dcache flush; icache flush; go 0x80000000"
39197
saveenv
40198
reset
41199
```
200+
201+
其中,最后的`reset`是重启命令。
202+
203+
204+
205+
## 5. 参考链接
206+
207+
1. 维护人: [xusiwei](https://github.com/xusiwei)
208+
2. AArch64工具链下载页面: [Arm GNU Toolchain Downloads – Arm Developer](https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads)
209+
3. Tftp64下载页面:https://github.com/PJO2/tftpd64/releases
210+
4. FRDM-i.MX91开发板介绍:[FRDM i.MX 91 Development Board | NXP 半导体](https://www.nxp.com.cn/design/design-center/development-boards-and-designs/FRDM-IMX91)
211+
5. i.MX91处理器介绍: [i.MX 91 Applications Processors Family | NXP 半导体](https://www.nxp.com.cn/products/i.MX91)
212+

bsp/nxp/imx/imx91/drivers/board.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,25 @@
2323
#include <limits.h>
2424

2525
#define DRAM_MAP_START KERNEL_BOOT_ADDR
26-
#define DRAM_MAP_SIZE (64 * 1024 * 1024) // part of DRAM
26+
#define DRAM_MAP_SIZE MB_SIZE(256) // part of DRAM
2727

2828
#define MEM_DESC(vaddr_start, size, paddr_start, attr) \
2929
vaddr_start, (vaddr_start + size - 1uL), paddr_start, attr
3030

31-
static volatile unsigned long MMUTable[512*4] __attribute__((aligned(4 * 1024)));
31+
// static volatile unsigned long MMUTable[512*2] __attribute__((aligned(4 * 1024)));
32+
extern volatile unsigned long MMUTable[];
3233

33-
struct mem_desc platform_mem_desc[] = {
34-
{MEM_DESC(DRAM_MAP_START, DRAM_MAP_SIZE, DRAM_MAP_START, NORMAL_MEM)},
35-
// {MEM_DESC(LPUART1_BASE, LPUART1_SIZE, LPUART1_BASE, DEVICE_MEM)}, // 0x4438_0000
36-
// {MEM_DESC(CCM_CTRL_BASE, CCM_CTRL_SIZE, CCM_CTRL_BASE, DEVICE_MEM)}, // 0x4445_8000
37-
// {MEM_DESC(GIC_DISTRIBUTOR_BASE, GIC_DISTRIBUTOR_SIZE, GIC_DISTRIBUTOR_BASE, DEVICE_MEM)}, // 0x4800_0000
38-
// {MEM_DESC(GIC_REDISTRIBUTOR_BASE, GIC_REDISTRIBUTOR_SIZE, GIC_REDISTRIBUTOR_BASE, DEVICE_MEM)}, // 0x4804_0000
34+
static struct mem_desc platform_mem_desc[] = {
35+
{MEM_DESC(LPUART1_BASE, LPUART1_SIZE, LPUART1_BASE, DEVICE_MEM)}, // 0x4438_0000
36+
{MEM_DESC(CCM_CTRL_BASE, CCM_CTRL_SIZE, CCM_CTRL_BASE, DEVICE_MEM)}, // 0x4445_8000
37+
{MEM_DESC(GIC_DISTRIBUTOR_BASE, GIC_DISTRIBUTOR_SIZE, GIC_DISTRIBUTOR_BASE, DEVICE_MEM)}, // 0x4800_0000
38+
{MEM_DESC(GIC_REDISTRIBUTOR_BASE, GIC_REDISTRIBUTOR_SIZE, GIC_REDISTRIBUTOR_BASE, DEVICE_MEM)}, // 0x4804_0000
39+
{MEM_DESC(DRAM_MAP_START, DRAM_MAP_SIZE, DRAM_MAP_START, NORMAL_MEM)}, // 0x8000_0000
3940
};
4041

41-
const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc)/sizeof(platform_mem_desc[0]);
42+
static const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc)/sizeof(platform_mem_desc[0]);
4243

43-
rt_region_t init_page_region = {
44-
(rt_size_t)PAGE_START,
45-
(rt_size_t)PAGE_END,
46-
};
44+
static rt_region_t init_page_region;
4745

4846
static rt_base_t get_sctlr_el1()
4947
{
@@ -57,18 +55,21 @@ static rt_base_t get_sctlr_el1()
5755
*/
5856
void rt_hw_board_init(void)
5957
{
58+
rt_hw_earlycon_ioremap();
59+
rt_hw_earlycon_print_hex("sctlr_el1: ", get_sctlr_el1());
6060
rt_hw_mmu_map_init(&rt_kernel_space, (void*)0x080000000000, 0x10000000, (size_t *) MMUTable, 0);
61+
62+
init_page_region.start = BOARD_PAGE_START;
63+
init_page_region.end = BOARD_PAGE_END;
6164
rt_page_init(init_page_region);
65+
6266
rt_hw_mmu_setup(&rt_kernel_space, platform_mem_desc, platform_mem_desc_size);
6367

64-
#ifdef RT_USING_HEAP
68+
#ifdef RT_USING_HEAP
6569
/* initialize system heap */
66-
rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END);
70+
rt_system_heap_init((void *)BOARD_HEAP_BEGIN, (void *)BOARD_HEAP_END);
6771
#endif
6872

69-
/* map LPUART1/CCM_CTRL/GIC_DISTRIBUTOR/GIC_REDISTRIBUTOR virtual address to equals physical address */
70-
rt_ioremap_early((void*)LPUART1_BASE, GIC_REDISTRIBUTOR_BASE + GIC_REDISTRIBUTOR_SIZE - LPUART1_BASE);
71-
7273
/* initialize hardware interrupt */
7374
rt_hw_interrupt_init();
7475

@@ -80,7 +81,6 @@ void rt_hw_board_init(void)
8081

8182
rt_components_board_init();
8283
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
83-
rt_kprintf("[rt_hw_board_init] rt_kprintf works!\n");
8484
}
8585

8686
/*@}*/

bsp/nxp/imx/imx91/drivers/board.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Date Author Notes
88
* 2025-08-10 Siwei Xu Add i.MX91 SDK
99
* 2025-09-15 Siwei Xu Fix LPUART driver
10+
* 2025-12-10 Siwei Xu Fix ioremap issues
1011
*/
1112

1213
#ifndef __BOARD_H__
@@ -15,16 +16,18 @@
1516
#include "imx91.h"
1617
#include "rtconfig.h"
1718

18-
extern int __bss_end;
19-
#define HEAP_BEGIN ((void*)&__bss_end)
20-
2119
#ifndef KERNEL_BOOT_ADDR
2220
#define KERNEL_BOOT_ADDR (ARCH_RAM_OFFSET + ARCH_TEXT_OFFSET)
2321
#endif
2422

25-
#define HEAP_END ((void*)((char*) HEAP_BEGIN + 32 * 1024 * 1024))
26-
#define PAGE_START ((size_t)HEAP_END)
27-
#define PAGE_END ((size_t)PAGE_START + 128 * 1024 * 1024)
23+
/* defined in linker script */
24+
extern unsigned char __bss_end;
25+
26+
#define BOARD_PAGE_START RT_ALIGN((rt_base_t)&__bss_end, KB_SIZE(4))
27+
#define BOARD_PAGE_END (BOARD_PAGE_START + MB_SIZE(1))
28+
29+
#define BOARD_HEAP_BEGIN (BOARD_PAGE_END)
30+
#define BOARD_HEAP_END (BOARD_HEAP_BEGIN + MB_SIZE(32))
2831

2932
void rt_hw_board_init(void);
3033

0 commit comments

Comments
 (0)