ixus175_elph180_100c porting attempt - page 11 - DryOS Development - CHDK Forum

ixus175_elph180_100c porting attempt

  • 201 Replies
  • 109455 Views
*

Offline axman

  • ***
  • 145
Re: ixus175_elph180_100c porting attempt
« Reply #100 on: 20 / June / 2017, 16:18:34 »
Advertisements
Thanks much for the advice. 

Compiles ok now, but runs worse.  :-D  Going back, taking stuff apart, to see about getting one-thing-at-a-time working. 

But unfortunately, other stuff calls, so It will be some days before I can get back to this.  Thanks again for all the help.

*

Offline reyalp

  • ******
  • 14125
Re: ixus175_elph180_100c porting attempt
« Reply #101 on: 20 / June / 2017, 16:59:50 »
Compiles ok now, but runs worse.  :-D  Going back, taking stuff apart, to see about getting one-thing-at-a-time working. 
Whenever you add code to inline ASM, you have to be careful to make sure it doesn't trash registers used by the surrounding code. The ASM_SAFE macro can be used to save / restore all registers.
Don't forget what the H stands for.

*

Offline axman

  • ***
  • 145
Re: ixus175_elph180_100c porting attempt
« Reply #102 on: 22 / June / 2017, 11:45:39 »
Compiles ok now, but runs worse.  :-D  Going back, taking stuff apart, to see about getting one-thing-at-a-time working. 
Whenever you add code to inline ASM, you have to be careful to make sure it doesn't trash registers used by the surrounding code. The ASM_SAFE macro can be used to save / restore all registers.
Thank you for the guidance.

Looked at g7x.  Have defined FILEWRITE_DEBUG_LOG in filewrite_hrd.c, along with other related code, and inserted jumps to the debug func inside code_gen.txt.

I read include/asmsafe.h, and the SD430 porting thread, where srsa_4c gave specific example how to use asm_safe.

Tried several syntax versions.  In each case, it looks like assembler is unhappy.  Current syntax;

code_gen.txt
Code: [Select]
>>>
"#ifdef FILEWRITE_DEBUG_LOG\n\t" // if we've def'ed this,
"ASM_SAFE("BL     log_fwt_start");\n\t"
"#endif\n\t"
<<<
FW 11
>>>
"#ifdef FILEWRITE_DEBUG_LOG\n\t"
"ASM_SAFE("LDR   R0, [SP]");\n\t"
"ASM_SAFE("BL    log_fwt_msg");\n\t"
"#endif\n\t"
<<<

results in this assembler error
Code: [Select]
filewrite.c: In function 'filewritetask':
filewrite.c:74:12: error: expected ':' or ')' before 'BL'
 "ASM_SAFE("BL   log_fwt_start");\n\t"
            ^
../../../makefile_sub.inc:40: recipe for target 'filewrite.o' failed
make[1]: *** [filewrite.o] Error 1
makefile_base.inc:103: recipe for target 'all-recursive' failed

The mention of 'expecting :' makes me think the assembler is expecting an operand constraint?  Any feedback is appreciated.

*

Offline reyalp

  • ******
  • 14125
Re: ixus175_elph180_100c porting attempt
« Reply #103 on: 22 / June / 2017, 16:39:36 »

code_gen.txt
Code: [Select]
"#ifdef FILEWRITE_DEBUG_LOG\n\t" // if we've def'ed this,
"ASM_SAFE("BL     log_fwt_start");\n\t"
"#endif\n\t"
ASM_SAFE is a C preprocessor macro, so it should not be quoted like inline asm. The ifdefs should also not be quoted.
Don't forget what the H stands for.

*

Offline axman

  • ***
  • 145
Re: ixus175_elph180_100c porting attempt
« Reply #104 on: 23 / June / 2017, 12:14:38 »
Regarding the romlog:

Exception!! Vector 0x10

is an invalid memory access. The task "PTPBulkState8" isn't one we hook directly, but is involved in PTP somehow.

LR and PC are respectively
Code: [Select]
0xFFA828DC
0x006BD1D4
Disassembling the code around these addresses might provide clues. The PC address looks the DryOS kernel code that is copied to RAM.

One way the PTP stuff could get a bad address is if the fwt_data_struct layout isn't correct.

Putting LogCameraEvent logging in filewrite (see g7x for an example) can be helpful to verify the struct, and might also help understand where in the process the crash is happening.

Studied the g7x capt_seq.c - to see how to apply the logging technique.  Thanks again for that pointer.

I put log statements in the main hook section, just before the patch is inserted to "jump to loc_C".  This spot corresponds most closely to the PC address contained in the romlog.

Test again w/  chdkptp remoteshoot;  crash w/lens out again, but no battery pull is required to recover.

Info regarding fwt_data_structure is now in the romlog. 
Code: [Select]
00068460: UI:fw m:12 o:0x00000000 fs:0x004db2b2 sf:0x0
00068460: UI:fw
00068460: UI:fw u 004db2b2 594cd143 00002083 00000000 0

I can kinda see which variables from debug code map to which debug outputs.   Since m=12, the var 'name' did not print..  Seek_flag is 0x0, BUT!!!  there are 2 lines in filewrite_hdr.c  that seem to force seek_flag to 0x40..  I don't quite understand that yet..

Where can I learn about fwt_data_structure and what it should be?  I realize it is different between cameras.

Thanks in advance - small Progress, but progress nonetheless!

*

Offline axman

  • ***
  • 145
Re: ixus175_elph180_100c porting attempt
« Reply #105 on: 23 / June / 2017, 20:02:01 »
re: fwt_data_struct, I re-arranged the order of the elements.  Romlong hinted that 'char name' came after unkn2 and before seek_flag..  Since that, No more crash with lens out.  :-D 

chdkptp shoot works, two images are saved to SD card.

chdkptp remoteshoot fails to save image to host PC (zero len file is created) but saves 2 images to SD card instead, and gives error "chdku.lua:1366 General error"

Both the above success are indicating there is still something wrong with capt_seq.  I think they also indicate that I got fw_data_struct correct..

"Main" capt_seq hook sections of code <index=1 by @reyalp guidance> are commented out, in attempt to isolate.

The only chdk code path for capt_seq now is the one for qs and remote ops..  And Canon's, provided I did not step on them.

half-shutter press followed by full-press records 1 image to SD card.. 

quickshoot (full shutter press with no half) also records 1 image to SD card..

Is half-press then full-press the "normal code path" ?

edit: clarified # of images saved, and added lua err
« Last Edit: 23 / June / 2017, 20:04:30 by axman »

*

Offline reyalp

  • ******
  • 14125
Re: ixus175_elph180_100c porting attempt
« Reply #106 on: 23 / June / 2017, 23:12:09 »
re: fwt_data_struct, I re-arranged the order of the elements.  Romlong hinted that 'char name' came after unkn2 and before seek_flag..  Since that, No more crash with lens out.  :-D 
You need to verify that each of the fields used by CHDK contains the expected values. Not crashing may just mean that you changed it to pass values that happen not crash, but still aren't correct.

You can log what happens when you shoot without using remote shoot.

Quote
chdkptp shoot works, two images are saved to SD card.

chdkptp remoteshoot fails to save image to host PC (zero len file is created) but saves 2 images to SD card instead, and gives error "chdku.lua:1366 General error"

Both the above success are indicating there is still something wrong with capt_seq.  I think they also indicate that I got fw_data_struct correct..
I agree with the first conclusions, not the second.

As I mentioned before, the double shot means the raw hook is not being called. This is a major problem in the port, so I'd suggest focusing on that before worrying too much about remote shoot. The missing hook and multiple shots could cause problems with remoteshoot even if the filewrite stuff was totally correct.

Quote
half-shutter press followed by full-press records 1 image to SD card..

quickshoot (full shutter press with no half) also records 1 image to SD card..
script shoot() taking two shots happens because the CHDK code doesn't recognize that the shot has been taken. Shooting using normal camera controls (or CHDK scripted key presses) would be expected to work normally unless you've broken the canon code capt_seq.

Quote
Is half-press then full-press the "normal code path" ?
Yes.

I don't understand your description of what you did in capt seq. To figure out which code paths are taken, I'd suggest using logging while shooting using the camera controls or scripted key presses.

Another alternative approach is to try to find a known working port with similar capt_seq code and put your hooks in the equivalent places.
Don't forget what the H stands for.

*

Offline blackhole

  • *****
  • 946
  • A590IS 101b
    • Planetary astrophotography
Re: ixus175_elph180_100c porting attempt
« Reply #107 on: 24 / June / 2017, 10:38:46 »

Quote
As I mentioned before, the double shot means the raw hook is not being called. This is a major problem in the port, so I'd suggest focusing on that before worrying too much about remote shoot. The missing hook and multiple shots could cause problems with remoteshoot even if the filewrite stuff was totally correct.
Here is test version with the modified capt_seq.c file.
Can anyone check if it's okay?

*

Offline axman

  • ***
  • 145
Re: ixus175_elph180_100c porting attempt
« Reply #108 on: 24 / June / 2017, 11:57:05 »

Quote
As I mentioned before, the double shot means the raw hook is not being called. This is a major problem in the port, so I'd suggest focusing on that before worrying too much about remote shoot. The missing hook and multiple shots could cause problems with remoteshoot even if the filewrite stuff was totally correct.
Here is test version with the modified capt_seq.c file.
Can anyone check if it's okay?
Thanks to you guys for trying to help fix this.  @blackhole, the attached build fails hooktest.lua in my cam, run from chdk gui/scripts  - it fails the same way my build does.  Log attached.

I have stripped my build down to only boot, and capt_seq. 
Temporary, I have not inserted shooting_expo_param_override.
The only hooks I try to set are ref=0 for quick press & remote, and ref=1 for main capt_seq hook.

Obviously I cannot see another possible branch for the main hook section; and cannot see a branch inside that main hook section that might carry me further.

Funny thing, if I knew more I might understand it.  The code section for this ixus175 main hook is "too small" compared to ixus160 and sx530hs.  Those 2 (working good) cams have many sequences of

/* SsCaptureCtrl.c */   the canon routine
...
_ClearEventFlag

before the main hook is placed.

In this 175, there is only a single in sequence of SsCaptureCrrl/_ClearEventFlag there..  It is ref=1, but may not actually be the 'main' section..?

Re: ixus175_elph180_100c porting attempt
« Reply #109 on: 24 / June / 2017, 12:05:41 »
how can i use this chdk. please tell me, i am newbie..

after i unzip the file and put them to sd card, what the next i must do?

how i can find ps.fi2 ?
« Last Edit: 24 / June / 2017, 12:15:01 by arlan_zafian »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal