硬汉嵌入式论坛

 找回密码
 立即注册
查看: 7038|回复: 4
收起左侧

[ThreadX全家桶] 请教下,自己捣鼓 usbx 运行到 ux_system_initialize 这个函数的第 186 行出现硬件错误 ?

[复制链接]

681

主题

3487

回帖

5555

积分

论坛元老

积分
5555
发表于 2020-12-13 13:23:02 | 显示全部楼层 |阅读模式
请教下,自己捣鼓 usbx 运行到 ux_system_initialize 这个函数的第 186 行出现硬件错误 ?

具体是

#define USBX_MEMORY_SIZE     (32 * 1024)       // 这个地方不管是设置为 32KB 还是 64KB 或者是 128KB 都一样的,都会出现硬件错误
CHAR   usbx_memory_buff[USBX_MEMORY_SIZE];



UINT ux_stm32_usb_init(void)
{
        UINT    status;
       
        bsp_InitUSB();   // io 口配置
       
        /* Initialize USBX Memory */
        ux_system_initialize(usbx_memory_buff, USBX_MEMORY_SIZE, UX_NULL, 0);    // 运行到这个函数里面时就会出现硬件错误,?? 这个还在初始化操作,其他的什么也还没有开始干啦,怎么会这样的 ??
       
        /* Initialize FileX.  */
        fx_system_initialize();
       
       
        /* The code below is required for installing the host portion of USBX.  */
        status =  ux_host_stack_initialize(UX_NULL);
        if (status != UX_SUCCESS)
                        return status;
       
        /* Register storage class.  */
        status =  ux_host_stack_class_register(_ux_system_host_class_storage_name,
                                                                                                                                                                _ux_host_class_storage_entry);
        if (status != UX_SUCCESS)
                        return status;
       
        /* Register all the USB host controllers available in this system.  */
        USB_Printf("ux_host_stack_hcd_register init please waiting ... ...\r\n");
        status =  ux_host_stack_hcd_register(_ux_system_host_hcd_stm32_name,
                                                                                                                                                                _ux_hcd_stm32_initialize_hscore,  // _ux_hcd_stm32_initialize_hscore, _ux_hcd_stm32_initialize_fscore

                                                                                                                                                                USB2_BASE_ADDRESS,
                                                                                                                                                                0x0);
        if (status != UX_SUCCESS)
                        return status;
        USB_Printf("ux_stm32_usb_init OK status = %d ... ...\r\n", status);
       
        return UX_SUCCESS;
}


memory_block_err-2.png


初始化函数 ux_system_initialize(usbx_memory_buff, USBX_MEMORY_SIZE, UX_NULL, 0)
memory_block_err-1.png

_ux_system -> ux_system_regular_memory_pool_start; 这个也有地址出来,也不是空指针,怎么会造成这样的问题出现啊  ???????????????




回复

使用道具 举报

58

主题

267

回帖

446

积分

高级会员

积分
446
发表于 2020-12-13 22:10:22 | 显示全部楼层
加大堆栈
回复

使用道具 举报

681

主题

3487

回帖

5555

积分

论坛元老

积分
5555
 楼主| 发表于 2020-12-14 10:37:01 | 显示全部楼层
本帖最后由 hpdell 于 2020-12-14 12:12 编辑

终于发现问题了,是没有 4字节对齐造成的

修改为

#pragma pack(4)
CHAR usbx_memory_buff [USBX_MEMORY_SIZE];
#pragma pack()

后就可以了

或者使用
ALIGN_32BYTES(CHAR usbx_memory_buff [USBX_MEMORY_SIZE]);  也行
回复

使用道具 举报

58

主题

267

回帖

446

积分

高级会员

积分
446
发表于 2020-12-14 11:25:52 | 显示全部楼层
hpdell 发表于 2020-12-14 10:37
终于发现问题了,是没有 4自己对齐造成的,貌似历程也没有4自己对齐

修改为

ULONG   usbx_memory_buff[USBX_MEMORY_SIZE/4];

我这边下载的例程好像是这么写的。
回复

使用道具 举报

681

主题

3487

回帖

5555

积分

论坛元老

积分
5555
 楼主| 发表于 2020-12-14 14:10:25 | 显示全部楼层
ihavedone 发表于 2020-12-14 11:25
ULONG   usbx_memory_buff;

我这边下载的例程好像是这么写的。

你是哪里下载的 ? 有网址不?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2025-5-19 21:09 , Processed in 0.433155 second(s), 26 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表