Skip to content

Commit d47c0c8

Browse files
Update mbedtls, lwip and cyw43-driver (#2405)
* Update LwIP to 2.2.1 * Update to mbedtls to 3.6.1 * Update lib/cyw43-driver to 1.1.0 * Support using a more recent version of mbedtls altcp_tls_mbedtls.c is not compatible with mbedtls 3.x so use a patched version until this is resolved. * Make sure MBEDTLS_VERSION_MAJOR is visible to LwIP. * Test mbedtls in kitchen sink * Add mbedtls to bazel
1 parent 93ea261 commit d47c0c8

27 files changed

+1724
-150
lines changed

.github/workflows/cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/checkout@v4
2727

2828
- name: Checkout submodules
29-
run: git submodule update --init
29+
run: git submodule update --init --recursive
3030

3131
- name: Create Build Environment
3232
# Some projects don't allow in-source building, so create a separate build directory

MODULE.bazel

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,25 @@ new_git_repository(
106106
new_git_repository(
107107
name = "cyw43-driver",
108108
build_file = "//src/rp2_common/pico_cyw43_driver:cyw43-driver.BUILD",
109-
commit = "c1075d4bc440422cf2b2fd12c64a1f53f77660ee", # keep-in-sync-with-submodule: lib/cyw43-driver
109+
commit = "dd7568229f3bf7a37737b9e1ef250c26efe75b23", # keep-in-sync-with-submodule: lib/cyw43-driver
110110
remote = "https://github.com/georgerobotics/cyw43-driver.git",
111111
)
112112

113113
# TODO: Provide lwip as a proper Bazel module.
114114
new_git_repository(
115115
name = "lwip",
116116
build_file = "//src/rp2_common/pico_lwip:lwip.BUILD",
117-
commit = "0a0452b2c39bdd91e252aef045c115f88f6ca773", # keep-in-sync-with-submodule: lib/lwip
117+
commit = "77dcd25a72509eb83f72b033d219b1d40cd8eb95", # keep-in-sync-with-submodule: lib/lwip
118118
remote = "https://github.com/lwip-tcpip/lwip.git",
119119
)
120120

121+
new_git_repository(
122+
name = "mbedtls",
123+
build_file = "//src/rp2_common/pico_mbedtls:mbedtls.BUILD",
124+
commit = "107ea89daaefb9867ea9121002fbbdf926780e98", # keep-in-sync-with-submodule: lib/mbedtls
125+
remote = "https://github.com/Mbed-TLS/mbedtls.git",
126+
)
127+
121128
register_toolchains(
122129
"//bazel/toolchain:linux-aarch64-rp2040",
123130
"//bazel/toolchain:linux-aarch64-rp2350",

bazel/config/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,9 @@ label_flag(
294294
name = "PICO_FREERTOS_LIB",
295295
build_setting_default = "//bazel:empty_cc_lib",
296296
)
297+
298+
# PICO_BAZEL_CONFIG: PICO_MBEDTL_CONFIG, [Bazel only] The cc_library that provides mbedtls_config.h, default=//bazel:empty_cc_lib, group=pico_mbedtls
299+
label_flag(
300+
name = "PICO_MBEDTLS_CONFIG",
301+
build_setting_default = "//bazel:empty_cc_lib",
302+
)

bazel/constraint/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,9 @@ label_flag_matches(
252252
flag = "//bazel/config:PICO_FREERTOS_LIB",
253253
value = "//bazel:empty_cc_lib",
254254
)
255+
256+
label_flag_matches(
257+
name = "pico_mbedtls_config_unset",
258+
flag = "//bazel/config:PICO_MBEDTLS_CONFIG",
259+
value = "//bazel:empty_cc_lib",
260+
)

bazel/util/transition.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ kitchen_sink_test_binary = declare_transtion(
114114
attrs = {
115115
"bt_stack_config": attr.label(mandatory = True),
116116
"lwip_config": attr.label(mandatory = True),
117+
"mbedtls_config": attr.label(mandatory = True),
117118
"enable_ble": attr.bool(default = False),
118119
"enable_bt_classic": attr.bool(default = False),
119120
# This could be shared, but we don't in order to make it clearer that
@@ -127,6 +128,7 @@ kitchen_sink_test_binary = declare_transtion(
127128
"@pico-sdk//bazel/config:PICO_LWIP_CONFIG": "lwip_config",
128129
"@pico-sdk//bazel/config:PICO_BT_ENABLE_BLE": "enable_ble",
129130
"@pico-sdk//bazel/config:PICO_BT_ENABLE_CLASSIC": "enable_bt_classic",
131+
"@pico-sdk//bazel/config:PICO_MBEDTLS_CONFIG": "mbedtls_config",
130132
},
131133
)
132134

docs/index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
* \defgroup tinyusb_device tinyusb_device
8181
* \defgroup tinyusb_host tinyusb_host
8282
* \endcond
83+
* \cond pico_mbedtls \defgroup pico_mbedtls pico_mbedtls \endcond
8384
* @}
8485
*
8586
* \defgroup networking Networking Libraries

lib/lwip

Submodule lwip updated 103 files

lib/mbedtls

Submodule mbedtls updated 1568 files

src/cmake/rp2_common.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ if (NOT PICO_BARE_METAL)
127127
pico_add_subdirectory(rp2_common/pico_async_context)
128128
pico_add_subdirectory(rp2_common/pico_btstack)
129129
pico_add_subdirectory(rp2_common/pico_cyw43_driver)
130+
pico_add_subdirectory(rp2_common/pico_mbedtls)
130131
pico_add_subdirectory(rp2_common/pico_lwip)
131132
pico_add_subdirectory(rp2_common/pico_cyw43_arch)
132-
pico_add_subdirectory(rp2_common/pico_mbedtls)
133133

134134
pico_add_subdirectory(rp2_common/pico_time_adapter)
135135

src/rp2_common/pico_btstack/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# PICO_CMAKE_CONFIG: PICO_BTSTACK_PATH, Path to an alternative version of btstack overriding the version in pico-sdk/libs/btstack. Can be passed to cmake or set in your environment, type=string, group=pico_btstack
12
if (DEFINED ENV{PICO_BTSTACK_PATH} AND (NOT PICO_BTSTACK_PATH))
23
set(PICO_BTSTACK_PATH $ENV{PICO_BTSTACK_PATH})
34
message("Using PICO_BTSTACK_PATH from environment ('${PICO_BTSTACK_PATH}')")

src/rp2_common/pico_cyw43_driver/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# PICO_CMAKE_CONFIG: PICO_CYW43_DRIVER_PATH, Path to an alternative version of cyw43-driver overriding the version in pico-sdk/libs/cyw43-driver, type=string, group=pico_cyw43_driver
12
if (DEFINED ENV{PICO_CYW43_DRIVER_PATH} AND (NOT PICO_CYW43_DRIVER_PATH))
23
set(PICO_CYW43_DRIVER_PATH $ENV{PICO_CYW43_DRIVER_PATH})
34
message("Using PICO_CYW43_DRIVER_PATH from environment ('${PICO_CYW43_DRIVER_PATH}')")

src/rp2_common/pico_lwip/BUILD.bazel

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ alias(
131131
actual = "@lwip//:pico_lwip_tftp",
132132
)
133133

134-
alias(
134+
cc_library(
135135
name = "pico_lwip_mbedtls",
136-
actual = "@lwip//:pico_lwip_mbedtls",
136+
srcs = ["altcp_tls_mbedtls.c"],
137+
deps = ["@lwip//:pico_lwip_mbedtls"],
137138
)
138139

139140
alias(
140-
name = "pico_lwip_mqttt",
141-
actual = "@lwip//:pico_lwip_mqttt",
141+
name = "pico_lwip_mqtt",
142+
actual = "@lwip//:pico_lwip_mqtt",
142143
)
143144

144145
alias(

src/rp2_common/pico_lwip/CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# PICO_CMAKE_CONFIG: PICO_LWIP_PATH, Path to an alternative version of lwip overriding the version in pico-sdk/libs/lwip. Can be passed to cmake or set in your environment, type=string, group=pico_lwip
12
if (DEFINED ENV{PICO_LWIP_PATH} AND (NOT PICO_LWIP_PATH))
23
set(PICO_LWIP_PATH $ENV{PICO_LWIP_PATH})
34
message("Using PICO_LWIP_PATH from environment ('${PICO_LWIP_PATH}')")
@@ -234,14 +235,29 @@ if (EXISTS ${PICO_LWIP_PATH}/${LWIP_TEST_PATH})
234235
${PICO_LWIP_PATH}/src/apps/tftp/tftp.c
235236
)
236237

238+
237239
# Mbed TLS files
238240
pico_add_library(pico_lwip_mbedtls NOFLAG)
239241
target_sources(pico_lwip_mbedtls INTERFACE
240-
${PICO_LWIP_PATH}/src/apps/altcp_tls/altcp_tls_mbedtls.c
241242
${PICO_LWIP_PATH}/src/apps/altcp_tls/altcp_tls_mbedtls_mem.c
242243
${PICO_LWIP_PATH}/src/apps/snmp/snmpv3_mbedtls.c
243244
)
244245

246+
# altcp_tls_mbedtls.c is not compatible with mbedtls 3.x so use a patched version until this is resolved
247+
# See https://savannah.nongnu.org/patch/index.php?10448
248+
if (MBEDTLS_VERSION_MAJOR AND MBEDTLS_VERSION_MAJOR GREATER_EQUAL 3)
249+
target_sources(pico_lwip_mbedtls INTERFACE
250+
${CMAKE_CURRENT_LIST_DIR}/altcp_tls_mbedtls.c
251+
)
252+
target_include_directories(pico_lwip_mbedtls INTERFACE
253+
${PICO_LWIP_PATH}/src/apps/altcp_tls
254+
)
255+
else()
256+
target_sources(pico_lwip_mbedtls INTERFACE
257+
${PICO_LWIP_PATH}/src/apps/altcp_tls/altcp_tls_mbedtls.c
258+
)
259+
endif()
260+
245261
# MQTT client files
246262
pico_add_library(pico_lwip_mqtt NOFLAG)
247263
target_sources(pico_lwip_mqtt INTERFACE

0 commit comments

Comments
 (0)