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

A580 porting - minor progress

  • 125 Replies
  • 64961 Views
*

Offline ag8

  • *
  • 4
Re: A580 porting - minor progress
« Reply #10 on: 15 / January / 2009, 06:19:49 »
Advertisements
Another tiny step:

I was able to jump from the loader to the core, and blink the led from function boot() in ./platform/a580/sub/100c/boot.c.

This however required some strange hack that may indicate a problem in my build process:

From my understanding, code in 'platform' and 'core' is compiled into ./core/main.elf,
converted to ./core/main.bin,
inserted into ./loader/a580/main.elf (as binary blob),
which is then converted into ./loader/a580/main.bin, and encoded into ./bin/DISKBOOT.bin.

During boot, the loader calls 'copy_and_restart()' to copy the core's binary blob into the 'right' memory address (which is MEMISOSTART), and then jumps to that position.

So far - am I right?

The above process assumes that the start of the core's main.bin (i.e. offset 0x0000) is the entry point.
Meaning - ./core/entry.S should reside at offset 0x0000 in ./core/main.bin.

This doesn't happen in my build - ./core/entry.S goes into offset MEMISOSTART+0x6B8.
So jump to MEMISOSTART in copy_and_restart() doesn't work.
I had to change copy_and_restart() and add the following line:
   dst_void = (void*) (MEMISOSTART + 0x6B8) ;

To jump into the correct location.

Inside ./core/main.dump I see that functions such as "__vid_get_bitmap_buffer_width_from_thumb" and "__get_zoom_x_from_thumb" got inserted before the entry point.

Does somebody have an Idea how to fix this?

Thanks for all your help so far.

*

Online reyalp

  • ******
  • 14121
Re: A580 porting - minor progress
« Reply #11 on: 15 / January / 2009, 17:36:27 »
What binutils are you using ? ISTR the most recent (2.19) do something like this.
Don't forget what the H stands for.

Re: A580 porting - minor progress
« Reply #12 on: 17 / January / 2009, 14:48:12 »
I've installed Cygwin and GCC according to the instructions in the wiki here: http://chdk.wikia.com/wiki/User:Geekmug/Compiling_CHDK_under_Windows

I then took the A720 platform and created platform a580 and platformsub 101b, modified camera.h, makefile.inc, kbd.c  (copied what was for A720)... basically done all the steps to reproduce what was tried in the first post... to make the camera go in infinite loop and recover when the card is removed... also to see if the led blinks.

Problem is this showed while compiling:

Code: [Select]

$ PATH=/arm-elf/bin:$PATH make fir
**** Build: 0.9.1
>> Entering to tools
<< Leaving tools
>> Entering to lib
>> Entering to lib/font
<< Leaving lib/font
>> Entering to lib/math
<< Leaving lib/math
>> Entering to lib/ubasic
<< Leaving lib/ubasic
>> Entering to lib/lang
<< Leaving lib/lang
>> Entering to lib/lua
<< Leaving lib/lua
<< Leaving lib
>> Entering to platform
>> Entering to platform/a580
>> Entering to platform/a580/sub
>> Entering to platform/a580/sub/101b
<< Leaving platform/a580/sub/101b
<< Leaving platform/a580/sub
<< Leaving platform/a580
<< Leaving platform
>> Entering to core
gui.c -> gui.o
-> main.elf
/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: ERROR: gui.o uses FPA
 instructions, whereas main.elf does not
/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: failed to merge targe
t specific data of file gui.o
/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: ERROR: /arm-elf/lib/g
cc/arm-elf/4.3.2/thumb/interwork/libgcc.a(_udivsi3.o) uses FPA instructions, whe
reas main.elf does not

[...]

/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: ERROR: /arm-elf/lib/g
cc/arm-elf/4.3.2/thumb/interwork/libgcc.a(_fixsfsi.o) uses FPA instructions, whe
reas main.elf does not
/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: failed to merge targe
t specific data of file /arm-elf/lib/gcc/arm-elf/4.3.2/thumb/interwork/libgcc.a(
_fixsfsi.o)
/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: ERROR: /arm-elf/lib/g
cc/arm-elf/4.3.2/thumb/interwork/libgcc.a(_fixunssfsi.o) uses FPA instructions,
whereas main.elf does not
/arm-elf/lib/gcc/arm-elf/4.3.2/../../../../arm-elf/bin/ld: failed to merge targe
t specific data of file /arm-elf/lib/gcc/arm-elf/4.3.2/thumb/interwork/libgcc.a(
_fixunssfsi.o)
collect2: ld returned 1 exit status
make[1]: *** [main.elf] Error 1
make: *** [all-recursive] Error 1


Any clue of what's wrong?

*

Online reyalp

  • ******
  • 14121
Re: A580 porting - minor progress
« Reply #13 on: 17 / January / 2009, 16:25:41 »
I would suggest using the pre-built gcc 3.x win32 environment.

Otherwise, read this thread: http://chdk.setepontos.com/index.php/topic,2500.0.html
Don't forget what the H stands for.


*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: A580 porting - minor progress
« Reply #14 on: 17 / January / 2009, 16:37:13 »
I would suggest using the pre-built gcc 3.x win32 environment.

Otherwise, read this thread: http://chdk.setepontos.com/index.php/topic,2500.0.html

... or the pre-built gcc 4.3.2 win32 environment (both  3 & 4 are here: http://drop.io/chdkdev)

... or CHDK-Shell including both here: http://drop.io/gcc_for_chdkshell

Note: NONE of these solutions work under Vista (the cygwin one should, though)

About the errors:
        does it also error compiling a known good platform, like the 720 you cloned your 580 from ?


wim

« Last Edit: 17 / January / 2009, 16:53:40 by whim »

Re: A580 porting - minor progress
« Reply #15 on: 17 / January / 2009, 17:27:37 »
I'm running Windows 2003. It should run just as XP, Windows 2003 doesn't have Vista's flaws.

Right now, I'm building binutils 2.18 instead of 2.19.

How am I supposed to use the pre-built gcc environments, just copy them in the cygwin folder?

If I still get errors after replacing binutils, I'll try to compile the known good platform a720.

If you guys think it helps, I can install Ubuntu or another OS in a Virtualbox session and try it out from there. I think I still have a CentOS image somewhere...

*

Offline whim

  • ******
  • 2046
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: A580 porting - minor progress
« Reply #16 on: 17 / January / 2009, 17:42:45 »
Quote
I'm building binutils 2.18 instead of 2.19.
that must be the problem then - other people have had trouble with 2.19

Quote
How am I supposed to use the pre-built gcc environments, just copy them in the cygwin folder?
no, they are MinGW based, and you can freely choose their location - as long as there is no spaces in the path.
usage info here: http://chdk.wikia.com/wiki/Compiling_CHDK_under_Windows


wim

Re: A580 porting - minor progress
« Reply #17 on: 17 / January / 2009, 18:21:59 »
It didn't work even with binutils 2.18

Tried gcc 3 and compiled right away... I assume the DISKBOOT.BIN is what it compiled :)

Code: [Select]
C:\cygwin\tmp\trunk>gmake PLATFORM=a580 PLATFORMSUB=101b fir
**** Build: 0.9.1
>> Entering to tools
<< Leaving tools
>> Entering to lib
>> Entering to lib/font
<< Leaving lib/font
>> Entering to lib/math
<< Leaving lib/math
>> Entering to lib/ubasic
<< Leaving lib/ubasic
>> Entering to lib/lang
<< Leaving lib/lang
>> Entering to lib/lua
<< Leaving lib/lua
<< Leaving lib
>> Entering to platform
>> Entering to platform/a580
>> Entering to platform/a580/sub
>> Entering to platform/a580/sub/101b
<< Leaving platform/a580/sub/101b
<< Leaving platform/a580/sub
<< Leaving platform/a580
<< Leaving platform
>> Entering to core
gui.c -> gui.o
-> main.elf
   text    data     bss     dec     hex filename
 251236   11344   71532  334112   51920 main.elf
main.elf -> main.bin
<< Leaving core
>> Entering to loader
>> Entering to loader/a580
>> Entering to loader/a580/resetcode
main.c -> main.o
-> main.elf
main.elf -> main.bin
<< Leaving loader/a580/resetcode
entry.S -> entry.o
main.c -> main.o
blobs.S -> blobs.o
-> main.elf
main.elf -> main.bin
<< Leaving loader/a580
<< Leaving loader
>> Entering to CHDK
-> LUALIB/GEN/propset1.lua
-> LUALIB/GEN/propset2.lua
<< Leaving CHDK
**** Firmware creation completed successfully

I'll copy it on a card and test it in a few minutes.

.... and nothing... camera boots in play mode and says card locked and shows no image.
« Last Edit: 17 / January / 2009, 18:38:51 by mariush »


*

Offline ag8

  • *
  • 4
Re: A580 porting - minor progress
« Reply #18 on: 21 / January / 2009, 21:07:06 »
@mariush:

At least with my version (100c) - I need to encode DISKBOOT.BIN inorder for the camera to recognize the file.

In makefile.inc, make sure you have "NEED_ENCODED_DISKBOOT" declaration.

Look at './chdk/platform/a590/sub/101b/makefile.inc'  for an example of such declaration.


Re: A580 porting - minor progress
« Reply #19 on: 22 / January / 2009, 06:21:03 »
Didn't know that, thanks for the tip. I guess i have to use NEED_ENCODED_DISKBOOT=very_yes according to wiki.

It's stuff like this that pisses me off... how am I supposed to know I need to use that option somewhere to make it work... it's only referenced once in the wiki and nowhere in the forum for another camera... there's also very little documentation about findsig/gensig, what they actually do, so I have to look around in a hundred places just to debug a compile error as the one in the screen dump below.  Oh well...

I stopped trying to compile it because I got this on compile:

Code: [Select]
C:\cygwin\tmp\trunk>gmake PLATFORM=A580 PLATFORMSUB=101b fir
**** Build: 0.9.1
>> 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 updated due to 'sig_ref_dryos_1.bin` is emp
ty!
finsig.c -> finsig.o
finsig.o -> finsig.exe
dancingbits.c -> dancingbits.o
dancingbits.o -> dancingbits.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:1560:6: #error camera type not defined
c:\gcc346\bin\gmake[2]: *** [font_8x16.o] Error 1
c:\gcc346\bin\gmake[1]: *** [all-recursive] Error 1
gmake: *** [all-recursive] Error 1

C:\cygwin\tmp\trunk>

I think it compiled before without errors because before that I compiled DISKBOOT.BIN for A720...

I'm not sure where I have to define the camera model, I've added in camera.h information about the camera but I guess I have to define CAMERA_a580 somewhere else first.

Anyways, I'm actually writing right now a tool that's supposed to compare two firmware dumps and match the functions inside. The sub_xxxxxx and loc_xxxxx in the A720 and the A580 firmware are almost identical so rather than manually searching the new offsets for each of those I'm writing a tool for this. It's almost done, just working on improving the match speed and improve match accuracy (right now it gives up too fast and returns a sub that matches 99.97% for example, when there's another one that's 100% identical).
« Last Edit: 22 / January / 2009, 06:43:02 by mariush »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal