CHDK Wiki
mNo edit summary
mNo edit summary
Line 1: Line 1:
 
[[File:CHDK-PT_screenshot.jpg|thumb|CHDK-PT porting tool]]'''''[ Modified from : [http://chdk.wikia.com/wiki/Adding_support_of_a_new_firmware_version new firmware version]]'''''
 
[[File:CHDK-PT_screenshot.jpg|thumb|CHDK-PT porting tool]]'''''[ Modified from : [http://chdk.wikia.com/wiki/Adding_support_of_a_new_firmware_version new firmware version]]'''''
   
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; font-weight: inherit; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline;">''Porting CHDK to a new camera for the first time is really hard and very time consuming. Porting to a different firwmare version of the same camera is much easier. With the introduction on CHDK-PT tool, it has become even easier. At least that's the hope.''</p>
+
''Porting CHDK to a new camera for the first time is really hard and very time consuming. Porting to a different firwmare version of the same camera is much easier. With the introduction on CHDK-PT tool, it has become even easier. At least that's the hope.''
  +
  +
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; font-weight: inherit; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline;">''{{notice|CHDK-PT tool offers a basic ARM dissassembler that knows how to interpret CHDK stub_entry.S files, producing output as gcc compatible C files, and will convert stubs files and source code between firmware versions with a little effort from the developer to produce address files.}}''</p>
   
 
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; font-style: inherit; font-weight: inherit; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline;">'''Prerequisites:'''</p>
 
<p style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; font-size: 13px; font-style: inherit; font-weight: inherit; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; vertical-align: baseline;">'''Prerequisites:'''</p>
Line 17: Line 19:
 
*Diff the newly generated stubs_entry.S and the one for the already supported firmware - while many of the addresses will have changed, you are looking to see if the same stubs were found with the same percentage of success.
 
*Diff the newly generated stubs_entry.S and the one for the already supported firmware - while many of the addresses will have changed, you are looking to see if the same stubs were found with the same percentage of success.
 
*Use CHDK-PT '''Convert Stubs '''function to create a new stubs_entry_2.S file for your new port.
 
*Use CHDK-PT '''Convert Stubs '''function to create a new stubs_entry_2.S file for your new port.
*Use CHDK-PT '''Stubs File '''function to dissassemble and create C file version of the stubs_entry_2.S files for the existing port and for your new port. Use the diff function in Notepad++ to compare the two resulting files. Where the routines match, your are done. If they don't match then you need to go searching for a better match with '''Local '''mode
+
*Use CHDK-PT '''Stubs File '''function tp dissassemble and create C file version of the stubs_entry_2.S files for the existing port and for your new port. Use the diff function in Notepad++ to compare the two resulting files. Where the routines match, your are done. If they don't match then you need to go searching for a better match with '''Local '''mode
 
'''<<<edit stopped here for now... more work needed ...>>>'''
 
'''<<<edit stopped here for now... more work needed ...>>>'''
 
*Open boot.c, find boot(), and compare the values there with the loops in the firmware dump. Update the code corresponding to the loops above. The start of initialized data has probably moved. If the sizes of the data and BSS have not changed, it's a good indication that the addresses of variables used by CHDK have not changed.
 
*Open boot.c, find boot(), and compare the values there with the loops in the firmware dump. Update the code corresponding to the loops above. The start of initialized data has probably moved. If the sizes of the data and BSS have not changed, it's a good indication that the addresses of variables used by CHDK have not changed.

Revision as of 16:28, 1 May 2011

CHDK-PT screenshot

CHDK-PT porting tool

[ Modified from : new firmware version]

Porting CHDK to a new camera for the first time is really hard and very time consuming. Porting to a different firwmare version of the same camera is much easier. With the introduction on CHDK-PT tool, it has become even easier. At least that's the hope.

Notice

CHDK-PT tool offers a basic ARM dissassembler that knows how to interpret CHDK stub_entry.S files, producing output as gcc compatible C files, and will convert stubs files and source code between firmware versions with a little effort from the developer to produce address files.

Prerequisites:

  • the CHDK-PT porting tool CHDK-PT (stub for now)
  • a working CHDK build environment like CHDK-Shell
  • a good text editor, preferrably with a built-in diff function like Notepad++
  • a basic knowledge of software, although you will not really be writing code, just changing existing code to reflect difference between firmware version of the same camera.
  • from a working port of you camera, you will need the firmware dump (PRIMARY.BIN) file and the camera specificfiles (boot.c, capt_seq.c, lib.c, movie_rec.c etc) in platform/<camera>/sub/<firmware>/*
  • for the new version you are trying to support, you will need the firmware dump (PRIMARY.BIN)

Steps:

  • Create the platform/<camera>/sub/<firmware>/* for your new canon firmware.
  • Copy the most closely related (i.e. numerically closest version) sub to a sub named for your new firmware. (e.g. 200h -> 201a)
  • Now you are ready to start updating files. I suggest keeping notes of which files you changed and what you did.
  • Build the new sub, with the PRIMARY.BIN in place. This will obviously not be a working port, you just want to generate stubs_entry.S
  • Diff the newly generated stubs_entry.S and the one for the already supported firmware - while many of the addresses will have changed, you are looking to see if the same stubs were found with the same percentage of success.
  • Use CHDK-PT Convert Stubs function to create a new stubs_entry_2.S file for your new port.
  • Use CHDK-PT Stubs File function tp dissassemble and create C file version of the stubs_entry_2.S files for the existing port and for your new port. Use the diff function in Notepad++ to compare the two resulting files. Where the routines match, your are done. If they don't match then you need to go searching for a better match with Local mode

<<<edit stopped here for now... more work needed ...>>>

  • Open boot.c, find boot(), and compare the values there with the loops in the firmware dump. Update the code corresponding to the loops above. The start of initialized data has probably moved. If the sizes of the data and BSS have not changed, it's a good indication that the addresses of variables used by CHDK have not changed.
  • Now scan through the assembler in boot.c, and the corresponding code in IDA. You don't really have to really examine every line, you are mostly looking for calls to functions that have an address higher than highest unchanged address noted above. If you find one, compare it with what's in IDA, and update as needed. Also keep an eye out for variables that might have moved.
  • Follow the same procedure for the capt_seq.c and movie_rec.c
  • If one of the functions you have to update is has moved, you probably want to copy the assembler from scratch rather than trying to correct it.
  • lib.c: If no variables have moved, you probably don't have to do anything here. You can sanity check by searching for the constants in both dumps, and making sure they are referenced by identical code (use "search for a sequence of bytes"). Hardware addresses are unlikely to have changed.
  • stubs_min.S: pretty much the same as lib.c, except FlashParamsTable which will probably have moved by the same amount as the canon data.
  • stubs_entry_2.S: Scan through for addresses that are higher than highest unchanged address, and correct as needed.
  • makefile.inc: MEMISOSTART will need updating if the size of canon DATA + BSS has changed.
  • That's it, you are done. Build it (from scratch with clean !) and find someone to try it it out...
  • OK, you weren't actually quite done yet. Assuming it works, update the toplevel makefile to include your new sub, and commit or submit a patch.

"Note that some of the assumptions above (like variables not moving) are just educated guesses. Canon could have changed the order of variables or functions but had them come out the same size."