espressif / ESP8266_RTOS_SDK

Latest ESP8266 SDK based on FreeRTOS, esp-idf style.
http://bbs.espressif.com
Apache License 2.0
3.35k stars 1.57k forks source link

Fix string to bytes conversion (GIT8266O-868) #1290

Open datxuantran opened 1 month ago

datxuantran commented 1 month ago

Description

This pull request introduces a change to the save_segment method in esptool.py. The main modification ensures that the segment.data is properly encoded as bytes if it is provided as a string. This change addresses potential issues when writing segment data to the image file, ensuring compatibility and preventing runtime errors due to incorrect data types.

Motivation

This enhancement is crucial as it maintains data integrity when saving segments, especially when segment data may inadvertently be in string format. It allows for more robust handling of input data types, ensuring that the writing process to the image file functions smoothly without requiring external type checks.

Related

Testing

I tested the changes by creating a new virtual environment and running the esptool with various segment data types (both string and bytes). All tests confirmed that the save_segment method works correctly, successfully writing segment data to the image file without any type-related errors.


Checklist

Before submitting a Pull Request, please ensure the following:

CLAassistant commented 1 month ago

CLA assistant check
All committers have signed the CLA.