Skip to content

[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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,081 changes: 1,081 additions & 0 deletions bsp/nxp/imx/imx91/.config

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions bsp/nxp/imx/imx91/Kconfig
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
10 changes: 10 additions & 0 deletions bsp/nxp/imx/imx91/Makefile
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
13 changes: 13 additions & 0 deletions bsp/nxp/imx/imx91/README.md
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
14 changes: 14 additions & 0 deletions bsp/nxp/imx/imx91/SConscript
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')
49 changes: 49 additions & 0 deletions bsp/nxp/imx/imx91/SConstruct
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)
15 changes: 15 additions & 0 deletions bsp/nxp/imx/imx91/applications/SConscript
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块多余的代码请删除

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

Return('group')
41 changes: 41 additions & 0 deletions bsp/nxp/imx/imx91/applications/application.c
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;
}

70 changes: 70 additions & 0 deletions bsp/nxp/imx/imx91/applications/startup.c
Copy link
Member

Choose a reason for hiding this comment

The 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main函数应该在 applications/main.c

{
/* disable interrupt first */
rt_hw_interrupt_disable();

/* invoke rtthread_startup */
rtthread_startup();

return 0;
}
3 changes: 3 additions & 0 deletions bsp/nxp/imx/imx91/drivers/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
config RT_USING_UART1
bool "Enable UART1"
default y
10 changes: 10 additions & 0 deletions bsp/nxp/imx/imx91/drivers/SConscript
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')
84 changes: 84 additions & 0 deletions bsp/nxp/imx/imx91/drivers/board.c
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);
}

/*@}*/
33 changes: 33 additions & 0 deletions bsp/nxp/imx/imx91/drivers/board.h
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
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The 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
#define CONFIG_MX6
#define CONFIG_MX6UL
#define CONFIG_MX91

Copilot uses AI. Check for mistakes.

Comment on lines +18 to +19
Copy link
Preview

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The 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
#define CONFIG_MX6
#define CONFIG_MX6UL
#define CONFIG_MX91

Copilot uses AI. Check for mistakes.


#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
Loading