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 Aug 23, 2024
1 parent b4e915f commit b628fd8
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 30 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
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 @@ -3645,6 +3645,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 b628fd8

Please sign in to comment.