Hi there! I'm completely new to arduino, but not to programming. I bought a gadget that is not behaving as expected and to my surprise the brains of the operation is an Arduino UNO.
After a bit of googling i was able to connect to it using avrdude and dump its contents.
This is the command I used to do it:
avrdude -CC:avrdude.conf -v -V -patmega328p -carduino "-PCOM10" -b115200 -D "-Uflash:r:dump.hex:i"
It worked, and as output i got the hex file and this info on the shell:
Using Port : COM10
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
avrdude.exe: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude.exe: Device signature = 0x1e950f (probably m328p)
avrdude.exe: safemode: lfuse reads as 0
avrdude.exe: safemode: hfuse reads as 0
avrdude.exe: safemode: efuse reads as 0
...
I'd like to reverse engineer the code to try to at least understand how it works and if or how I can fix it.
Using Ghidra I was able to have it decompile the dump succesfully, ( at least it appears to be ), however, being completely new to the platform I have no idea where to find the relevant information.
Where does the user code start? What are the registers, device registers addresses, memory mapped devices ecc.
Previous questions on the topic were more specific and/or were met with pessimism.
Do you know of any resource that could help me? Have you tried something similar in the past? Do you know of any tool that could help me?
Thank you!