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

Can we able to convert the hex file to C code for PIC 16F #3348

Open
Velvizhiarulmozhivarma-eaton opened this issue May 28, 2024 · 9 comments
Labels
Question A question about the project, future development, ... Waiting-For: Author This issue or PR is awaiting for a response or action from the author

Comments

@Velvizhiarulmozhivarma-eaton

I dumped the hex file and tried to convert hex file to C code with PIC uc - PIC16F family.
By selecting the Pic controller, it shows invalid, and my graph and disassembly is not generated properly.
I have attached a image for your reference.

My doubt is whether the cutter will support PIC16F or not?
Uploading MicrosoftTeams-image (3).png…

@karliss
Copy link
Member

karliss commented May 28, 2024

I don't see any images

@karliss karliss added the Waiting-For: Author This issue or PR is awaiting for a response or action from the author label May 28, 2024
@Velvizhiarulmozhivarma-eaton
Copy link
Author

Velvizhiarulmozhivarma-eaton commented May 28, 2024

Okay. I will provide it. Can you please clarify whether you support decompilation of PIC 16F code using Cutter

@Velvizhiarulmozhivarma-eaton
Copy link
Author

Hexfile for PIC16F

@karliss
Copy link
Member

karliss commented May 28, 2024

One step at a time.
First you need to get a proper disassembly and only then you can consider fancier functionality like decompilation.

As can be seen hexdump you have opened the .hex file as raw binary and inspecting the bytes within .hex file instead of the bytes that .hex file represents. To open a hex file you need to choose the ihex:// IO mode in the initial window

image
image

Afterwards you will also have to choose appropriate architecture and CPU family in the load option window
image

Use the microchip documentation to find out whether your specific pic16 classifies as midrange or baseline. Seems like there are groups of 16F in both categories.

@karliss karliss added the Question A question about the project, future development, ... label May 28, 2024
@karliss
Copy link
Member

karliss commented May 28, 2024

Once you have that done you should get better disassembly. Don't use the parsing/disassembly sidepanel within hexdump tab it doesn't do what you probably want. Use the disassembly tab instead.

As for decompilation looks like currently the rizin ghidra plugin doesn't have the mapping between rizin and ghidra architectures. https://github.com/rizinorg/rz-ghidra/blob/733ad009bd603a9ea03d386d2781acff7a150ee2/src/ArchMap.cpp#L71

@Velvizhiarulmozhivarma-eaton
Copy link
Author

I have followed the above-mentioned steps and got a disassembly code and Hexdump code and the decompiler remains empty
I will provide the image below.

Could you please explain the steps to be followed to get the C code from the hex file

@Velvizhiarulmozhivarma-eaton
Copy link
Author

Disassemby

@Velvizhiarulmozhivarma-eaton
Copy link
Author

Hexdump

@Velvizhiarulmozhivarma-eaton
Copy link
Author

And my Decompiler tab remains empty could please guide me how to get decompiled code and from that how to extract the C code.
Decompiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question A question about the project, future development, ... Waiting-For: Author This issue or PR is awaiting for a response or action from the author
Projects
None yet
Development

No branches or pull requests

2 participants