From 4b38d37cfd1e65ba884039a2e54ffe8b76d5f8eb Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Fri, 26 Jun 2020 12:36:51 +0200 Subject: [PATCH] pkg/driver_atwinc15x0: enable vendor spi_flash --- pkg/driver_atwinc15x0/Makefile | 1 + pkg/driver_atwinc15x0/Makefile.dep | 1 + .../0001-change-CONST-to-_CONST_.patch | 2 +- .../patches/0002-remove-platform-files.patch | 2 +- .../0003-change-default-debug-config.patch | 2 +- ...004-fix-ETH_MODE-compilation-problem.patch | 2 +- ...ove-dependency-from-spi_flash-module.patch | 2 +- .../0006-rename-spi_flash_-functons.patch | 374 ++++++++++++++++++ 8 files changed, 381 insertions(+), 5 deletions(-) create mode 100644 pkg/driver_atwinc15x0/patches/0006-rename-spi_flash_-functons.patch diff --git a/pkg/driver_atwinc15x0/Makefile b/pkg/driver_atwinc15x0/Makefile index 39d75a31a5..ab84af721d 100644 --- a/pkg/driver_atwinc15x0/Makefile +++ b/pkg/driver_atwinc15x0/Makefile @@ -17,3 +17,4 @@ CFLAGS += -I$(PKG_SOURCE_DIR)/src all: "$(MAKE)" -C $(PKG_SOURCE_DIR)/src/driver/source -f $(RIOTBASE)/Makefile.base MODULE=driver_atwinc15x0 "$(MAKE)" -C $(PKG_SOURCE_DIR)/src/common/source -f $(RIOTBASE)/Makefile.base MODULE=driver_atwinc15x0_common + "$(MAKE)" -C $(PKG_SOURCE_DIR)/src/spi_flash/source -f $(RIOTBASE)/Makefile.base MODULE=driver_atwinc15x0_spi_flash diff --git a/pkg/driver_atwinc15x0/Makefile.dep b/pkg/driver_atwinc15x0/Makefile.dep index 487b9134f4..0abab40325 100644 --- a/pkg/driver_atwinc15x0/Makefile.dep +++ b/pkg/driver_atwinc15x0/Makefile.dep @@ -3,3 +3,4 @@ FEATURES_REQUIRED += periph_spi USEMODULE += driver_atwinc15x0 USEMODULE += driver_atwinc15x0_common +USEMODULE += driver_atwinc15x0_spi_flash diff --git a/pkg/driver_atwinc15x0/patches/0001-change-CONST-to-_CONST_.patch b/pkg/driver_atwinc15x0/patches/0001-change-CONST-to-_CONST_.patch index 5660ee2dfd..63a061be5d 100644 --- a/pkg/driver_atwinc15x0/patches/0001-change-CONST-to-_CONST_.patch +++ b/pkg/driver_atwinc15x0/patches/0001-change-CONST-to-_CONST_.patch @@ -1,7 +1,7 @@ From f07d66798c27359b4348e4a4842b55f601068bd0 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 26 Mar 2020 15:26:52 +0100 -Subject: [PATCH 1/5] change CONST to _CONST_ +Subject: [PATCH 1/6] change CONST to _CONST_ --- src/bsp/include/nm_bsp.h | 2 +- diff --git a/pkg/driver_atwinc15x0/patches/0002-remove-platform-files.patch b/pkg/driver_atwinc15x0/patches/0002-remove-platform-files.patch index 42d441d142..e382398529 100644 --- a/pkg/driver_atwinc15x0/patches/0002-remove-platform-files.patch +++ b/pkg/driver_atwinc15x0/patches/0002-remove-platform-files.patch @@ -1,7 +1,7 @@ From 6c56be47ce245340129438daafa09b4b0a45b2d2 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 26 Mar 2020 23:23:17 +0100 -Subject: [PATCH 2/5] remove platform files +Subject: [PATCH 2/6] remove platform files --- src/bsp/include/nm_bsp_arduino.h | 74 ------ diff --git a/pkg/driver_atwinc15x0/patches/0003-change-default-debug-config.patch b/pkg/driver_atwinc15x0/patches/0003-change-default-debug-config.patch index 4c40cf4a82..3e648cf32e 100644 --- a/pkg/driver_atwinc15x0/patches/0003-change-default-debug-config.patch +++ b/pkg/driver_atwinc15x0/patches/0003-change-default-debug-config.patch @@ -1,7 +1,7 @@ From f18b91094401e75f4700d272c1072a92ac870beb Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 26 Mar 2020 23:55:39 +0100 -Subject: [PATCH 3/5] change default debug config +Subject: [PATCH 3/6] change default debug config --- src/common/include/nm_debug.h | 6 ++++++ diff --git a/pkg/driver_atwinc15x0/patches/0004-fix-ETH_MODE-compilation-problem.patch b/pkg/driver_atwinc15x0/patches/0004-fix-ETH_MODE-compilation-problem.patch index 185d2e338c..6d68bc9cf8 100644 --- a/pkg/driver_atwinc15x0/patches/0004-fix-ETH_MODE-compilation-problem.patch +++ b/pkg/driver_atwinc15x0/patches/0004-fix-ETH_MODE-compilation-problem.patch @@ -1,7 +1,7 @@ From fc93442983afdc95f28a777429279ad5e4fb7fd7 Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Fri, 27 Mar 2020 13:22:22 +0100 -Subject: [PATCH 4/5] fix ETH_MODE compilation problem +Subject: [PATCH 4/6] fix ETH_MODE compilation problem --- src/driver/source/m2m_wifi.c | 2 +- diff --git a/pkg/driver_atwinc15x0/patches/0005-remove-dependency-from-spi_flash-module.patch b/pkg/driver_atwinc15x0/patches/0005-remove-dependency-from-spi_flash-module.patch index b70b8905e3..6600f83d99 100644 --- a/pkg/driver_atwinc15x0/patches/0005-remove-dependency-from-spi_flash-module.patch +++ b/pkg/driver_atwinc15x0/patches/0005-remove-dependency-from-spi_flash-module.patch @@ -1,7 +1,7 @@ From 0e118023ed9a1426e5299b9e6802e11bd488de8b Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Mon, 30 Mar 2020 02:22:18 +0200 -Subject: [PATCH 5/5] remove dependency from spi_flash module +Subject: [PATCH 5/6] remove dependency from spi_flash module --- src/driver/source/nmdrv.c | 2 +- diff --git a/pkg/driver_atwinc15x0/patches/0006-rename-spi_flash_-functons.patch b/pkg/driver_atwinc15x0/patches/0006-rename-spi_flash_-functons.patch new file mode 100644 index 0000000000..ff8208f7db --- /dev/null +++ b/pkg/driver_atwinc15x0/patches/0006-rename-spi_flash_-functons.patch @@ -0,0 +1,374 @@ +From f904e4d6ec1d6d5afa8f7b6da2822fb9e332796a Mon Sep 17 00:00:00 2001 +From: Gunar Schorcht +Date: Thu, 2 Apr 2020 01:54:57 +0200 +Subject: [PATCH 6/6] rename spi_flash_* functons + +--- + src/driver/source/nmdrv.c | 2 +- + src/spi_flash/include/spi_flash.h | 10 ++-- + src/spi_flash/source/spi_flash.c | 86 +++++++++++++++---------------- + 3 files changed, 49 insertions(+), 49 deletions(-) + +diff --git a/src/driver/source/nmdrv.c b/src/driver/source/nmdrv.c +index 3de10c3..d29560a 100644 +--- a/src/driver/source/nmdrv.c ++++ b/src/driver/source/nmdrv.c +@@ -385,7 +385,7 @@ sint8 nm_drv_deinit(void * arg) + } + + /* Disable SPI flash to save power when the chip is off */ +- /* ret = spi_flash_enable(0); */ ++ ret = atwinc15x0_flash_enable(0); + if (M2M_SUCCESS != ret) { + M2M_ERR("[nmi stop]: SPI flash disable fail\n"); + goto ERR1; +diff --git a/src/spi_flash/include/spi_flash.h b/src/spi_flash/include/spi_flash.h +index a85aa72..41515d8 100644 +--- a/src/spi_flash/include/spi_flash.h ++++ b/src/spi_flash/include/spi_flash.h +@@ -124,7 +124,7 @@ extern "C" { + * @brief Enable spi flash operations + * @version 1.0 + */ +-sint8 spi_flash_enable(uint8 enable); ++sint8 atwinc15x0_flash_enable(uint8 enable); + /** \defgroup SPIFLASHAPI Function + * @ingroup SPIFLASH + */ +@@ -139,7 +139,7 @@ sint8 spi_flash_enable(uint8 enable); + * @note Returned value in Mb (Mega Bit). + * @return SPI flash size in case of success and a ZERO value in case of failure. + */ +-uint32 spi_flash_get_size(void); ++uint32 atwinc15x0_flash_get_size(void); + /**@}*/ + + /** @defgroup SPiFlashRead spi_flash_read +@@ -166,7 +166,7 @@ uint32 spi_flash_get_size(void); + * @sa m2m_wifi_download_mode, spi_flash_get_size + * @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise. + */ +-sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz); ++sint8 atwinc15x0_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz); + /**@}*/ + + /** @defgroup SPiFlashWrite spi_flash_write +@@ -197,7 +197,7 @@ sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz); + * @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise. + + */ +-sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz); ++sint8 atwinc15x0_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz); + /**@}*/ + + /** @defgroup SPiFlashErase spi_flash_erase +@@ -223,7 +223,7 @@ sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz); + * @return The function returns @ref M2M_SUCCESS for successful operations and a negative value otherwise. + + */ +-sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz); ++sint8 atwinc15x0_flash_erase(uint32 u32Offset, uint32 u32Sz); + /**@}*/ + #ifdef ARDUINO + #ifdef __cplusplus +diff --git a/src/spi_flash/source/spi_flash.c b/src/spi_flash/source/spi_flash.c +index 12eff59..e70827c 100644 +--- a/src/spi_flash/source/spi_flash.c ++++ b/src/spi_flash/source/spi_flash.c +@@ -96,7 +96,7 @@ SPI Flash DMA + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_read_status_reg(uint8 * val) ++static sint8 atwinc15x0_flash_read_status_reg(uint8 * val) + { + sint8 ret = M2M_SUCCESS; + uint8 cmd[1]; +@@ -130,7 +130,7 @@ static sint8 spi_flash_read_status_reg(uint8 * val) + * @author M. Abdelmawla + * @version 1.0 + */ +-static uint8 spi_flash_read_security_reg(void) ++static uint8 atwinc15x0_flash_read_security_reg(void) + { + uint8 cmd[1]; + uint32 reg; +@@ -161,7 +161,7 @@ static uint8 spi_flash_read_security_reg(void) + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_gang_unblock(void) ++static sint8 atwinc15x0_flash_gang_unblock(void) + { + uint8 cmd[1]; + uint32 val = 0; +@@ -191,7 +191,7 @@ static sint8 spi_flash_gang_unblock(void) + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_clear_security_flags(void) ++static sint8 atwinc15x0_flash_clear_security_flags(void) + { + uint8 cmd[1]; + uint32 val = 0; +@@ -229,7 +229,7 @@ static sint8 spi_flash_clear_security_flags(void) + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz) ++static sint8 atwinc15x0_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz) + { + uint8 cmd[5]; + uint32 val = 0; +@@ -271,7 +271,7 @@ static sint8 spi_flash_load_to_cortus_mem(uint32 u32MemAdr, uint32 u32FlashAdr, + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_sector_erase(uint32 u32FlashAdr) ++static sint8 atwinc15x0_flash_sector_erase(uint32 u32FlashAdr) + { + uint8 cmd[4]; + uint32 val = 0; +@@ -309,7 +309,7 @@ static sint8 spi_flash_sector_erase(uint32 u32FlashAdr) + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_write_enable(void) ++static sint8 atwinc15x0_flash_write_enable(void) + { + uint8 cmd[1]; + uint32 val = 0; +@@ -339,7 +339,7 @@ static sint8 spi_flash_write_enable(void) + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_write_disable(void) ++static sint8 atwinc15x0_flash_write_disable(void) + { + uint8 cmd[1]; + uint32 val = 0; +@@ -374,7 +374,7 @@ static sint8 spi_flash_write_disable(void) + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz) ++static sint8 atwinc15x0_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 u32Sz) + { + uint8 cmd[4]; + uint32 val = 0; +@@ -417,11 +417,11 @@ static sint8 spi_flash_page_program(uint32 u32MemAdr, uint32 u32FlashAdr, uint32 + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_read_internal(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz) ++static sint8 atwinc15x0_flash_read_internal(uint8 *pu8Buf, uint32 u32Addr, uint32 u32Sz) + { + sint8 ret = M2M_SUCCESS; + /* read size must be < 64KB */ +- ret = spi_flash_load_to_cortus_mem(HOST_SHARE_MEM_BASE, u32Addr, u32Sz); ++ ret = atwinc15x0_flash_load_to_cortus_mem(HOST_SHARE_MEM_BASE, u32Addr, u32Sz); + if(M2M_SUCCESS != ret) goto ERR; + ret = nm_read_block(HOST_SHARE_MEM_BASE, pu8Buf, u32Sz); + ERR: +@@ -441,21 +441,21 @@ ERR: + * @author M. Abdelmawla + * @version 1.0 + */ +-static sint8 spi_flash_pp(uint32 u32Offset, uint8 *pu8Buf, uint16 u16Sz) ++static sint8 atwinc15x0_flash_pp(uint32 u32Offset, uint8 *pu8Buf, uint16 u16Sz) + { + sint8 ret = M2M_SUCCESS; + uint8 tmp; +- spi_flash_write_enable(); ++ atwinc15x0_flash_write_enable(); + /* use shared packet memory as temp mem */ + ret += nm_write_block(HOST_SHARE_MEM_BASE, pu8Buf, u16Sz); +- ret += spi_flash_page_program(HOST_SHARE_MEM_BASE, u32Offset, u16Sz); +- ret += spi_flash_read_status_reg(&tmp); ++ ret += atwinc15x0_flash_page_program(HOST_SHARE_MEM_BASE, u32Offset, u16Sz); ++ ret += atwinc15x0_flash_read_status_reg(&tmp); + do + { + if(ret != M2M_SUCCESS) goto ERR; +- ret += spi_flash_read_status_reg(&tmp); ++ ret += atwinc15x0_flash_read_status_reg(&tmp); + }while(tmp & 0x01); +- ret += spi_flash_write_disable(); ++ ret += atwinc15x0_flash_write_disable(); + ERR: + return ret; + } +@@ -467,7 +467,7 @@ ERR: + * @author M.S.M + * @version 1.0 + */ +-static uint32 spi_flash_rdid(void) ++static uint32 atwinc15x0_flash_rdid(void) + { + unsigned char cmd[1]; + uint32 reg = 0; +@@ -504,19 +504,19 @@ static uint32 spi_flash_rdid(void) + * @version 1.0 + */ + #if 0 +-static void spi_flash_unlock(void) ++static void atwinc15x0_flash_unlock(void) + { + uint8 tmp; +- tmp = spi_flash_read_security_reg(); +- spi_flash_clear_security_flags(); ++ tmp = atwinc15x0_flash_read_security_reg(); ++ atwinc15x0_flash_clear_security_flags(); + if(tmp & 0x80) + { +- spi_flash_write_enable(); +- spi_flash_gang_unblock(); ++ atwinc15x0_flash_write_enable(); ++ atwinc15x0_flash_gang_unblock(); + } + } + #endif +-static void spi_flash_enter_low_power_mode(void) { ++static void atwinc15x0_flash_enter_low_power_mode(void) { + volatile unsigned long tmp; + unsigned char* cmd = (unsigned char*) &tmp; + +@@ -531,7 +531,7 @@ static void spi_flash_enter_low_power_mode(void) { + } + + +-static void spi_flash_leave_low_power_mode(void) { ++static void atwinc15x0_flash_leave_low_power_mode(void) { + volatile unsigned long tmp; + unsigned char* cmd = (unsigned char*) &tmp; + +@@ -553,7 +553,7 @@ static void spi_flash_leave_low_power_mode(void) { + * @author M. Abdelmawla + * @version 1.0 + */ +-sint8 spi_flash_enable(uint8 enable) ++sint8 atwinc15x0_flash_enable(uint8 enable) + { + sint8 s8Ret = M2M_SUCCESS; + if(REV(nmi_get_chipid()) >= REV_3A0) { +@@ -569,9 +569,9 @@ sint8 spi_flash_enable(uint8 enable) + u32Val |= ((0x1111ul) << 12); + nm_write_reg(0x1410, u32Val); + if(enable) { +- spi_flash_leave_low_power_mode(); ++ atwinc15x0_flash_leave_low_power_mode(); + } else { +- spi_flash_enter_low_power_mode(); ++ atwinc15x0_flash_enter_low_power_mode(); + } + /* Disable pinmux to SPI flash to minimize leakage. */ + u32Val &= ~((0x7777ul) << 12); +@@ -595,14 +595,14 @@ ERR1: + * @author M. Abdelmawla + * @version 1.0 + */ +-sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz) ++sint8 atwinc15x0_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz) + { + sint8 ret = M2M_SUCCESS; + if(u32Sz > FLASH_BLOCK_SIZE) + { + do + { +- ret = spi_flash_read_internal(pu8Buf, u32offset, FLASH_BLOCK_SIZE); ++ ret = atwinc15x0_flash_read_internal(pu8Buf, u32offset, FLASH_BLOCK_SIZE); + if(M2M_SUCCESS != ret) goto ERR; + u32Sz -= FLASH_BLOCK_SIZE; + u32offset += FLASH_BLOCK_SIZE; +@@ -610,7 +610,7 @@ sint8 spi_flash_read(uint8 *pu8Buf, uint32 u32offset, uint32 u32Sz) + } while(u32Sz > FLASH_BLOCK_SIZE); + } + +- ret = spi_flash_read_internal(pu8Buf, u32offset, u32Sz); ++ ret = atwinc15x0_flash_read_internal(pu8Buf, u32offset, u32Sz); + + ERR: + return ret; +@@ -629,7 +629,7 @@ ERR: + * @author M. Abdelmawla + * @version 1.0 + */ +-sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz) ++sint8 atwinc15x0_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz) + { + #ifdef PROFILING + uint32 t1 = 0; +@@ -657,7 +657,7 @@ sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz) + if (u32off)/*first part of data in the address page*/ + { + u32wsz = u32Blksz - u32off; +- if(spi_flash_pp(u32Offset, pu8Buf, (uint16)BSP_MIN(u32Sz, u32wsz))!=M2M_SUCCESS) ++ if(atwinc15x0_flash_pp(u32Offset, pu8Buf, (uint16)BSP_MIN(u32Sz, u32wsz))!=M2M_SUCCESS) + { + ret = M2M_ERR_FAIL; + goto ERR; +@@ -672,7 +672,7 @@ sint8 spi_flash_write(uint8* pu8Buf, uint32 u32Offset, uint32 u32Sz) + u32wsz = BSP_MIN(u32Sz, u32Blksz); + + /*write complete page or the remaining data*/ +- if(spi_flash_pp(u32Offset, pu8Buf, (uint16)u32wsz)!=M2M_SUCCESS) ++ if(atwinc15x0_flash_pp(u32Offset, pu8Buf, (uint16)u32wsz)!=M2M_SUCCESS) + { + ret = M2M_ERR_FAIL; + goto ERR; +@@ -706,7 +706,7 @@ ERR: + * @author M. Abdelmawla + * @version 1.0 + */ +-sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz) ++sint8 atwinc15x0_flash_erase(uint32 u32Offset, uint32 u32Sz) + { + uint32 i = 0; + sint8 ret = M2M_SUCCESS; +@@ -718,14 +718,14 @@ sint8 spi_flash_erase(uint32 u32Offset, uint32 u32Sz) + M2M_PRINT("\r\n>Start erasing...\r\n"); + for(i = u32Offset; i < (u32Sz +u32Offset); i += (16*FLASH_PAGE_SZ)) + { +- ret += spi_flash_write_enable(); +- ret += spi_flash_read_status_reg(&tmp); +- ret += spi_flash_sector_erase(i + 10); +- ret += spi_flash_read_status_reg(&tmp); ++ ret += atwinc15x0_flash_write_enable(); ++ ret += atwinc15x0_flash_read_status_reg(&tmp); ++ ret += atwinc15x0_flash_sector_erase(i + 10); ++ ret += atwinc15x0_flash_read_status_reg(&tmp); + do + { + if(ret != M2M_SUCCESS) goto ERR; +- ret += spi_flash_read_status_reg(&tmp); ++ ret += atwinc15x0_flash_read_status_reg(&tmp); + }while(tmp & 0x01); + + } +@@ -744,14 +744,14 @@ ERR: + * @author M.S.M + * @version 1.0 + */ +-uint32 spi_flash_get_size(void) ++uint32 atwinc15x0_flash_get_size(void) + { + uint32 u32FlashId = 0, u32FlashPwr = 0; + static uint32 gu32InernalFlashSize= 0; + + if(!gu32InernalFlashSize) + { +- u32FlashId = spi_flash_rdid();//spi_flash_probe(); ++ u32FlashId = atwinc15x0_flash_rdid();//spi_flash_probe(); + if(u32FlashId != 0xffffffff) + { + /*flash size is the third byte from the FLASH RDID*/ +@@ -767,4 +767,4 @@ uint32 spi_flash_get_size(void) + } + + return gu32InernalFlashSize; +-} +\ No newline at end of file ++} +-- +2.17.1 +