Skip to content

Commit 3b28818

Browse files
committed
fix(examples): idf_as_lib linux build
The Linux build was broken after IDF flash API was updated without updating the Linux stub library in the example. This commit updates the spi_flash stub library such that: - The API now matches same API as IDF's spi_flash component - Links the stub_esp32 library to pull in basic types and defines
1 parent 0b69224 commit 3b28818

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
add_library(stub_esp32 STATIC system_api.c cpu_start.c)
22
target_include_directories(stub_esp32 PUBLIC .)
33
add_library(stub::esp32 ALIAS stub_esp32)
4-
5-
target_link_libraries(stub_esp32 stub::spi_flash)

examples/build_system/cmake/idf_as_lib/stubs/esp32/esp_system.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
extern "C" {
1010
#endif
1111

12+
#define ESP_OK 0 /*!< esp_err_t value indicating success (no error) */
13+
14+
typedef int esp_err_t;
15+
1216
void esp_restart(void);
1317

1418
#ifdef __cplusplus
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
add_library(stub_spi_flash STATIC flash_ops.c)
2-
target_include_directories(stub_spi_flash INTERFACE .)
2+
target_include_directories(stub_spi_flash PUBLIC .)
33
add_library(stub::spi_flash ALIAS stub_spi_flash)
4+
target_link_libraries(stub_spi_flash PUBLIC stub_esp32)

examples/build_system/cmake/idf_as_lib/stubs/spi_flash/esp_flash.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
66

77
#pragma once
88

9-
#include <stddef.h>
9+
#include <stdint.h>
10+
#include "esp_system.h"
1011

1112
#ifdef __cplusplus
1213
extern "C" {
1314
#endif
1415

15-
int spi_flash_get_chip_size(void);
16+
typedef void * esp_flash_t;
17+
18+
esp_err_t esp_flash_get_size(esp_flash_t *chip, uint32_t *out_size);
1619

1720
#ifdef __cplusplus
1821
}
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Unlicense OR CC0-1.0
55
*/
66

7-
int spi_flash_get_chip_size(void)
7+
#include "esp_flash.h"
8+
9+
esp_err_t esp_flash_get_size(esp_flash_t *chip, uint32_t *out_size)
810
{
9-
return (1024 * 1024 * 1024);
11+
*out_size = 1024 * 1024 * 1024;
12+
return ESP_OK;
1013
}

0 commit comments

Comments
 (0)