IXUS 990 / SD970 IS porting thread - DryOS Development - CHDK Forum

IXUS 990 / SD970 IS porting thread

  • 24 Replies
  • 900 Views
*

Offline koshy

  • *****
  • 1037
IXUS 990 / SD970 IS porting thread
« on: 12 / January / 2020, 18:52:52 »
Advertisements
To be filled with a link to the initial code base for ixus990_sd970 later.
If the subject does not meet conventions please tell me.

INITIAL SOURCE ATTACHED  :xmas (Updated, had still 0 downloads)
« Last Edit: 13 / January / 2020, 08:44:51 by koshy »
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline koshy

  • *****
  • 1037
Re: ixus990_sd970 porting thread
« Reply #1 on: 12 / January / 2020, 19:02:10 »
In late 2018 I stumbled into porting an unknown FW version of Powershot S80, how and why is beyond the scope of this. As I did that and worked with tools now perceived to be archaic but archeologically interesting and valuable I glimpsed at the new stuff and thought this is interesting, very interesting, one day you should port an all new camera, not the bleeding edge Digic VI or VII stuff but rather an old one you might enjoy... Some time passed and I finally looked at possible candidates. I settled on the Ixus 990 / SD970 which was never even mentioned on the forum as far as I could tell but seemed to be a high class cameras as far as these go. So, I got two of them and life got in the way.
When reyalp started to detail all the things concerning Ghidra I figured it would finally be time to see if I could make my first port come together. I wanted to see how far I'd get on my own. I mentioned doing this and nafraf kindly offered assistance if I had any questions. That was super helpful, thank you. But with him being pretty busy I kind of outpaced my own initial questions. I asked two things of reyalp by PM and his responses were much more elaborate than I expected. Thank you for that! I'll re-format that exchange and will add it to this thread. So much for the prelude...
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline koshy

  • *****
  • 1037
Re: ixus990_sd970 porting thread
« Reply #2 on: 12 / January / 2020, 19:03:05 »
Some of this may be interesting to other readers. The only reason to ask privately was that I hoped for as little help as possible  ;)

Quoted areas in replies shortened to meet forum’s 7.5K char limit…

I have completed my SD970 boot sequence, led, spytask and can connect by CHDKPTP which is not bad. I plan to implement the keymap next so that I can enter ALT mode etc. but guess I need a pointer. If I can get that OSD for experimentally finding the kbd.c values by pressing the buttons onto the camera by CHDKPTP that would be great, any alternative method by CHDKPTP would be as great.

Originally I thought I'd get the OSD that shows the values when you press a key by uncommenting
Code: [Select]
gui_draw_debug_vals_osd(); from core/gui.c. The porting wikia page instructs "you can force it to be always visible by uncommenting the commented call to gui_draw_debug_vals_osd() in core/gui.c and removing the if at the beginning of that function." I did not figure out what if that would be - is that hint deprecated? I did not get it to work.

Thanks :-)

I have completed my SD970 boot sequence, led, spytask and can connect by CHDKPTP which is not bad.
Nice work.
Quote
I plan to implement the keymap next so that I can enter ALT mode etc. but guess I need a pointer […]
My preferred method to do this is with chdkptp rmem, like I described in https://chdk.setepontos.com/index.php?topic=13355.msg142207#msg142207
The camera ignores keys when USB is connected (except power/play) and you can read the text on your PC instead of the camera screen.

Quote
The porting wikia page instructs […] and removing the if at the beginning of that function." I did not figure out what if that would be - is that hint deprecated? I did not get it to work.
It refers to "if (conf.debug_misc_vals_show)" which isn't quite at the beginning any more.

This hint is just so you can turn it on the display if your keyboard is so messed up you can't navigate to the debug menu. For dryos cameras, the key definitions in stubs_entry.S from the sig finder should normally get most of the basics right.

srsa_4c also made a phys bit display that's really nice: https://chdk.setepontos.com/index.php?topic=13426.msg142287#msg142287

Thank you so much, that is plenty to work with.

I guess I made ample progress with my first actual port. Keybord is now implemented, custom palette, too. Raw shooting is implemented, ActiveArea set, ColorMatrix determined, Exposures longer 60 seconds tested so it is all getting to a point where I'm wrestling with the smaller things.

I'm sort of puzzled by the Jogdial stuff. Here is where I'm at:
Code: [Select]
// ##TODO## SD970
// 0x874 and 0x875 values may be camera model dependent, search them in firmware (in pair with RotateJogDialRight(Left)) strings.
// sd970: table "PrintMenu" @ ffb8060e, fw 1.00A
void JogDial_CW(void){
 _PostLogicalEventForNotPowerType(0x874, 1);  // sd970: RotateJogDialRight (in table "PrintMenu" @ ffb81b5a, fw 1.00A)
}
void JogDial_CCW(void){
 _PostLogicalEventForNotPowerType(0x875, 1);  // sd970: RotateJogDialLeft (in table "PrintMenu" @ ffb81ad3, fw 1.00A)
}

Other ports mentioned the entries in the table so I looked them up but I find no references to those hex addresses in Ghidra and looking through all functions that are listed to use the table "PrintMenu" did not give any clues.  0x874 and 0x875 values don't seem to work, can you think of what needs to be done to find the correct values?

The other thing I thought I'd better ask about is the today preferred way to fill the tables in shooting.c with data. These tables:
Code: [Select]
aperture_sizes_table
shutter_speeds_table
iso_table
modemap

After that I'll look at the CHDKPTP things which don't seem to be working fully in the reference port and zebra which also does not work if comments are correct. I guess for Zebra it's just getting the sizes right, by now I get a zebra but expanded in height. I'll figure it out I hope...

I guess I made ample progress with my first actual port. Keybord is now implemented, custom palette, too. Raw shooting is implemented, ActiveArea set, ColorMatrix and ForwardMatrix determined by calibration using actual RAW imagery,
If you can post how you did the calibration, that could be quite helpful.

Quote
I'm sort of puzzled by the Jogdial stuff.
 
You can dump the levent table with find_levent in the tools directory
Code: [Select]
make find_levent.exe
./find_levent.exe -full ../../dumps/ixus990_sd970/sub/100a/PRIMARY.BIN  0xff810000 > ixus990_sd970-levent.txt
The IDs appear to be correct:
Code: [Select]
0x0874,  2164, RotateJogDialRight, 2
0x0875,  2165, RotateJogDialLeft, 2
It's possible the parameter needs to be 2 rather than one, some existing ports are that way.

Note that these functions are for sending jogdial inputs from script with wheel_left and wheel_right. Using the jogdial in CHDK menus is separate code, usually in kbd.c
Quote
preferred way to fill the tables in shooting.c with data
 
So, this is a kind of broken neglected area that still needs to have something in it.
Assuming this cam ND filter only (looks like it from the manual) and CAM_DRAW_EXPOSITION isn't defined, I don't think it's really used at all, although it still needs to exist and probably have at least one entry.
On cameras that don't have ton of zoom steps, I've used the PROPCASE_AV value at each zoom step, with string from the canon UI, repeated with ND in (forced by a bright light source). But I think you could get away with just putting in the first value.

shutter_speeds_table can just be copied from another port with the same shutter speed range. ixus100 looks like it should do.

iso_table can be copied from another camera with the same iso range, probably ixus100 again. If there isn't a "high" auto setting, you can remove that.

modemap
This one is actually good to get right. Watch the PROPCASE_SHOOTING_MODE value and go through all the available shooting modes. For a camera of that vintage, there should already be an appropriate MODE_ enum value. If you can find some that are listed in stubs_entry, they are usually a setting within another mode, or somewhere else in the menu. E.g. "face self timer" and "wink self timer" might both be under one mode setting, but have different propcas values.

Quote
I guess for Zebra it's just getting the sizes right
Screenshots might be helpful. It looks like ixus100 didn't have the live view functions fully implemented. We can probably fix that.
« Last Edit: 12 / January / 2020, 21:16:21 by koshy »
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline koshy

  • *****
  • 1037
Re: ixus990_sd970 porting thread
« Reply #3 on: 12 / January / 2020, 19:12:12 »
Now where am I? I think I did what I set out to do on my own and can share what I have thus far. The solitary "let's see what I can do here" phase is over for me. I'd apreciate it if I could understand what will happen to improve this port in the following but I don't need to do it, so welcome to this port (code should follow tonight).

What is done (or what I hope to be done, anyway):

- boot & spytask
- powerup sequence by Play and Rec buttons
- keyboard, all CHDKPTP buttons tested
- jogdial, including CHDKPTP buttons
   - no longer gets through to Canon FW
   - controls CHDK menus just fine
- shooting DNG
   - ColorMatrix / ForwardMatrix (using proprietary means, don't ask at this time please)
   - ActiveArea
- USB remote is tested
- Quick press of shutter button does write DNG
- Custom palette for Rec mode including Func palette
- Long time exposures > 60 sec. tested working
- implemented the same Movie related stuff as on sd780 but did not test it
- CHDKPTP File write task is tested
- CHDKPTP Palette is working
- CHDKPTP Liveview is implemented for all modes including Video 320
- the 25 tests reyalp and I used to run on a lot of cameras recently all pass
- Zebra is working
... maybe I forgot Something

What is still to be done:

- most importantly to me at this time: I do not get the Debug entry on the Misc. CHDK menu
   - after I get that I working - why could it be missing? I'll complete the modemap table in shooting.c
      - current modemap is thus erroneous (sd780 one)
- something sometimes causes glitches in drawing the CHDK menu, refresh by moving selection fixes it, need to figure out what that is about
- I saw a crash on half shutter press and obtained a ROMLOG
   - but again no debug menu no ROMLOG...
- whatever video stuff needs to be done beyond what sd780 implemented
- testing of FW 100B which I don't have a camera with
   - so that is a blind port but except lib.c and stubs it's codegen. OK for ALPHA I guess.
- find "recreview_hold" for stubs_min.S
- while zebra works edge overlay is stretched for 1px to cover 2px (only upper half image used on full screen)
- whatever I forgot :-)
« Last Edit: 13 / January / 2020, 08:46:17 by koshy »
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)


Re: IXUS 990 / SD970 IS porting thread
« Reply #4 on: 12 / January / 2020, 22:13:53 »
Nice work.   Doing your first original port is fun isn't it?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 12431
Re: ixus990_sd970 porting thread
« Reply #5 on: 12 / January / 2020, 23:20:06 »
- most importantly to me at this time: I do not get the Debug entry on the Misc. CHDK menu
Do you have OPT_DEBUGGING turned off in buildconf.inc / localbuildconf.inc?

Quote
but again no debug menu no ROMLOG...
You can get a romlog using chdkptp devutil
Code: [Select]
!require'extras/devutil'.init_cli()
dromlog
Don't forget what the H stands for.

*

Offline koshy

  • *****
  • 1037
Re: IXUS 990 / SD970 IS porting thread
« Reply #6 on: 13 / January / 2020, 08:01:33 »
Nice work.   Doing your first original port is fun isn't it?
Indeed, I enjoyed doing it. The tools available today are amazing, codegen is really cool and Ghidra is quite convenient, too. Not that one couldn't do it with CHDK_PT ;-)


- most importantly to me at this time: I do not get the Debug entry on the Misc. CHDK menu
Do you have OPT_DEBUGGING turned off in buildconf.inc / localbuildconf.inc?
The trunk I worked into is as it came off Assembla. I did not touch buildconf.inc and have no localbuildconf.inc. Your suggestion that this is a global thing let me quickly build an SD780 FW using te same system and since that exhibited the same problem that isn't about my code. I'm using CHDK Compiler GUI 0.9.288 by msl and I figured it out. @msl That debugging checkbox being in the "Compiler" section along with the "Warnings" threw me off.

Quote
but again no debug menu no ROMLOG...
You can get a romlog using chdkptp devutil
Code: [Select]
!require'extras/devutil'.init_cli()
dromlog
Thank you I got it and it is from the time I recall the crash. Date is off, I didn't care to set it...

Any help with reading what the ROMLOG points to would be quite welcome.

With the debug thing figured out I'll fix the modemap.
With the debug thing figured out I fixed the modemap and updated the source package in post 1 of the thread.
« Last Edit: 13 / January / 2020, 08:50:44 by koshy »
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

*

Offline Caefix

  • ***
  • 143
  • Sorry, busy deleting test shots...
Re: IXUS 990 / SD970 IS porting thread
« Reply #7 on: 13 / January / 2020, 12:34:59 »
 :-X Not from the verbose one...
Once upon the time I got this, don´t ask for context, please...
All lifetime is a loan from eternity.


*

Offline reyalp

  • ******
  • 12431
Re: IXUS 990 / SD970 IS porting thread
« Reply #8 on: 13 / January / 2020, 12:52:24 »
Any help with reading what the ROMLOG points to would be quite welcome.

Code: [Select]
Exception!! Vector 0x0A
Occured Time  2009:02:01 23:13:37
Task ID: -1
Task name: <ISR>
That's odd. Vector is normally a multiple of 4. I have seen other values for exceptions in an ISR, but I'm not sure what they mean.
Code: [Select]
Exc Registers:
0x0034DFC0
0x00000000
0x00000000
0x00000000
0x002F2738
0x000000B0
0x19A14780
0x00000001
0x3B9ACA00
0x00001A34
0x19980218
0x19980218
0xFF815C40
0x0000D974
0xFF817AB0 < LR
0xFF817AB0 < PC
0xA0000033
PC should be where the exception happened, so you can look at that address and Ghidra and see if anything jumps out. LR being the same seems suspect.
Don't forget what the H stands for.

*

Offline koshy

  • *****
  • 1037
Re: IXUS 990 / SD970 IS porting thread
« Reply #9 on: 13 / January / 2020, 13:41:44 »
PC should be where the exception happened, so you can look at that address and Ghidra and see if anything jumps out. LR being the same seems suspect.
Thanks, perhaps someone else wants to see it, too. Made a collage of ASM and decompile... Cursor is at "PC/LR"

EDIT: That function is at the same address for SD780 FW 100B matched by exact function mnemonics. For the SX10 FW 100C which is the second I have on active compare it's at 0xff817970.
« Last Edit: 13 / January / 2020, 13:49:56 by koshy »
Koshy had a little ELPH which wasn't white as snow but everywhere that Koshy went the ELPH was sure to go. (actually an SD, but that detail ruins the rhyme...)

 

Related Topics