logo elektroda
logo elektroda
X
logo elektroda

Ripping firmware from the ESP32-WROOM-32D IoT module: tools and methods

gigiraffa 3096 15
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19257500
    gigiraffa
    Level 4  
    Welcome,

    I'm new to the subject so I'm very much asking for your understanding and help.

    I need to rip firmware from an IoT device that uses the ESP32-WROOM-32D module. I am very much asking for advice on how to bite this. I've taken the device apart and verified that I can plug into the pinouts: (2) 3V3, (34) RXD0, (35) TXD0, (3) EN, (25) IO0, (38) GND.

    What is the best tool to use? Will a simple UART converter do the job?

    Warm regards
  • ADVERTISEMENT
  • Helpful post
    #2 19257510
    khoam
    Level 42  
    gigiraffa wrote:
    Will a regular UART converter do the job?
    .
    It should.

    The "ripping" itself can be done with the esptool program: Link .

    Installing esptool on windows: Link
  • #3 19257628
    gigiraffa
    Level 4  
    Ok, thank you.

    Is there anything I should watch out for when linking?

    What baud rates does this module operate on? Or how can this be easily calculated?

    Best regards
  • Helpful post
    #4 19257659
    khoam
    Level 42  
    Baud rate will largely depend on the USB converter used - it is safe to rip at 512 kbps. RX/TX of the converter should work in 3V3 logic.
    GPIO 0 should be shorted to ground just before ripping.
    EN should be connected to 3V3 power supply (probably already there - need to check, can be shorted via resistor).

    Ripping firmware from the ESP32-WROOM-32D IoT module: tools and methods .
  • ADVERTISEMENT
  • #5 19258377
    gigiraffa
    Level 4  
    Extra, thanks!

    One more question - could you please advise how to find which addressing to use in the read_flash command to read the firmware? Would it be read_flash 0 0x400000 for 4MB flash or should I limit the range somehow? Additionally, how do I check the COM port?

    Best regards
  • Helpful post
    #6 19258465
    khoam
    Level 42  
    gigiraffa wrote:
    Will it be read_flash 0 0x400000 for 4MB flash
    .
    Exactly, yes.

    gigiraffa wrote:
    Additionally, how to check COM port?
    .
    I don't use windows, but there I think there is such a thing as "Device Manager" and you can preview the COM no. when the USB converter is connected?
  • #7 19259964
    gigiraffa
    Level 4  
    Thank you!!!

    And one more question regarding the earlier connection diagram. What if I would like to have the power source from the wall and not from the UART dongle? Do I still need to connect the EN somewhere?

    Additionally, I came across a tutorial that talks about pressing a button on the dev board to enter programming mode. Do I need to override this somehow without having a programming board? Is connecting IO0 enough to boot into programming mode?

    Thank you very much for your help and understanding!
  • ADVERTISEMENT
  • #8 19260159
    khoam
    Level 42  
    gigiraffa wrote:
    What if I would like to have the power source from the wall and not from the UART dongle?
    .
    Do not simply connect the 3V3 from the converter to the circuit. The grounds must remain connected.

    gigiraffa wrote:
    Do I still need to connect the EN somewhere??
    .
    Yes, the EN must be connected to 3V3, but it is possible that this is already done in the device.

    gigiraffa wrote:
    Do I need to replace this somehow by not having a programming board? Is connecting IO0 enough to boot this programming mode?
    .
    If GPIO 0 is connected to ground while the ESP32 is booting, the chip will enter programming mode and it will be possible to write or read firmware from the ESP32.
  • #9 19260851
    gigiraffa
    Level 4  
    Super! Thank you again!

    One last (I hope) question: I connected to the device and found out from the esptool flash_id that the flash is 16MB. I used esptool first as a test to read the first 2MB from read_flash and everything worked nicely. Now I have tried to read the whole 16MG but it crashes at 72% and goes no further. Could this be because the range that can be read is smaller than 16MB? What is the best way to check the correct addressing to read_flash?
  • #10 19261208
    khoam
    Level 42  
    Interesting, ESP32s with 16MB flash are relatively rare. I have to ask, what kind of IoT device is this?

    The esptool should handle this size of flash as well. What I can suggest are two options:
    1. an additional parameter -fs 16MB when calling esptool or
    2. read the firmware in chunks of 2MB or 4MB each and write to separate BIN files - for the individual chunks you need to specify the respective start and start addresses, e.g. 0 0x400000, 0x400001 0x800000, etc. Later, you will also be able to write each part in a similar way from the corresponding start address to another ESP32.

    At what speed was the 2MB read operation performed?
  • ADVERTISEMENT
  • #11 19261716
    gigiraffa
    Level 4  
    With speed do you mean baud rate? I set 115200 - checking the port screen this baud rate gave me reasonable output, others I tried gave garbage. Is this a reasonable baud rate for read_flash? Maybe use some other one better?

    Additionally, as I mentioned - it crashed at 72%, and 72% of 1600000 is 1152000 which is a total of ten times the baud rate set. Is this somehow related to each other?

    As for the device - it's a hub that connects other iot devices so maybe that's why the larger (custom) flash?
  • #12 19261974
    khoam
    Level 42  
    gigiraffa wrote:
    With speed do you mean baud rate? I have set 115200
    .
    This is OK.

    gigiraffa wrote:
    Additionally, as I mentioned - it crashed at 72%, and 72% of 1600000 is 1152000 which is a total of ten times the baud rate set. Is this somehow related to each other?
    .
    I don't think so :) .

    Try reading the flash in parts as I wrote in a previous post. By the way, what was the form of the whole command from esptool when you tried to read the whole 16MB?
  • #13 19262752
    gigiraffa
    Level 4  
    sudo esptool -p /dev/ttyUSB0 -b 115200 read_flash 0 0x1600000 flash.bin - did I mess something up here?

    I am now trying to read in chunks. What is the best way to then combine them for analysis in Ghidra?

    Warm regards
  • #14 19262758
    khoam
    Level 42  
    gigiraffa wrote:
    sudo esptool -p /dev/ttyUSB0 -b 115200 read_flash 0 0x1600000 flash.bin - did I break something here?
    .
    Should be:
    Code: Bash
    Log in, to see the code

    Knowledge of the hexadecimal system applies ;) .
  • #15 19262840
    gigiraffa
    Level 4  
    yes yes, I just grasped that too! but I think it was 6 zeros and not 5 as you stated?

    Added after 55 [seconds]: .

    Speaking of merging, a simple merge will be ok?
  • #16 19262861
    khoam
    Level 42  
    Yes, it is supposed to be 6 zeros. I have corrected the previous post.

    gigiraffa wrote:
    As far as merging is concerned a simple merge will be ok?
    .
    Yes, it won't work because of the checksums.

Topic summary

The discussion revolves around extracting firmware from an IoT device utilizing the ESP32-WROOM-32D module. The primary tool recommended for this task is the esptool, which can be installed on various operating systems. Users are advised to connect the GPIO 0 to ground during boot to enter programming mode and ensure the EN pin is connected to a 3.3V power supply. The baud rate for communication can be set to 512 kbps or 115200, depending on the USB converter used. When reading firmware, it is suggested to read in chunks, especially for devices with larger flash memory, and to use the correct addressing format in the read_flash command. Issues with reading the entire flash memory at once can be mitigated by specifying the flash size and reading in smaller segments. Additionally, care must be taken to maintain a common ground between the device and the UART converter.
Summary generated by the language model.
ADVERTISEMENT