byronsong 发表于 2019-4-16 17:23:10

NUCLEO-H743ZI cubemx生成lwip以太网工程ping不通

本帖最后由 songshiqun2010 于 2019-4-23 13:32 编辑

同样的配置在STM32F4上用DP83848则没问题。。。

1.修改链接配置文件
/* Highest address of the user mode stack */
_estack = 0x24080000;    /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x800;      /* required amount of heap*/
_Min_Stack_Size = 0x400; /* required amount of stack */

/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
    . = ALIGN(4);
    _sdata = .;      /* create a global symbol at data start */
    *(.data)         /* .data sections */
    *(.data*)          /* .data* sections */

    . = ALIGN(4);
    _edata = .;      /* define a global symbol at data end */
} >RAM_D1 AT> FLASH


/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
    /* This is used by the startup in order to initialize the .bss secion */
    _sbss = .;         /* define a global symbol at bss start */
    __bss_start__ = _sbss;
    *(.bss)
    *(.bss*)
    *(COMMON)

    . = ALIGN(4);
    _ebss = .;         /* define a global symbol at bss end */
    __bss_end__ = _ebss;
} >RAM_D1

/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
{
    . = ALIGN(4);
    PROVIDE ( end = . );
    PROVIDE ( _end = . );
    . = . + _Min_Heap_Size;
    . = . + _Min_Stack_Size;
    . = ALIGN(4);
} >RAM_D1

.lwip_sec (NOLOAD) : {
    . = ABSOLUTE(0x30040000);
    *(.RxDecripSection)

    . = ABSOLUTE(0x30040060);
    *(.TxDecripSection)

    . = ABSOLUTE(0x30040200);
    *(.RxArraySection)
} >RAM_D2 AT> FLASH

2.配置mpu
static void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct;

/* Disable the MPU */
HAL_MPU_Disable();

/* Configure the MPU attributes as Device not cacheable
   for ETH DMA descriptors */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30040000;
MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Configure the MPU attributes as Cacheable write through
   for LwIP RAM heap which contains the Tx buffers */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x30044000;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Enable the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

int main(void)
{
/* USER CODE BEGIN 1 */
      MPU_Config();
/* USER CODE END 1 */


......

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
          MX_LWIP_Process();
}
/* USER CODE END 3 */
}


byronsong 发表于 2019-4-17 10:29:08

cubemx 生成的 h7系的程序,使用非DTCM RAM ,目前得手动配置mpu。

你若安好_清风徐来 发表于 2019-4-17 18:25:59

我调试了两天,没通,各种各样的错误,让我眼花缭乱啊,你写好了分享分享啊   

折翼的信鸽 发表于 2020-11-26 14:21:11

songshiqun2010 发表于 2019-4-17 10:29
cubemx 生成的 h7系的程序,使用非DTCM RAM ,目前得手动配置mpu。

我还是没有ping通,不知道还有哪块的配置没配,方便说一下么

byronsong 发表于 2020-11-27 10:40:09

折翼的信鸽 发表于 2020-11-26 14:21
我还是没有ping通,不知道还有哪块的配置没配,方便说一下么

1.配置好MPU
2.注意刷cache
页: [1]
查看完整版本: NUCLEO-H743ZI cubemx生成lwip以太网工程ping不通