-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Fixed esp_core_dump_image_erase() for flash encryption with 16byte long write buffers (IDFGH-5173) #6949
Fixed esp_core_dump_image_erase() for flash encryption with 16byte long write buffers (IDFGH-5173) #6949
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
#include <string.h> | ||
#include <assert.h> | ||
#include "esp_core_dump.h" | ||
#include "esp_partition.h" | ||
#include "esp_log.h" | ||
#include "esp_core_dump_types.h" | ||
|
@@ -484,9 +486,21 @@ esp_err_t esp_core_dump_image_erase(void) | |
return err; | ||
} | ||
|
||
// helper to create (multiple of) 16 byte long write buffers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a simpler way to do that I would prefer, it's to add at the beginning of this function the following snippet:
You can add the static assert right after (same as now, |
||
struct __attribute__((__packed__)) { | ||
uint32_t size; | ||
char buf[16-sizeof(uint32_t)]; | ||
} helper; | ||
|
||
_Static_assert(sizeof(helper) % 16 == 0, "esp_partition_write() needs multiple of 16 byte long buffers"); | ||
|
||
// Mark core dump as deleted by setting field size | ||
const uint32_t blank_size = BLANK_COREDUMP_SIZE; | ||
err = esp_partition_write(core_part, 0, &blank_size, sizeof(blank_size)); | ||
helper.size = BLANK_COREDUMP_SIZE; | ||
|
||
// fill the remaining bytes | ||
memset(&helper.buf, '\0', sizeof(helper.buf)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you follow my comment above, no need to |
||
|
||
err = esp_partition_write(core_part, 0, &helper, sizeof(helper)); | ||
if (err != ESP_OK) { | ||
ESP_LOGE(TAG, "Failed to write core dump partition size (%d)!", err); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was these includes strictly required?
_Static_assert
can be used without them