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

Fixed esp_core_dump_image_erase() for flash encryption with 16byte long write buffers (IDFGH-5173) #6949

Conversation

0xFEEDC0DE64
Copy link
Contributor

esp_partition_write() kept failing in esp_core_dump_image_erase() when I enabled flash encryption, as the write function then requires multiple of 16 byte long write buffers.

I changed the erase method so it always writes 16 bytes and the blank coredump size at the beginning.

Also I added a compile time static assert to make sure the struct has a valid size.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 27, 2021
@github-actions github-actions bot changed the title Fixed esp_core_dump_image_erase() for flash encryption with 16byte long write buffers Fixed esp_core_dump_image_erase() for flash encryption with 16byte long write buffers (IDFGH-5173) Apr 27, 2021
@Alvin1Zhang
Copy link
Collaborator

@0xFEEDC0DE64 Thanks for your contribution.

@0xFEEDC0DE64
Copy link
Contributor Author

Is this fix already merged? or is there anything I can do to help?

@o-marshmallow
Copy link
Collaborator

Hello @0xFEEDC0DE64,

Sorry for the delay of response, thank you for your contribution once again 😄 !
I am going to handle this

Copy link
Collaborator

@o-marshmallow o-marshmallow left a comment

Choose a reason for hiding this comment

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

I just added few comments to simplify what you did, please check them

@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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:

/* If flash is encrypted, we can only write blocks of 16 bytes. */
uint32_t helper[4] = { BLANK_COREDUMP_SIZE };

You can add the static assert right after (same as now, sizeof(helper) will return 16).

helper.size = BLANK_COREDUMP_SIZE;

// fill the remaining bytes
memset(&helper.buf, '\0', sizeof(helper.buf));
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you follow my comment above, no need to memset the memory

@@ -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"
Copy link
Collaborator

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

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Jun 3, 2021
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: In Progress Work is in progress labels Jul 13, 2021
espressif-bot pushed a commit that referenced this pull request Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants