Porting a camera sx530hs - page 26 - DryOS Development - CHDK Forum supplierdeeply

Porting a camera sx530hs

  • 300 Replies
  • 137807 Views
*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #250 on: 13 / June / 2017, 17:20:11 »
Advertisements
boot.c

Since posting a tarball of /platform/sx530hs here, I have restored fix_writable_media_flag and init_required_fw_features.  Also enabled JogDial code which was originally present, but portions were de-activated, incomplete or commented out.  I have also restored liveview, previously removed by mistake.

'svn diff' of vanilla src boot.c to my branch, summary;

task_MovieRecord and task_Filewrite are enabled.
task_ExpDrv appears to already be enabled.
task_RotaryEncoder appears to already be enabled.
My extra comments in code_gen.txt are of course visible.
liveimage is present again, so, no diffs from src..
jogdial is present, but not functional.  Does not appear to harm anything.

attached diff from vanilla src boot.c to my branch.

I will post a specific, made-to-order boot.c (containing or not containing exp_drv_task) and (containing or not containing jogdial) when the preferred approach is clear.

<edit:  attach the diff, not the .c>

*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #251 on: 13 / June / 2017, 17:38:14 »
code_gen.txt

Changes since posting a tarball of /platform/sx530hs here, I have:

  • Restored fix_writable_media_flag and init_required_fw_features.
  • Enabled JogDial code originally present, but incomplete or commented out.  Tested no-op.
  • Restored liveview, previously removed by mistake.  Tested good.
  • movie_rec and filewrite are enabled.  Tested good.
  • exp_drv_task is enabled.  Tested good.
  • Extra comments are visible, as a learning aid.  Let me know if undesireable.
  • liveimage is present again, so, no diffs from src..
  • jogdial is present, but not functional.  Does not appear to harm anything.
I can post a specific, made-to-order code_gen.txt (containing or not containing exp_drv_task) and (containing or not containing jogdial) when the preferred approach is clear.

'svn diff' of vanilla src code_gen.txt to my branch is attached. 

code_gen.txt can be provided, if useful.

*

Offline reyalp

  • ******
  • 14080
Re: Porting a camera sx530hs
« Reply #252 on: 13 / June / 2017, 22:08:17 »
Please post a single patch for all the affected files in a given change. You can this just by doing svn diff > myfile.diff in top of the source directory.

Quote
jogdial is present, but not functional.  Does not appear to harm anything.

If something doesn't work, it shouldn't be enabled.
Don't forget what the H stands for.

*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #253 on: 17 / June / 2017, 21:56:16 »
Please post a single patch for all the affected files in a given change. You can this just by doing svn diff > myfile.diff in top of the source directory.

Quote
jogdial is present, but not functional.  Does not appear to harm anything.

If something doesn't work, it shouldn't be enabled.

THanks for the svn clue.  My source currently contains *all* the changes I've made.  Including your suggestion above, eg I have commented out jogdial since it doesn't work. 

Diff of my source is not a "step by step, add filewrite and post diffs" diff.  It's all my changes. 

I had asked earlier if you wanted me to take it apart (question hidden inside the several walls of txt above, my bad )  and so I guess you didn't see that..

Do you want me to reverse all my changes to "filewrite alone" and submit an svn diff of that?

Or svn diff the whole ball of wax as it stands now? 

(current status is:
filewrite tested good,
exp_drv_task present & tested,
init_required_fw is there,
movie_rec tested good,
liveimage tested good.)

Sorry for the hassle, thanks in advance for the guidance.


*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #254 on: 22 / June / 2017, 13:27:17 »
Svn diff of platform/sx530hs with only filewrite changes is attached.  Tested good using chdkptp remoteshoot.

*

Offline reyalp

  • ******
  • 14080
Re: Porting a camera sx530hs
« Reply #255 on: 25 / June / 2017, 01:32:39 »
Svn diff of platform/sx530hs with only filewrite changes is attached.  Tested good using chdkptp remoteshoot.
Thanks for posting this and apologies for the delay.

There were a few issues:
* The patch still has quite a bit of "noise" unrelated to the filewrite changes. Even if the unrelated changes are inconsequential, I still have to spend time looking at them to be sure they are.
* The code_gen.txt refers to ../boot_extras.c, which was not included in the patch. To have a new file appear in an svn patch, you should add it with svn add before doing the diff.
* Since there is only one platform_camera.h per platform, optional features like filewrite must be implemented for all firmware versions, while the patch only includes 100c.

Since the filewrite codegen code doesn't refer to any firmware addresses, it should probably work fine on both firmware versions.

Attached is a patch with only the filewrite changes implemented for both 100a and 100c, and a 100c build. I have obviously not tested it. I can provide a 100a build if anyone else wants to test that.

If you can confirm that it works, I will check it in.  To apply the patch, you would use the following in the root of an unmodified source tree
patch -p 0 < axman-sx530hs-filewrite-mods-reyalp-1.diff

When testing filewrite, you should check whether continuous mode works. To do this, enabled continuous mode in the Canon UI, and use something like rs -cont=5

You can also check for the other issues in http://chdk.wikia.com/wiki/User:Nafraf/RemoteShootIssues

You should also verify that regular shooting without remote shoot still works.
Don't forget what the H stands for.

*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #256 on: 29 / June / 2017, 12:08:58 »
Thanks for looking at it, feedback is much appreciated. 

Sorry for the 'noise' - next submit will hopefully have less.

Understood about omitting boot_extras.c.  I did not think to add it with svn, but of course that action would be neccessary if submission is to be part of trunk..

About applying the submitted code to all firmware versions - (meaning this same camera w/ different fw's) - I was not sure about how to actually do that, given that I don't have those cameras with other fw versions..  Thanks for clarifying, it makes sense.

I will test the provided build.  Also will apply your patch to a clean source trunk and build it, then test again with what was built. 

Thanks also for pointer to testing with continuous mode  :xmas and  for mentioning @nafraf issues, & regular shooting.  I will check them as well.

*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #257 on: 29 / June / 2017, 15:38:06 »
Case 1. Tested with the provided build, results good.

Case 2, Got trunk version 4834, unaltered, applied the provided patch, and built.  Tested good.

Re: @nafraf issues (great page, Thanks!) of the 3 issues mentioned, none are seen in either set of test cases performed above.

Results summary for both test cases above are attached. 
hooktest and camtests results are available.

Tests;
Regular shooting without remoteshoot (quick press, half-followed-by-full press)
hooktest w/continuous mode Off
hooktest w/continuous mode On
chdkptp camtests.runbench
chdkptp remoteshoot, both single and continuous (with Continuous Enabled and Disabled)


*

Offline reyalp

  • ******
  • 14080
Re: Porting a camera sx530hs
« Reply #258 on: 30 / June / 2017, 02:37:09 »
Understood about omitting boot_extras.c.  I did not think to add it with svn, but of course that action would be neccessary if submission is to be part of trunk..
No problem, it's not obvious
Quote
About applying the submitted code to all firmware versions - (meaning this same camera w/ different fw's) - I was not sure about how to actually do that, given that I don't have those cameras with other fw versions..
Usually, someone does the other version blind and waits for an owner of the other firmware to test it, or if it looks very safe (e.g. filewrite which is all code-gen with no direct references to firmware specific values), just check it in.

Thanks for all the testing.

I was going to check this in, but looking at the filewrite code more closely I have a concern that will require some more debugging or reverse engineering.
Code: [Select]
"    LDR R3, =ignore_current_write\n" // !!
"    LDR R3, [R3]\n"
"    CMP R3, #0\n"
"    BNE loc_A\n" // skip creating directory
...
"    BL      sub_FF02EB34 \n"
" LDR R3, =ignore_current_write\n" // mod start
" LDR R3, [R3]\n"
" CMP R3, #0\n"
" BNE loc_B\n" // skip flushing the cache
"    ADD     R0, SP, #4 \n"
"    BL      sub_FF02D9F0 \n"
"loc_B:\n"
"    MOV     R7, R0 \n"
"    ADD     R0, R4, #0x58 \n"
"loc_A:\n"
"    BL      sub_FF030DA4 \n"
"    LDR     R1, [R5, #0x1C] \n"
"    BL      sub_FF02EC74 \n"
"    LDR     R1, [R5, #0x14] \n"
"    CMP     R1, #0 \n"
"    BEQ     loc_FF3AF220 \n"
"    CMP     R7, #1 \n"
In both the loc_B case, the call to sub_FF02D9F0 is skipped, but the MOV R7, R0 is trying to store the return value of that call in R0. Moving loc_B down one more instruction wouldn't help, because R7 is still used below. R7 is also potentially used unset in the loc_A case.

It's possible the code involving R7 is never used in regular operation (if the value from [R5, #0x14] is 0) but otherwise it's not obvious how to get correct behavior.

Code from earlier cameras (e.g. elph130, elph160) doesn't have this case at all.

I understand that it worked in your testing, but this kind of thing could easily cause intermittent problems.

edit:
Don't feel bad about missing this either, it's an unusual case where just following what was done on other ports doesn't help.
« Last Edit: 30 / June / 2017, 02:43:48 by reyalp »
Don't forget what the H stands for.

*

Offline axman

  • ***
  • 145
Re: Porting a camera sx530hs
« Reply #259 on: 30 / June / 2017, 14:54:02 »
@reyalp,

Thanks for the helpful and encouraging feedback.  :-)  I learn a lot from testing and debugging, happy to do it.  Mutual benefits.

Re: concerns about filewrite 'skip-dir' and 'skip-flush' code sections..  I believe I can now insert logging statements and compile with success. 

q1) Where to insert log lines, so this code section can be exercised properly?  eg expose a fault

  just before   "BNE  loc_A\n"
  just after    "BL   sub_FF02EB34"
  just after    "loc_B:"
  just after    "loc_A:"
  just after    "BL   sub_FF030DA4"

?  If debugging in this manner is useful, pls suggest where to insert.. Thanks in advance!

q2) What specific cam behavior will exercise the code around inserted log lines?

remoteshoot in continuous mode?

 

Related Topics