From 02cfd92c29481ebaae99a674b9105d327d422715 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Tue, 6 Feb 2024 16:41:36 +0100 Subject: [PATCH 1/8] ci: Add GCC 13.2 to compilers test build workflow This will test code with latest version of ARM GCC. --- .github/workflows/build_cc_target.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_cc_target.yml b/.github/workflows/build_cc_target.yml index e76c809c60..a44f3e70c3 100644 --- a/.github/workflows/build_cc_target.yml +++ b/.github/workflows/build_cc_target.yml @@ -28,14 +28,14 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - gcc: ['12.2.Rel1', '11.3.Rel1', '10.3-2021.10', '9-2020-q2', '8-2019-q3'] + gcc: ['13.2.Rel1', '12.2.Rel1', '11.3.Rel1', '10.3-2021.10', '9-2020-q2', '8-2019-q3'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: go-version: 'stable' - - uses: carlosperate/arm-none-eabi-gcc-action@48db4484a55750df7a0ccca63347fcdea6534d78 + - uses: carlosperate/arm-none-eabi-gcc-action@v1.8.1 with: release: ${{ matrix.gcc }} - name: Install newt From 33d069e5c5edd82e754d33d1c5d2c88418af93e1 Mon Sep 17 00:00:00 2001 From: Wojciech Pietraszewski Date: Wed, 7 Feb 2024 14:05:25 +0100 Subject: [PATCH 2/8] host/uuid: Amend doxygen comments in the header file Corrects variadic macro documentation (BLE_UUID128_INIT). Adds minor formatting improvements. --- nimble/host/include/host/ble_uuid.h | 30 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/nimble/host/include/host/ble_uuid.h b/nimble/host/include/host/ble_uuid.h index be96bb4227..16ba4157fa 100644 --- a/nimble/host/include/host/ble_uuid.h +++ b/nimble/host/include/host/ble_uuid.h @@ -135,7 +135,8 @@ typedef union { * * This macro initializes a 128-bit UUID with the provided value. * - * @param uuid128 The value of the 128-bit UUID. + * @param ... A sequence of values in little-endian order representing + * the 128-bit UUID. * * @return The initialized 128-bit UUID structure. */ @@ -148,7 +149,8 @@ typedef union { } /** - * @brief Macro for declaring a pointer to a 16-bit UUID structure initialized with a specific 16-bit UUID value. + * @brief Macro for declaring a pointer to a 16-bit UUID structure initialized + * with a specific 16-bit UUID value. * * @param uuid16 The 16-bit UUID value to initialize the structure with. * @@ -158,7 +160,8 @@ typedef union { ((ble_uuid_t *) (&(ble_uuid16_t) BLE_UUID16_INIT(uuid16))) /** - * @brief Macro for declaring a pointer to a 32-bit UUID structure initialized with a specific 32-bit UUID value. + * @brief Macro for declaring a pointer to a 32-bit UUID structure initialized + * with a specific 32-bit UUID value. * * @param uuid32 The 32-bit UUID value to initialize the structure with. * @@ -168,7 +171,8 @@ typedef union { ((ble_uuid_t *) (&(ble_uuid32_t) BLE_UUID32_INIT(uuid32))) /** - * @brief Macro for declaring a pointer to a 128-bit UUID structure initialized with specific 128-bit UUID values. + * @brief Macro for declaring a pointer to a 128-bit UUID structure initialized + * with specific 128-bit UUID values. * * @param uuid128 The 128-bit UUID value to initialize the structure with. * @@ -178,7 +182,8 @@ typedef union { ((ble_uuid_t *) (&(ble_uuid128_t) BLE_UUID128_INIT(uuid128))) /** - * @brief Macro for casting a pointer to a `ble_uuid_t` structure to a pointer to 16-bit UUID structure. + * @brief Macro for casting a pointer to a `ble_uuid_t` structure to a pointer + * to 16-bit UUID structure. * * @param u Pointer to a `ble_uuid_t` structure. * @@ -188,7 +193,8 @@ typedef union { ((ble_uuid16_t *) (u)) /** - * @brief Macro for casting a pointer to a `ble_uuid_t` structure to a pointer to 32-bit UUID structure. + * @brief Macro for casting a pointer to a `ble_uuid_t` structure to a pointer + * to 32-bit UUID structure. * * @param u Pointer to a `ble_uuid_t` structure. * @@ -198,7 +204,8 @@ typedef union { ((ble_uuid32_t *) (u)) /** - * @brief Macro for casting a pointer to a `ble_uuid_t` structure to a pointer to 128-bit UUID structure. + * @brief Macro for casting a pointer to a `ble_uuid_t` structure to a pointer + * to 128-bit UUID structure. * * @param u Pointer to a `ble_uuid_t` structure. * @@ -218,8 +225,8 @@ typedef union { * @param buf The source buffer to parse. * @param len The size of the buffer, in bytes. * - * @return 0 on success, BLE_HS_EINVAL if the source buffer does not contain - * a valid UUID. + * @return 0 on success; + * BLE_HS_EINVAL if the source buffer does not contain a valid UUID. */ int ble_uuid_init_from_buf(ble_uuid_any_t *uuid, const void *buf, size_t len); @@ -228,7 +235,8 @@ int ble_uuid_init_from_buf(ble_uuid_any_t *uuid, const void *buf, size_t len); * @param uuid1 The first UUID to compare. * @param uuid2 The second UUID to compare. * - * @return 0 if the two UUIDs are equal, nonzero if the UUIDs differ. + * @return 0 if the two UUIDs are equal; + * nonzero if the UUIDs differ. */ int ble_uuid_cmp(const ble_uuid_t *uuid1, const ble_uuid_t *uuid2); @@ -289,4 +297,4 @@ uint16_t ble_uuid_u16(const ble_uuid_t *uuid); * @} */ -#endif /* _BLE_HOST_UUID_H */ +#endif /* H_BLE_UUID_ */ From ae9273d3af8ef7af4ad653b8eb6d92e6c21f6d6a Mon Sep 17 00:00:00 2001 From: Wojciech Pietraszewski Date: Wed, 7 Feb 2024 15:02:46 +0100 Subject: [PATCH 3/8] host/hs_log: Amend doxygen comments in the header file Adds missing macro documentation (BLE_NPL_LOG_MODULE). Adds minor formatting improvements. --- nimble/host/include/host/ble_hs_log.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/nimble/host/include/host/ble_hs_log.h b/nimble/host/include/host/ble_hs_log.h index 3e1ded4cdd..1514a2ba5c 100644 --- a/nimble/host/include/host/ble_hs_log.h +++ b/nimble/host/include/host/ble_hs_log.h @@ -20,12 +20,6 @@ #ifndef H_BLE_HS_LOG_ #define H_BLE_HS_LOG_ -#ifndef BLE_NPL_LOG_MODULE -#define BLE_NPL_LOG_MODULE BLE_HS_LOG -#endif - -#include - /** * @file ble_hs_log.h * @@ -39,6 +33,13 @@ * @{ */ +#ifndef BLE_NPL_LOG_MODULE +/** Defines the logging module for NimBLE Porting Layer (NPL). */ +#define BLE_NPL_LOG_MODULE BLE_HS_LOG +#endif + +#include + #ifdef __cplusplus extern "C" { #endif @@ -103,4 +104,4 @@ void ble_hs_log_flat_buf(const void *data, int len); * @} */ -#endif +#endif /* H_BLE_HS_LOG_*/ From 4080f942f185fe5f52dff7fa5cb6169dfc29769d Mon Sep 17 00:00:00 2001 From: Magdalena Kasenberg Date: Tue, 23 Jan 2024 16:12:54 +0100 Subject: [PATCH 4/8] babblesim: Fix build errors that occurred after recent updates (nordic-nrfx v3.3.0.) --- babblesim/core/include/core_cm4.h | 2 ++ babblesim/core/src/main_config.c | 4 +++- babblesim/edtt/hci_test/src/main.c | 13 ++----------- babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_timer.c | 4 +++- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/babblesim/core/include/core_cm4.h b/babblesim/core/include/core_cm4.h index ef8f9c3fb9..8b35f4a515 100644 --- a/babblesim/core/include/core_cm4.h +++ b/babblesim/core/include/core_cm4.h @@ -17,6 +17,8 @@ extern void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority); extern void NVIC_EnableIRQ(IRQn_Type IRQn); extern void NVIC_DisableIRQ(IRQn_Type IRQn); +extern void NVIC_SetPendingIRQ(IRQn_Type IRQn); +extern void NVIC_ClearPendingIRQ(IRQn_Type IRQn); void __WFI(void); diff --git a/babblesim/core/src/main_config.c b/babblesim/core/src/main_config.c index 467ae6234b..39a03c3cd5 100644 --- a/babblesim/core/src/main_config.c +++ b/babblesim/core/src/main_config.c @@ -23,6 +23,8 @@ uint global_device_nbr; struct nrf52_bsim_args_t *args; +extern int mynewt_main(int argc, char **argv); + void bst_tick(bs_time_t time) { @@ -46,7 +48,7 @@ main_clean_up_trace_wrap(void) return inner_main_clean_up(0); } -void +int main(int argc, char** argv) { setvbuf(stdout, NULL, _IOLBF, 512); diff --git a/babblesim/edtt/hci_test/src/main.c b/babblesim/edtt/hci_test/src/main.c index 0ca152cfc2..43ef621264 100644 --- a/babblesim/edtt/hci_test/src/main.c +++ b/babblesim/edtt/hci_test/src/main.c @@ -22,8 +22,8 @@ #include "os/mynewt.h" #include "ble_hci_edtt.h" -static int -main_fn(int argc, char **argv) +int +mynewt_main(int argc, char **argv) { sysinit(); @@ -34,12 +34,3 @@ main_fn(int argc, char **argv) } return 0; } - -int -main(int argc, char **argv) -{ - extern void bsim_init(int argc, char** argv, void *main_fn); - bsim_init(argc, argv, main_fn); - - return 0; -} diff --git a/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_timer.c b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_timer.c index 0e3d914c98..a847e9b68a 100644 --- a/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_timer.c +++ b/babblesim/hw/mcu/nordic/nrf52_bsim/src/hal_timer.c @@ -663,7 +663,9 @@ hal_timer_config(int timer_num, uint32_t freq_hz) nrf_timer_task_trigger(hwtimer, NRF_TIMER_TASK_CLEAR); /* Put the timer in timer mode using 32 bits. */ - nrf_timer_mode_set(hwtimer, NRF_TIMER_MODE_TIMER); + hwtimer->MODE = (hwtimer->MODE & ~TIMER_MODE_MODE_Msk) | + ((NRF_TIMER_MODE_TIMER << TIMER_MODE_MODE_Pos) & + TIMER_MODE_MODE_Msk); hwtimer->BITMODE = TIMER_BITMODE_BITMODE_32Bit; /* Set the pre-scalar */ From d42a0ebe6632bd0c318560e4293a522634f60594 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 29 Jan 2024 16:28:12 +0100 Subject: [PATCH 5/8] nimble/host: Fix disconnect on host connection timeout We don't need to have double loop and lock-unlock host lock when issuing disconnect. ble_gap_terminate_with_conn() can be used to disconnect and it can be called with already provided conn object under host lock. --- nimble/host/src/ble_hs_conn.c | 111 +++++++++++++++------------------- 1 file changed, 49 insertions(+), 62 deletions(-) diff --git a/nimble/host/src/ble_hs_conn.c b/nimble/host/src/ble_hs_conn.c index 9b7bdbb3d0..57ba16af87 100644 --- a/nimble/host/src/ble_hs_conn.c +++ b/nimble/host/src/ble_hs_conn.c @@ -477,86 +477,73 @@ ble_hs_conn_timer(void) #endif struct ble_hs_conn *conn; - ble_npl_time_t now; - int32_t next_exp_in; + ble_npl_time_t now = ble_npl_time_get(); + int32_t next_exp_in = BLE_HS_FOREVER; + int32_t next_exp_in_new; + bool next_exp_in_updated; int32_t time_diff; - uint16_t conn_handle; - for (;;) { - conn_handle = BLE_HS_CONN_HANDLE_NONE; - next_exp_in = BLE_HS_FOREVER; - now = ble_npl_time_get(); + ble_hs_lock(); - ble_hs_lock(); - - /* This loop performs one of two tasks: - * 1. Determine if any connections need to be terminated due to timeout. - * If so, break out of the loop and terminate the connection. This - * function will need to be executed again. - * 2. Otherwise, determine when the next timeout will occur. - */ - SLIST_FOREACH(conn, &ble_hs_conns, bhc_next) { - if (!(conn->bhc_flags & BLE_HS_CONN_F_TERMINATING)) { + /* This loop performs one of two tasks: + * 1. Determine if any connections need to be terminated due to timeout. If + * so connection is disconnected. + * 2. Otherwise, determine when the next timeout will occur. + */ + SLIST_FOREACH(conn, &ble_hs_conns, bhc_next) { + if (!(conn->bhc_flags & BLE_HS_CONN_F_TERMINATING)) { + next_exp_in_updated = false; #if MYNEWT_VAL(BLE_L2CAP_RX_FRAG_TIMEOUT) != 0 - /* Check each connection's rx fragment timer. If too much time - * passes after a partial packet is received, the connection is - * terminated. - */ - if (conn->bhc_rx_chan != NULL) { - time_diff = conn->bhc_rx_timeout - now; - - if (time_diff <= 0) { - /* ACL reassembly has timed out. Remember the connection - * handle so it can be terminated after the mutex is - * unlocked. - */ - conn_handle = conn->bhc_handle; - break; - } - - /* Determine if this connection is the soonest to time out. */ - if (time_diff < next_exp_in) { - next_exp_in = time_diff; - } - } -#endif + /* Check each connection's rx fragment timer. If too much time + * passes after a partial packet is received, the connection is + * terminated. + */ + if (conn->bhc_rx_chan != NULL) { + time_diff = conn->bhc_rx_timeout - now; -#if BLE_HS_ATT_SVR_QUEUED_WRITE_TMO - /* Check each connection's rx queued write timer. If too much - * time passes after a prep write is received, the queue is - * cleared. - */ - time_diff = ble_att_svr_ticks_until_tmo(&conn->bhc_att_svr, now); if (time_diff <= 0) { - /* ACL reassembly has timed out. Remember the connection - * handle so it can be terminated after the mutex is - * unlocked. - */ - conn_handle = conn->bhc_handle; - break; + /* ACL reassembly has timed out.*/ + ble_gap_terminate_with_conn(conn, BLE_ERR_REM_USER_CONN_TERM); + continue; } /* Determine if this connection is the soonest to time out. */ if (time_diff < next_exp_in) { - next_exp_in = time_diff; + next_exp_in_new = time_diff; + next_exp_in_updated = true; } + } #endif + +#if BLE_HS_ATT_SVR_QUEUED_WRITE_TMO + /* Check each connection's rx queued write timer. If too much + * time passes after a prep write is received, the queue is + * cleared. + */ + time_diff = ble_att_svr_ticks_until_tmo(&conn->bhc_att_svr, now); + if (time_diff <= 0) { + /* Queued write has timed out.*/ + ble_gap_terminate_with_conn(conn, BLE_ERR_REM_USER_CONN_TERM); + continue; } - } - ble_hs_unlock(); + /* Determine if this connection is the soonest to time out. */ + if (time_diff < next_exp_in) { + next_exp_in_new = time_diff; + next_exp_in_updated = true; + } +#endif - /* If a connection has timed out, terminate it. We need to repeatedly - * call this function again to determine when the next timeout is. - */ - if (conn_handle != BLE_HS_CONN_HANDLE_NONE) { - ble_gap_terminate(conn_handle, BLE_ERR_REM_USER_CONN_TERM); - continue; + if (next_exp_in_updated) { + next_exp_in = next_exp_in_new; + } } - - return next_exp_in; } + + ble_hs_unlock(); + + return next_exp_in; } int From b27535edbc5f8e1bd60824fbe48c1de1014143ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Thu, 15 Feb 2024 10:11:52 +0100 Subject: [PATCH 6/8] host/ble_iso.h: remove unused functions ble_gap_rx_create_big_complete and ble_gap_rx_terminate_big_complete are a leftover from initial implementation and shall be removed. Correct, implemented funcions are ble_iso_rx_create_big_complete and ble_iso_rx_terminate_big_completem, in private API --- nimble/host/include/host/ble_iso.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/nimble/host/include/host/ble_iso.h b/nimble/host/include/host/ble_iso.h index 44877dca68..0d2ddbb11f 100644 --- a/nimble/host/include/host/ble_iso.h +++ b/nimble/host/include/host/ble_iso.h @@ -109,14 +109,6 @@ int ble_iso_create_big(const struct ble_iso_create_big_params *create_params, int ble_iso_terminate_big(uint8_t big_id); -void -ble_gap_rx_create_big_complete(const struct - ble_hci_ev_le_subev_create_big_complete *ev); -void -ble_gap_rx_terminate_big_complete(const struct - ble_hci_ev_le_subev_terminate_big_complete - *ev); - int ble_iso_tx(uint16_t conn_handle, void *data, uint16_t data_len); int ble_iso_init(void); From 20c55b223be145659a9a69caf644acbfbb8c370b Mon Sep 17 00:00:00 2001 From: Wojciech Pietraszewski Date: Wed, 14 Feb 2024 16:47:43 +0100 Subject: [PATCH 7/8] host/audio_broadcast: Amend doxygen comments in the header file Adds missing structures and functions documentation. Corrects usage of 'param' tags. --- .../host/include/host/ble_audio_broadcast.h | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/nimble/host/include/host/ble_audio_broadcast.h b/nimble/host/include/host/ble_audio_broadcast.h index acfc5734ec..9a9fecc7cc 100644 --- a/nimble/host/include/host/ble_audio_broadcast.h +++ b/nimble/host/include/host/ble_audio_broadcast.h @@ -20,11 +20,22 @@ #ifndef H_BLE_AUDIO_BROADCAST_ #define H_BLE_AUDIO_BROADCAST_ +/** + * @file ble_audio_broadcast.h + * + * @brief Bluetooth Low Energy Audio Broadcast API + * + * @defgroup bt_le_audio_broadcast Bluetooth LE Audio Broadcast + * @ingroup bt_host + * @{ + */ + #include #include "host/ble_gap.h" #include "host/ble_iso.h" #include "host/ble_audio_common.h" +/** Parameters used for creating BASE configuration. */ struct ble_broadcast_create_params { /** Broadcast Audio Source Endpoint */ struct ble_audio_base *base; @@ -54,6 +65,7 @@ struct ble_broadcast_create_params { uint16_t svc_data_len; }; +/** Parameters used for updating BASE configuration. */ struct ble_broadcast_update_params { /** Broadcast name - null terminated. * Set NULL to not include in advertising @@ -73,6 +85,7 @@ struct ble_broadcast_update_params { uint32_t broadcast_id; }; +/** Function prototype for broadcast destroy callback. */ typedef int ble_audio_broadcast_destroy_fn(struct ble_audio_base *base, void *args); @@ -182,7 +195,7 @@ struct ble_broadcast_subgroup_params { * structure. Created subgroup extends subgroup list in provided BASE. * This function increases `num_subgroups` in BASE structure. * - * @param[in/out] base Pointer to a `ble_audio_base` structure, + * @param[in,out] base Pointer to a `ble_audio_base` structure, * that will be extended by the new subgroup. * In case of error, filled out data may be * erroneous. @@ -221,7 +234,7 @@ struct ble_broadcast_bis_params { * structure. Created BIS extends BIS list in provided subgroup. * This function increases `bis_cnt` in subgroup structure. * - * @param[in/out] subgroup Pointer to a updated `ble_audio_big_subgroup` + * @param[in,out] subgroup Pointer to a updated `ble_audio_big_subgroup` * structure, that will be extended by the new * BIS. In case of error, filled out data may be * erroneous. @@ -241,5 +254,15 @@ int ble_audio_broadcast_build_bis(struct ble_audio_big_subgroup *subgroup, const struct ble_broadcast_bis_params *params); +/** + * Initializes memory for LE Audio Broadcast. + * + * @return 0 on success + */ int ble_audio_broadcast_init(void); -#endif + +/** + * @} + */ + +#endif /* H_BLE_AUDIO_BROADCAST_*/ From 60aab30a594007df071993d83a920dd005808aec Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Fri, 16 Feb 2024 17:31:10 +0100 Subject: [PATCH 8/8] ci: Use latest RAT release RAT 0.16.1 was released so we no longer need to use snapshots for SPDX support. --- .github/workflows/compliance_check.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/compliance_check.yml b/.github/workflows/compliance_check.yml index c76225a8e6..9b2ee76315 100644 --- a/.github/workflows/compliance_check.yml +++ b/.github/workflows/compliance_check.yml @@ -51,15 +51,11 @@ jobs: - name: Install Dependencies shell: bash run: | - sudo apt-get update - sudo apt-get install -y libxml2-utils mkdir repos git clone --depth=1 https://github.com/apache/mynewt-core repos/apache-mynewt-core - wget https://repository.apache.org/content/repositories/snapshots/org/apache/rat/apache-rat/maven-metadata.xml -O snapshot.xml - SNAPSHOT=`xmllint --xpath "//latest/text()" snapshot.xml` - wget https://repository.apache.org/content/repositories/snapshots/org/apache/rat/apache-rat/$SNAPSHOT/maven-metadata.xml -O version.xml - VERSION=`xmllint --xpath "//snapshotVersion[1]/value/text()" version.xml` - wget https://repository.apache.org/content/repositories/snapshots/org/apache/rat/apache-rat/$SNAPSHOT/apache-rat-$VERSION.jar -O apache-rat.jar + wget https://dlcdn.apache.org//creadur/apache-rat-0.16.1/apache-rat-0.16.1-bin.tar.gz + tar zxf apache-rat-0.16.1-bin.tar.gz apache-rat-0.16.1/apache-rat-0.16.1.jar + mv apache-rat-0.16.1/apache-rat-0.16.1.jar apache-rat.jar - name: check licensing shell: bash run: |