supplierdeeply

Powershot N Porting Thread

  • 197 Replies
  • 18502 Views
Powershot N Porting Thread
« on: 25 / April / 2014, 20:01:02 »
Advertisements
Got access to a new toy. 



Was a bit worried as it's a touch screen camera that uses microSD cards but the label says "Powershot" so I thought I'd give it a try.  Canon BASIC runs if you start with the playback button and immediately press the zoom ring to the left so I've dumped the ROM : http://chdk.setepontos.com/index.php?topic=11458.0 

I've also verified that it will display the "Firmware Update" menu item if you start in playback with a ps.fi2 file on the microSD card.

I have no idea if it will autoboot - microSD cards do not have "Card Lock" switches.

Onwards ....

Update : configured the microSD card so that it's bootable (used an adapter card). The BOOTDISK string at 0x01E0 seems to be ignored  - camera boots normally. Same microSD in an adapter with Card Lock ON does not even starting when used on the wrong camera.  Sigh.
« Last Edit: 25 / April / 2014, 20:18:31 by waterwingz »

*

Offline reyalp

  • ******
  • 10067
Re: Powershot N Porting Thread
« Reply #1 on: 25 / April / 2014, 22:02:40 »
From http://chdk.setepontos.com/index.php?topic=11212.10 it appears that IXUS500 boots normally from micro SD, so you might want to double check that your bootdisk string is actually set correctly.
This is probably incorrect, nafraf reports the camera does not autoboot.

The fact that it doesn't work in an adapter with a known working camera also seem to point that way. The card type really shouldn't matter, I've used micro SD in adapters before.
« Last Edit: 25 / April / 2014, 22:47:40 by reyalp »
Don't forget what the H stands for.

Re: Powershot N Porting Thread
« Reply #2 on: 25 / April / 2014, 22:19:52 »
The fact that it doesn't work in an adapter with a known working camera also seem to point that way. The card type really shouldn't matter, I've used micro SD in adapters before.
Sorry - I created confusion.  I used STICK with an adapter & microSD to configure the card for the SX50.   I tried the resulting combo in my A1200 and the camera failed to start with the SD card lock switch in the LOCKED position.  I took that for a good sign - it was obviously loading  diskboot.bin and crashing rather than proceeding and giving me an "SD Card Locked" message. 

The same microSD in the Powershot N booted normally. But maybe the fi2.inc / dancingbits type stuff was wrong and the ps.fi2 file ignored?

Glad to hear the IXUS500 will autoboot.  Give me hope once I get through the rest of the porting process.  I've been spoiled by chdkptp - going back to swapping memory cards while working is a real pain.  :'(

*

Offline reyalp

  • ******
  • 10067
Re: Powershot N Porting Thread
« Reply #3 on: 25 / April / 2014, 22:31:04 »
The same microSD in the Powershot N booted normally. But maybe the fi2.inc / dancingbits type stuff was wrong and the ps.fi2 file ignored?
PS.FI2 should give you an update error if you try to load an incorrect encoding.  As far as I know, incorrect dancingbits is never detected, the camera just loads it and tries to execute the resulting garbage.

So maybe the N can't boot from microSD after all.

Looking back at the ixus500 thread, I don't actually see anyone explicitly saying that diskboot works, though I would have expected someone to complain if it didn't.
Don't forget what the H stands for.


Re: Powershot N Porting Thread
« Reply #4 on: 25 / April / 2014, 22:42:51 »
PS.FI2 should give you an update error if you try to load an incorrect encoding. 
It does - right after you select "Firmware Update".

Quote
So maybe the N can't boot from microSD after all.
:'(

When I get that far,  I'll see if I can figure out where the firmware for other cams looks for the "BOOTDISK" string in the boot block and then see if anything similar exists in the N.  Time consuming project at that point.

BTW ..  added it to the platform & loader directories as powershot_n in my build.   Just calling it "N" seems kinda weird.  Especially as there is now a "Facebook N" model - which we should just decide to ban on principal  I think.

I know searching for any info about the cam on the forum was a royal PITA ....

« Last Edit: 25 / April / 2014, 22:45:04 by waterwingz »

*

Offline srsa_4c

  • ******
  • 3170
Re: Powershot N Porting Thread
« Reply #5 on: 27 / April / 2014, 15:23:40 »
Seeing your wikia edits, I did a small research on LED addresses. The LED table only knows 1 LED (as much as I understand), and the sigfinder fails on identifying it.
Its address is 0xc022c30c, switching it on and off requires setting and clearing some of its bits, with disabled interrupts  ???
LED on: see code from 0xff09082c to 0xff09083c
LED off: 0xff090848 ... 0xff09085c

Code: [Select]
loc_ff1c0498: ; 2 refs (LED on)
ff1c0498: e92d4010 push {r4, lr}
ff1c049c: e1a04000 mov r4, r0
ff1c04a0: e5d42000 ldrb r2, [r4]
ff1c04a4: e1a00001 mov r0, r1
ff1c04a8: e3520000 cmp r2, #0
ff1c04ac: 0a000002 beq loc_ff1c04bc
ff1c04b0: e3520006 cmp r2, #6
ff1c04b4: 0b00006f bleq loc_ff1c0678
ff1c04b8: ea000002 b loc_ff1c04c8
loc_ff1c04bc:
ff1c04bc: e5940004 ldr r0, [r4, #4]
ff1c04c0: e59f10a0 ldr r1, [pc, #160] ; ff1c0568: (0093d800)
ff1c04c4: ebfb40a8 bl loc_ff09076c
loc_ff1c04c8:
ff1c04c8: e3a00000 mov r0, #0
ff1c04cc: e5c40009 strb r0, [r4, #9]
ff1c04d0: e8bd8010 pop {r4, pc}
loc_ff1c04d4: ; 3 refs (LED off)
ff1c04d4: e92d4010 push {r4, lr}
ff1c04d8: e1a04000 mov r4, r0
ff1c04dc: e5d00000 ldrb r0, [r0]
ff1c04e0: e3500000 cmp r0, #0
ff1c04e4: 0a000002 beq loc_ff1c04f4
ff1c04e8: e3500006 cmp r0, #6
ff1c04ec: 0b00006f bleq loc_ff1c06b0
ff1c04f0: ea000002 b loc_ff1c0500
loc_ff1c04f4:
ff1c04f4: e5940004 ldr r0, [r4, #4]
ff1c04f8: e59f106c ldr r1, [pc, #108] ; ff1c056c: (0083dc00)
ff1c04fc: ebfb409a bl loc_ff09076c
loc_ff1c0500:
ff1c0500: e3a00001 mov r0, #1
ff1c0504: e5c40009 strb r0, [r4, #9]
ff1c0508: e8bd8010 pop {r4, pc}
loc_ff1c050c: (LED table init)
ff1c050c: e3a01000 mov r1, #0
ff1c0510: e5c01000 strb r1, [r0]
ff1c0514: e3a01106 mov r1, #-2147483647 ; 0x80000001
ff1c0518: e5801004 str r1, [r0, #4]
ff1c051c: e3a01006 mov r1, #6
ff1c0520: e5c01100 strb r1, [r0, #256] ; 0x100
ff1c0524: e5c01180 strb r1, [r0, #384] ; 0x180
ff1c0528: e5c012c0 strb r1, [r0, #704] ; 0x2c0
ff1c052c: e12fff1e bx lr

loc_ff09076c: ; 121 refs (set GPIO, thunk)
ff09076c: ea000011 b loc_ff0907b8

loc_ff0907b8: (set GPIO)
ff0907b8: e92d4070 push {r4, r5, r6, lr}
ff0907bc: e1a04001 mov r4, r1
ff0907c0: e59f10a0 ldr r1, [pc, #160] ; ff090868: (0093d800)
ff0907c4: e59f60a0 ldr r6, [pc, #160] ; ff09086c: (0083dc00)
ff0907c8: e59f5090 ldr r5, [pc, #144] ; ff090860: (c022c000)
ff0907cc: e3500102 cmp r0, #-2147483648 ; 0x80000000
ff0907d0: 1a00000d bne loc_ff09080c
ff0907d4: e1540001 cmp r4, r1
ff0907d8: 1a000005 bne loc_ff0907f4
ff0907dc: eb57e828 bl loc_68a884 ; <GetSRAndDisableInterrupt -0xFEA05F58>
ff0907e0: e595130c ldr r1, [r5, #780] ; 0x30c
ff0907e4: e3c11c03 bic r1, r1, #768 ; 0x300
ff0907e8: e3811c02 orr r1, r1, #512 ; 0x200
ff0907ec: e585130c str r1, [r5, #780] ; 0x30c
ff0907f0: eb57e824 bl loc_68a888 ; <SetSR -0xFEA05F68>
loc_ff0907f4:
ff0907f4: e1540006 cmp r4, r6
ff0907f8: 18bd8070 popne {r4, r5, r6, pc}
ff0907fc: eb57e820 bl loc_68a884 ; <GetSRAndDisableInterrupt -0xFEA05F78>
ff090800: e595130c ldr r1, [r5, #780] ; 0x30c
ff090804: e3c11c03 bic r1, r1, #768 ; 0x300
ff090808: ea000011 b loc_ff090854
loc_ff09080c:
ff09080c: e3500106 cmp r0, #-2147483647 ; 0x80000001  ; this is the LED from the LED table
ff090810: 159f1058 ldrne r1, [pc, #88] ; ff090870: (ff5bd654)
ff090814: 17910100 ldrne r0, [r1, r0, lsl #2]
ff090818: 15804000 strne r4, [r0]
ff09081c: 18bd8070 popne {r4, r5, r6, pc}
ff090820: e1540001 cmp r4, r1          ; LED on?
ff090824: 1a000005 bne loc_ff090840
ff090828: eb57e815 bl loc_68a884 ; <GetSRAndDisableInterrupt -0xFEA05FA4>
ff09082c: e595130c ldr r1, [r5, #780] ; 0x30c
ff090830: e3c11030 bic r1, r1, #48 ; 0x30
ff090834: e3811020 orr r1, r1, #32
ff090838: e585130c str r1, [r5, #780] ; 0x30c
ff09083c: eb57e811 bl loc_68a888 ; <SetSR -0xFEA05FB4>
loc_ff090840:
ff090840: e1540006 cmp r4, r6          ; LED off?
ff090844: 18bd8070 popne {r4, r5, r6, pc}
ff090848: eb57e80d bl loc_68a884 ; <GetSRAndDisableInterrupt -0xFEA05FC4>
ff09084c: e595130c ldr r1, [r5, #780] ; 0x30c
ff090850: e3c11030 bic r1, r1, #48 ; 0x30
loc_ff090854:
ff090854: e585130c str r1, [r5, #780] ; 0x30c
ff090858: e8bd4070 pop {r4, r5, r6, lr}
ff09085c: ea57e809 b loc_68a888 ; <SetSR -0xFEA05FD4>

Re: Powershot N Porting Thread
« Reply #6 on: 27 / April / 2014, 16:20:53 »
Seeing your wikia edits, I did a small research on LED addresses. The LED table only knows 1 LED (as much as I understand), and the sigfinder fails on identifying it.
Its address is 0xc022c30c, switching it on and off requires setting and clearing some of its bits, with disabled interrupts  ???
Nasty.  But thanks for taking a look.

I think I can live without having an LED I can blink from the startup code.  I've got the initial code running through the loader and the first function in boot.c.  I just change the last branch in that function to jump back to ROM and doing a firmware update load gets me through and back to normal operation (I also tested that changing the last branch to jump to itself hangs the camera).

We will have to see how well the little microSD card stands up to the "edit, build, reload & go" phase of debugging.

Update :  I guess the better question would be "Can I call that directly using the entry addresses you tagged"?
« Last Edit: 27 / April / 2014, 16:42:56 by waterwingz »

*

Offline srsa_4c

  • ******
  • 3170
Re: Powershot N Porting Thread
« Reply #7 on: 27 / April / 2014, 16:59:00 »
Update :  I guess the better question would be "Can I call that directly using the entry addresses you tagged"?
No (they are part of a subroutine), I was just lazy translating the methods to C.
LED on:
*(int*)0xc022c30c = ( (*(int*)0xc022c30c) & 0xffffffcf ) | 0x20;
LED off:
*(int*)0xc022c30c = (*(int*)0xc022c30c) & 0xffffffcf;

The above code is missing the interrupt related stuff of course, not sure how important that is.


Re: Powershot N Porting Thread
« Reply #8 on: 27 / April / 2014, 17:33:11 »
The above code is missing the interrupt related stuff of course, not sure how important that is.
Wrote a little "blinker" routine and added it to the first function in boot.c to blink the power LED three time.

Works !   :D

Thanks a lot for that -  I guess masking interrupts might matter more once everything is running but during early boot it seems to be optional.

Re: Powershot N Porting Thread
« Reply #9 on: 03 / May / 2014, 14:41:35 »
More "fun" news for the Powershot N :

  • The neck strap mounts on either side of the camera body provide some interesting option for mounting without using the 1/4-20 tripod screw.
  • This camera will start-up when USB power is applied! This feature has not been available on a Canon P&S camera for many years and is really nice to have when doing long term intervalometer shooting.
  • Its battery is charged using the USB port.  Another really nice feature if you are using a solar cell setup to keep your battery charged during long term intervalometer sessions.
  • The camera will autoboot CHDK when the cover over the microSD is left open. This is important because microSD cards do not have a card lock switch, preventing cameras using that format from autobooting CHDK

Item four was discovered after a lot of code digging took me to a routine at sub_FF0381C4 that was different from another camera released at the same time (A1400).  It convinced me that the camera was looking for something other than a non-existant microSD card lock switch to indicate it should load DISKBOOT.BIN.   Trial and error with a valid DISKBOOT.BIN file for the Powershot N eventually led me to the microSD card door cover trick.  Once I have the port fully working, I'll probably mod the switch on the door so that it always reports open.

 

Related Topics