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

ESP Firmware Image Support #47

Open
brandond opened this issue Jan 18, 2019 · 3 comments
Open

ESP Firmware Image Support #47

brandond opened this issue Jan 18, 2019 · 3 comments

Comments

@brandond
Copy link

brandond commented Jan 18, 2019

I have some firmware images dumped from the flash of a few IOT devices whose functionality I'm trying to re-implement using ESPHomeLib. They all appear to be in esp8266 v1 format. It appears that the esptool.py 'elf2image' command grabs various parts of the ELF binary (IROM, TEXT, etc) and packs them into the format that the on-chip bootloader wants. It does not appear to have any code to do the reverse - convert the flash image back to an ELF binary for analysis.

Is there any way I can analyze these files with ScratchABit, or is it pretty well dependent on having an ELF binary?

@pfalcon
Copy link
Owner

pfalcon commented Jan 19, 2019

ScratchABit is a completely generic solution, operated by plugins. As long as you have (written) suitable loader plugin, it will load anything. ELF loader is nothing but a plugin shipped with the main repo. For simple formats (no symbolic relocations, etc.), you can just split images to raw binary sections (by any tools you like) and load where needed.

The original motivation for writing ScratchABit was reverse-engineering ESP8266 code. See example project at https://github.com/pfalcon/xtensa-subjects

@brandond
Copy link
Author

Alright, I'll take a look at that. It looks like in your project rather than writing a whole loader you're just importing the scratchabit module and calling it on blobs of extracted ROM dump. Would you recommend that I start that way, or would it be better to write a proper loader that understood the images?

@pfalcon
Copy link
Owner

pfalcon commented Jan 19, 2019

Just use common sense: what's your aim - writing loaders? Or reverse engineer a firmware? ;-) The quickest solution is the best. YMMV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants