Porting chdk to the G9 - page 3 - DryOS Development - CHDK Forum

Porting chdk to the G9

  • 245 Replies
  • 126710 Views
Re: Porting chdk to the G9
« Reply #20 on: 21 / April / 2008, 10:23:17 »
Advertisements
To our beloved developers (in primis GrAnd, Jeff666):

Can you please give some hints on how to start?

My progress:

- dowloaded gcc-hdk and sources from https://tools.assembla.com/chdk/browser/branches/grand with svn checkout https://tools.assembla.com/svn/chdk/trunk chdk
- setted up the environment variables
- following this guide Compiling CHDK under Windows - CHDK Wiki

is it premature?
« Last Edit: 21 / April / 2008, 10:32:45 by bongo_bingo »

*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: Porting chdk to the G9
« Reply #21 on: 21 / April / 2008, 10:53:55 »
- dowloaded gcc-hdk and sources from https://tools.assembla.com/chdk/browser/branches/grand

Use trunk: https://tools.assembla.com/chdk/browser/trunk
This is the current state.

Check that a currently supported device compiles, then duplicate the device-dependent directories and rename them accordingly. As source-directories for duplication I recommend the A720-code.

Device-dependent directories are are in loader/ and platform/

Also modify makefile.inc and add new PLATFORM and PLATFORMSUB lines.

Then check if code for your pseudo-platform compiles. If it does, you can continue with the reset-code. Good news is: you will probably not need to change much.

For testing two lines need changing. In resetcode/main.c:94 you find
 //"LDR     R0, =0xFFC00000\n"   // original jump-vector
"MOV     R0, %0\n"              // new jump-vector

For testing we need to continue at the official firmware-start. So change them to:
"LDR     R0, =0xFF810000\n"   // original jump-vector
// "MOV     R0, %0\n"              // new jump-vector (disabled for test)

A few lines later, execution is branched to R0, so for testing we point R0 to the regular start. If this works we point it to our code and revert the changes.


What happens so far is:
1. the camera starts, initializes some stuff
2. checks the card for diskboot.bin, loads it to 0x1900 and jumps there
3. at 0x1900 is the resetcode we copied from the original firmware (from my A720) which will restart the device => goto 1.

To break the loop and see if the device starts properly we need to prevent diskboot.bin from loading. Easiest method at this point is removing the card. So you need a minor hardware-hack to take out the card while the cam is on.

If you did this and the cam starts properly, you can continue with platform/.../main.c

I'm in a little hurry, right now, so if anything is unclear: ask.

Cheers.

Re: Porting chdk to the G9
« Reply #22 on: 21 / April / 2008, 11:01:53 »
Thanks a lot Jeff666! :)

Edit 1:

This is the log:

C:\CHDK\src>gmake PLATFORM=g9 PLATFORMSUB=100f fir
**** Build: 50
>> Entering to tools
pakwif.c -> pakwif.o
pakwif.o -> pakwif.exe
gensig.c -> gensig.o
gensig.o -> gensig.exe
-> signatures_dryos.h
CAUTION! 'signatures_dryos.h' is not uptated due to 'sig_ref_dryos_1.bin` is emp
ty!
finsig.c -> finsig.o
finsig.o -> finsig.exe
<< Leaving tools
>> Entering to lib
>> Entering to lib/font
font_8x16.c -> font_8x16.o
In file included from ../../include/stdlib.h:1,
                 from font_8x16.c:2:
../../include/camera.h:445:2: #error camera type not defined
c:\CHDK\gcc\bin\gmake[2]: *** [font_8x16.o] Error 1
c:\CHDK\gcc\bin\gmake[1]: *** [all-recursive] Error 1
gmake: *** [all-recursive] Error 1

Edit 2:
Compiling for a720 gives:

Firmware creation completed successfully

Edit 3:
- So I decideded to modify main.c in the a720 /loader/directory/resetcode
- gmake PLATFORM=a720 PLATFORMSUB=100c fir compiled succcefully
- renamed \src\loader\a720\resetcode\main.bin in diskboot.bin then copied it on a bootable sd card
- powered the g9 with the sd card, nothing appened
- removed the sd card, still nothing appened
- had to remove the battery to have the cam working again

What did I miss?
« Last Edit: 21 / April / 2008, 12:57:48 by bongo_bingo »

*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: Porting chdk to the G9
« Reply #23 on: 21 / April / 2008, 13:00:30 »
- renamed \src\loader\a720\resetcode\main.bin in diskboot.bin then copied it on a bootable sd card

Use bin/diskboot.bin, that is the binary which runs on the camera. It doesn't matter that most of the code in there won't work on your camera, since it is skipped anyway (changes in loader skip it).

I had a look at the restart-code in the g9 firmware and it is identical to the A720 and S5, so the loader doesn't need any changes (as expected).

Right now I'll prepare platform/g9/sub/100d/boot.c which should get the camera started. I'll upload a zip when I'm done (which should be in about an hour, maybe two).

Edit: I just noticed you have 1.00f. I'll grab your dump and use it.

Cheers.
« Last Edit: 21 / April / 2008, 13:09:35 by jeff666 »


Re: Porting chdk to the G9
« Reply #24 on: 21 / April / 2008, 13:14:13 »
- renamed \src\loader\a720\resetcode\main.bin in diskboot.bin then copied it on a bootable sd card

Use bin/diskboot.bin, that is the binary which runs on the camera. It doesn't matter that most of the code in there won't work on your camera, since it is skipped anyway (changes in loader skip it).

I had a look at the restart-code in the g9 firmware and it is identical to the A720 and S5, so the loader doesn't need any changes (as expected).

Right now I'll prepare platform/g9/sub/100d/boot.c which should get the camera started. I'll upload a zip when I'm done (which should be in about an hour, maybe two).

Edit: I just noticed you have 1.00f. I'll grab your dump and use it.

Cheers.

Using bin/diskboot.bin the tricks worked!

Thanks a lot Jeff666, that's great! :)

Re: Porting chdk to the G9
« Reply #25 on: 21 / April / 2008, 13:23:28 »
What can I do in the mean time? :D

Edit 1:


- I've copied the firmware dump to platform\g9\sub\100f, watching at the makefile.inc I had to identify:

PLATFORMID=?

PLATFORMOS=dryos

MEMBASEADDR=0x?
RESTARTSTART=0x?
MEMISOSTART=0x?
MEMISOSIZE=0x?
ROMBASEADDR=0x?
« Last Edit: 21 / April / 2008, 13:52:51 by bongo_bingo »

*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: Porting chdk to the G9
« Reply #26 on: 21 / April / 2008, 14:04:14 »
What can I do in the mean time? :D

Have coffee :D

Familiarize with the A720 dump. You need it for comparison since the code you are looking at is from the A720.

Loading instructions are similar to the G9 except rom offset is 0xFFC00000. Signatures and scripts are the same as used with the G9.

Quote
- I've copied the firmware dump to platform\g9\sub\100f, watching at the makefile.inc I had to identify:

MEMBASEADDR=0x1900
RESTARTSTART=0x50000
MEMISOSTART=0xB0B68
MEMISOSIZE=0x40000
ROMBASEADDR=0xff810000

MEMBASEADDR is mentioned at FF810134
RESTARTSTART is chdk-related and does not depend on the firmware
MEMIOSTART is mentioned at FF81014C
MEMIOSIZE is chdk-related (space reserved for chdk)
ROMBASEADDR is known to be 0xff810000 for S/G-series and 0xFFC00000 for A-Series.

But you won't need to change anything there. You'll get working files when I'm done. I'm working on 100d and 100f at the same time. I hope I don't mix up things 8)

Cheers.

Re: Porting chdk to the G9
« Reply #27 on: 21 / April / 2008, 14:36:22 »
You'll get working files when I'm done. I'm working on 100d and 100f at the same time. I hope I don't mix up things 8)

Wow jeff666. I was meanwile thinking that I ask you to do for 1.00D also but you were quicker.  :) Thanks a lot....


*

Offline GrAnd

  • ****
  • 916
  • [A610, S3IS]
    • CHDK
Re: Porting chdk to the G9
« Reply #28 on: 21 / April / 2008, 14:48:41 »
../../include/camera.h:445:2: #error camera type not defined

Define the section for your camera in that file (include/camera.h). You may just copy all defines from A720 at the beginning.
CHDK Developer.

*

Offline jeff666

  • ****
  • 181
  • A720IS
Re: Porting chdk to the G9
« Reply #29 on: 21 / April / 2008, 15:14:15 »
I was meanwile thinking that I ask you to do for 1.00D also but you were quicker.  :) Thanks a lot....

No problem. At least the start-relevant things seem absolutely identical. I attached binaries for a quick test. Although they are built against specific firmware versions, they should be interchangeable (at least at the current stage).

Current source is here: zSHARE - g9-test1.zip

This is what I did:
* create platform-dependent directories for g9 100f & 100d
* modify makefile.inc and camera.h so the new branch compiles
* modify platform/g9/sub/.../boot.c to restart the cam and skip diskboot. Changes end at line 282. Modified until task_Startup_my().

In task_Startup_my are two pending changes commented.
1. CreateTask_spytask()
2. CreateTask_PhySw()

This is where you want to continue porting.
Also the function-entrypoints have to be found. Use tools/finsig and IDA and look at platform/g9/sub/.../stubs_entry*.S

Before you go on, you need at least CreateTask.

Note: This doesn't do much, right now. It just boots the cam, does some basic init-stuff and skips the diskboot-loader. You may want to turn on an LED at some point to indicate that our code actually runs :D

Cheers.

 

Related Topics