-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[bsp][nxp][imx] WIP: Add FRDM-i.MX91 bsp #10570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
mainmenu "RT-Thread Configuration" | ||
|
||
BSP_DIR := . | ||
|
||
RTT_DIR := ../../../.. | ||
|
||
PKGS_DIR := packages | ||
|
||
config BOARD_IMX91 | ||
bool | ||
select ARCH_ARM_CORTEX_A55 | ||
select RT_USING_GIC_V2 | ||
default y | ||
|
||
source "$(RTT_DIR)/Kconfig" | ||
osource "$PKGS_DIR/Kconfig" | ||
|
||
source "$(BSP_DIR)/drivers/Kconfig" | ||
|
||
config SOC_MIMX91X1D | ||
bool | ||
select RT_USING_COMPONENTS_INIT | ||
select RT_USING_USER_MAIN | ||
default y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
scons:=python ${SCONS}\scons.py | ||
|
||
all: | ||
@$(scons) | ||
|
||
clean: | ||
@$(scons) -c | ||
|
||
copy: | ||
@$(scons) --copy -s |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# i.MX91 | ||
|
||
The i.MX 91 applications processor features an Arm® Cortex®-A55 running at up to 1.4 GHz and support for modern LPDDR4 memory to enable platform longevity and reliability; dual Gigabit Ethernet for gateway or multi-network segment support; dual USB ports; and the essential I/O for products in smart factory, smart home, smart office, medical device, metering, and cost-optimized | ||
system-on-module platforms. | ||
|
||
The i.MX 91 may be used in applications such as: | ||
• EV Charging | ||
• Matter-enabled IoT Platforms | ||
• Smart Home, Office, and City | ||
• Building Automation and Monitoring | ||
• Industrial Monitoring and HMI | ||
• Portable or small form-factor Medical and Healthcare devices | ||
• Audio and Entertainment IoT |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# for module compiling | ||
import os | ||
Import('RTT_ROOT') | ||
|
||
cwd = str(Dir('#')) | ||
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') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import sys | ||
import rtconfig | ||
|
||
if os.getenv('RTT_ROOT'): | ||
RTT_ROOT = os.getenv('RTT_ROOT') | ||
else: | ||
RTT_ROOT = os.path.join(os.getcwd(), '..', '..', '..', '..') | ||
|
||
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')] | ||
from building import * | ||
|
||
def bsp_pkg_check(): | ||
import subprocess | ||
|
||
check_paths = [ | ||
os.path.join("packages", "nxp-imx91-sdk-latest"), | ||
] | ||
|
||
need_update = not all(os.path.exists(p) for p in check_paths) | ||
|
||
if need_update: | ||
print("\n==============================================================") | ||
print("Dependency packages missing, please running 'pkgs --update'...") | ||
print("==============================================================") | ||
exit(1) | ||
|
||
RegisterPreBuildingAction(bsp_pkg_check) | ||
|
||
TARGET = 'rtthread.' + rtconfig.TARGET_EXT | ||
|
||
DefaultEnvironment(tools=[]) | ||
env = Environment(tools = ['mingw'], | ||
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, | ||
CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS, | ||
CXX= rtconfig.CXX, CXXFLAGS = rtconfig.CFLAGS, | ||
AR = rtconfig.AR, ARFLAGS = '-rc', | ||
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) | ||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH) | ||
env['ASCOM'] = env['ASPPCOM'] | ||
|
||
Export('RTT_ROOT') | ||
Export('rtconfig') | ||
|
||
# prepare building environment | ||
objs = PrepareBuilding(env, RTT_ROOT) | ||
|
||
# make a building | ||
DoBuilding(TARGET, objs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from building import * | ||
import os | ||
|
||
cwd = GetCurrentDir() | ||
src = Glob('*.c') | ||
CPPPATH = [cwd] | ||
|
||
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') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2006-2025, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
* 2025-07-12 BruceOu the first version | ||
*/ | ||
|
||
#include <rtthread.h> | ||
|
||
#include <sdk_version.h> | ||
#include <ccm_pll.h> | ||
|
||
void show_freq(void) | ||
{ | ||
rt_kprintf("CPU: %d MHz\n", get_main_clock(CPU_CLK)/1000000); | ||
rt_kprintf("DDR: %d MHz\n", get_main_clock(MMDC_CH0_AXI_CLK)/1000000); | ||
rt_kprintf("IPG: %d MHz\n", get_main_clock(IPG_CLK)/1000000); | ||
} | ||
|
||
void init_thread(void* parameter) | ||
{ | ||
rt_kprintf("Freescale i.MX91 Platform SDK %s\n", SDK_VERSION_STRING); | ||
show_freq(); | ||
|
||
rt_components_init(); | ||
} | ||
|
||
int rt_application_init() | ||
{ | ||
rt_thread_t tid; | ||
|
||
tid = rt_thread_create("init", init_thread, RT_NULL, | ||
1024, RT_THREAD_PRIORITY_MAX/3, 10); | ||
if (tid != RT_NULL) rt_thread_startup(tid); | ||
|
||
return 0; | ||
} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 正确姿势不应该重写这个文件吧? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2006-2025, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
* 2025-07-12 BruceOu the first version | ||
*/ | ||
|
||
#include <rthw.h> | ||
#include <rtthread.h> | ||
|
||
#include <board.h> | ||
|
||
extern int rt_application_init(void); | ||
extern void rt_hw_board_init(void); | ||
|
||
/** | ||
* This function will startup RT-Thread RTOS. | ||
*/ | ||
void rtthread_startup(void) | ||
{ | ||
// platform_init(); | ||
// print_version(); | ||
|
||
/* initialzie hardware interrupt */ | ||
rt_hw_interrupt_init(); | ||
|
||
/* initialize board */ | ||
rt_hw_board_init(); | ||
|
||
/* show RT-Thread version */ | ||
rt_show_version(); | ||
|
||
/* initialize memory system */ | ||
#ifdef RT_USING_HEAP | ||
rt_system_heap_init(HEAP_BEGIN, HEAP_END); | ||
#endif | ||
|
||
/* initialize scheduler system */ | ||
rt_system_scheduler_init(); | ||
|
||
/* initialize timer and soft timer thread */ | ||
rt_system_timer_init(); | ||
rt_system_timer_thread_init(); | ||
|
||
/* initialize application */ | ||
rt_application_init(); | ||
|
||
/* initialize idle thread */ | ||
rt_thread_idle_init(); | ||
|
||
/* start scheduler */ | ||
rt_system_scheduler_start(); | ||
|
||
/* never reach here */ | ||
return ; | ||
} | ||
|
||
int main(void) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. main函数应该在 |
||
{ | ||
/* disable interrupt first */ | ||
rt_hw_interrupt_disable(); | ||
|
||
/* invoke rtthread_startup */ | ||
rtthread_startup(); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
config RT_USING_UART1 | ||
bool "Enable UART1" | ||
default y |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from building import * | ||
|
||
cwd = GetCurrentDir() | ||
src = Glob('*.c') + Glob('iomux/*.c') | ||
|
||
CPPPATH = [cwd, cwd + '/iomux'] | ||
|
||
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH) | ||
|
||
Return('group') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2006-2025, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
* 2025-07-12 BruceOu the first version | ||
*/ | ||
|
||
#include <rthw.h> | ||
#include <rtthread.h> | ||
|
||
#include "board.h" | ||
|
||
#include <registers/regsarmglobaltimer.h> | ||
#include <registers/regsepit.h> | ||
|
||
#include <imx_uart.h> | ||
#include <epit.h> | ||
#include <cortex_a.h> | ||
|
||
#include <mmu.h> | ||
|
||
struct mem_desc platform_mem_desc[] = { | ||
{0x00000000, 0x80000000, 0x00000000, DEVICE_MEM}, | ||
{0x80000000, 0xFFF00000, 0x80000000, NORMAL_MEM} | ||
}; | ||
|
||
const rt_uint32_t platform_mem_desc_size = sizeof(platform_mem_desc)/sizeof(platform_mem_desc[0]); | ||
|
||
static void rt_hw_timer_isr(int vector, void *param) | ||
{ | ||
rt_tick_increase(); | ||
epit_get_compare_event(HW_EPIT1); | ||
} | ||
|
||
int rt_hw_timer_init(void) | ||
{ | ||
uint32_t freq; | ||
|
||
// Make sure the timer is off. | ||
HW_ARMGLOBALTIMER_CONTROL.B.TIMER_ENABLE = 0; | ||
|
||
HW_ARMGLOBALTIMER_CONTROL.B.FCR0 =1; | ||
|
||
HW_ARMGLOBALTIMER_CONTROL.B.FCR1 =0; | ||
|
||
HW_ARMGLOBALTIMER_CONTROL.B.DBG_ENABLE =0; | ||
|
||
// Clear counter. | ||
HW_ARMGLOBALTIMER_COUNTER_HI_WR(0); | ||
HW_ARMGLOBALTIMER_COUNTER_LO_WR(0); | ||
|
||
// Now turn on the timer. | ||
HW_ARMGLOBALTIMER_CONTROL.B.TIMER_ENABLE = 1; | ||
|
||
freq = get_main_clock(IPG_CLK); | ||
|
||
epit_init(HW_EPIT1, CLKSRC_IPG_CLK, freq / 1000000, | ||
SET_AND_FORGET, 10000, WAIT_MODE_EN | STOP_MODE_EN); | ||
|
||
epit_counter_enable(HW_EPIT1, 10000, IRQ_MODE); | ||
|
||
rt_hw_interrupt_install(IMX_INT_EPIT1, rt_hw_timer_isr, RT_NULL, "tick"); | ||
rt_hw_interrupt_umask(IMX_INT_EPIT1); | ||
|
||
return 0; | ||
} | ||
INIT_BOARD_EXPORT(rt_hw_timer_init); | ||
|
||
/** | ||
* This function will initialize hardware board | ||
*/ | ||
void rt_hw_board_init(void) | ||
{ | ||
enable_neon_fpu(); | ||
disable_strict_align_check(); | ||
|
||
rt_components_board_init(); | ||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME); | ||
} | ||
|
||
/*@}*/ |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,33 @@ | ||||||||||||||
/* | ||||||||||||||
* Copyright (c) 2006-2025, RT-Thread Development Team | ||||||||||||||
* | ||||||||||||||
* SPDX-License-Identifier: Apache-2.0 | ||||||||||||||
* | ||||||||||||||
* Change Logs: | ||||||||||||||
* Date Author Notes | ||||||||||||||
* 2025-07-12 BruceOu the first version | ||||||||||||||
*/ | ||||||||||||||
|
||||||||||||||
#ifndef __BOARD_H__ | ||||||||||||||
#define __BOARD_H__ | ||||||||||||||
|
||||||||||||||
#include <registers.h> | ||||||||||||||
#include <irq_numbers.h> | ||||||||||||||
#include "imx91.h" | ||||||||||||||
|
||||||||||||||
#define CONFIG_MX6 | ||||||||||||||
#define CONFIG_MX6UL | ||||||||||||||
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This macro definition is incorrect for i.MX91. It should be '#define CONFIG_MX91' or similar to match the actual SoC family.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback
Comment on lines
+18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This macro definition is incorrect for i.MX91. It should be '#define CONFIG_MX91' or similar to match the actual SoC being supported.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||
|
||||||||||||||
#if defined(__CC_ARM) | ||||||||||||||
extern int Image$$RW_IRAM1$$ZI$$Limit; | ||||||||||||||
#define HEAP_BEGIN ((void*)&Image$$RW_IRAM1$$ZI$$Limit) | ||||||||||||||
#elif defined(__GNUC__) | ||||||||||||||
extern int __bss_end; | ||||||||||||||
#define HEAP_BEGIN ((void*)&__bss_end) | ||||||||||||||
#endif | ||||||||||||||
|
||||||||||||||
#define HEAP_END (void*)(0x80000000 + 32 * 1024 * 1024) | ||||||||||||||
|
||||||||||||||
void rt_hw_board_init(void); | ||||||||||||||
|
||||||||||||||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块多余的代码请删除