Skip to content

Commit

Permalink
Fix wifi driver build, add an option to just include the wifi firmwar…
Browse files Browse the repository at this point in the history
…e in the image
  • Loading branch information
multiplemonomials committed Jul 29, 2024
1 parent 9ea675d commit e3c0bbb
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_library(mbed-minimal-cyhal STATIC
target_include_directories(mbed-minimal-cyhal PUBLIC .)
target_link_libraries(mbed-minimal-cyhal PUBLIC
mbed-core-flags
mbed-cy-rtos-abstraction)
mbed-rtos-flags)

# This is needed in order to make cybsp_wifi.h include cycfg.h
target_compile_definitions(mbed-minimal-cyhal PUBLIC COMPONENT_CUSTOM_DESIGN_MODUS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ MBED_WEAK wiced_result_t whd_firmware_check_hook(const char *mounted_name, int m
return WICED_ERROR;
}

wiced_filesystem_t resource_fs_handle = 0;

wiced_result_t wiced_filesystem_setup()
{
static QSPIFBlockDevice *qspi_bd = nullptr;
Expand All @@ -82,6 +84,7 @@ wiced_result_t wiced_filesystem_setup()
mbr_bd = new mbed::MBRBlockDevice(qspi_bd, WIFI_DEFAULT_PARTITION);
if(mbr_bd->init() != mbed::BD_ERROR_OK)
{
whd_firmware_check_hook(WIFI_DEFAULT_MOUNT_NAME, true);
delete mbr_bd;
mbr_bd = nullptr;
return WICED_ERROR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <stdio.h>
#include "cyhal.h"
#include "cybsp.h"
#include "drivers/DigitalIn.h"
#include "drivers/DigitalOut.h"
#include "drivers/InterruptIn.h"

#include <minimal_cyhal_config.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ typedef int wiced_file_t;
*/
typedef int wiced_filesystem_handle_type_t;

// Global "FS handle" object. Just here to match the WHD driver's expectations, we have one global
// Global "FS handle" object. Just here to match the WHD driver's expectations, we in fact have one global
// filesystem object.
static wiced_filesystem_t resource_fs_handle = 0;
extern wiced_filesystem_t resource_fs_handle;

/**
* @brief Sets up the file system where the wifi module resources will be loaded from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "wiced_resource.h"
#include "mbed-target-config.h"

#if defined(CY_STORAGE_WIFI_DATA)
CY_SECTION_WHD(CY_STORAGE_WIFI_DATA) __attribute__((used))
Expand Down Expand Up @@ -25489,5 +25490,9 @@ const unsigned char wifi_firmware_image_data[421098] = {
49, 45, 53, 97, 102, 99, 56, 99, 49, 101, 0, 254, 0, 68, 86, 73, 68,
32, 48, 49, 45, 101, 100, 48, 100, 55, 97, 53, 54
};
resource_hnd_t wifi_firmware_image = { RESOURCE_IN_EXTERNAL_STORAGE, 421098, {.fs = { 0, "/wlan/4343WA1.BIN" }}};

#if MBED_CONF_TARGET_WIFI_DRIVER_IN_QSPI_FLASH
resource_hnd_t wifi_firmware_image = { RESOURCE_IN_EXTERNAL_STORAGE, 421098, {.fs = { 0, "/wlan/4343WA1.BIN" }}};
#else
const resource_hnd_t wifi_firmware_image = { RESOURCE_IN_MEMORY, 421098, {.mem = { (const char *) wifi_firmware_image_data }}};
#endif
14 changes: 14 additions & 0 deletions connectivity/netsocket/tests/TESTS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,19 @@ if(DEFAULT_IFC_IDX EQUAL -1)
set(TEST_SKIPPED "No default network interface on this target")
endif()

# Set up variables for wi-fi SSID and password
if("MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE=WIFI" IN_LIST MBED_CONFIG_DEFINITIONS)
set(MBED_GREENTEA_WIFI_SECURE_SSID "" CACHE STRING "SSID of a secured wi-fi network with internet access, for greentea tests which need to connect to wifi")
set(MBED_GREENTEA_WIFI_SECURE_PASSWORD "" CACHE STRING "Password to the network given by MBED_GREENTEA_WIFI_SECURE_SSID")

if("${MBED_GREENTEA_WIFI_SECURE_SSID}" STREQUAL "" OR "${MBED_GREENTEA_WIFI_SECURE_PASSWORD}" STREQUAL "")
message(WARNING "MBED_GREENTEA_WIFI_SECURE_SSID and MBED_GREENTEA_WIFI_SECURE_PASSWORD must be set in order for wi-fi greentea tests to pass")
else()
add_compile_definitions(
"MBED_GREENTEA_WIFI_SECURE_SSID=\"${MBED_GREENTEA_WIFI_SECURE_SSID}\""
"MBED_GREENTEA_WIFI_SECURE_PASSWORD=\"${MBED_GREENTEA_WIFI_SECURE_PASSWORD}\"")
endif()
endif()

add_subdirectory(netsocket)
add_subdirectory(network)
8 changes: 7 additions & 1 deletion connectivity/netsocket/tests/TESTS/netsocket/udp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#define WIFI 2
#if !defined(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE) || \
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_CONF_NSAPI_DEFAULT_WIFI_SSID))
(MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI && !defined(MBED_GREENTEA_WIFI_SECURE_SSID))
#error [NOT_SUPPORTED] No network configuration found for this target.
#else

Expand Down Expand Up @@ -61,7 +61,13 @@ void drop_bad_packets(UDPSocket &sock, int orig_timeout)
}
static void _ifup()
{
#if MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == WIFI
WiFiInterface * net = WiFiInterface::get_default_instance();
net->set_credentials(MBED_GREENTEA_WIFI_SECURE_SSID, MBED_GREENTEA_WIFI_SECURE_PASSWORD);
#else
NetworkInterface *net = NetworkInterface::get_default_instance();
#endif

TEST_ASSERT_NOT_NULL_MESSAGE(net, "No NetworkInterface configured");
nsapi_error_t err = net->connect();

Expand Down
2 changes: 1 addition & 1 deletion drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ target_include_directories(mbed-core-flags
.
./include
./include/drivers
./include/drivers/internal
./include/drivers/interfaces
)

target_sources(mbed-core-sources
Expand Down
2 changes: 1 addition & 1 deletion features/frameworks/cy_rtos_rtx_adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ else()
# Build as part of the minimal CyHAL if it's enabled
if(TARGET mbed-minimal-cyhal)
target_sources(mbed-minimal-cyhal PRIVATE ${CY_RTOS_RTX_ADAPTER_SOURCES})
target_include_directories(mbed-minimal-cyhal INTERFACE ${CY_RTOS_RTX_ADAPTER_INCLUDE_DIRS})
target_include_directories(mbed-minimal-cyhal PUBLIC ${CY_RTOS_RTX_ADAPTER_INCLUDE_DIRS})
endif()
endif()
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
=======
/*
* Copyright 2024 Arduino SA
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,23 +19,4 @@

#include "objects.h"

#endif
=======
#include "cyhal_system.h"

#include "mbed_critical.h"

uint32_t cyhal_system_critical_section_enter(void)
{
bool were_interrupts_enabled = !core_util_in_critical_section();

core_util_critical_section_enter();

return were_interrupts_enabled;
}

void cyhal_system_critical_section_exit(uint32_t old_state)
{
(void)old_state;
core_util_critical_section_exit();
}
#endif
4 changes: 4 additions & 0 deletions targets/targets.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3623,6 +3623,10 @@
"usb_speed": {
"help": "USE_USB_OTG_FS or USE_USB_OTG_HS or USE_USB_HS_IN_FS",
"value": "USE_USB_OTG_HS"
},
"wifi_driver_in_qspi_flash": {
help: "If this is false, and wifi is used in the application, the wifi chip firmware will be included in the application firmware (+411kiB code size). If true, then the wifi firmware is loaded from the external QSPI flash instead, and you must install it using the Arduino IDE sketch for this purpose.",
value: false
}
},
"components_add": [
Expand Down

0 comments on commit e3c0bbb

Please sign in to comment.