diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_eth.c b/bsp/stm32/libraries/HAL_Drivers/drv_eth.c index f71807c22f0a91e7c313423b3bd569068de8ba1f..21c2e90cf2f39db8480e21a423f29dd4484c8714 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_eth.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_eth.c @@ -86,7 +86,7 @@ static rt_err_t rt_stm32_eth_init(rt_device_t dev) /* ETHERNET Configuration */ EthHandle.Instance = ETH; EthHandle.Init.MACAddr = (rt_uint8_t *)&stm32_eth_device.dev_addr[0]; - EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE; + EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_DISABLE; EthHandle.Init.Speed = ETH_SPEED_100M; EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX; EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; @@ -96,9 +96,16 @@ static rt_err_t rt_stm32_eth_init(rt_device_t dev) HAL_ETH_DeInit(&EthHandle); /* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */ - HAL_ETH_Init(&EthHandle); - LOG_D("eth hardware init finished"); - + if (HAL_ETH_Init(&EthHandle) != HAL_OK) + { + LOG_E("eth hardware init failed"); + return -RT_ERROR; + } + else + { + LOG_D("eth hardware init success"); + } + /* Initialize Tx Descriptors list: Chain Mode */ HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, Tx_Buff, ETH_TXBUFNB); @@ -252,7 +259,6 @@ rt_err_t rt_stm32_eth_tx(rt_device_t dev, struct pbuf *p) /* Prepare transmit descriptors to give to DMA */ /* TODO Optimize data send speed*/ LOG_D("transmit frame lenth :%d", framelength); - rt_thread_mdelay(1); state = HAL_ETH_TransmitFrame(&EthHandle, framelength); if (state != HAL_OK) @@ -420,7 +426,7 @@ static void phy_monitor_thread_entry(void *parameter) HAL_ETH_ReadPHYRegister(&EthHandle, PHY_ID1_REG, (uint32_t *)&temp); - if (temp != 0xFFFF) + if (temp != 0xFFFF && temp != 0x00) { phy_addr = i; break; @@ -503,15 +509,9 @@ static void phy_monitor_thread_entry(void *parameter) stm32_eth_device.ETH_Mode = ETH_MODE_HALFDUPLEX; } - if (rt_stm32_eth_init((rt_device_t)&stm32_eth_device) != RT_EOK) - { - break; - } - else - { - /* send link up. */ - eth_device_linkchange(&stm32_eth_device.parent, RT_TRUE); - } + /* send link up. */ + eth_device_linkchange(&stm32_eth_device.parent, RT_TRUE); + } /* link up. */ else { diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_eth.h b/bsp/stm32/libraries/HAL_Drivers/drv_eth.h index 5fbdf11fe9fe028b752527d55e33f7e5b6cb0e18..fbfe08d4847bacde1495f251b401ec622f845c44 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_eth.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_eth.h @@ -50,4 +50,12 @@ #define PHY_FULL_DUPLEX_MASK (1<<4) #endif /* PHY_USING_LAN8720A */ +#ifdef PHY_USING_DM9161CEP +#define PHY_Status_REG 0x11U +#define PHY_10M_MASK ((1<<12) || (1<<13)) +#define PHY_100M_MASK ((1<<14) || (1<<15)) +#define PHY_FULL_DUPLEX_MASK ((1<<15) || (1<<13)) + +#endif /* PHY_USING_DM9161CEP */ + #endif /* __DRV_ETH_H__ */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash.h b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash.h index a1d2daea317650f53be2c16f6ddda5573225bb96..954580b688dd76f3c817691ac2bb083f60ee6db2 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash.h +++ b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash.h @@ -16,8 +16,8 @@ #include #include -int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size); -int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size); -int stm32_flash_erase(long offset, size_t size); +int stm32_flash_read(rt_uint32_t addr, rt_uint8_t *buf, size_t size); +int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size); +int stm32_flash_erase(rt_uint32_t addr, size_t size); #endif /* __DRV_FLASH_H__ */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f0.c b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f0.c index 87f04c172408e9f06439af0fa57f0d356ac0f486..dd472b9694008497af63543ae77c4a92b96c5083 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f0.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f0.c @@ -44,10 +44,9 @@ static uint32_t GetPage(uint32_t addr) * * @return result */ -int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) +int stm32_flash_read(rt_uint32_t addr, rt_uint8_t *buf, size_t size) { size_t i; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; if ((addr + size) > STM32_FLASH_END_ADDRESS) { @@ -74,10 +73,9 @@ int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) +int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; rt_uint32_t end_addr = addr + size; if (addr % 4 != 0) @@ -139,10 +137,9 @@ int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_erase(long offset, size_t size) +int stm32_flash_erase(rt_uint32_t addr, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; uint32_t PAGEError = 0; /*Variable used for Erase procedure*/ @@ -180,6 +177,27 @@ __exit: } #if defined(PKG_USING_FAL) -const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, FLASH_PAGE_SIZE, {NULL, stm32_flash_read, stm32_flash_write, stm32_flash_erase} }; + +static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_erase(long offset, size_t size); + +const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, FLASH_PAGE_SIZE, {NULL, fal_flash_read, fal_flash_write, fal_flash_erase} }; + +static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash.addr + offset, buf, size); +} + +static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash.addr + offset, buf, size); +} + +static int fal_flash_erase(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash.addr + offset, size); +} + #endif #endif /* BSP_USING_ON_CHIP_FLASH */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c index 566955862222a33a4af81bd031b8936e0e89e592..306b2fb665c9d7968ea6a1b83b3ae6ae20b98d94 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c @@ -44,10 +44,9 @@ static uint32_t GetPage(uint32_t addr) * * @return result */ -int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) +int stm32_flash_read(rt_uint32_t addr, rt_uint8_t *buf, size_t size) { size_t i; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; if ((addr + size) > STM32_FLASH_END_ADDRESS) { @@ -74,10 +73,9 @@ int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) +int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; rt_uint32_t end_addr = addr + size; if (addr % 4 != 0) @@ -139,10 +137,9 @@ int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_erase(long offset, size_t size) +int stm32_flash_erase(rt_uint32_t addr, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; uint32_t PAGEError = 0; /*Variable used for Erase procedure*/ @@ -180,6 +177,27 @@ __exit: } #if defined(PKG_USING_FAL) -const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, FLASH_PAGE_SIZE, {NULL, stm32_flash_read, stm32_flash_write, stm32_flash_erase} }; + +static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_erase(long offset, size_t size); + +const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, FLASH_PAGE_SIZE, {NULL, fal_flash_read, fal_flash_write, fal_flash_erase} }; + +static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash.addr + offset, buf, size); +} + +static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash.addr + offset, buf, size); +} + +static int fal_flash_erase(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash.addr + offset, size); +} + #endif #endif /* BSP_USING_ON_CHIP_FLASH */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f4.c b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f4.c index fd704f73623095c7536d90ab76c7de777921f22f..7664e7a4b4540b2ad07c835f93f7c30a4b414cc7 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f4.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f4.c @@ -178,10 +178,9 @@ static rt_uint32_t GetSector(rt_uint32_t Address) * * @return result */ -int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) +int stm32_flash_read(rt_uint32_t addr, rt_uint8_t *buf, size_t size) { size_t i; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; if ((addr + size) > STM32_FLASH_END_ADDRESS) { @@ -208,10 +207,9 @@ int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) +int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; rt_uint32_t end_addr = addr + size; if ((end_addr) > STM32_FLASH_END_ADDRESS) @@ -267,10 +265,9 @@ int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_erase(long offset, size_t size) +int stm32_flash_erase(rt_uint32_t addr, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; rt_uint32_t FirstSector = 0, NbOfSectors = 0; rt_uint32_t SECTORError = 0; @@ -317,6 +314,61 @@ __exit: } #if defined(PKG_USING_FAL) -const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, (128 * 1024), {NULL, stm32_flash_read, stm32_flash_write, stm32_flash_erase} }; + +static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_read_64k(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_read_128k(long offset, rt_uint8_t *buf, size_t size); + +static int fal_flash_write_16k(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_write_64k(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_write_128k(long offset, const rt_uint8_t *buf, size_t size); + +static int fal_flash_erase_16k(long offset, size_t size); +static int fal_flash_erase_64k(long offset, size_t size); +static int fal_flash_erase_128k(long offset, size_t size); + +const struct fal_flash_dev stm32_onchip_flash_16k = { "onchip_flash_16k", STM32_FLASH_START_ADRESS, FLASH_SIZE_GRANULARITY_16K, (16 * 1024), {NULL, fal_flash_read_16k, fal_flash_write_16k, fal_flash_erase_16k} }; +const struct fal_flash_dev stm32_onchip_flash_64k = { "onchip_flash_64k", STM32_FLASH_START_ADRESS, FLASH_SIZE_GRANULARITY_64K, (64 * 1024), {NULL, fal_flash_read_64k, fal_flash_write_64k, fal_flash_erase_64k} }; +const struct fal_flash_dev stm32_onchip_flash_128k = { "onchip_flash_128k", STM32_FLASH_START_ADRESS, FLASH_SIZE_GRANULARITY_128K, (128 * 1024), {NULL, fal_flash_read_128k, fal_flash_write_128k, fal_flash_erase_128k} }; + +static int fal_flash_read_16k(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash_16k.addr + offset, buf, size); +} +static int fal_flash_read_64k(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash_64k.addr + offset, buf, size); +} +static int fal_flash_read_128k(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash_128k.addr + offset, buf, size); +} + +static int fal_flash_write_16k(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash_16k.addr + offset, buf, size); +} +static int fal_flash_write_64k(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash_64k.addr + offset, buf, size); +} +static int fal_flash_write_128k(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash_128k.addr + offset, buf, size); +} + +static int fal_flash_erase_16k(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash_16k.addr + offset, size); +} +static int fal_flash_erase_64k(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash_64k.addr + offset, size); +} +static int fal_flash_erase_128k(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash_128k.addr + offset, size); +} + #endif #endif /* BSP_USING_ON_CHIP_FLASH */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f7.c b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f7.c index 178cc2923a73fe93ac5f20f8da8ba9daa0b708fe..d71013d3ea2994f11a82b5bf6ce90945c5dcaec7 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f7.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f7.c @@ -22,33 +22,18 @@ #define LOG_TAG "drv.flash" #include -/* Base address of the Flash sectors Bank 1 */ -#define ADDR_FLASH_SECTOR_0 ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_1 ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_2 ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_3 ((uint32_t)0x0800C000) /* Base @ of Sector 3, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_4 ((uint32_t)0x08010000) /* Base @ of Sector 4, 64 Kbytes */ -#define ADDR_FLASH_SECTOR_5 ((uint32_t)0x08020000) /* Base @ of Sector 5, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_6 ((uint32_t)0x08040000) /* Base @ of Sector 6, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_7 ((uint32_t)0x08060000) /* Base @ of Sector 7, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_8 ((uint32_t)0x08080000) /* Base @ of Sector 8, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_9 ((uint32_t)0x080A0000) /* Base @ of Sector 9, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_10 ((uint32_t)0x080C0000) /* Base @ of Sector 10, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_11 ((uint32_t)0x080E0000) /* Base @ of Sector 11, 128 Kbytes */ - -/* Base address of the Flash sectors Bank 2 */ -#define ADDR_FLASH_SECTOR_12 ((uint32_t)0x08100000) /* Base @ of Sector 0, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_13 ((uint32_t)0x08104000) /* Base @ of Sector 1, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_14 ((uint32_t)0x08108000) /* Base @ of Sector 2, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_15 ((uint32_t)0x0810C000) /* Base @ of Sector 3, 16 Kbytes */ -#define ADDR_FLASH_SECTOR_16 ((uint32_t)0x08110000) /* Base @ of Sector 4, 64 Kbytes */ -#define ADDR_FLASH_SECTOR_17 ((uint32_t)0x08120000) /* Base @ of Sector 5, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_18 ((uint32_t)0x08140000) /* Base @ of Sector 6, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_19 ((uint32_t)0x08160000) /* Base @ of Sector 7, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_20 ((uint32_t)0x08180000) /* Base @ of Sector 8, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_21 ((uint32_t)0x081A0000) /* Base @ of Sector 9, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_22 ((uint32_t)0x081C0000) /* Base @ of Sector 10, 128 Kbytes */ -#define ADDR_FLASH_SECTOR_23 ((uint32_t)0x081E0000) /* Base @ of Sector 11, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_0 ((rt_uint32_t)0x08000000) /* Base address of Sector 0, 32 Kbytes */ +#define ADDR_FLASH_SECTOR_1 ((rt_uint32_t)0x08008000) /* Base address of Sector 1, 32 Kbytes */ +#define ADDR_FLASH_SECTOR_2 ((rt_uint32_t)0x08010000) /* Base address of Sector 2, 32 Kbytes */ +#define ADDR_FLASH_SECTOR_3 ((rt_uint32_t)0x08018000) /* Base address of Sector 3, 32 Kbytes */ +#define ADDR_FLASH_SECTOR_4 ((rt_uint32_t)0x08020000) /* Base address of Sector 4, 128 Kbytes */ +#define ADDR_FLASH_SECTOR_5 ((rt_uint32_t)0x08040000) /* Base address of Sector 5, 256 Kbytes */ +#define ADDR_FLASH_SECTOR_6 ((rt_uint32_t)0x08080000) /* Base address of Sector 6, 256 Kbytes */ +#define ADDR_FLASH_SECTOR_7 ((rt_uint32_t)0x080C0000) /* Base address of Sector 7, 256 Kbytes */ +#define ADDR_FLASH_SECTOR_8 ((rt_uint32_t)0x08100000) /* Base address of Sector 8, 256 Kbytes */ +#define ADDR_FLASH_SECTOR_9 ((rt_uint32_t)0x08140000) /* Base address of Sector 9, 256 Kbytes */ +#define ADDR_FLASH_SECTOR_10 ((rt_uint32_t)0x08180000) /* Base address of Sector 10, 256 Kbytes */ +#define ADDR_FLASH_SECTOR_11 ((rt_uint32_t)0x081C0000) /* Base address of Sector 11, 256 Kbytes */ /** * @brief Gets the sector of a given address @@ -59,104 +44,54 @@ static rt_uint32_t GetSector(rt_uint32_t Address) { rt_uint32_t sector = 0; - if((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0)) + if ((Address < ADDR_FLASH_SECTOR_1) && (Address >= ADDR_FLASH_SECTOR_0)) { sector = FLASH_SECTOR_0; } - else if((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1)) + else if ((Address < ADDR_FLASH_SECTOR_2) && (Address >= ADDR_FLASH_SECTOR_1)) { sector = FLASH_SECTOR_1; } - else if((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2)) + else if ((Address < ADDR_FLASH_SECTOR_3) && (Address >= ADDR_FLASH_SECTOR_2)) { sector = FLASH_SECTOR_2; } - else if((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3)) + else if ((Address < ADDR_FLASH_SECTOR_4) && (Address >= ADDR_FLASH_SECTOR_3)) { sector = FLASH_SECTOR_3; } - else if((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4)) + else if ((Address < ADDR_FLASH_SECTOR_5) && (Address >= ADDR_FLASH_SECTOR_4)) { sector = FLASH_SECTOR_4; } - else if((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5)) + else if ((Address < ADDR_FLASH_SECTOR_6) && (Address >= ADDR_FLASH_SECTOR_5)) { sector = FLASH_SECTOR_5; } - else if((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6)) + else if ((Address < ADDR_FLASH_SECTOR_7) && (Address >= ADDR_FLASH_SECTOR_6)) { sector = FLASH_SECTOR_6; } - else if((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7)) + else if ((Address < ADDR_FLASH_SECTOR_8) && (Address >= ADDR_FLASH_SECTOR_7)) { sector = FLASH_SECTOR_7; } - else if((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8)) + else if ((Address < ADDR_FLASH_SECTOR_9) && (Address >= ADDR_FLASH_SECTOR_8)) { sector = FLASH_SECTOR_8; } - else if((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9)) + else if ((Address < ADDR_FLASH_SECTOR_10) && (Address >= ADDR_FLASH_SECTOR_9)) { sector = FLASH_SECTOR_9; } - else if((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10)) + else if ((Address < ADDR_FLASH_SECTOR_11) && (Address >= ADDR_FLASH_SECTOR_10)) { sector = FLASH_SECTOR_10; } - else if((Address < ADDR_FLASH_SECTOR_12) && (Address >= ADDR_FLASH_SECTOR_11)) + else /* (Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_11) */ { sector = FLASH_SECTOR_11; } -#if defined(STM32F765xx) || defined(STM32F767xx) || defined(STM32F769xx)|| defined(STM32F777xx) || defined(STM32F779xx) - else if((Address < ADDR_FLASH_SECTOR_13) && (Address >= ADDR_FLASH_SECTOR_12)) - { - sector = FLASH_SECTOR_12; - } - else if((Address < ADDR_FLASH_SECTOR_14) && (Address >= ADDR_FLASH_SECTOR_13)) - { - sector = FLASH_SECTOR_13; - } - else if((Address < ADDR_FLASH_SECTOR_15) && (Address >= ADDR_FLASH_SECTOR_14)) - { - sector = FLASH_SECTOR_14; - } - else if((Address < ADDR_FLASH_SECTOR_16) && (Address >= ADDR_FLASH_SECTOR_15)) - { - sector = FLASH_SECTOR_15; - } - else if((Address < ADDR_FLASH_SECTOR_17) && (Address >= ADDR_FLASH_SECTOR_16)) - { - sector = FLASH_SECTOR_16; - } - else if((Address < ADDR_FLASH_SECTOR_18) && (Address >= ADDR_FLASH_SECTOR_17)) - { - sector = FLASH_SECTOR_17; - } - else if((Address < ADDR_FLASH_SECTOR_19) && (Address >= ADDR_FLASH_SECTOR_18)) - { - sector = FLASH_SECTOR_18; - } - else if((Address < ADDR_FLASH_SECTOR_20) && (Address >= ADDR_FLASH_SECTOR_19)) - { - sector = FLASH_SECTOR_19; - } - else if((Address < ADDR_FLASH_SECTOR_21) && (Address >= ADDR_FLASH_SECTOR_20)) - { - sector = FLASH_SECTOR_20; - } - else if((Address < ADDR_FLASH_SECTOR_22) && (Address >= ADDR_FLASH_SECTOR_21)) - { - sector = FLASH_SECTOR_21; - } - else if((Address < ADDR_FLASH_SECTOR_23) && (Address >= ADDR_FLASH_SECTOR_22)) - { - sector = FLASH_SECTOR_22; - } - else /* (Address < FLASH_END_ADDR) && (Address >= ADDR_FLASH_SECTOR_23) */ - { - sector = FLASH_SECTOR_23; - } -#endif return sector; } @@ -170,14 +105,13 @@ static rt_uint32_t GetSector(rt_uint32_t Address) * * @return result */ -int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) +int stm32_flash_read(rt_uint32_t addr, rt_uint8_t *buf, size_t size) { size_t i; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; if ((addr + size) > STM32_FLASH_END_ADDRESS) { - LOG_E("read outrange flash size! addr is (0x%p)", (void*)(addr + size)); + LOG_E("read outrange flash size! addr is (0x%p)", (void *)(addr + size)); return -1; } @@ -200,15 +134,14 @@ int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) +int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; rt_uint32_t end_addr = addr + size; if ((end_addr) > STM32_FLASH_END_ADDRESS) { - LOG_E("write outrange flash size! addr is (0x%p)", (void*)(addr + size)); + LOG_E("write outrange flash size! addr is (0x%p)", (void *)(addr + size)); return -RT_EINVAL; } @@ -217,8 +150,8 @@ int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) return -RT_EINVAL; } + /* Unlock the Flash to enable the flash control register access */ HAL_FLASH_Unlock(); - __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | FLASH_FLAG_PGPERR | FLASH_FLAG_ERSERR); for (size_t i = 0; i < size; i++, addr++, buf++) @@ -259,16 +192,15 @@ int stm32_flash_write(long offset, const rt_uint8_t *buf, size_t size) * * @return result */ -int stm32_flash_erase(long offset, size_t size) +int stm32_flash_erase(rt_uint32_t addr, size_t size) { rt_err_t result = RT_EOK; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; rt_uint32_t FirstSector = 0, NbOfSectors = 0; rt_uint32_t SECTORError = 0; if ((addr + size) > STM32_FLASH_END_ADDRESS) { - LOG_E("ERROR: erase outrange flash size! addr is (0x%p)\n", (void*)(addr + size)); + LOG_E("ERROR: erase outrange flash size! addr is (0x%p)\n", (void *)(addr + size)); return -RT_EINVAL; } @@ -295,6 +227,7 @@ int stm32_flash_erase(long offset, size_t size) } __exit: + HAL_FLASH_Lock(); if (result != RT_EOK) @@ -302,11 +235,66 @@ __exit: return result; } - LOG_D("erase done: addr (0x%p), size %d", (void*)addr, size); + LOG_D("erase done: addr (0x%p), size %d", (void *)addr, size); return result; } #if defined(PKG_USING_FAL) -const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, (128 * 1024), {NULL, stm32_flash_read, stm32_flash_write, stm32_flash_erase} }; + +static int fal_flash_read_32k(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_read_128k(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_read_256k(long offset, rt_uint8_t *buf, size_t size); + +static int fal_flash_write_32k(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_write_128k(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_write_256k(long offset, const rt_uint8_t *buf, size_t size); + +static int fal_flash_erase_32k(long offset, size_t size); +static int fal_flash_erase_128k(long offset, size_t size); +static int fal_flash_erase_256k(long offset, size_t size); + +const struct fal_flash_dev stm32_onchip_flash_32k = { "onchip_flash_32k", STM32_FLASH_START_ADRESS, FLASH_SIZE_GRANULARITY_32K, (32 * 1024), {NULL, fal_flash_read_32k, fal_flash_write_32k, fal_flash_erase_32k} }; +const struct fal_flash_dev stm32_onchip_flash_128k = { "onchip_flash_128k", STM32_FLASH_START_ADRESS, FLASH_SIZE_GRANULARITY_128K, (128 * 1024), {NULL, fal_flash_read_128k, fal_flash_write_128k, fal_flash_erase_128k} }; +const struct fal_flash_dev stm32_onchip_flash_256k = { "onchip_flash_256k", STM32_FLASH_START_ADRESS, FLASH_SIZE_GRANULARITY_256K, (256 * 1024), {NULL, fal_flash_read_256k, fal_flash_write_256k, fal_flash_erase_256k} }; + +static int fal_flash_read_32k(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash_32k.addr + offset, buf, size); +} +static int fal_flash_read_128k(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash_128k.addr + offset, buf, size); +} +static int fal_flash_read_256k(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash_256k.addr + offset, buf, size); +} + +static int fal_flash_write_32k(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash_32k.addr + offset, buf, size); +} +static int fal_flash_write_128k(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash_128k.addr + offset, buf, size); +} +static int fal_flash_write_256k(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash_256k.addr + offset, buf, size); +} + +static int fal_flash_erase_32k(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash_32k.addr + offset, size); +} +static int fal_flash_erase_128k(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash_128k.addr + offset, size); +} +static int fal_flash_erase_256k(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash_256k.addr + offset, size); +} + #endif #endif /* BSP_USING_ON_CHIP_FLASH */ diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_l4.c b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_l4.c index 37fce587a94e0c5b58739224504d28107845238e..6567db13f19ff2843dd2b9a4fa13d8afa0957f4e 100644 --- a/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_l4.c +++ b/bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_l4.c @@ -92,10 +92,9 @@ static uint32_t GetBank(uint32_t Addr) * * @return result */ -int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) +int stm32_flash_read(rt_uint32_t addr, rt_uint8_t *buf, size_t size) { size_t i; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; if ((addr + size) > STM32_FLASH_END_ADDRESS) { @@ -123,12 +122,11 @@ int stm32_flash_read(long offset, rt_uint8_t *buf, size_t size) * @return result */ -int stm32_flash_write(long offset, const uint8_t *buf, size_t size) +int stm32_flash_write(rt_uint32_t addr, const uint8_t *buf, size_t size) { size_t i, j; rt_err_t result = 0; rt_uint64_t write_data = 0, temp_data = 0; - rt_uint32_t addr = STM32_FLASH_START_ADRESS + offset; if ((addr + size) > STM32_FLASH_END_ADDRESS) { @@ -221,10 +219,9 @@ __exit: * * @return result */ -int stm32_flash_erase(long offset, size_t size) +int stm32_flash_erase(rt_uint32_t addr, size_t size) { rt_err_t result = RT_EOK; - uint32_t addr = STM32_FLASH_START_ADRESS + offset; uint32_t FirstPage = 0, NbOfPages = 0, BankNumber = 0; uint32_t PAGEError = 0; @@ -272,6 +269,27 @@ __exit: } #if defined(PKG_USING_FAL) -const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, 2048, {NULL, stm32_flash_read, stm32_flash_write, stm32_flash_erase} }; + +static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size); +static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size); +static int fal_flash_erase(long offset, size_t size); + +const struct fal_flash_dev stm32_onchip_flash = { "onchip_flash", STM32_FLASH_START_ADRESS, STM32_FLASH_SIZE, 2048, {NULL, fal_flash_read, fal_flash_write, fal_flash_erase} }; + +static int fal_flash_read(long offset, rt_uint8_t *buf, size_t size) +{ + return stm32_flash_read(stm32_onchip_flash.addr + offset, buf, size); +} + +static int fal_flash_write(long offset, const rt_uint8_t *buf, size_t size) +{ + return stm32_flash_write(stm32_onchip_flash.addr + offset, buf, size); +} + +static int fal_flash_erase(long offset, size_t size) +{ + return stm32_flash_erase(stm32_onchip_flash.addr + offset, size); +} + #endif #endif /* BSP_USING_ON_CHIP_FLASH */ diff --git a/bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h b/bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h index ab1ce5f83671af233de1ee2c4ed8671c64910f0c..6ed136aad259a541956bc1cde6661d700793b796 100644 --- a/bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h +++ b/bsp/stm32/stm32f407-atk-explorer/board/ports/fal_cfg.h @@ -14,21 +14,31 @@ #include #include -extern const struct fal_flash_dev stm32_onchip_flash; +#define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024) +#define FLASH_SIZE_GRANULARITY_64K (FLASH_SIZE_GRANULARITY_16K + 64 * 1024) +#define FLASH_SIZE_GRANULARITY_128K (FLASH_SIZE_GRANULARITY_64K + 7 * 128 * 1024) + +extern const struct fal_flash_dev stm32_onchip_flash_16k; +extern const struct fal_flash_dev stm32_onchip_flash_64k; +extern const struct fal_flash_dev stm32_onchip_flash_128k; /* flash device table */ #define FAL_FLASH_DEV_TABLE \ { \ - &stm32_onchip_flash, \ + &stm32_onchip_flash_16k, \ + &stm32_onchip_flash_64k, \ + &stm32_onchip_flash_128k, \ } /* ====================== Partition Configuration ========================== */ #ifdef FAL_PART_HAS_TABLE_CFG /* partition table */ -#define FAL_PART_TABLE \ -{ \ - {FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 1008 * 1024, 0},\ - {FAL_PART_MAGIC_WROD, "param", "onchip_flash", 1008* 1024 , 16 * 1024, 0}, \ +#define FAL_PART_TABLE \ +{ \ + {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k", 0 , FLASH_SIZE_GRANULARITY_16K , 0}, \ + {FAL_PART_MAGIC_WROD, "param", "onchip_flash_64k", FLASH_SIZE_GRANULARITY_16K , FLASH_SIZE_GRANULARITY_64K , 0}, \ + {FAL_PART_MAGIC_WROD, "app", "onchip_flash_128k", FLASH_SIZE_GRANULARITY_64K, FLASH_SIZE_GRANULARITY_128K, 0}, \ } + #endif /* FAL_PART_HAS_TABLE_CFG */ #endif /* _FAL_CFG_H_ */ diff --git a/bsp/stm32/stm32f429-armfly-v6/board/Kconfig b/bsp/stm32/stm32f429-armfly-v6/board/Kconfig index 5c500fbd35f6f58849e604a37e6df7b7850b90c2..5986331df261836113ab388ecb8f7a364c1d486e 100644 --- a/bsp/stm32/stm32f429-armfly-v6/board/Kconfig +++ b/bsp/stm32/stm32f429-armfly-v6/board/Kconfig @@ -34,14 +34,14 @@ menu "Onboard Peripheral Drivers" select RT_USING_DFS_ELMFAT default n - config PHY_USING_LAN8720A + config PHY_USING_DM9161CEP bool config BSP_USING_ETH bool "Enable Ethernet" default n select RT_USING_LWIP - select PHY_USING_LAN8720A + select PHY_USING_DM9161CEP config BSP_USING_MPU6050 bool "Enable MPU6050(i2c1)" diff --git a/bsp/stm32/stm32f429-armfly-v6/board/ports/fal_cfg.h b/bsp/stm32/stm32f429-armfly-v6/board/ports/fal_cfg.h index f7dfc02b8795215c0e8b7079c8cee8b99109ce31..df06c652270dc3d34972959c6c515a57665413c4 100644 --- a/bsp/stm32/stm32f429-armfly-v6/board/ports/fal_cfg.h +++ b/bsp/stm32/stm32f429-armfly-v6/board/ports/fal_cfg.h @@ -14,21 +14,31 @@ #include #include -extern const struct fal_flash_dev stm32_onchip_flash; +#define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024) +#define FLASH_SIZE_GRANULARITY_64K (FLASH_SIZE_GRANULARITY_16K + 64 * 1024) +#define FLASH_SIZE_GRANULARITY_128K (FLASH_SIZE_GRANULARITY_64K + 7 * 128 * 1024) + +extern const struct fal_flash_dev stm32_onchip_flash_16k; +extern const struct fal_flash_dev stm32_onchip_flash_64k; +extern const struct fal_flash_dev stm32_onchip_flash_128k; /* flash device table */ #define FAL_FLASH_DEV_TABLE \ { \ - &stm32_onchip_flash, \ + &stm32_onchip_flash_16k, \ + &stm32_onchip_flash_64k, \ + &stm32_onchip_flash_128k, \ } /* ====================== Partition Configuration ========================== */ #ifdef FAL_PART_HAS_TABLE_CFG /* partition table */ -#define FAL_PART_TABLE \ -{ \ - {FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 2032 * 1024, 0},\ - {FAL_PART_MAGIC_WROD, "param", "onchip_flash", 2032* 1024 , 16 * 1024, 0},\ +#define FAL_PART_TABLE \ +{ \ + {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k", 0 , FLASH_SIZE_GRANULARITY_16K , 0}, \ + {FAL_PART_MAGIC_WROD, "param", "onchip_flash_64k", FLASH_SIZE_GRANULARITY_16K , FLASH_SIZE_GRANULARITY_64K , 0}, \ + {FAL_PART_MAGIC_WROD, "app", "onchip_flash_128k", FLASH_SIZE_GRANULARITY_64K, FLASH_SIZE_GRANULARITY_128K, 0}, \ } + #endif /* FAL_PART_HAS_TABLE_CFG */ #endif /* _FAL_CFG_H_ */ diff --git a/bsp/stm32/stm32f429-atk-apollo/board/ports/fal_cfg.h b/bsp/stm32/stm32f429-atk-apollo/board/ports/fal_cfg.h index 3f014dbc9da7c5470ada2037dd9e0ac564f477c2..df06c652270dc3d34972959c6c515a57665413c4 100644 --- a/bsp/stm32/stm32f429-atk-apollo/board/ports/fal_cfg.h +++ b/bsp/stm32/stm32f429-atk-apollo/board/ports/fal_cfg.h @@ -14,21 +14,31 @@ #include #include -extern const struct fal_flash_dev stm32_onchip_flash; +#define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024) +#define FLASH_SIZE_GRANULARITY_64K (FLASH_SIZE_GRANULARITY_16K + 64 * 1024) +#define FLASH_SIZE_GRANULARITY_128K (FLASH_SIZE_GRANULARITY_64K + 7 * 128 * 1024) + +extern const struct fal_flash_dev stm32_onchip_flash_16k; +extern const struct fal_flash_dev stm32_onchip_flash_64k; +extern const struct fal_flash_dev stm32_onchip_flash_128k; /* flash device table */ #define FAL_FLASH_DEV_TABLE \ { \ - &stm32_onchip_flash, \ + &stm32_onchip_flash_16k, \ + &stm32_onchip_flash_64k, \ + &stm32_onchip_flash_128k, \ } /* ====================== Partition Configuration ========================== */ #ifdef FAL_PART_HAS_TABLE_CFG /* partition table */ -#define FAL_PART_TABLE \ -{ \ - {FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 1008 * 1024, 0},\ - {FAL_PART_MAGIC_WROD, "param", "onchip_flash", 1008* 1024 , 16 * 1024, 0},\ +#define FAL_PART_TABLE \ +{ \ + {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k", 0 , FLASH_SIZE_GRANULARITY_16K , 0}, \ + {FAL_PART_MAGIC_WROD, "param", "onchip_flash_64k", FLASH_SIZE_GRANULARITY_16K , FLASH_SIZE_GRANULARITY_64K , 0}, \ + {FAL_PART_MAGIC_WROD, "app", "onchip_flash_128k", FLASH_SIZE_GRANULARITY_64K, FLASH_SIZE_GRANULARITY_128K, 0}, \ } + #endif /* FAL_PART_HAS_TABLE_CFG */ #endif /* _FAL_CFG_H_ */ diff --git a/bsp/stm32/stm32f429-fire-challenger/board/ports/fal_cfg.h b/bsp/stm32/stm32f429-fire-challenger/board/ports/fal_cfg.h index 3f014dbc9da7c5470ada2037dd9e0ac564f477c2..5f27860dacbb920ca960c16028686e0afe51940c 100644 --- a/bsp/stm32/stm32f429-fire-challenger/board/ports/fal_cfg.h +++ b/bsp/stm32/stm32f429-fire-challenger/board/ports/fal_cfg.h @@ -14,21 +14,31 @@ #include #include -extern const struct fal_flash_dev stm32_onchip_flash; +#define FLASH_SIZE_GRANULARITY_16K (4 * 16 * 1024) +#define FLASH_SIZE_GRANULARITY_64K (FLASH_SIZE_GRANULARITY_16K + 64 * 1024) +#define FLASH_SIZE_GRANULARITY_128K (FLASH_SIZE_GRANULARITY_64K + 7 * 128 * 1024) + +extern const struct fal_flash_dev stm32_onchip_flash_16k; +extern const struct fal_flash_dev stm32_onchip_flash_64k; +extern const struct fal_flash_dev stm32_onchip_flash_128k; /* flash device table */ #define FAL_FLASH_DEV_TABLE \ { \ - &stm32_onchip_flash, \ + &stm32_onchip_flash_16k, \ + &stm32_onchip_flash_64k, \ + &stm32_onchip_flash_128k, \ } /* ====================== Partition Configuration ========================== */ #ifdef FAL_PART_HAS_TABLE_CFG /* partition table */ -#define FAL_PART_TABLE \ -{ \ - {FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 1008 * 1024, 0},\ - {FAL_PART_MAGIC_WROD, "param", "onchip_flash", 1008* 1024 , 16 * 1024, 0},\ +#define FAL_PART_TABLE \ +{ \ + {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_16k", 0 , FLASH_SIZE_GRANULARITY_16K , 0}, \ + {FAL_PART_MAGIC_WROD, "app", "onchip_flash_64k", FLASH_SIZE_GRANULARITY_16K , FLASH_SIZE_GRANULARITY_64K , 0}, \ + {FAL_PART_MAGIC_WROD, "download", "onchip_flash_128k", FLASH_SIZE_GRANULARITY_64K, FLASH_SIZE_GRANULARITY_128K, 0}, \ } + #endif /* FAL_PART_HAS_TABLE_CFG */ #endif /* _FAL_CFG_H_ */ diff --git a/bsp/stm32/stm32f767-atk-apollo/board/ports/fal_cfg.h b/bsp/stm32/stm32f767-atk-apollo/board/ports/fal_cfg.h index 3f014dbc9da7c5470ada2037dd9e0ac564f477c2..10c05885da602c32b02335537e1b5d332bef6779 100644 --- a/bsp/stm32/stm32f767-atk-apollo/board/ports/fal_cfg.h +++ b/bsp/stm32/stm32f767-atk-apollo/board/ports/fal_cfg.h @@ -14,21 +14,31 @@ #include #include -extern const struct fal_flash_dev stm32_onchip_flash; +#define FLASH_SIZE_GRANULARITY_32K (4 * 32 * 1024) +#define FLASH_SIZE_GRANULARITY_128K (FLASH_SIZE_GRANULARITY_32K + 128 * 1024) +#define FLASH_SIZE_GRANULARITY_256K (FLASH_SIZE_GRANULARITY_128K + 3 * 256 * 1024) + +extern const struct fal_flash_dev stm32_onchip_flash_32k; +extern const struct fal_flash_dev stm32_onchip_flash_128k; +extern const struct fal_flash_dev stm32_onchip_flash_256k; /* flash device table */ #define FAL_FLASH_DEV_TABLE \ { \ - &stm32_onchip_flash, \ + &stm32_onchip_flash_32k, \ + &stm32_onchip_flash_128k, \ + &stm32_onchip_flash_256k, \ } /* ====================== Partition Configuration ========================== */ #ifdef FAL_PART_HAS_TABLE_CFG /* partition table */ -#define FAL_PART_TABLE \ -{ \ - {FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 1008 * 1024, 0},\ - {FAL_PART_MAGIC_WROD, "param", "onchip_flash", 1008* 1024 , 16 * 1024, 0},\ +#define FAL_PART_TABLE \ +{ \ + {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_32k", 0 , FLASH_SIZE_GRANULARITY_32K , 0}, \ + {FAL_PART_MAGIC_WROD, "param", "onchip_flash_128k", FLASH_SIZE_GRANULARITY_32K , FLASH_SIZE_GRANULARITY_128K, 0}, \ + {FAL_PART_MAGIC_WROD, "app", "onchip_flash_256k", FLASH_SIZE_GRANULARITY_128K, FLASH_SIZE_GRANULARITY_256K, 0}, \ } + #endif /* FAL_PART_HAS_TABLE_CFG */ #endif /* _FAL_CFG_H_ */ diff --git a/bsp/stm32/stm32f767-fire-challenger/board/ports/fal_cfg.h b/bsp/stm32/stm32f767-fire-challenger/board/ports/fal_cfg.h index 3f014dbc9da7c5470ada2037dd9e0ac564f477c2..10c05885da602c32b02335537e1b5d332bef6779 100644 --- a/bsp/stm32/stm32f767-fire-challenger/board/ports/fal_cfg.h +++ b/bsp/stm32/stm32f767-fire-challenger/board/ports/fal_cfg.h @@ -14,21 +14,31 @@ #include #include -extern const struct fal_flash_dev stm32_onchip_flash; +#define FLASH_SIZE_GRANULARITY_32K (4 * 32 * 1024) +#define FLASH_SIZE_GRANULARITY_128K (FLASH_SIZE_GRANULARITY_32K + 128 * 1024) +#define FLASH_SIZE_GRANULARITY_256K (FLASH_SIZE_GRANULARITY_128K + 3 * 256 * 1024) + +extern const struct fal_flash_dev stm32_onchip_flash_32k; +extern const struct fal_flash_dev stm32_onchip_flash_128k; +extern const struct fal_flash_dev stm32_onchip_flash_256k; /* flash device table */ #define FAL_FLASH_DEV_TABLE \ { \ - &stm32_onchip_flash, \ + &stm32_onchip_flash_32k, \ + &stm32_onchip_flash_128k, \ + &stm32_onchip_flash_256k, \ } /* ====================== Partition Configuration ========================== */ #ifdef FAL_PART_HAS_TABLE_CFG /* partition table */ -#define FAL_PART_TABLE \ -{ \ - {FAL_PART_MAGIC_WROD, "app", "onchip_flash", 0, 1008 * 1024, 0},\ - {FAL_PART_MAGIC_WROD, "param", "onchip_flash", 1008* 1024 , 16 * 1024, 0},\ +#define FAL_PART_TABLE \ +{ \ + {FAL_PART_MAGIC_WROD, "bootloader", "onchip_flash_32k", 0 , FLASH_SIZE_GRANULARITY_32K , 0}, \ + {FAL_PART_MAGIC_WROD, "param", "onchip_flash_128k", FLASH_SIZE_GRANULARITY_32K , FLASH_SIZE_GRANULARITY_128K, 0}, \ + {FAL_PART_MAGIC_WROD, "app", "onchip_flash_256k", FLASH_SIZE_GRANULARITY_128K, FLASH_SIZE_GRANULARITY_256K, 0}, \ } + #endif /* FAL_PART_HAS_TABLE_CFG */ #endif /* _FAL_CFG_H_ */