A580 porting - minor progress - page 6 - General Discussion and Assistance - CHDK Forum

A580 porting - minor progress

  • 125 Replies
  • 60617 Views
Re: A580 porting - minor progress
« Reply #50 on: 15 / February / 2009, 19:56:09 »
Advertisements
The problem is I don't really know how to disable stuff in the boot process.

For example with the movie rec stuff, do I leave the original "B       sub_FFC5EA24\n" in and comment out //"B       sub_FFC5EA24_my\n"  and this means movie_rec stuff is ignored ?

For mykbd_task and core_spytask stuff, how do i disable these, do I go in platform/generic/main.c and disable the function calls there?

I don't like to ask a lot of questions because I'm worried you guys will start to think I want everything served on a plate and not look on wiki and forum for info first.

I don't mind working in the meantime on movie_rec.c as eventually it will have to be done, and adapting it will probably be as easy as boot.c - basically the code is 99.99% identical, just the offsets are changed.

*

Offline reyalp

  • ******
  • 14082
Re: A580 porting - minor progress
« Reply #51 on: 15 / February / 2009, 20:36:16 »
In dryos cameras, we essentially copy the canon firmware code that starts all the standard tasks, and replace those whose behavior we want to modify (task is like a thread or process). Using a720 as an example, this happens in boot.c  task_Startup_my

movieRecord happens later (in the same branch as the SDHC/multiparition stuff, which you could also ignore for the moment), but the idea is the same.

To not run the modified stuff, all you have to do is use the original function instead of the _my.

spytask is the main CHDK task, which is required for the UI to work. You'll probably want to get this running as soon as possible, although you could just blink leds at various points without enabling that. the kbd task is our replacement for the canon physw task, and is require to interact with the buttons, and also overrides the write protect flag and deals with usb remote stuff.

You are correct that everything will need to be done eventually, but debugging will be much easier if you only have the minimum modifications needed to get to a given point. For example, a trivial error your modified capt_seq could cause the camera to crash on boot. If you have all the capt_seq, movie_req and SDHC stuff enabled at once, tracking down the location of the crash will be more difficult. That doesn't mean you should work on all the bits that you need, but you should take the time to figure out where non-critical parts can be disabled.
Don't forget what the H stands for.

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: A580 porting - minor progress
« Reply #52 on: 16 / February / 2009, 04:39:06 »
It is also possible for DryOS cameras to use tasks "hooking" (to avoid copying millions lines of code, especially for "InitFileModules" and "MovieRecord" tasks). It used in G9 1.00I and S5 (see boot.c file, boot() function).
However, even it works, this is undocumented feature  ;)

Re: A580 porting - minor progress
« Reply #53 on: 16 / February / 2009, 15:14:26 »
So far I've found out that it freezes in the last function of boot.c. It enters it (i can blink the led right before the asm code) but after that it's gone.

I've tried disabling the fat 32 detection code but still no luck... I'll keep trying to find an exact location where it goes poof.


Re: A580 porting - minor progress
« Reply #54 on: 16 / February / 2009, 16:50:15 »
Mariush, I took a quick look on the files.

I wonder if you included all your files, because I cannot compile it right now.  I assume all the files in the folder "platform-a580-sub-101b" goes in the folders platform/a580/sub/101b.

(I am going to bed, but tomorrow I will read the whole thread to see if I missed something).

Re: A580 porting - minor progress
« Reply #55 on: 16 / February / 2009, 17:04:29 »

That's right. The rest in the root folder and I think what's in include folder in the include folder.
You also need the firmware extracted in 101b and named PRIMARY.BIN and then it will compile.

Anyway the best thing is to follow the instructions in the wiki regarding compiling chdk.

I'm using an older snapshot from the svn - i think it's 656 - this could also be why it doesn't compile on your system but without the error messages you get I can't say.


Re: A580 porting - minor progress
« Reply #56 on: 16 / February / 2009, 17:10:45 »

That's right. The rest in the root folder and I think what's in include folder in the include folder.
You also need the firmware extracted in 101b and named PRIMARY.BIN and then it will compile.


Well, the chdk/platform/a580 folder is empty except for the sub-folder, and there is no makefile in the subfolder either.   Do you just copy files for these directories from some other camera, and if yes which one?

Re: A580 porting - minor progress
« Reply #57 on: 16 / February / 2009, 17:31:51 »
You have to copy all the files in loader\a720 to loader\a580 and platform\a720 to platform\a580

Both cameras use the same DryOS version, just different revisions, so they're very similar.

So basically start with the assumption that for example a720 100c is identical to A580 101b and adapt the A580 101b code to match the a580 firmware in IDA.

As far as I can see, the assembly code is 99.9% identical, but the functions in the assembly are at different hex offsets in the 4MB firmware so those offsets (where you see sub_FFC01234 or loc_FFC01234 what's after _ is offset in firmware) have to be adapted.

I work by having open the A720 100c in one IDA window and the A580 101b in another window.

Both firmwares start in boot.c with asm volatile ("B      sub_FFC001a4_my\n"); but you'll see that soon those sub_xxxxxxxx and loc_xxxxxxxxx begin to differ and you have to adapt the code. The content of those sub_ and loc_ is 99.99% identical just the offsets change. Inside the subs usually just some memory addresses change, rarely.

The subs with _my at the end  are functions that are replaced with our code and are listed usually in the same .c file a bit lower. You just have to pay attention and follow the function calls and I'm sure you'll understand the process.

My suggestion for now is to open both firmwares in ida and the two boot.c files - one from a720 and the one I uploaded.
« Last Edit: 16 / February / 2009, 17:33:50 by mariush »


Re: A580 porting - minor progress
« Reply #58 on: 16 / February / 2009, 18:19:50 »
Thank you very much, that certainly got me further!

Now I almost managed to compile!  I will continue trying tomorrow, it seems to be a problem with my buildenvironment, I probably have some old files laying around.

I had to make a change in core/kbd.c to enable ZSTEP_TABLE_SIZE .. I gave it the same size as the a570 and a590.  This made me reach the linking stage.

Re: A580 porting - minor progress
« Reply #59 on: 17 / February / 2009, 04:34:47 »
OK .. there was some problems because the code is newer now, but with a little help I managed to compile!

Thank you for you help folks, and thank you reyalIp for sacrificing your sleep to help me fix the last linking errors.

Now I will setup some tools to analyse the firmware in GNU/Linux.

 

Related Topics