Skip to content

Support arbitrary storage alongside WiFi firmware in external storage on Cypress targets #14063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@
#include "events/mbed_shared_queues.h"
#include "whd_wlioctl.h"
#include "whd_buffer_api.h"
#include "wiced_resource.h"
#include "cybsp_wifi.h"
#include "emac_eapol.h"
#include "cy_result.h"

#if defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE
#include "cy_ext_wifi_fw_reserved_region_bd.h"
#endif /* defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE */

#define NULL_MAC(a) ( ( ( ( (unsigned char *)a )[0] ) == 0 ) && \
( ( ( (unsigned char *)a )[1] ) == 0 ) && \
( ( ( (unsigned char *)a )[2] ) == 0 ) && \
Expand Down Expand Up @@ -112,7 +117,17 @@ bool WHD_EMAC::power_up()
WHD_EMAC &emac_other = WHD_EMAC::get_instance(interface_type == WHD_STA_ROLE ? WHD_AP_ROLE :
WHD_STA_ROLE);
if (!emac_other.powered_up) {
#if defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE
CyReservedRegionBlockDevice *reserved_region_bd = cy_get_ext_wifi_fw_reserved_region_bd();
reserved_region_bd->init();

extern whd_resource_source_t cy_ext_wifi_fw_resource_ops;
res = cybsp_wifi_init_primary_extended(&ifp /* OUT */, &cy_ext_wifi_fw_resource_ops, NULL, NULL);

reserved_region_bd->deinit();
#else
res = cybsp_wifi_init_primary(&ifp /* OUT */);
#endif /* defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE */
} else {
ifp = emac_other.ifp;
}
Expand Down Expand Up @@ -295,4 +310,13 @@ extern "C"
}
}

#if defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE
resource_result_t platform_read_external_resource(const resource_hnd_t *resource, uint32_t offset, uint32_t maxsize, uint32_t *size, void *buffer)
{
CyReservedRegionBlockDevice *bd = cy_get_ext_wifi_fw_reserved_region_bd();
int status = bd->reserved_read(buffer, (mbed::bd_addr_t) resource->val.external_storage_context + offset, *size);
return (status == 0) ? RESOURCE_SUCCESS : RESOURCE_FILE_READ_FAIL;
}
#endif /* defined(CY_EXT_WIFI_FW_STORAGE) && !MBED_CONF_TARGET_XIP_ENABLE */

} // extern "C"
3 changes: 3 additions & 0 deletions storage/kvstore/kv_config/filesystem/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
"target_overrides": {
"MCU_PSOC6": {
"rbp_internal_size": "7168"
},
"CY_EXTERNAL_WIFI_FW": {
"blockdevice": "other"
}
}
}
5 changes: 5 additions & 0 deletions storage/kvstore/kv_config/filesystem_no_rbp/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,10 @@
"help": "Path for the working directory where the FileSystemStore stores the data",
"value": "kvstore"
}
},
"target_overrides": {
"CY_EXTERNAL_WIFI_FW": {
"blockdevice": "other"
}
}
}
3 changes: 3 additions & 0 deletions storage/kvstore/kv_config/tdb_external/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"target_overrides": {
"MCU_PSOC6": {
"rbp_internal_size": "7168"
},
"CY_EXTERNAL_WIFI_FW": {
"blockdevice": "other"
}
}
}
5 changes: 5 additions & 0 deletions storage/kvstore/kv_config/tdb_external_no_rbp/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
"help": "The default will set start address to address 0",
"value": "0"
}
},
"target_overrides": {
"CY_EXTERNAL_WIFI_FW": {
"blockdevice": "other"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -231,7 +233,7 @@ place at address (__ICFEDIT_region_IROM1_start__ + BOOT_HEADER_SIZE) { block RO
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block CM0P_RO with size = (FLASH_CM0P_SIZE - BOOT_HEADER_SIZE) { readonly section .cy_m0p_image };
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -238,7 +240,7 @@ place at start of IROM1_region { block RO };
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -230,7 +232,7 @@ place in IROM1_region { block RO };
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block CM0P_RO with size = FLASH_CM0P_SIZE { readonly section .cy_m0p_image };
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -235,7 +237,7 @@ place at start of IROM1_region { block RO };
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -230,7 +232,7 @@ place in IROM1_region { block RO };
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block CM0P_RO with size = FLASH_CM0P_SIZE { readonly section .cy_m0p_image };
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -235,7 +237,7 @@ place at start of IROM1_region { block RO };
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ define block HEAP with expanding size, alignment = 8, minimum size = __ICF
define block HSTACK {block HEAP, block PROC_STACK, last block CSTACK};
define block RO {first section .intvec, readonly};

define block cy_xip { section .cy_xip };

/*-Initializations-*/
initialize by copy { readwrite };
do not initialize { section .noinit, section .intvec_ram };
Expand Down Expand Up @@ -230,7 +232,7 @@ place in IROM1_region { block RO };
".cy_efuse" : place at start of IROM8_region { section .cy_efuse };

/* Execute in Place (XIP). See the smif driver documentation for details. */
".cy_xip" : place at start of EROM1_region { section .cy_xip };
"cy_xip" : place at start of EROM1_region { block cy_xip };

/* RAM */
place at start of IRAM1_region { readwrite section .intvec_ram};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ LR_SFLASH_RTOC_2 SFLASH_RTOC_2_START SFLASH_RTOC_2_SIZE
; Places the code in the Execute in Place (XIP) section. See the smif driver documentation for details.
LR_EROM XIP_START XIP_SIZE
{
.cy_xip +0
cy_xip +0
{
* (.cy_xip)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,11 @@ SECTIONS
/* Places the code in the Execute in Place (XIP) section. See the smif driver
* documentation for details.
*/
.cy_xip :
cy_xip :
{
__cy_xip_start = .;
KEEP(*(.cy_xip))
__cy_xip_end = .;
} > xip


Expand Down
Loading