3131#include "driver/mtd/gd25qxx.h"
3232#include "driver/range_finder/tofsense.h"
3333#include "drv_adc.h"
34+ #include "drv_eth.h"
3435#include "drv_fdcan.h"
3536#include "drv_gpio.h"
3637#include "drv_i2c.h"
@@ -218,6 +219,38 @@ static void MPU_Config(void)
218219 MPU_InitStruct .DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE ;
219220 HAL_MPU_ConfigRegion (& MPU_InitStruct );
220221
222+ /* Configure the MPU attributes as Device not cacheable
223+ for ETH DMA descriptors */
224+ MPU_InitStruct .Enable = MPU_REGION_ENABLE ;
225+ MPU_InitStruct .BaseAddress = 0x30040000 ;
226+ MPU_InitStruct .Size = MPU_REGION_SIZE_256B ;
227+ MPU_InitStruct .AccessPermission = MPU_REGION_FULL_ACCESS ;
228+ MPU_InitStruct .IsBufferable = MPU_ACCESS_BUFFERABLE ;
229+ MPU_InitStruct .IsCacheable = MPU_ACCESS_NOT_CACHEABLE ;
230+ MPU_InitStruct .IsShareable = MPU_ACCESS_NOT_SHAREABLE ;
231+ MPU_InitStruct .Number = MPU_REGION_NUMBER2 ;
232+ MPU_InitStruct .TypeExtField = MPU_TEX_LEVEL0 ;
233+ MPU_InitStruct .SubRegionDisable = 0x00 ;
234+ MPU_InitStruct .DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE ;
235+
236+ HAL_MPU_ConfigRegion (& MPU_InitStruct );
237+
238+ /* Configure the MPU attributes as Cacheable write through
239+ for LwIP RAM heap which contains the Tx buffers */
240+ MPU_InitStruct .Enable = MPU_REGION_ENABLE ;
241+ MPU_InitStruct .BaseAddress = 0x30044000 ;
242+ MPU_InitStruct .Size = MPU_REGION_SIZE_16KB ;
243+ MPU_InitStruct .AccessPermission = MPU_REGION_FULL_ACCESS ;
244+ MPU_InitStruct .IsBufferable = MPU_ACCESS_NOT_BUFFERABLE ;
245+ MPU_InitStruct .IsCacheable = MPU_ACCESS_CACHEABLE ;
246+ MPU_InitStruct .IsShareable = MPU_ACCESS_NOT_SHAREABLE ;
247+ MPU_InitStruct .Number = MPU_REGION_NUMBER3 ;
248+ MPU_InitStruct .TypeExtField = MPU_TEX_LEVEL0 ;
249+ MPU_InitStruct .SubRegionDisable = 0x00 ;
250+ MPU_InitStruct .DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE ;
251+
252+ HAL_MPU_ConfigRegion (& MPU_InitStruct );
253+
221254 /* Enable the MPU */
222255 HAL_MPU_Enable (MPU_PRIVILEGED_DEFAULT );
223256}
@@ -229,13 +262,13 @@ static void MPU_Config(void)
229262 */
230263static void CPU_Config (void )
231264{
232- // MPU_Config();
265+ MPU_Config ();
233266
234267 /*
235268 * When enabling the D-cache there is cache coherency issue.
236269 * This matter crops up when multiple masters (CPU, DMAs...)
237270 * share the memory. If the CPU writes something to an area
238- * that has a write-back cache attribute (example SRAM), the
271+ * that has a write-back cache attribute (example SRAM), thed
239272 * write result is not seen on the SRAM as the access is
240273 * buffered, and then if the DMA reads the same memory area
241274 * to perform a data transfer, the values read do not match
@@ -354,6 +387,9 @@ void bsp_early_initialize(void)
354387 /* System clock initialization */
355388 SystemClock_Config ();
356389
390+ /* gpio driver init */
391+ RT_CHECK (drv_gpio_init ());
392+
357393 /* usart driver init */
358394 RT_CHECK (drv_usart_init ());
359395
@@ -363,9 +399,6 @@ void bsp_early_initialize(void)
363399 /* systick driver init */
364400 RT_CHECK (drv_systick_init ());
365401
366- /* gpio driver init */
367- RT_CHECK (drv_gpio_init ());
368-
369402 /* i2c driver init */
370403 RT_CHECK (drv_i2c_init ());
371404
@@ -415,6 +448,16 @@ void bsp_initialize(void)
415448 /* adc driver init */
416449 RT_CHECK (drv_adc_init ());
417450
451+ /* init rt_workqueue, which is used by tcpip stack */
452+ FMT_CHECK (rt_work_sys_workqueue_init ());
453+
454+ /* init lwip */
455+ extern int lwip_system_init ();
456+ FMT_CHECK (lwip_system_init ());
457+
458+ /* eth driver init */
459+ RT_CHECK (drv_eth_init ());
460+
418461#if defined(FMT_USING_SIH ) || defined(FMT_USING_HIL )
419462 FMT_CHECK (advertise_sensor_imu (0 ));
420463 FMT_CHECK (advertise_sensor_mag (0 ));
0 commit comments