How To Read Bin File From ESP32 and ESP8266

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello friends today I will show you how to extract hex code from esp32 or esp8266 in this tutorial I will be using the esp32 development module but the steps are the same for any other esp32 or esp8266 device currently I have uploaded a simple blink sketch onto this esp32 it blinks the built-in LED at 500 milliseconds interval my goal is to extract this code from this esp32 and then upload it to another esp32 module this process will enable you to clone any ESP device making it easier to duplicate functionality across multiple devices first ensure that you have the Arduino IDE installed on your computer additionally make sure to add support for esp32 in the Arduino IDE it doesn't matter which version you have installed now go to the tools menu and select the esp32 board there are various boards available simply choose any of them randomly for this demonstration I will be using the esp32 development module next you need to enable the verbose output from the preferences so open the preferences window in the Arduino IDE and select the show verbose output during compilation and upload this setting is required for the upcoming steps now click on upload button but remember you don't need to connect the esp32 to the computer since the board is not connected so the error message will be displayed however there is no need to worry about the error at this stage we just need this last white line so just select all data in this line then copy it by pressing Ctrl C now open the notepad and paste the copied data here first I will delete some unnecessary data that is not required now look at this file esptool.xz file this file is required to extract the hex code from the esp32 and here is the path where the ESP tool.exe file is stored on your computer to access the file you just copy the selected path and paste it into the address bar of the Windows File Explorer then press enter to navigate to the file location as you can see our file is available here next make a copy of the esptool.exe file and then paste it in a convenient location for example you can paste it inside the D drive please ensure that you do not use the drive where Windows is installed since my windows Drive is the C drive so I will keep this file in the D drive now we have the file next step is to test this file to do this open the command prompt it will be used to execute the necessary commands for extracting the hex file from the esp32 here navigate to the D drive where we have stored the esptool.xe file now enter the following command esptool.xe space version and then press enter to execute the command as you can see the version is displayed it means the ESP tool is working fine now let's move back to the notepad here first delete the path as we no longer need it before extracting the hex file you need the exact size of the flash memory of the esp32 if you try to copy the entire contents without knowing the size you might miss some data therefore it is important to determine the flash size accurately and there is a simple method to read the size of the flash memory first select this command you do not need the full command just copy the command until baud rate and then duplicate it here I will delete the chip type as the ESP tool will automatically detect it next enter the com Port of your esp32 module if you are unsure about the com Port then you can check it from the Arduino IDE from here you can find the com port to which your esp32 is connected make sure enter the same com port in the notepad now enter the flash ID command at the end of the line this command will display the exact size of the flash memory in esp32 now copy this updated command and paste it into the command prompt press enter to execute the command as you can see it automatically detect the chip type which is esp32 and Below you can see the flash memory size which is 4 megabytes now we have the flash memory size you just remember it as it will be used in The Next Step now we are ready to read the contents of the flash memory to do this you just duplicate this command again but this time delete the flash ID part and then enter the read flash command this command will be used to read the flash memory next enter the starting address of the flash memory which is zero for the ending address of the flash memory you should enter 0x and then 4 followed by five zeros this is a hexadecimal address to calculate this address you need to do a little math first let's start with the flash memory size which is 4 megabytes now we will convert this value into bytes to do this first enter the size of flash memory which is 4. then multiply it by 10 24 twice this formula will convert the megabytes into bytes now we have the number of bytes next we will convert these bytes into hexadecimal format to do this just copy calculated bytes then paste them into the search bar of the Google and then enter to hex now press enter key to get the hexadecimal value here you can see the hexadecimal value it represents the ending address for the 4 megabytes flash memory the same way you can calculate the address for flash memory devices with different sizes such as 8 megabytes or 16 megabytes after calculating the address make sure to enter the resulting address in the notepad next step is to specify the file name where the extracted data will be stored you can choose any suitable and descriptive file name for easy identification make sure the file name ends with bin extension this file will hold the extracted hex code from the esp32's flash memory now the command is ready so open the command prompt and then paste the command here now press enter to start the hex code extraction process when you see the connecting message then press and hold the boot Button of the esp32 until the reading process starts as you can see the reading process is started you just wait for it to finish now the reading process is complete let's look at the file so navigate to the D drive here you can see our required file you can verify its size as you can see the size of this file is 4 megabytes it means we have read the entire flash memory inside this file it represents the blink sketch that blink the LED at the interval of 500 milliseconds now let's upload it onto another esp32 module first connect the other esp32 module to the computer currently the built-in LED of the esp32 is off it indicates there is no any blink code inside its flash memory so let's upload the blink code using the bin file this time you will need the full command so just duplicate this command here first enter the com Port of the newly connected esp32 you can find the com Port from the Arduino IDE next at the end of the command enter the starting address of the flash memory which is 0x0 finally enter the path and name of our bin file that we have extracted earlier you just copy the name of the file from the D drive and then paste it at the end of the command in the notepad now the command is ready let's execute it from the command prompt when you see the connecting message then press and hold the boot Button of the esp32 until the writing process starts as you can see the writing process is started you just wait for it to finish now the bin file is uploaded if you look at the esp32 you can see the LED start blinking after every 500 milliseconds this way you can create an exact copy of any code stored in an esp32 or esp8266 it saves you a valuable time and effort in programming that's all for today if you have any questions feel free to leave a comment below see you in another video bye
Info
Channel: Ahmad Logs
Views: 32,155
Rating: undefined out of 5
Keywords: esp32 read bin file, esp32 how to extract bin file, esp8266 extract bin file, esp32 upload bin file, esp32 upload binary, esp32 extract code, esp32 extract firmware.
Id: 7OAqwUBOv5w
Channel Id: undefined
Length: 10min 22sec (622 seconds)
Published: Mon Jul 24 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.