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

A580 porting - minor progress

  • 125 Replies
  • 50617 Views
*

Offline reyalp

  • ******
  • 13502
Re: A580 porting - minor progress
« Reply #70 on: 20 / February / 2009, 21:57:19 »
Advertisements
I was looking more to an explanation regarding what's the reason for that conf array and why it needs to copy memory from one place to another. Sounds like a lot of memory fragmenting and small memory allocations right from the start and maybe it could be avoided.
Erm, there's no allocation happening there, so no fragmentation.

It's copying the default values into the current values. Both need to be stored, or you couldn't return to defaults. You can't simply dump the conf file into memory, because it might have more or less values.

The conf stuff definitely deserves a re-work (I would personally prefer text based cfg files) but it works on other cameras, so the crash is a problem with your code. Most likely in one of the callback funcs. Only a small portion of the conf values require callbacks, so that should narrow your search a lot.
Don't forget what the H stands for.

Re: A580 porting - minor progress
« Reply #71 on: 21 / February / 2009, 02:15:24 »
I don't know VB a lot.  However, I heard that in VB you don't handle the pointers yourself.  An important difference between C and VB.  Certain equivalent code would probably run fine in VB while it would crash in C.

In C, you need to allocate memory for each pointer before using it.  If it is a struct pointer, you also need to allocate memory for each field in the struct.

Re: A580 porting - minor progress
« Reply #72 on: 21 / February / 2009, 20:56:10 »
I had to comment out this:

Code: [Select]
CONF_INFO( 38, conf.reader_file,            CONF_DEF_PTR,   ptr:"A/README.TXT", conf_change_script_file)
CONF_INFO(194, conf.script_file,            CONF_DEF_PTR,   ptr:"", conf_change_script_file

They both load script_load so it's probably some function there like strcmp,fopen, fread etc with bad entry in stubs_entry_2.s. I'll investigate.

In Play mode, I started the camera and after quite a few blinks from the blue led, it started and showed the chdk logo for a few seconds so it's working! \:D/  well, not quite... that's about it.

I pressed buttons randomly and I think when I switched to record mode (or another button, I'm no longer sure) it showed the battery indicator...
Also when I press the shoot button as if I want to make pictures, a very small counter appeared on top right saying initially 24 and afterwards each time I pressed the button it increased with 1 or 2.

Some tips on how should I continue, what should I do next to actually make the chdk menu to appear or something ?

Here's everything I worked on so far, including DISKBOOT.BIN in case anyone wants to see the logo on his A580 1.01b :

http://www.definethis.org/temp/chdk/a580_20090222.rar

Dabian: if you still have problems dissassembling the firmwares in Linux, I've created these a580 and a720 asm listings for you, have fun with them:

http://www.definethis.org/temp/chdk/asmfiles.rar

*

Offline reyalp

  • ******
  • 13502
Re: A580 porting - minor progress
« Reply #73 on: 21 / February / 2009, 22:10:53 »
If you can get something displaying, modify the debug osd stuff (gui.c gui_draw_osd()) to show the 3 words of physw_status. Then watch the values as you press buttons, and you should be able to set the button mappings correctly in kbd.c

I'd suggest moving the debug display to the start of the gui_draw_osd() function, as there are some early returns you might hit if your stubs_min isn't correct.
Don't forget what the H stands for.


Re: A580 porting - minor progress
« Reply #74 on: 22 / February / 2009, 00:51:51 »
Thank you very much Mariush!

I found out the problem with disassemble relates to the version 2.18 of binutils, 2.19.1 of binutils is able to disassemble.   Thank you very much though, and congratulations on your progress!  I  am very excited about this!

*

Offline whim

  • ******
  • 2041
  • A495/590/620/630 ixus70/115/220/230/300/870 S95
Re: A580 porting - minor progress
« Reply #75 on: 22 / February / 2009, 04:44:27 »
@mariush

Quote
Also when I press the shoot button as if I want to make pictures, a very small counter appeared on top right saying initially 24 and afterwards each time I pressed the button it increased with 1 or 2.

that's probably the clock seconds


congrats on the breakthrough, and big thumbs up here for your courage !

wim


*

Offline fe50

  • ******
  • 3136
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: A580 porting - minor progress
« Reply #76 on: 22 / February / 2009, 05:54:42 »
@mariush

Congrats !
As i understand you don't have access to a camera running CHDK ?
The OSD map from the End-Users-Guide (CHDK wikia) could be helpful then, maybe also some (older) OSD screenshots from here...

Re: A580 porting - minor progress
« Reply #77 on: 22 / February / 2009, 13:49:05 »
fe50, whim, thank you.

fe50: no, I don't have another camera but the link you game me helps. My sister has an A560 and I'm not sure if it's the firmware supported so far by chdk. who knows, maybe it will be my next free time filler after a580 is done.

now back to business... i've uncommented and moved to the top of the function as recommended the code to show the three key words. (edit: I said here that the first two words don't change but as you can see below they do change so I guess i  must have picked to right offset)

Here's the values while idle:

1. 1c0040
2. fd609cc0
3. effd, effe (alternates)

while key pressed:

efe d/e  - up (iso)
ef7 d/e - left (macro)
efd d/e - down (timer/delete)
efb d/e - right (flash)
ebf d/e - disp
eef d/e - set
edf d/e - menu

2nd word:

bd609cc0 - half shoot
3d609cc0 - full shoot

3rd word:
eff 5/6 zoom to left (close zoom)
eff 9/a zoom to right (apply zoom)

turning wheel makes the first char from third word change and for some cases the first three chars in second word change.

print fde09cc0 - after this is pressed camera freezes (i mean pressing keys no longer updates the values except the last character in third word goes between d and e

I need to know how these values are changed to the values listed in kbd.c - just in case I can't figure it out by myself - in VB i very rarely did bit operations as it doesn't have such functions built in so I have to re-read how they work and understand them.
« Last Edit: 26 / February / 2009, 15:18:59 by mariush »


*

Offline fe50

  • ******
  • 3136
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: A580 porting - minor progress
« Reply #78 on: 22 / February / 2009, 14:05:05 »
@mariush
The A560 with fw version 1.00A is CHDK-ready...
For C bit ops: see e.g. here...

Re: A580 porting - minor progress
« Reply #79 on: 24 / February / 2009, 19:53:48 »
I've written a few lines in PHP and determined that the buttons (at least for left, up, down, right) are the same as in A720.

I don't understand why the camera would still say that the card is locked. Isn't the code supposed to hide this by modifying those three words physw?

The reason why I haven't posted yet is because I've tried to solve the problem with conf_change_script_file

I've found that the problem is actually in script_scan() which uses right at the start strncpy and strrchr.

I couldn't find these in the firmware (and I still can't)  so initially I tried commenting the subs in stubs_entry_2.s and writing these in lib.c:

Code: [Select]
char *_strrchr(const char *s, int c)
{
    char* ret=0;
    do {
        if( *s == (char)c )
            ret=s;
    } while(*s++);
    return ret;
}

char *_strncpy(char *dest, const char *src, long n)
{
    char *ret = dest;
    do {
        if (!n--)
            return ret;
    } while (*dest++ = *src++);
    while (n--)
        *dest++ = 0;
    return ret;
}


Well, it didn't work, the camera still froze right after entering the function... but maybe it's my fault, I don't know exactly how the functions are compiled, if the functions are entered were actually used (I know there also platform/generic/wrappers.c for example which I don't know if it's touched during compile)

I've also tried to add them as assembly in boot.c, following how _time was added in another camera platform:

Code: [Select]
char __attribute__((naked,noinline)) *_strncpy(char *dest, const char *src, long n) {
asm volatile (
                "MOV     R3, R0\n"
                "B       loc_FFC0E87C\n"
"loc_FFC0E854:\n"
                "LDRB    R12, [R1],#1\n"
                "CMP     R12, #0\n"
                "STRB    R12, [R3],#1\n"
                "BNE     loc_FFC0E87C\n"
                "MOV     R1, #0\n"
"loc_FFC0E868:\n"
                "SUB     R2, R2, #1\n"
                "CMN     R2, #1\n"
                "STRNEB  R1, [R3],#1\n"
                "BNE     loc_FFC0E868\n"
                "BX      LR\n"
"loc_FFC0E87C:\n"
                "SUBS    R2, R2, #1\n"
                "BCS     loc_FFC0E854\n"
                "BX      LR\n"
);
}


char __attribute__((naked,noinline)) *_strrchr(const char *s, int c) {
asm volatile (
                "MOV     R2, #0\n"
                "AND     R3, R1, #0xFF\n"
"loc_FFC71BD4:\n"
                "LDRB    R1, [R0]\n"
                "CMP     R1, R3\n"
                "MOVEQ   R2, R0\n"
                "CMP     R1, #0\n"
                "ADD     R0, R0, #1\n"
                "BNE     loc_FFC71BD4\n"
                "MOV     R0, R2\n"
                "BX      LR\n"
);
}

These also didn't work but probably I screwed the definition, I don't know how pointers work with inline assembly so I don't know if I've written the definition correctly.

Help, please ?

edit:

Nevermind, I found them in firmware... I looked for lines like "ADD     R0, R0, #1" and "SUB     R2, R2, #1" and I actually found both.
Still, it would be nice to know if for some reason I can't find that function, how it should be done to add it manually, so if you have some time, please explain.

ps2. I also got the last code from svn today and it gives me the following error:

Code: [Select]
C:\CHDK\trunk>gmake clean
makefile.inc:204: platform/a580/sub/101b: Permission denied
makefile.inc:204: /makefile.inc: No such file or directory
gmake: *** No rule to make target `/makefile.inc'.  Stop.

The makefile.inc are in the right places so any clue why this would happen?
« Last Edit: 24 / February / 2009, 20:16:15 by mariush »

 

Related Topics