SD940 (IXUS120) porting thread - page 15 - DryOS Development - CHDK Forum supplierdeeply

SD940 (IXUS120) porting thread

  • 542 Replies
  • 201239 Views
Re: SD940 (IXUS120) porting thread
« Reply #140 on: 26 / December / 2010, 16:47:34 »
Advertisements
What is the 103B directory in the trunk1001-SD940-BETA1.zip archive based on?  I just noticed that boot.c is quite different between it and the one for 103C.  Should I be using the files for 103C as a 103B baseline?
Sorry for the confusion.  I had put your Primary.BIN file in the the 103B folder when I was setting up the directories and I ran a trial build of the 103B.  So the stubs_entry.S is based on your firmware dump.  I deleted the firmware dumps when making the zip file. You can put it back in and follow fe50's suggestions from above to rebuild.  The boot.c file in there is an older version of the 103C build - probably better to just discard it and work from the current 103C or 102C files.  They are now pretty close to being the same.  The S90 port also makes a good reference.

Two things that to think about.  Having a dissassembly for either the 103C or 102C and using that to help figure out correct address is advised.   I wasted too many night before I figured that out - the S90 code is pretty close and I if I had know I would have used that for comparison.

Also,  notepad+ is a nice little programming editor that understands and hightlights syntax.  More important,  it has a nice plugin for comparing two files side by side.  Very handy when porting code.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline waldo

  • ***
  • 238
Re: SD940 (IXUS120) porting thread
« Reply #141 on: 27 / December / 2010, 10:03:32 »
@waterwingz, You may want to test while enabling raw, dng, edge overlay and zebra.  My camera shows virtually no free memory and will crash when enabling combinations of those features.

Re: SD940 (IXUS120) porting thread
« Reply #142 on: 27 / December / 2010, 10:21:37 »
@waterwingz, You may want to test while enabling raw, dng, edge overlay and zebra.
Raw seems to be okay on its own although the image is useless.  I suspect buffer address needs work. Dng won't work because LUA will not create a badpixel file.  In fact most of LUA functions seem to crash - could not run the LLIBTST.LUA script for example. Have not been able to get anything but snow from my first looks at edge overlay and zebra.  Not sure if that's RAM or bad addresses yet.

My camera shows virtually no free memory and will crash when enabling combinations of those features.
Stupid question time - how do you tell how much free memory you have ?  Also, does this mean doing a more custom port and cutting out things like games and/or maybe one of the two scripting engines ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline waldo

  • ***
  • 238
Re: SD940 (IXUS120) porting thread
« Reply #143 on: 27 / December / 2010, 10:29:12 »
Stupid question time - how do you tell how much free memory you have ?  Also, does this mean doing a more custom port and cutting out things like games and/or maybe one of the two scripting engines ?

CHDK menu/Miscellaneous/Show memory info
It changes as features are turned on and off, but I have seen as little as 512 bytes free.


Re: SD940 (IXUS120) porting thread
« Reply #144 on: 27 / December / 2010, 11:05:48 »
It changes as features are turned on and off, but I have seen as little as 512 bytes free.

Oh good - something else probably not working yet.  Free Memory shows about 130K using the Show Memory Info menu item.  It varies a few K depending on what's enable.  I assume this probably means its calculating free memory based on some parameter not set correctly in one of the many files that need to be edited.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline waldo

  • ***
  • 238
Re: SD940 (IXUS120) porting thread
« Reply #145 on: 27 / December / 2010, 11:45:15 »
Free Memory shows about 130K using the Show Memory Info menu item.  It varies a few K depending on what's enable.  I assume this probably means its calculating free memory based on some parameter not set correctly in one of the many files that need to be edited.

No, it malloc's larger and larger blocks until it fails.

Re: SD940 (IXUS120) porting thread
« Reply #146 on: 27 / December / 2010, 19:57:52 »
Status update, sick as a dog with a bad cold so I've had nothing but time to play with this stuff.  :(

I whipped up a perl script that analyses the stubs_entry.s files for an existing FW (103C) and a new FW(103B).  It calculates any offset ranges and then iterates through the various files and updates any addresses it finds accordingly.  Here's the output from an example run:

Quote from: Offsetinator Script output
Analyzing 103c/stubs_entry.S and 103b/stubs_entry.S to determine offset ranges.

For addresses less than 0xFF87E5C8 no offset required
For addresses between 0xFF87E5C8 and 0xFF925848 add the offset:    -80(0x50)
For addresses between 0xFF9358EC and 0xFFB0A224 add the offset:    -444(0x1BC)
For addresses greater than 0xFFB0A224 use offset:       -444 (0x1BC)

36 addresses updated in 103b/stubs_entry_2_with_offsets.S
24 addresses updated with offsets in 103b/boot.c_with_offsets
277 addresses updated with offsets in 103b/capt_seq.c_with_offsets
391 addresses updated with offsets in 103b/movie_rec.c_with_offsets

Compare these files to the originals in 103b/ and save as such if they look good

Looking at the modified addresses (including sub_ and loc_ tags) in my PRIMARY.BIN's dissassembly it seems to be working.  If I'm on the right track I need to go through the offset files and find/fix any discrepancies.

You can see the script here and the modified files (slightly renamed for easy diffing) here.  I also included my 103B PRIMARY.BIN with the modified files.  waterwingz, you must have gotten that 103B file from somewhere else as I didn't upload mine until now.  If someone could take a quick peek for a sanity check I'd be much obliged.

Hope everyone had/is having a great holiday!

Re: SD940 (IXUS120) porting thread
« Reply #147 on: 27 / December / 2010, 21:30:17 »
Looking at the modified addresses (including sub_ and loc_ tags) in my PRIMARY.BIN's dissassembly it seems to be working.  If I'm on the right track I need to go through the offset files and find/fix any discrepancies.
Ha ha - I did something very similiar while I was working through it - although I used an Excel spreadsheet to calculate variances between the SD940 and SD980 releases I was trying to understand.  Turned out to be a pretty much useless exercise as, in the end, I put the two dissassembly dumps side by side and matched address from the first stubs_entry_2.S to the source code for that camera and then found the same source code for the other camera and saved the resulting address in its stubs_entry_2.S.

waterwingz, you must have gotten that 103B file from somewhere else as I didn't upload mine until now. 
Yes - lost track of where things came from - somebody named http://chdk.wikia.com/wiki/User:Spike940 did the dump for the 103B and was hoping somebody else was going to be able to do the port.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: SD940 (IXUS120) porting thread
« Reply #148 on: 28 / December / 2010, 12:17:04 »
@waldo :  Does LUA work for you ? I cannot call functions in my version - makes me suspicious about stack allocation.

This works :
Code: [Select]
--[[
@title LUA Test 1
--]]

repeat
press("shoot_full")
release("shoot_full")
sleep(5000)
until false

this does not ( camera shutsdown with nothing saved )
Code: [Select]
--[[
@title LUA Test 2
--]]

 function TakePicture()
  press("shoot_full")
release("shoot_full")
 end
 
repeat
TakePicture()
sleep(5000)
until false

Would you mind trying this on your port ?

Thnk
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline waldo

  • ***
  • 238
Re: SD940 (IXUS120) porting thread
« Reply #149 on: 28 / December / 2010, 19:25:08 »
@waldo :  Does LUA work for you ? I cannot call functions in my version - makes me suspicious about stack allocation.

This works :
Code: [Select]
--[[
@title LUA Test 1
--]]

repeat
press("shoot_full")
release("shoot_full")
sleep(5000)
until false

this does not ( camera shutsdown with nothing saved )
Code: [Select]
--[[
@title LUA Test 2
--]]

 function TakePicture()
  press("shoot_full")
release("shoot_full")
 end
 
repeat
TakePicture()
sleep(5000)
until false

Would you mind trying this on your port ?

Thnk

Both scripts work for me.  The difference between the two is just Lua plumbing so I would not expect that a particular port could make one work and the other fail.  Maybe it's a memory problem - I've had my SD940 crash just taking pictures without running scripts.  I'm pretty sure that was due to running out of memory.

 

Related Topics