硬汉嵌入式论坛

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

[技术讨论] GD32H7移植NEXTDUO遇到问题

  [复制链接]

5

主题

11

回帖

26

积分

新手上路

菜鸟在飞

积分
26
发表于 2024-9-18 18:12:44 | 显示全部楼层 |阅读模式
本帖最后由 关翼飞 于 2024-9-18 18:14 编辑

我在GD32H759im上参照硬汉哥《V7-2402_ThreadX NetXDUO TCP Server》移植Threadx+Netxduo,移植完之后,遇到如下问题:
1、Dcache打开网络无法链接,mpu开启也没有用
[C] 纯文本查看 复制代码
enet_descriptors_struct  rxdesc_tab[ENET_RXBUF_NUM] __attribute__((section(".ARM.__at_0x30000000")));          /*!< ENET RxDMA descriptor */

enet_descriptors_struct txdesc_tab[ENET_TXBUF_NUM] __attribute__((section(".ARM.__at_0x30000160"))); /*!< ENET TxDMA descriptor */
uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE] __attribute__((section(".ARM.__at_0x30000300"))); /*!< ENET receive buffer */
uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE] __attribute__((section(".ARM.__at_0x30002100"))); /*!< ENET transmit buffer */
[/mw_shl_code]
[C] 纯文本查看 复制代码
    /* Configure the DMA descriptors and Rx/Tx buffer*/
    mpu_init_struct.region_base_address = 0x30000000;                                                        // 设置MPU(内存保护单元)区域的基地址
    mpu_init_struct.region_size = MPU_REGION_SIZE_16KB;                                                // 设置内存区域的大小为16KB
    mpu_init_struct.access_permission = MPU_AP_FULL_ACCESS;                                // 设置访问权限为完全访问(读、写、执行)
    mpu_init_struct.access_bufferable = MPU_ACCESS_BUFFERABLE;                // 设置该区域为可缓冲的(可以使用缓冲区内存)
    mpu_init_struct.access_cacheable = MPU_ACCESS_NON_CACHEABLE;        // 设置该区域为不可缓存(内存访问绕过缓存)
    mpu_init_struct.access_shareable = MPU_ACCESS_NON_SHAREABLE;        // 设置该区域为不可共享的(该区域不在不同处理器或核心间共享)
    mpu_init_struct.region_number = MPU_REGION_NUMBER0;                                                // 选择MPU区域号(此处为区域0)
    mpu_init_struct.subregion_disable = MPU_SUBREGION_ENABLE;                        // 禁用该内存区域的子区域(MPU_SUBREGION_ENABLE可用于禁用特定子区域)
    mpu_init_struct.instruction_exec = MPU_INSTRUCTION_EXEC_PERMIT;// 允许在此内存区域执行指令
    mpu_init_struct.tex_type = MPU_TEX_TYPE0;                                                                                        // 将该区域的TEX(类型扩展)属性设置为类型0(通常用于设置内存类型)
    mpu_region_config(&mpu_init_struct);                                                                                                        // 配置MPU区域
    mpu_region_enable();                                                                                                                                                                        // 启用MPU区域

此处为dma收发描述符与收发缓冲区位置和MPU配置

2、不开启dcache 网络跑一段时间会卡死,由于这款芯片debug有些问题无法查看内存,猜测可能是堆栈溢出,但是加大堆栈之后没有效果。这种情况下网络协议栈调试方法是怎样的还请各位大佬指点迷津。

文末有原工程


GD32H759I-EVAL-master1.rar

2.34 MB, 下载次数: 10

回复

使用道具 举报

0

主题

13

回帖

13

积分

新手上路

积分
13
发表于 2024-9-18 19:56:35 | 显示全部楼层
在发送函数_nx_driver_hardware_packet_send中发送之前需要对发送的buff做cache清理操作,否则会有异常,你可以试一下看看,具体如下:

static UINT  _nx_driver_hardware_packet_send(NX_PACKET *packet_ptr)
{

    ULONG          curIdx;
    NX_PACKET      *pktIdx;
    ULONG          bd_count = 0;
    //UCHAR          remainder = 0;
    //UCHAR*         src_addr;
    UCHAR         cnt;
   
    /* Pick up the first BD. */
    curIdx = nx_driver_information.nx_driver_information_transmit_current_index;
   
    /* Check if it is a free descriptor.  */   //ENET_TDES0_DAV  the descriptor is busy due to own by the DMA
    if ((nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status & ENET_TDES0_DAV) || nx_driver_information.nx_driver_information_transmit_packets[curIdx])
    {
        /* Buffer is still owned by device.  */
        return(NX_DRIVER_ERROR);
    }

    /* Set the buffer size.  */
    nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size = (packet_ptr -> nx_packet_append_ptr - packet_ptr->nx_packet_prepend_ptr);

//    remainder = (UCHAR )((ULONG)(packet_ptr->nx_packet_prepend_ptr )& 0x1F);   //32 byte aliment  - 2
//
//    if(remainder)
//    {
//        src_addr = packet_ptr->nx_packet_prepend_ptr;
//      
//        /*make sure transmit BD buffer 8byte alignment*/
//        packet_ptr->nx_packet_prepend_ptr -= remainder;
//      
//        memmove(packet_ptr->nx_packet_prepend_ptr,src_addr,nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size);
//    }
    if(((ULONG)(packet_ptr->nx_packet_prepend_ptr) >= 0x30008000)||((ULONG)(packet_ptr->nx_packet_prepend_ptr) < 0x30000000))
    {
    /* Find the Buffer, set the Buffer pointer. */
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)           //cache清理操作        
        //SCB_CleanDCache_by_Addr((uint32_t*)(packet_ptr->nx_packet_prepend_ptr), ((nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size&0xFFFFFFE0)|0x20));
        cnt = (UCHAR)((ULONG)(packet_ptr->nx_packet_prepend_ptr)&0x1F);
        SCB_CleanDCache_by_Addr((uint32_t*)(packet_ptr->nx_packet_prepend_ptr-cnt), (((nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size+cnt)&0xFFFFFFE0)|0x20));
#endif     
    }
    nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].buffer1_addr = (ULONG)(packet_ptr->nx_packet_prepend_ptr);   

    /* Clear the first Descriptor's LS bit.  */
    nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status &= ~ENET_TDES0_LSG;
    /* Find next packet.  */
    for (pktIdx = packet_ptr -> nx_packet_next;
         pktIdx != NX_NULL;
         pktIdx = pktIdx -> nx_packet_next)
    {
        
        /* Move to next descriptor.  */
        curIdx = (curIdx + 1) & (NX_DRIVER_TX_DESCRIPTORS - 1);
   
        /* Check if it is a free descriptor.  */   
        if ((nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status & ENET_TDES0_DAV) || nx_driver_information.nx_driver_information_transmit_packets[curIdx])
        {
            
            /* No more descriptor available, return driver error status.  */
            return(NX_DRIVER_ERROR);
        }   
        
        /* Set the buffer size.  */
        nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size = (pktIdx -> nx_packet_append_ptr - pktIdx->nx_packet_prepend_ptr);
        
//        remainder = (UCHAR )((ULONG)(packet_ptr->nx_packet_prepend_ptr )& 0x1F);   //32 byte aliment  - 2
//
//        if(remainder)
//        {
//            src_addr = packet_ptr->nx_packet_prepend_ptr;
//         
//            /*make sure transmit BD buffer 8byte alignment*/
//            packet_ptr->nx_packet_prepend_ptr -= remainder;
//         
//            memmove(packet_ptr->nx_packet_prepend_ptr,src_addr,nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size);
//        }
        if(((ULONG)(packet_ptr->nx_packet_prepend_ptr) >= 0x30008000)||((ULONG)(packet_ptr->nx_packet_prepend_ptr) < 0x30000000))
        {
        /* Find the Buffer, set the Buffer pointer. */
#if defined (__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)     //SCB_CleanDCache_by_Addr  32byte alignment
            //SCB_CleanDCache_by_Addr((uint32_t*)(packet_ptr->nx_packet_prepend_ptr), ((nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size&0xFFFFFFE0)|0x20));
            cnt = (UCHAR)((ULONG)(packet_ptr->nx_packet_prepend_ptr)&0x1F);
            SCB_CleanDCache_by_Addr((uint32_t*)(packet_ptr->nx_packet_prepend_ptr-cnt), (((nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].control_buffer_size+cnt)&0xFFFFFFE0)|0x20));
#endif     
        }
        
        /* Find the Buffer, set the Buffer pointer.  */
        nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].buffer1_addr = (ULONG)(pktIdx->nx_packet_prepend_ptr);
   
        
        
        /* Clear the descriptor's LS bit.  */
        nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status &= ~ENET_TDES0_LSG;

        /* Increment the BD count.  */
        bd_count++;
        
    }
   
    /* Set the last Descriptor's LS & IC & OWN bit.  */
    if(bd_count == 0)     /*只有1帧*/
    {
        nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status |= (ENET_TDES0_FSG |ENET_TDES0_LSG | ENET_TDES0_DAV);   /*LSG 最后一部分数据  FSG代表新帧   ENET_TDES0_DAV:允许发送     | ENET_TDES0_INTC*/
    }
    else
    {
        nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status |= (ENET_TDES0_FSG  | ENET_TDES0_DAV  );   /*FSG 首帧  */
    }

    /* Save the pkt pointer to release.  */
    nx_driver_information.nx_driver_information_transmit_packets[curIdx] = packet_ptr;
   
    /* Set the current index to the next descriptor.  */
    nx_driver_information.nx_driver_information_transmit_current_index = (curIdx + 1) & (NX_DRIVER_TX_DESCRIPTORS - 1);
   
    /* Increment the transmit buffers in use count.  */
    nx_driver_information.nx_driver_information_number_of_transmit_buffers_in_use += (bd_count + 1);
   
    /* Set OWN bit to indicate BDs are ready.  */
    for (; bd_count > 0; bd_count--)
    {
        
        /* Set OWN bit in reverse order, move to prevous BD.  */
        curIdx = (curIdx - 1) & (NX_DRIVER_TX_DESCRIPTORS - 1);
        
        /* Set this BD's OWN bit.  */
        nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status |= ENET_TDES0_DAV;     /*ENET_TDES0_DAV:允许发送*/
        if(bd_count == 1)
        {
            nx_driver_information.nx_driver_information_dma_tx_descriptors[curIdx].status |= ENET_TDES0_LSG;   /*最后一帧 */
        }
    }

    /* check Tx buffer unavailable flag status */
    if (((uint32_t)RESET != (ENET_DMA_STAT(ENET) & ENET_DMA_STAT_TBU)) || ((uint32_t)RESET != (ENET_DMA_STAT(ENET) & ENET_DMA_STAT_TU))){
        /* clear TBU and TU flag */
        ENET_DMA_STAT(ENET) = (ENET_DMA_STAT(ENET) & ENET_DMA_STAT_TBU);
        ENET_DMA_STAT(ENET) = (ENET_DMA_STAT(ENET) & ENET_DMA_STAT_TU);
    }
    /* resume DMA transmission by writing to the TPEN register*/
    ENET_DMA_TPEN(ENET) = 0U;    /* 写入任意值到 ENET_DMA_TPEN 寄存器中,使 TxDMA 退出挂起模式,开始发送数据*/

    return(NX_SUCCESS);
}
回复

使用道具 举报

24

主题

195

回帖

267

积分

高级会员

积分
267
QQ
发表于 2024-9-18 20:22:53 | 显示全部楼层
我这边的 MPU 配置是开 cache 的,关于这一条。
mpu_init_struct.access_cacheable = MPU_ACCESS_NON_CACHEABLE;
不是很清楚到底开不开,我这大概率也是抄的硬汉老哥。
回复

使用道具 举报

5

主题

11

回帖

26

积分

新手上路

菜鸟在飞

积分
26
 楼主| 发表于 2024-9-19 08:36:40 | 显示全部楼层
qqzhaojs 发表于 2024-9-18 19:56
在发送函数_nx_driver_hardware_packet_send中发送之前需要对发送的buff做cache清理操作,否则会有异常,你 ...

好的,感谢老哥,我试一下
回复

使用道具 举报

5

主题

11

回帖

26

积分

新手上路

菜鸟在飞

积分
26
 楼主| 发表于 2024-9-19 08:38:28 | 显示全部楼层
yono 发表于 2024-9-18 20:22
我这边的 MPU 配置是开 cache 的,关于这一条。
mpu_init_struct.access_cacheable = MPU_ACCESS_NON_CACH ...

这里我查到的资料都说是不开,但我还真没试过打开这里我马上试下
回复

使用道具 举报

4

主题

1449

回帖

1461

积分

至尊会员

积分
1461
发表于 2024-10-9 10:38:13 | 显示全部楼层
关翼飞 发表于 2024-9-19 08:38
这里我查到的资料都说是不开,但我还真没试过打开这里我马上试下

好了吗?我也打算用下GD32H759的以太网。谢谢!
回复

使用道具 举报

5

主题

11

回帖

26

积分

新手上路

菜鸟在飞

积分
26
 楼主| 发表于 2024-10-9 13:49:00 | 显示全部楼层
morning_enr6U 发表于 2024-10-9 10:38
好了吗?我也打算用下GD32H759的以太网。谢谢!

按照上边老哥给的接口文件代码,可以用,但是还是无法开cache,这个问题还没解决,项目要往下进行了,就先没搞这个
回复

使用道具 举报

4

主题

1449

回帖

1461

积分

至尊会员

积分
1461
发表于 2024-10-9 15:24:58 | 显示全部楼层
关翼飞 发表于 2024-10-9 13:49
按照上边老哥给的接口文件代码,可以用,但是还是无法开cache,这个问题还没解决,项目要往下进行了,就 ...

感谢告知
回复

使用道具 举报

5

主题

24

回帖

39

积分

新手上路

积分
39
发表于 2024-10-10 11:22:01 | 显示全部楼层
GD32H7最骚的地方就是必须要在MPU里设置0x87的约束,不然跑着跑着芯片就跑飞了,我之前的产品没设置0x87的约束基本1个晚上就是跑挂,设置了约束就没挂过……
回复

使用道具 举报

4

主题

1449

回帖

1461

积分

至尊会员

积分
1461
发表于 2024-10-10 11:47:51 | 显示全部楼层
可乐狂魔 发表于 2024-10-10 11:22
GD32H7最骚的地方就是必须要在MPU里设置0x87的约束,不然跑着跑着芯片就跑飞了,我之前的产品没设置0x87的 ...

请教一下,0x87约束是具体是指什么,谢谢!
回复

使用道具 举报

5

主题

24

回帖

39

积分

新手上路

积分
39
发表于 2024-10-10 12:08:44 | 显示全部楼层
    mpu_region_init_struct mpu_init_struct;
    /* disable MPU */
    ARM_MPU_Disable();
   
    mpu_init_struct.region_number       = MPU_REGION_NUMBER0;
    mpu_init_struct.region_base_address = 0x00000000U;
    mpu_init_struct.instruction_exec    = MPU_INSTRUCTION_EXEC_NOT_PERMIT;
    mpu_init_struct.access_permission   = MPU_AP_NO_ACCESS;
    mpu_init_struct.tex_type            = MPU_TEX_TYPE0;
    mpu_init_struct.access_shareable    = MPU_ACCESS_SHAREABLE;
    mpu_init_struct.access_cacheable    = MPU_ACCESS_NON_CACHEABLE;
    mpu_init_struct.access_bufferable   = MPU_ACCESS_NON_BUFFERABLE;
    mpu_init_struct.subregion_disable   = 0x87;
    mpu_init_struct.region_size         = MPU_REGION_SIZE_4GB;  
   
    mpu_region_config(&mpu_init_struct);
    mpu_region_enable();
    /* enable MPU */
    ARM_MPU_Enable(MPU_MODE_PRIV_DEFAULT);
回复

使用道具 举报

4

主题

1449

回帖

1461

积分

至尊会员

积分
1461
发表于 2024-10-10 13:31:38 | 显示全部楼层
可乐狂魔 发表于 2024-10-10 12:08
mpu_region_init_struct mpu_init_struct;
    /* disable MPU */
    ARM_MPU_Disable();

[C] 纯文本查看 复制代码
#define MPU_SUBREGION_ENABLE            ((uint8_t)0x00U)          /*!< Subregion enable */
#define MPU_SUBREGION_DISABLE           ((uint8_t)0x01U)          /*!< Subregion disable */


这个0x87什么梗啊?
回复

使用道具 举报

4

主题

1449

回帖

1461

积分

至尊会员

积分
1461
发表于 2024-10-10 13:36:10 | 显示全部楼层
可乐狂魔 发表于 2024-10-10 12:08
mpu_region_init_struct mpu_init_struct;
    /* disable MPU */
    ARM_MPU_Disable();

[C] 纯文本查看 复制代码
    mpu_region_init_struct mpu_init_struct;
    mpu_region_struct_para_init(&mpu_init_struct);

    /* disable the MPU */
    ARM_MPU_Disable();
    ARM_MPU_SetRegion(0, 0);

    /* Configure the memory of netxduo pool to be protected */
    mpu_init_struct.region_base_address = 0x24000000;
    mpu_init_struct.region_size          = MPU_REGION_SIZE_512KB;
    mpu_init_struct.access_permission    = MPU_AP_FULL_ACCESS;
    mpu_init_struct.access_bufferable    = MPU_ACCESS_BUFFERABLE;
    mpu_init_struct.access_cacheable     = MPU_ACCESS_CACHEABLE;
    mpu_init_struct.access_shareable     = MPU_ACCESS_NON_SHAREABLE;
    mpu_init_struct.region_number        = MPU_REGION_NUMBER0;
    mpu_init_struct.subregion_disable    = MPU_SUBREGION_ENABLE;
    mpu_init_struct.instruction_exec     = MPU_INSTRUCTION_EXEC_PERMIT;
    mpu_init_struct.tex_type             = MPU_TEX_TYPE1;
    mpu_region_config(&mpu_init_struct);
    mpu_region_enable();

    
    /* enable the MPU */
    ARM_MPU_Enable(MPU_MODE_PRIV_DEFAULT);


我都是这么用的,你那里 0x87  还要左移8位,  都覆盖别的区域了吧?

[C] 纯文本查看 复制代码
void mpu_region_config(mpu_region_init_struct *mpu_init_struct)
{
    MPU->RNR = mpu_init_struct->region_number;
    MPU->RBAR = mpu_init_struct->region_base_address;
    MPU->RASR = ((uint32_t)mpu_init_struct->instruction_exec  << MPU_RASR_XN_Pos) |
                ((uint32_t)mpu_init_struct->access_permission << MPU_RASR_AP_Pos) |
                ((uint32_t)mpu_init_struct->tex_type          << MPU_RASR_TEX_Pos)|
                ((uint32_t)mpu_init_struct->access_shareable  << MPU_RASR_S_Pos)  |
                ((uint32_t)mpu_init_struct->access_cacheable  << MPU_RASR_C_Pos)  |
                ((uint32_t)mpu_init_struct->access_bufferable << MPU_RASR_B_Pos)  |
                ((uint32_t)mpu_init_struct->subregion_disable << MPU_RASR_SRD_Pos)|
                ((uint32_t)mpu_init_struct->region_size       << MPU_RASR_SIZE_Pos);
}

回复

使用道具 举报

5

主题

24

回帖

39

积分

新手上路

积分
39
发表于 2024-10-10 13:47:35 | 显示全部楼层
morning_enr6U 发表于 2024-10-10 13:36
[mw_shl_code=c,true]    mpu_region_init_struct mpu_init_struct;
    mpu_region_struct_para_init(& ...

就是要限制其他的区域,这个就是GD库函数不完善的地方,你以为这个变量只能取那两个值,其实不然。
可以对照STM32的MPU设置,默认cubemx生产的配置也有这个0x87,但是STM32不设置0x87也不会有什么问题,但是GD32H7就必须要设置一下……
这个参数mpu_init_struct.subregion_disable可以配成0x87我还是从GD32那边提供的demo程序里找到的,不然我还不知道能这么设,反正最后配置成这个后,芯片就没出过类似于死机的异常现象。
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
116223
QQ
发表于 2024-10-11 09:15:24 | 显示全部楼层
可乐狂魔 发表于 2024-10-10 12:08
mpu_region_init_struct mpu_init_struct;
    /* disable MPU */
    ARM_MPU_Disable();

现在CubeMX生成的H7代码,也会强制提示是否配置这个4GB空间的MPU.

不过我不配置全局,基本都是单独配置的。
回复

使用道具 举报

1

主题

3

回帖

6

积分

新手上路

积分
6
发表于 2025-2-8 08:51:11 | 显示全部楼层
老哥,这个问题解决了吗,我这边调试也有这种情况
回复

使用道具 举报

1

主题

3

回帖

6

积分

新手上路

积分
6
发表于 2025-2-8 10:33:18 | 显示全部楼层
老哥,这个问题解决了吗,我最近调试GD32以太网也有这个问题,看厂家手册说把用到的内存区域的cache访问权改成不缓冲和不缓存也没效果
回复

使用道具 举报

1万

主题

7万

回帖

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
116223
QQ
发表于 2025-2-9 08:15:43 | 显示全部楼层
Seven1 发表于 2025-2-8 10:33
老哥,这个问题解决了吗,我最近调试GD32以太网也有这个问题,看厂家手册说把用到的内存区域的cache访问权 ...

以太网描述符要配置成和STM32H7一样的MPU属性。

而以太网缓冲区也配置MPU,以太网底层收发方式做Cache无效化Clean操作,看看是不是好点
回复

使用道具 举报

1

主题

3

回帖

6

积分

新手上路

积分
6
发表于 2025-2-10 14:00:38 | 显示全部楼层
eric2013 发表于 2025-2-9 08:15
以太网描述符要配置成和STM32H7一样的MPU属性。

而以太网缓冲区也配置MPU,以太网底层收发方式做Cache ...

硬汉哥 我按照你的方法试了下 还是没有通,后来我把大小改成512MB的时候就可以,向下试了其他大小的设置发现都不行,必须是512MB分开两个256MB也不可以,但是512MB的话就覆盖了0x40000000到0x50000000,这段区域包含了所有的外设,会影响其他的外设使用,感觉这么修改不太对。


这是定义的代码和MPU配置的代码
#pragma location=0x30000000
enet_descriptors_struct  rxdesc_tab[ENET_RXBUF_NUM];        /*!< ENET RxDMA descriptor */
#pragma location=0x30000160
enet_descriptors_struct  txdesc_tab[ENET_TXBUF_NUM];        /*!< ENET TxDMA descriptor */
#pragma location=0x30000300
uint8_t rx_buff[ENET_RXBUF_NUM][ENET_RXBUF_SIZE];           /*!< ENET receive buffer */
#pragma location=0x30002100
uint8_t tx_buff[ENET_TXBUF_NUM][ENET_TXBUF_SIZE];           /*!< ENET transmit buffer */



#pragma location = 0x30004000
NX_DRIVER_INFORMATION nx_driver_information;



    /* Configure the DMA descriptors and Rx/Tx buffer*/
    mpu_init_struct.region_base_address = 0x30000000;
    mpu_init_struct.region_size = MPU_REGION_SIZE_16KB;
    mpu_init_struct.access_permission = MPU_AP_FULL_ACCESS;
    mpu_init_struct.access_bufferable = MPU_ACCESS_BUFFERABLE;
    mpu_init_struct.access_cacheable = MPU_ACCESS_NON_CACHEABLE;
    mpu_init_struct.access_shareable = MPU_ACCESS_NON_SHAREABLE;
    mpu_init_struct.region_number = MPU_REGION_NUMBER0;
    mpu_init_struct.subregion_disable = MPU_SUBREGION_ENABLE;
    mpu_init_struct.instruction_exec = MPU_INSTRUCTION_EXEC_PERMIT;
    mpu_init_struct.tex_type = MPU_TEX_TYPE0;
    mpu_region_config(&mpu_init_struct);
    mpu_region_enable();

    /* Configure the  RAM heap */
    mpu_init_struct.region_base_address = 0x30004000;
    mpu_init_struct.region_size = MPU_REGION_SIZE_16KB;
    mpu_init_struct.access_permission = MPU_AP_FULL_ACCESS;
    mpu_init_struct.access_bufferable = MPU_ACCESS_BUFFERABLE;
    mpu_init_struct.access_cacheable = MPU_ACCESS_NON_CACHEABLE;
    mpu_init_struct.access_shareable = MPU_ACCESS_NON_SHAREABLE;
    mpu_init_struct.region_number = MPU_REGION_NUMBER1;
    mpu_init_struct.subregion_disable = MPU_SUBREGION_ENABLE;
    mpu_init_struct.instruction_exec = MPU_INSTRUCTION_EXEC_PERMIT;
    mpu_init_struct.tex_type = MPU_TEX_TYPE0;
    mpu_region_config(&mpu_init_struct);
    mpu_region_enable();

    mpu_init_struct.region_base_address = 0x38800000;
    mpu_init_struct.region_size = MPU_REGION_SIZE_512MB;
    mpu_init_struct.access_permission = MPU_AP_FULL_ACCESS;
    mpu_init_struct.access_bufferable = MPU_ACCESS_BUFFERABLE;
    mpu_init_struct.access_cacheable = MPU_ACCESS_NON_CACHEABLE;
    mpu_init_struct.access_shareable = MPU_ACCESS_NON_SHAREABLE;
    mpu_init_struct.region_number = MPU_REGION_NUMBER2;
    mpu_init_struct.subregion_disable = MPU_SUBREGION_ENABLE;
    mpu_init_struct.instruction_exec = MPU_INSTRUCTION_EXEC_PERMIT;
    mpu_init_struct.tex_type = MPU_TEX_TYPE0;
    mpu_region_config(&mpu_init_struct);
    mpu_region_enable();


或者直接从0x30000000配置512MB也可以

这个还会有其他可能得因素吗?
回复

使用道具 举报

20

主题

38

回帖

98

积分

初级会员

积分
98
发表于 2025-2-25 15:23:45 | 显示全部楼层
老哥,问题解决了吗,我也是同样的问题,但是我ping包的话 ping四五个小时没出现过问题
回复

使用道具 举报

5

主题

24

回帖

39

积分

新手上路

积分
39
发表于 2025-2-27 10:15:39 | 显示全部楼层
有没有试一下我上面提到的全局MPU的约束?0x87那个配置~
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-6-10 13:03 , Processed in 0.438253 second(s), 28 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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