imxrt1170 SD运行问题

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imxrt1170 SD运行问题

Jump to solution
5,029 Views
jingyangxie
Contributor V

我有一块1170的开发板,在调试模式下,USB检测程序运行正常(程序运行RT-Thread系统),U盘插入能自动挂载,但将程序烧录到SD卡(启动设备)再启动,系统直接宕机,串口无反应,请问1170使用SD卡作为启动设备有什么限制吗

0 Kudos
1 Solution
4,864 Views
jingyangxie
Contributor V

问题就出在USB初始化的时候,时钟配置不对,原代码为

    usb_phy_config_struct_t phyConfig = {
        BOARD_USB_PHY_D_CAL, BOARD_USB_PHY_TXCAL45DP,   BOARD_USB_PHY_TXCAL45DM,
    };
    if (controller_id == kUSB_ControllerEhci0)
    {
        CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
        CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U);
    }
    else
    {
        CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
        CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, 480000000U);
    }

    USB_EhciPhyInit(controller_id, 24000000U, &phyConfig);
 
修改为:
    uint32_t usbClockFreq;
    usb_phy_config_struct_t phyConfig = {
        BOARD_USB_PHY_D_CAL, BOARD_USB_PHY_TXCAL45DP, BOARD_USB_PHY_TXCAL45DM,
    };
   
    usbClockFreq = 24000000;

    if (controller_id == kUSB_ControllerEhci0)
    {
        CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, usbClockFreq);
        CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, usbClockFreq);
    }
    else
    {
        CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, usbClockFreq);
        CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, usbClockFreq);
    }

    USB_EhciPhyInit(controller_id, 24000000U, &phyConfig);
下载进SD卡,正常运行

View solution in original post

0 Kudos
17 Replies
5,019 Views
jeremyzhou
NXP Employee
NXP Employee

Hi @jingyangxie ,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
从你的表述来看,你是说RT1170从SD card启动失败,是这样吗?
如果是,我想知道你的测试平台和测试步骤,同时如果你手上有MIMXRT1170 EVK开发板的话,能否复现上述现象。
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
------------------------------------------------------------------------------

0 Kudos
5,017 Views
jingyangxie
Contributor V

我用的就是MIMXRT1170 EVK开发板,整个测试是这样的,我用的是RT-Thread的BSP:

https://github.com/RT-Thread/rt-thread/tree/master/bsp/imxrt/imxrt1170-nxp-evk/m7

 

在调试模式下,配置USB支持是可以的,但程序烧录到SD卡中,串口除了显示RT-thread版本号后,无法操作,也不显示其它内容(正常情况下会显示main函数的信息)

0 Kudos
5,008 Views
jeremyzhou
NXP Employee
NXP Employee

Hi @jingyangxie ,
谢谢回复。
你的意思是说工程代码在RAM中调试时,运行都是正常的,但是同样的代码从SD卡启动并拷贝到RAM中运行,就有问题,是这样吗?在测试其他工程代码,比如NXP SDK中的代码时有出现这种现象吗?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
------------------------------------------------------------------------------

0 Kudos
5,005 Views
jingyangxie
Contributor V
是的,在RAM中调试是正常的,通过BootUtility烧录SD卡,同样的代码从SD卡启动并拷贝到RAM中运行,就有问题,目前NXP SDK的代码我测试的比较小,比如hello world或者led, 测试USB fatfs demo,因为开发板没有USB A口,所以没法测试U盘插入动作,此时,串口就只显示一个 host init done.此时串口无法输入,也没有输出,无法判断程序是否运行正常
0 Kudos
4,992 Views
jeremyzhou
NXP Employee
NXP Employee

Hi @jingyangxie ,
谢谢回复。
我有个疑问,你前面说在RAM中调试是正常的,但是后面你有提到开发板没有USB A口,所以我不清楚’调试正常‘是个什么样的情况?
还有测试非USB工程代码,都是可以从SD卡正常启动运行吗?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
------------------------------------------------------------------------------

0 Kudos
4,990 Views
jingyangxie
Contributor V

抱歉,我没表述清楚,调试OK的是我自己的板卡,和开发板一样,只是把otg换成了标准usb口,另外,SDK里面的其它demo,我试了有四五个,下载到SD卡均可以正常运行,当然,我自己的板卡也运行正常;但只要加载USB,我的板卡和开发板下载到SD卡中,都不能正常运行(程序用的依然是RTT)

0 Kudos
4,931 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
谢谢回复。
从你测试来说,就是host_msd_fatfs_freertos可以从SD启动,并在RAM中运行,但是RTOS变成RT-thread就不正常工作了,那么我想问一下代码是否在相同RAM块中运行呢?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
4,929 Views
jingyangxie
Contributor V

链接文件是一样的,可以看https://community.nxp.com/t5/i-MX-RT/imxrt-1170-usb-problem/m-p/1546130#M22276,我对问题的范围缩小了,就是代码中一旦对ehciInstance->ehciIpBase->PORTSC1这个寄存器赋值,不管是什么,系统就挂起了,感觉这个寄存器是只读的了,但调试模式又没事,很费解

0 Kudos
4,897 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
谢谢回复。
测试host_msd_fatfs_freertos能复现问题吗?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
4,894 Views
jingyangxie
Contributor V

没有复现,这个demo是OK的,所以很奇怪,这个demo用的是FreeRTOS,而我用的是RTT,问题是卡住的地方在USB_HOSTInit里面,USB还没开始用呢

0 Kudos
4,865 Views
jingyangxie
Contributor V

问题就出在USB初始化的时候,时钟配置不对,原代码为

    usb_phy_config_struct_t phyConfig = {
        BOARD_USB_PHY_D_CAL, BOARD_USB_PHY_TXCAL45DP,   BOARD_USB_PHY_TXCAL45DM,
    };
    if (controller_id == kUSB_ControllerEhci0)
    {
        CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
        CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, 480000000U);
    }
    else
    {
        CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, 480000000U);
        CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, 480000000U);
    }

    USB_EhciPhyInit(controller_id, 24000000U, &phyConfig);
 
修改为:
    uint32_t usbClockFreq;
    usb_phy_config_struct_t phyConfig = {
        BOARD_USB_PHY_D_CAL, BOARD_USB_PHY_TXCAL45DP, BOARD_USB_PHY_TXCAL45DM,
    };
   
    usbClockFreq = 24000000;

    if (controller_id == kUSB_ControllerEhci0)
    {
        CLOCK_EnableUsbhs0PhyPllClock(kCLOCK_Usbphy480M, usbClockFreq);
        CLOCK_EnableUsbhs0Clock(kCLOCK_Usb480M, usbClockFreq);
    }
    else
    {
        CLOCK_EnableUsbhs1PhyPllClock(kCLOCK_Usbphy480M, usbClockFreq);
        CLOCK_EnableUsbhs1Clock(kCLOCK_Usb480M, usbClockFreq);
    }

    USB_EhciPhyInit(controller_id, 24000000U, &phyConfig);
下载进SD卡,正常运行
0 Kudos
4,869 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
我觉得你首先可以对比一下SDK中的USB代码和你的工程代码的区别,因为从你的测试结果看,硬件应该是没问题的。
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
4,866 Views
jingyangxie
Contributor V

区别是有的,就是内存分配的方式,SDK用的是Freertos的heap_4.c中的分配内存的方法;而我的是用的rt-thread的rt_malloc函数分配内存

0 Kudos
4,964 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
谢谢回复。
有测试过SDK中的USB例程吗?可以正常工作吗?
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
4,946 Views
jingyangxie
Contributor V
重新解压SDK包2.12版本,测试host_msd_fatfs_freertos,链接文件选择ram.icf,调试和下载到SD卡中,串口输出一致,能看到识别出U盘,并做了测试;
猜想:是否USB的代码需要放到合适的地方(在链接文件中指定或是有宏定义控制),我把相同的USB代码拷贝我我的工程中,自有宏定义不同,因为我用的是RT-thread,而不是freertos
0 Kudos
4,957 Views
jingyangxie
Contributor V

测过usb的host_msd_fatfs_freertos这个demo,虽然不会死机 ,但插入U盘没有任何反应(串口无输出),只在调试模式下进行了测试

0 Kudos
4,960 Views
jingyangxie
Contributor V

加入USB支持后,map文件会提示这个:

No sections matched the following patterns:

section CodeQuickAccess in block QACCESS_CODE
section DataQuickAccess in block QACCESS_DATA
section NonCacheable.init in block NCACHE_VAR
section m_usb_dma_init_data in block RW
section m_usb_dma_noninit_data in block ZI

 

不知道有影响没

0 Kudos