IXUS 240/ELPH 320 HS Porting thread

  • 283 Replies
  • 25560 Views
*

Offline nafraf

  • *****
  • 1269
IXUS 240/ELPH 320 HS Porting thread
« on: 23 / November / 2012, 21:31:11 »
Advertisements
Hi, I started a blind port for ixus240/elph320 101a. Just for fun... :)

camcrazy posted the dump here.

camcrazy is testing. If any other user can help with pre-alpha version tests, send a private message to me.




Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #1 on: 23 / November / 2012, 21:36:34 »
Hi, I started a blind port for ixus240/elph320 101a. Just for fun... :)
Well,  I'm starting to think someone is crazy here .. but I'm not sure its camcrazy.   :o

Good for you - I was telling someone today that a year ago,  you could pretty much not buy a new camera in the store that had CHDK support yet.  You've changed that.  Good for you !

*

Offline nafraf

  • *****
  • 1269
Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #2 on: 23 / November / 2012, 21:41:34 »
Good for you - I was telling someone today that a year ago,  you could pretty much not buy a new camera in the store that had CHDK support yet.  You've changed that.  Good for you !
It's important to note that in blind ports a lot of work is done by chdk-pt ;)

Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #3 on: 23 / November / 2012, 21:49:41 »
It's important to note that in blind ports a lot of work is done by chdk-pt ;)
Thanks.  But at the risk of turning this into a "group hug", much of what I wrote CHDK-PT for is no longer even needed due to philmoz's work on the sigfinder.  And that is a very good thing !


Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #4 on: 26 / November / 2012, 09:53:25 »
LED's

0xC0220000-0xC0220600  NONE
0xC0223000-0xC0223100  SX260 NONE
0xC022C000-0xC022C200  SX260 NONE
0xC022C201-0xC022C2FF  G1_X   248-250 LOCKS todo: 251-2FF
0xC022C300-0xC022C30F  30B-F OFF
0xC022C310-0xC022CA00  NONE

These are ranges that have been checked with the loop:

Quote
for c = 0xC022C800 to 0xC022CA00
    sprintf(msgstr,"LED address = %0X",c)
    LCDMsg_SetStr(a,msgstr)
    Poke8(c, 0x46)
    Wait(1000)
  next
« Last Edit: 26 / November / 2012, 10:28:39 by camcrazy »

Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #5 on: 28 / November / 2012, 16:12:54 »
This turns the light on:
Poke8(0xC0220020, 0x46)
Poke8(0xC022C0CC, 0x46)

This turns the light off:
Poke8(0xC0220020, 0x44)
Poke8(0xC022C0CC, 0x44)

The way I went about finding this was a bit different than what I'm seeing on the forum.  Most scripts would poke a range of addresses which would lead to unusual results.   One script would actually turn the lights on and off but didn't tell you the address.  My thought was why not combine the scripts together and see what happens.


Step 1: Run the script below

Code: [Select]
private sub Initialize()

    System.Create()
    Driver.Create()
    UI.CreatePublic()

    a=LCDMsg_Create()
    LCDMsg_SetStr(a,"LED Test")
    LCDMsg_Move(a,100,100)
    LCDMsg_ChangeColor(a,3)

    b=LCDMsg_Create()

    for c=0 to 15 
        LCDMsg_SetNum(b,c)
        LCDMsg_Move(b,100,200)
        LCDMsg_ChangeColor(b,2)
        BeepDrive(3)
        Wait(500)
        LEDDrive(c,0)
        Wait(2000)
        LEDDrive(c,1)
    next
 
    Wait(2000)
    LCDMsg_SetStr(a,"Test End")

end sub
private sub terminate( )
' Ending code
end sub

On a piece of paper I wrote down the different lights LED, WIFI, AF and then as this script ran I noted the number that was being used to turn which lights on/off.

I then compiled a list of all the LED locations from all IV & V chip cameras to make a range of addresses to search as most were doing.  The difference in my script is that instead of randomly Poke8 to each address which causes the camera to lock up I just Peek8 the address and dump it to the SD card. 

Step 2: Modify and run this script with c=number of the light you'd like to test.  On the ELPH320HS a zero '0' would turn the power LED on/off in the first script. 

Code: [Select]
private sub Initialize()
'Starting memory address
startaddy=0xC0220000

'Ending memory address
maxaddy=0xC022FFFF

'ELPH320HS Light 0=I/O, 4-6=AF, 8=WIFI
c=0

System.Create()
Driver.Create()
UI.CreatePublic()
msgstr = AllocateMemory(80)
a=LCDMsg_Create()
LCDMsg_Move(a,100,100)
LCDMsg_ChangeColor(a,3)
        LCDMsg_SetStr(a,"LED TEST")
        BeepDrive(3)
        Wait(500)

'Dump memory address:value to file0
msgfile = Fopen_Fut("A/MEMORY0.LOG","a")
        for x = startaddy to maxaddy
   d = Peek8(x)
           sprintf(msgstr,"%0X:%0X", x, d)
   LCDMsg_SetStr(a,msgstr)
   if msgfile <> 0 then
Fwrite_Fut(msgstr,strlen(msgstr),1,msgfile)
Fwrite_Fut("\n",1,1,msgfile)
   end if
        next
Fclose_Fut(msgfile)

        'Turn on LED
        LEDDrive(c,0)

'Dump memory address:value to file1
msgfile = Fopen_Fut("A/MEMORY1.LOG","a")
        for x = startaddy to maxaddy
   d = Peek8(x)
           sprintf(msgstr,"%0X:%0X", x, d)
   LCDMsg_SetStr(a,msgstr)
   if msgfile <> 0 then
Fwrite_Fut(msgstr,strlen(msgstr),1,msgfile)
Fwrite_Fut("\n",1,1,msgfile)
   end if
        next
Fclose_Fut(msgfile)

'Turn off LED
        LEDDrive(c,1)
 
Wait(500)
    LCDMsg_SetStr(a,"Test End")
    FreeMemory(msgstr)
end sub

private sub terminate( )
' Ending code
end sub

After running this (IT WILL TAKE A WHILE) I then have 2 files on the SD card MEMORY0.LOG & MEMORY1.LOG.  In each of these files there is a list of addresses and their values:

Quote
....
C022E150:FFFFFFF3
C022E151:3
C022E152:7
C022E153:FFFFFFC0
....

Step 3: Using the 'diff' command in linux I then compared both files together and saw some interesting output:

Quote
mbp:Cannon Camera/LED#diff MEMORY0.LOG MEMORY1.LOG
29c29
< C022001C:9
---
> C022001C:8
33c33
< C0220020:0
---
> C0220020:1
277c277
< C0220114:9
---
> C0220114:8
514c514
< C0220201:C
---
> C0220201:D
521c521
< C0220208:C
---
> C0220208:3C
49357c49357
< C022C0CC:8
---
> C022C0CC:9

Step 4: I then took all the distinct addresses above and put them into a third script

Code: [Select]
private sub Initialize()

    System.Create()
    Driver.Create()
    UI.CreatePublic()

    a=LCDMsg_Create()
    LCDMsg_SetStr(a,"LED Test")
    LCDMsg_Move(a,100,100)
    LCDMsg_ChangeColor(a,3)

    b=LCDMsg_Create()

    for c=0 to 10
        BeepDrive(3)
        Wait(500)
Poke8(0xC022001C, 0x46)
Poke8(0xC0220020, 0x46)
Poke8(0xC0220114, 0x46)
Poke8(0xC0220201, 0x46)
Poke8(0xC0220208, 0x46)
Poke8(0xC022C0CC, 0x46)
Poke8(0xC022F484, 0x46)
Poke8(0xC022F485, 0x46)
Poke8(0xC022F486, 0x46)
Poke8(0xC022F48E, 0x46)
Poke8(0xC022F4A4, 0x46)
Poke8(0xC022F4A5, 0x46)
Poke8(0xC022F4A6, 0x46)
Poke8(0xC022F4A7, 0x46)
Poke8(0xC022F5E4, 0x46)
        Wait(500)
Poke8(0xC022001C, 0x44)
Poke8(0xC0220020, 0x44)
Poke8(0xC0220114, 0x44)
Poke8(0xC0220201, 0x44)
Poke8(0xC0220208, 0x44)
Poke8(0xC022C0CC, 0x44)
Poke8(0xC022F484, 0x44)
Poke8(0xC022F485, 0x44)
Poke8(0xC022F486, 0x44)
Poke8(0xC022F48E, 0x44)
Poke8(0xC022F4A4, 0x44)
Poke8(0xC022F4A5, 0x44)
Poke8(0xC022F4A6, 0x44)
Poke8(0xC022F4A7, 0x44)
Poke8(0xC022F5E4, 0x44)
    next
 
    Wait(1000)
    LCDMsg_SetStr(a,"Test End")

end sub
private sub terminate( )
' Ending code
end sub

Running this all sorts of chaos was observed on the camera including a flashing LED.  I then started commenting out each set of Poke's starting at the top and working my way down the list and found the 2 addresses above were required to make the light blink on and off. 

By using this method I believe it will save a great deal of time and repetitive testing and narrow down the addresses to only a handful that need checked as opposed to huge ranges. 
« Last Edit: 28 / November / 2012, 16:26:46 by camcrazy »

*

Offline nafraf

  • *****
  • 1269
Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #6 on: 02 / December / 2012, 09:43:57 »
Some news about this port:

I'm using ixus310/elph500hs porting thread as reference to port the ixus240 touch screen interface.

By comparison of firmware code, I got the addresses to returns separate X & Y co-ordinates, and ported the functions to process them. It seems to be right, because we got consistent values when touching screen in different positions.
Touch panel driver: AD7879
Coordinates conversion formula: 'value = ((value & 0x7FFF) >> 2) ^ 0x3FF)'
Returned values are in the ranges:  X =195 - 831,  Y =330 - 690  aprox.

Now we are trying to discover address of
touch_screen_active
canon_play_menu_active


Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #7 on: 10 / January / 2013, 03:40:28 »
Hey Guys,

Just to let you know that the work you have done already to generate CHDK for the 240HS is highly appreciated over here. Must say the jpegs superfine look awesome already, but raw , well you know.... would make this camera king of it's league.

Kind regards,
Bart


*

Offline nafraf

  • *****
  • 1269
Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #8 on: 10 / January / 2013, 10:10:47 »
Hi,
The latest source code for firmware version 101a (platform and loader directories) are available here

CHDK boots, but the touch screen interface is not fully ported. Touch screen calibration is needed.

capture and movie functions are ported, but due to touch screen problems, they have not been tested.


Re: IXUS 240/ELPH 320 HS Porting thread
« Reply #9 on: 10 / January / 2013, 10:36:29 »
I've been away from this for the past month due to holidays.  I'll be back on it soon esp if someone else is interested in assisting or testing.  I think we're close on touch screen. 

 

Related Topics