Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yann/feature/ble/allow larger packet reception #1356

Merged
merged 3 commits into from
May 13, 2024

Conversation

YannLocatelli
Copy link
Member

@YannLocatelli YannLocatelli commented Jan 17, 2024

@YannLocatelli YannLocatelli added the 01 - type: task Something to do label Jan 17, 2024
@YannLocatelli YannLocatelli added this to the Future Release milestone Jan 17, 2024
@YannLocatelli YannLocatelli self-assigned this Jan 17, 2024
Copy link

github-actions bot commented Jan 17, 2024

🔖 Version comparison

Version Same as filename Same as os_version
os 1.4.0+1715595989 ✔️ ✔️
firmware
(bootloader + os)
1.4.0+1715595989 ✔️ ✔️

Copy link

codecov bot commented Jan 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.70%. Comparing base (0a6affc) to head (73cd435).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1356   +/-   ##
========================================
  Coverage    98.70%   98.70%           
========================================
  Files          146      146           
  Lines         3795     3795           
========================================
  Hits          3746     3746           
  Misses          49       49           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jan 17, 2024

📈 Changes Impact Analysis Report

📌 Info

  • toolchain: GNU Arm Embedded Toolchain 10.3-2021.10 - 10.3.1 20210824
  • enable_log_debug: ON
base head
branch develop yann/feature/ble/allow-larger-packet-reception
sha a4584c4 afdc6b2
mbed mbed-os@master+fixes+gcc-11-support mbed-os@master+fixes+gcc-11-support
-std -std=c++20 -std=c++20

🤖 Firmware impact analysis

Target Flash Used (base/head) Flash Used Δ Flash Available (base/head) Static RAM (base/head) Static RAM Δ
bootloader 183708 (70%) ø 78436 (29%)
78436 (29%)
41656 (7%) ø
os 502828 (32%) ø 1061844 (67%)
1061844 (67%)
94864 (18%) ø
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

🔬 Detailed impact analysis

Click to show detailed analysis for all targets
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 502828 (23%) ø 94864 (18%) ø
bootloader ✔️ 183708 (8%) ø 41656 (7%) ø
functional_ut_boost_ut ✔️ 409276 (19%) ø 30608 (5%) ø
functional_ut_core_imu ✔️ 385140 (18%) ø 31120 (5%) ø
functional_ut_deep_sleep_core_buffered_serial ✔️ 370716 (17%) ø 30560 (5%) ø
functional_ut_deep_sleep_core_lcd ✔️ 401172 (19%) ø 62608 (11%) ø
functional_ut_deep_sleep_core_motor ✔️ 373196 (17%) ø 30632 (5%) ø
functional_ut_deep_sleep_core_pwm ✔️ 374164 (17%) ø 30632 (5%) ø
functional_ut_deep_sleep_log_kit ✔️ 365268 (17%) ø 30976 (5%) ø
functional_ut_deep_sleep_mbed_hal ✔️ 366712 (17%) ø 30560 (5%) ø
functional_ut_file_manager ✔️ 388092 (18%) ø 30856 (5%) ø
functional_ut_firmware_kit ✔️ 379116 (18%) ø 30848 (5%) ø
functional_ut_imu_kit ✔️ 389120 (18%) ø 31296 (5%) ø
functional_ut_io_expander ✔️ 371176 (17%) ø 30576 (5%) ø
functional_ut_qdac ✔️ 372344 (17%) ø 30576 (5%) ø
spike_lk_activity_kit ✔️ 245028 (11%) ø 66480 (12%) ø
spike_lk_audio ✔️ 137724 (6%) ø 25168 (4%) ø
spike_lk_behavior_kit ✔️ 199236 (9%) ø 58672 (11%) ø
spike_lk_ble ✔️ 238492 (11%) ø 39688 (7%) ø
spike_lk_bluetooth ✔️ 92364 (4%) ø 22224 (4%) ø
spike_lk_cg_animations ✔️ 154680 (7%) ø 57232 (10%) ø
spike_lk_color_kit ✔️ 88544 (4%) ø 24376 (4%) ø
spike_lk_command_kit ✔️ 230740 (11%) ø 63728 (12%) ø
spike_lk_config_kit ✔️ 139780 (6%) ø 25184 (4%) ø
spike_lk_coreled ✔️ 88108 (4%) ø 24264 (4%) ø
spike_lk_core_touch_sensor ✔️ 93164 (4%) ø 22824 (4%) ø
spike_lk_event_queue ✔️ 84152 (4%) ø 22904 (4%) ø
spike_lk_file_manager_kit ✔️ 154560 (7%) ø 25520 (4%) ø
spike_lk_file_reception ✔️ 339964 (16%) ø 38448 (7%) ø
spike_lk_flash_memory ✔️ 86776 (4%) ø 22216 (4%) ø
spike_lk_fs ✔️ 179316 (8%) ø 57544 (10%) ø
spike_lk_imu_kit ✔️ 107504 (5%) ø 23744 (4%) ø
spike_lk_lcd ✔️ 174572 (8%) ø 57528 (10%) ø
spike_lk_led_kit ✔️ 115204 (5%) ø 25104 (4%) ø
spike_lk_log_kit ✔️ 84776 (4%) ø 23408 (4%) ø
spike_lk_motion_kit ✔️ 116288 (5%) ø 25704 (4%) ø
spike_lk_motors ✔️ 86344 (4%) ø 22248 (4%) ø
spike_lk_qdac ✔️ 91796 (4%) ø 22768 (4%) ø
spike_lk_reinforcer ✔️ 226260 (10%) ø 60400 (11%) ø
spike_lk_rfid ✔️ 84376 (4%) ø 22184 (4%) ø
spike_lk_sensors_battery ✔️ 87480 (4%) ø 23312 (4%) ø
spike_lk_sensors_imu_lsm6dsox ✔️ 98624 (4%) ø 23536 (4%) ø
spike_lk_sensors_imu_lsm6dsox_fusion_calibration ✔️ 105064 (5%) ø 23104 (4%) ø
spike_lk_sensors_light ✔️ 84072 (4%) ø 22216 (4%) ø
spike_lk_sensors_microphone ✔️ 84824 (4%) ø 22216 (4%) ø
spike_lk_sensors_temperature_humidity ✔️ 90616 (4%) ø 22192 (4%) ø
spike_lk_serial_number ✔️ 145028 (6%) ø 25256 (4%) ø
spike_lk_ticker_timeout ✔️ 82712 (3%) ø 22232 (4%) ø
spike_lk_touch_sensor_kit ✔️ 96668 (4%) ø 23392 (4%) ø
spike_lk_update_process_app_base ✔️ 157932 (7%) ø 26288 (5%) ø
spike_lk_update_process_app_update ✔️ 100456 (4%) ø 23240 (4%) ø
spike_lk_watchdog_isr ✔️ 87616 (4%) ø 24136 (4%) ø
spike_lk_wifi ✔️ 130984 (6%) ø 25528 (4%) ø
spike_mbed_blinky ✔️ 57616 (2%) ø 11496 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 84176 (4%) ø 23080 (4%) ø
spike_stl_cxxsupport ✔️ 83488 (3%) ø 22304 (4%) ø

🗺️ Map files diff output

No differenes where found in map files.

@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/allow-larger-packet-reception branch from 7805280 to c3856b9 Compare January 17, 2024 15:54
Copy link

github-actions bot commented Jan 17, 2024

📈 Changes Impact Analysis Report

📌 Info

  • toolchain: GNU Arm Embedded Toolchain 10.3-2021.10 - 10.3.1 20210824
  • enable_log_debug: OFF
base head
branch develop yann/feature/ble/allow-larger-packet-reception
sha a4584c4 afdc6b2
mbed mbed-os@master+fixes+gcc-11-support mbed-os@master+fixes+gcc-11-support
-std -std=c++20 -std=c++20

🤖 Firmware impact analysis

Target Flash Used (base/head) Flash Used Δ Flash Available (base/head) Static RAM (base/head) Static RAM Δ
bootloader 170904 (65%) ø 91240 (34%)
91240 (34%)
30952 (5%) ø
os 444792 (28%) ø 1119880 (71%)
1119880 (71%)
83640 (15%) ø
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

🔬 Detailed impact analysis

Click to show detailed analysis for all targets
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 444792 (21%) ø 83640 (15%) ø
bootloader ✔️ 170904 (8%) ø 30952 (5%) ø
functional_ut_boost_ut ✔️ 394140 (18%) ø 20456 (3%) ø
functional_ut_core_imu ✔️ 377656 (18%) ø 20968 (3%) ø
functional_ut_deep_sleep_core_buffered_serial ✔️ 362984 (17%) ø 20440 (3%) ø
functional_ut_deep_sleep_core_lcd ✔️ 389572 (18%) ø 52456 (10%) ø
functional_ut_deep_sleep_core_motor ✔️ 361532 (17%) ø 20480 (3%) ø
functional_ut_deep_sleep_core_pwm ✔️ 362564 (17%) ø 20480 (3%) ø
functional_ut_deep_sleep_log_kit ✔️ 352568 (16%) ø 20408 (3%) ø
functional_ut_deep_sleep_mbed_hal ✔️ 354344 (16%) ø 20408 (3%) ø
functional_ut_file_manager ✔️ 376272 (17%) ø 20696 (3%) ø
functional_ut_firmware_kit ✔️ 367084 (17%) ø 20688 (3%) ø
functional_ut_imu_kit ✔️ 381572 (18%) ø 21144 (4%) ø
functional_ut_io_expander ✔️ 359576 (17%) ø 20424 (3%) ø
functional_ut_qdac ✔️ 360744 (17%) ø 20424 (3%) ø
spike_lk_activity_kit ✔️ 242208 (11%) ø 55816 (10%) ø
spike_lk_audio ✔️ 127092 (6%) ø 14592 (2%) ø
spike_lk_behavior_kit ✔️ 190096 (9%) ø 48096 (9%) ø
spike_lk_ble ✔️ 230112 (10%) ø 28744 (5%) ø
spike_lk_bluetooth ✔️ 82948 (3%) ø 11544 (2%) ø
spike_lk_cg_animations ✔️ 146984 (7%) ø 46536 (8%) ø
spike_lk_color_kit ✔️ 65840 (3%) ø 13744 (2%) ø
spike_lk_command_kit ✔️ 221384 (10%) ø 52640 (10%) ø
spike_lk_config_kit ✔️ 127324 (6%) ø 14360 (2%) ø
spike_lk_coreled ✔️ 76292 (3%) ø 13688 (2%) ø
spike_lk_core_touch_sensor ✔️ 80508 (3%) ø 12248 (2%) ø
spike_lk_event_queue ✔️ 74800 (3%) ø 12072 (2%) ø
spike_lk_file_manager_kit ✔️ 139528 (6%) ø 14440 (2%) ø
spike_lk_file_reception ✔️ 336000 (16%) ø 27792 (5%) ø
spike_lk_flash_memory ✔️ 63880 (3%) ø 11448 (2%) ø
spike_lk_fs ✔️ 176676 (8%) ø 47936 (9%) ø
spike_lk_imu_kit ✔️ 98860 (4%) ø 13032 (2%) ø
spike_lk_lcd ✔️ 164376 (7%) ø 46688 (8%) ø
spike_lk_led_kit ✔️ 103424 (4%) ø 14528 (2%) ø
spike_lk_log_kit ✔️ 63288 (3%) ø 12256 (2%) ø
spike_lk_motion_kit ✔️ 111316 (5%) ø 15160 (2%) ø
spike_lk_motors ✔️ 62808 (2%) ø 11488 (2%) ø
spike_lk_qdac ✔️ 78852 (3%) ø 11808 (2%) ø
spike_lk_reinforcer ✔️ 218600 (10%) ø 49824 (9%) ø
spike_lk_rfid ✔️ 79180 (3%) ø 11504 (2%) ø
spike_lk_sensors_battery ✔️ 78500 (3%) ø 12600 (2%) ø
spike_lk_sensors_imu_lsm6dsox ✔️ 89468 (4%) ø 12824 (2%) ø
spike_lk_sensors_imu_lsm6dsox_fusion_calibration ✔️ 97916 (4%) ø 12952 (2%) ø
spike_lk_sensors_light ✔️ 60056 (2%) ø 11440 (2%) ø
spike_lk_sensors_microphone ✔️ 72496 (3%) ø 11504 (2%) ø
spike_lk_sensors_temperature_humidity ✔️ 67272 (3%) ø 11424 (2%) ø
spike_lk_serial_number ✔️ 133084 (6%) ø 14304 (2%) ø
spike_lk_ticker_timeout ✔️ 69052 (3%) ø 11632 (2%) ø
spike_lk_touch_sensor_kit ✔️ 87896 (4%) ø 12824 (2%) ø
spike_lk_update_process_app_base ✔️ 145620 (6%) ø 15576 (2%) ø
spike_lk_update_process_app_update ✔️ 77632 (3%) ø 12352 (2%) ø
spike_lk_watchdog_isr ✔️ 80356 (3%) ø 13288 (2%) ø
spike_lk_wifi ✔️ 116544 (5%) ø 14808 (2%) ø
spike_mbed_blinky ✔️ 58032 (2%) ø 11400 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 63208 (3%) ø 12448 (2%) ø
spike_stl_cxxsupport ✔️ 58456 (2%) ø 11400 (2%) ø

🗺️ Map files diff output

No differenes where found in map files.

@YannLocatelli YannLocatelli linked an issue Jan 18, 2024 that may be closed by this pull request
@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/allow-larger-packet-reception branch from c3856b9 to 4610e3b Compare January 23, 2024 14:59
@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/allow-larger-packet-reception branch 3 times, most recently from 8794b46 to 1640964 Compare February 5, 2024 09:47
Copy link

sonarqubecloud bot commented Feb 5, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/allow-larger-packet-reception branch from 9066aab to fbc72d7 Compare March 18, 2024 15:37
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@YannLocatelli YannLocatelli mentioned this pull request Mar 19, 2024
3 tasks
@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/allow-larger-packet-reception branch from fbc72d7 to 5ca6fdf Compare May 7, 2024 15:23
Copy link
Member

@ladislas ladislas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need better understanding of the values chosen, why the default ones where not good, the issues encountered and how you came up with the new values.

the explanations and details must be added to the commit messages.

@@ -15,6 +15,7 @@
"bluenrg_ms.SPI_nCS": "BLE_SPI_NSS",
"bluenrg_ms.SPI_SCK": "BLE_SPI_SCK",
"cordio.desired-att-mtu": 251,
"cordio.max-prepared-writes": 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YannLocatelli can you explain why the default value of 4 was not working and why the value of 1 is better?

my understanding is that a lower value might impact the efficiency of operations requiring multiple attribute writes.

is 1 used to avoid more than one thing happening at once? and to make sure each command are processed one at a time?

can you explain the issue you were encountering?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked about it few months ago, with value of 4 it works but we have to handle it differently.

You receive 4 packets at the same time in the robot and since you write directly in the file the data you received, you have to handle writing + ordering at the same time
I tried some solutions but never succeed, if you have any idea, let me know.

@@ -15,6 +15,7 @@
"bluenrg_ms.SPI_nCS": "BLE_SPI_NSS",
"bluenrg_ms.SPI_SCK": "BLE_SPI_SCK",
"cordio.desired-att-mtu": 251,
"cordio.rx-acl-buffer-size": 189,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, it's not clear to me why the default value 70 was not working and why the value 189 is the one chosen.

my understanding (but I might be wrong) is that the value must be bigger than the desired-att-mtu size.

what would happen with a value of 256?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never said it does not work
It is a size for a "packet" and it was downed to 189 to fit with iPad max buffer size (modulo some header or wrapper related to BLE protocol probably)
As you suggest with ChatGPT, value of 259 works

@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/allow-larger-packet-reception branch from 5ca6fdf to 73cd435 Compare May 10, 2024 12:40
This setting determines how many prepare write requests can be queued before they are executed.
Each prepare write request can contain a segment of the data to be written to an attribute.

When cordio.max-prepared-writes is set to 1, it means your system can only hold one prepare
write request at a time. This setting minimizes memory usage but can slow down the process
if the device needs to wait for each segment to be confirmed before sending the next.

Default value is 4

With the default value, we were often receiving 4 packets at the same
time. For DFU, this meant adding more logic to handle the 4 packets
correctly which we deemed too much work for now.

Setting the value to 1 prevents mutliple packets from being received at
once and breaking the DFU process.
This parameter configures the size of the buffer used for receiving ACL (Asynchronous Connection-Less)
data packets. The size of this buffer should be large enough to accommodate the largest expected
incoming data payload.

Default is 70

In our case we wanted the maximum size of 251 bytes for the MTU.

Here’s how to calculate an appropriate ACL buffer size:

MTU Consideration: The ATT MTU size of 251 bytes means that the maximum size of data that can be sent in one ATT packet is 251 bytes.

L2CAP Header: The L2CAP protocol uses a 4-byte header on each packet.

HCI Header: When data is transmitted over the HCI interface, there is also an HCI header involved, typically adding an additional 4 bytes (for ACL-U packets).

Given these, the total size for each ACL packet when transmitting maximum sized ATT packets would be:

Total ACL packet size = ATT MTU + L2CAP Header + HCI Header

So in our case:

Total ACL packet size = 251 bytes (ATT MTU) + 4 bytes (L2CAP Header) + 4 bytes (HCI Header) = 259
@ladislas ladislas force-pushed the yann/feature/ble/allow-larger-packet-reception branch from 73cd435 to afdc6b2 Compare May 13, 2024 10:24
@ladislas ladislas merged commit a4584c4 into develop May 13, 2024
22 of 23 checks passed
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@ladislas ladislas deleted the yann/feature/ble/allow-larger-packet-reception branch May 23, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - type: task Something to do
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BLE - check MTU size ipad/robot
2 participants