CHDK PTP interface - page 71 - General Discussion and Assistance - CHDK Forum

CHDK PTP interface

  • 1244 Replies
  • 541381 Views
Re: CHDK PTP interface
« Reply #700 on: 26 / February / 2012, 13:02:53 »
Advertisements

However, the basic frame buffer addresses and characteristics are already known for all complete ports, since they are required for histogram, zebra, md etc. There are some additional characteristics and special cases required for live view which that are *not* already in the code, and these will have to be added for each camera to enable full functionality. There is no way around this.

Tonight will be a long brawl between your trunk's code, Code Compare, and yours truly.  :P

Re: CHDK PTP interface
« Reply #701 on: 26 / February / 2012, 21:49:01 »

Uuuh...since I'm not sure... the A540's base ROM address is 0xFFC00000, right ?

Fact is, the last program I used one can call a disassembler was running under MSDOS, and targeted 386 CPUs.  :-[

So, I've done a little cross-check between three "sub/xxxx/lib.c" files, namely :
  • your A540 sub100b, from your live view port.
  • the A540 sub 100b "lib.c" from trunk 1672 .
  • the A430 sub 100b "lib.c" from trunk 1672 as well.

The main diff I noticed (apart from the platforms offsets, of course), is at the very end of your file :

Code: [Select]

// PTP display stuff
int vid_get_palette_type() { return 1; }
int vid_get_palette_size() { return 16*4; }

void *vid_get_bitmap_active_palette() {
    return (void *)0x634E0; // GetPaletteFromPhysicalScreen
}

void *vid_get_bitmap_active_buffer()
{
    return (void*)(*(int*)0x5ED0); // FFD23420 DisplayPhysicalScreenWithYUVPalette
}


Ask me to do some complicated hardware reverse engineering: fine, I've done it on a regular basis for the last 15 years or so...
Now, I'm so rusty at software reverse engineering I don't even know how to search a runtime ref to a hard-coded string with IDA. :-[
Anyway, that was just to state my current disasm skills... moldy  ;)


Looking at the last two functions in your code, I obviously need to find the bitmap's palette and raster indices map offsets.
To do so, I have to locate any usage references about "GetPaletteFromPhysicalScreen" and "DisplayPhysicalScreenWithYUVPalette"... but DisplayPhysicalScreenWithYUVPalette doesn't even appear in the A540 dump ! I've run it through IDA: nothing ! Where did you find it reyalp :-X




*

Offline reyalp

  • ******
  • 14128
Re: CHDK PTP interface
« Reply #702 on: 26 / February / 2012, 22:53:31 »
Uuuh...since I'm not sure... the A540's base ROM address is 0xFFC00000, right ?
Yes.
Quote
The main diff I noticed (apart from the platforms offsets, of course), is at the very end of your file :
FWIW, a better way to see what I've changed is http://trac.assembla.com/chdk/log/branches/reyalp-ptp-live (or check out the source with your favorite svn client and look at the logs and diffs)
Quote

To do so, I have to locate any usage references about "GetPaletteFromPhysicalScreen" and "DisplayPhysicalScreenWithYUVPalette"... but DisplayPhysicalScreenWithYUVPalette doesn't even appear in the A540 dump ! I've run it through IDA: nothing ! Where did you find it reyalp :-X
I don't actually remember  :-[ Someone (probably me, possibly ewarv) found them a long time ago to support ewavrs chdkcam liveview code. That history can probably be found somewhere near the start of this thread...

DisplayPhysicalScreenWithYUVPalette appears to be something identified by the A series flirt sigs. See http://chdk.wikia.com/wiki/Loading_dump_to_IDA

But, since you have the address for one camera (the address in the comment is correct for a540), all you need to do is find some convenient landmark that identifies that code in the known dump, and then find the corresponding landmark in yours.

GetPaletteFromPhysicalScreen is an eventproc, so should be easier to find.
« Last Edit: 26 / February / 2012, 22:57:17 by reyalp »
Don't forget what the H stands for.

Re: CHDK PTP interface
« Reply #703 on: 27 / February / 2012, 20:25:36 »
FWIW, a better way to see what I've changed is http://trac.assembla.com/chdk/log/branches/reyalp-ptp-live...

Very useful indeed. I'm a noob with assembla. TIL something new about it, thanks reyalp !   :xmas

DisplayPhysicalScreenWithYUVPalette appears to be something identified by the A series flirt sigs. See http://chdk.wikia.com/wiki/Loading_dump_to_IDA

A-series indeed. I've just understood it's part of the VxWorks signatures semantic. Loading those 'old' signatures on both A540 and A430 binaries binary dumps helped me find it in less than an hour !  :P
How could I live this long without using IDA before ?  ::)

GetPaletteFromPhysicalScreen is an eventproc, so should be easier to find.

Yup... found it almost instantly, thanks to the CHDK idc scripts.  :)


Excellent. I now have the offsets I missed in "./sub/lib.c".  8)
As soon as I get my hand on the A430, I'll test it with your brand new ChdkPtp binary. I'm away from home for a week or so, and only brough a copy of my CHDK directory on a laptop.
brb (in a week max, maybe on Friday).
« Last Edit: 27 / February / 2012, 20:28:38 by asmodyne »

*

Offline reyalp

  • ******
  • 14128
Re: CHDK PTP interface
« Reply #704 on: 27 / February / 2012, 21:59:31 »
Very useful indeed. I'm a noob with assembla. TIL something new about it, thanks reyalp !   :xmas
If you are going to be working with the source, I strongly suggest getting tortoisesvn (assuming you are on windows) and checking out the code with it.
Quote
Excellent. I now have the offsets I missed in "./sub/lib.c".  8)
FWIW, you don't need any of these bitmap/palette functions for the most basic live view function.
Don't forget what the H stands for.

Re: CHDK PTP interface
« Reply #705 on: 27 / February / 2012, 22:06:34 »
If you are going to be working with the source, I strongly suggest getting tortoisesvn (assuming you are on windows) and checking out the code with it.
Command line svn commands under Linux turn out to be not too bad.  Still,  the integration of TortoiseSVN into Windows that allows the file and directory icons in change to reflect their svn status is a nice feature I miss a lot.  Yes, you get the same info with   svn st chdk  on the command line but its not the same somehow.

Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline fe50

  • ******
  • 3152
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: CHDK PTP interface
« Reply #706 on: 28 / February / 2012, 01:29:17 »
Still,  the integration of TortoiseSVN into Windows that allows the file and directory icons in change to reflect their svn status is a nice feature
You may have a look to RapidSVN (http://rapidsvn.tigris.org/ ) for a Linux GUI.
I often use it with Windows, should work on Linux & Mac too.

The deep integration into the windows system is one thing i don't like with TortoiseSVN, with big projects sometimes it slows down a fast PC extremely. If anyway possible, i use all my software portable, without installation; this works with a lot of apps, also with software which isn't designed to run 'portable'.
For SVN, a nice solution for me is portable RapidSVN, running from a RAMdisk (also portable, of course) to speed up things & to hold off thousands of svn files from my hard discs ;)

Re: CHDK PTP interface
« Reply #707 on: 28 / February / 2012, 14:33:41 »
    Okay, I asked my other half to do an
over-the-phone test of the modified CHDK, from your live-view trunk, reyalp.
Ain't I a resourceful lad ?  :haha

Anyway, the A430 responded nicely when asking for the UI overlay feed. But as soon as we ask for the viewfinder feed, the beast crashes.

Here is a screenshot of the live streamed UI :




The operations leading to this were :
  • Hit the 'Connect button
  • "    "    'rec' button
  • "Live" tab -> Arbitrarily set "Target FPS" to 3.
  • "Debug" tab ->Checking "Dump to file"
  • Checking "UI Overlay" checkbox.
  • Waiting a bit, watching the seconds pass by on the UI capture.
  • Checking "Viewfinder" ... Mayday, device down.


Of course, dumping the stream didn't brough any light upon the issue, but ChdpPtp's console textbox gave some (presumably) meaningful info :
[/list]
Code: [Select]
bm_max_width:360
bm_max_height:240
bm_buffer_width:360
lcd_ascpect_ratio:0
update_vidinfo: changed
vp_xoffset:nil->0
vp_yoffset:nil->0
vp_width:nil->720
vp_height:nil->240
vp_buffer_start:nil->0
vp_buffer_size:nil->0
bm_buffer_start:nil->44
bm_buffer_size:nil->86400
palette_type:nil->1
palette_buffer_start:nil->86444
palette_buffer_size:nil->64
palette:
0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0xff, 0x3c, 0xde, 0x4a, 0xff, 0xb9, 0x00, 0x00,
0x7f, 0x00, 0x00, 0x00, 0xff, 0x6e, 0xa1, 0xa2, 0xff, 0xb2, 0x8c, 0x1f, 0xff, 0x5f, 0x00, 0x00,
0xff, 0x9a, 0xa9, 0x50, 0xff, 0x8a, 0x50, 0xb0, 0xff, 0x4b, 0x3d, 0xd4, 0xff, 0x23, 0x1b, 0xe2,
0x7f, 0x00, 0x7b, 0xe2, 0xff, 0x30, 0x00, 0x00, 0xff, 0x69, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
recording to chdk_30f8_20120228_132726.lvdump


I suppose all those variable followed by a "nil->xxx" means the value was missing and replaced by default constants, right ?
« Last Edit: 28 / February / 2012, 15:13:51 by asmodyne »

*

Offline reyalp

  • ******
  • 14128
Re: CHDK PTP interface
« Reply #708 on: 28 / February / 2012, 16:06:53 »
But as soon as we ask for the viewfinder feed, the beast crashes.
The camera, or the client ?
Quote
I suppose all those variable followed by a "nil->xxx" means the value was missing and replaced by default constants, right ?
Not quite. It only prints this when the information changes (since it would be bad to spam every frame).  The x->y just tells you the old and new value. On the first frame, the "old" values are all nil. The code for this can be seen in lua/gui_live.lua in the chdkptp package.

I'm not clear if the information in the console comes from before crash (in which case, it tells us nothing) or relates to the data that caused the crash.

The camera may crash if the viewport address is incorrect or zero.

The camera may generate a romlog when it crashes, see http://chdk.wikia.com/wiki/Debugging#Camera_crash_logs_.28romlog.29

watching the return value of vid_get_viewport_active_buffer may shed light on the situation (see misc debug vals in chdk core/gui.c ).

Note that you can enable "viewfinder" in playback mode, it will show you whatever picture is on the screen. This may fail (return null address, crash) if a video is selected.
Don't forget what the H stands for.

Re: CHDK PTP interface
« Reply #709 on: 28 / February / 2012, 18:46:21 »
But as soon as we ask for the viewfinder feed, the beast crashes.
The camera, or the client ?

The camera crashes.

I'm not clear if the information in the console comes from before crash (in which case, it tells us nothing) or relates to the data that caused the crash.

The console log here is what's written out before the device crashes. After that, the only thing updated is the console window, saying it received the bad return value 0x2FF, as it does anytime the A430 crashes for any reason whatsoever, while a ptp session's in progress.

The camera may generate a romlog when it crashes, see http://chdk.wikia.com/wiki/Debugging#Camera_crash_logs_.28romlog.29

watching the return value of vid_get_viewport_active_buffer may shed light on the situation (see misc debug vals in chdk core/gui.c ).

Nice ! I'll look into it.  8)

Note that you can enable "viewfinder" in playback mode, it will show you whatever picture is on the screen. This may fail (return null address, crash) if a video is selected.

Excellent ! I assumed the record mode was a must for some reason. I'll try that. :)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal