fix(ble_ota): fix reading of NimBLE's mbufs (AEGHB-1060) #502
+6
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When testing the ble_ota example, using version 1.2.0 of the Android test app, I could not get the OTA to work, it was failing on "Unable to decipher GCM key". Putting a couple of
ESP_LOG_BUFFER_HEX
in the code, I found out that chunks of the file were being skipped.The problem was how the Nimble's mbufs were being read in the code path of the pre-encoded OTA. It seems only the first two buffers of the mbuf linked list were being manually read. I fixed that by replacing the manual code with provided APIs like
os_mbuf_copydata
andos_mbuf_len
. I applied the same fix to the non-pre-encoded OTA code path, although I believe it was not broken like the pre-encoded OTA; however, I did not confirm this.After fixing the problem, I had to increase the stack size of the NimBLE task.
Related
Testing
I am not sure if this bug always happens or specific conditions are necessary. I tested it using the following
sdkconfig.defaults
(got fromidf.py save-defconfig
) with a custom board with a ESP32-C3, with version 1.2.0 and 1.1.0 of the test APP on Android 13, sending thebuild/ble_ota_secure.bin
file from the same build as the flashed code.Checklist
Before submitting a Pull Request, please ensure the following: