title: Decompiling 8051 binary, read from EEPROM
body: <p>I'm trying to decompile the firmware of a Logitech Freedom 2.4 Cordless Joystick. I've managed to get something of the EEPROM. (<a href="https://filebin.net/kxht1rruvvph6www/LogitechFreedom2.4CordlessJoystick.rom?t=2sqw9uv2" rel="nofollow noreferrer">here</a>)
  The EEPROM that is used is the Microchip 25AA320, which is a 32Kbit SPI-EEPROM. The MCU is a nRF24E1G , that contains a 8051 MCU. 
  The ROM should be 4096 bytes, so I think that my reading program looped over it self 4 times.
  I managed to extract a 4kB ROM (<a href="https://filebin.net/kxht1rruvvph6www/dump.rom?t=6eph4wap" rel="nofollow noreferrer">here</a>), but the start of the file doesn't look clean.</p>
  
  <p>I loaded both files into IDA Pro and Ghidra and selected the 8051 processor. They don't generate anything useful.</p>
  
  <p>Could anyone help me decompiling this ROM?</p>
  
  <p>I used <a href="https://pastebin.com/iRjVd1jF" rel="nofollow noreferrer">this</a> Arduino Sketch to dump the rom.
  Together with this python script</p>
  
  <pre><code>## Author: Arpan Das
  ## Date:   Fri Jan 11 12:16:59 2019 +0530
  ## URL: https://github.com/Cyberster/SPI-Based-EEPROM-Reader-Writer
  
  ## It listens to serial port and writes contents into a file
  ## requires pySerial to be installed 
  import sys 
  import serial
  import time
  start = time.time()
  
  MEMORY_SIZE = 4096 # In bytes
  serial_port = 'COM5'
  baud_rate = 115200 # In arduino, Serial.begin(baud_rate)
  write_to_file_path = "dump.rom"
  
  output_file = open(write_to_file_path, "wb")
  ser = serial.Serial(serial_port, baud_rate)
  
  print("Press d for dump ROM else CTRL+C to exit.")
  ch = sys.stdin.read(1)
  
  if ch == 'd':
      ser.write('d')
      for i in range(MEMORY_SIZE/32): # i.e. MEMORY_SIZE / 32
          # wait until arduino response with 'W' i.e. 1 byte of data write request
          while (ser.read() != 'W'): continue
          ser.write('G') # sends back write request granted signal
  
          for j in range(32):
              byte = ser.read(1);
              output_file.write(byte);
  
          print(str(MEMORY_SIZE - (i * 32)) + " bytes remaining.")
  
  print '\nIt took', time.time()-start, ' seconds.'
  </code></pre>