Powershot SX150 IS Porting Thread

  • 279 Replies
  • 38302 Views
Re: Powershot SX150 IS Porting Thread
« Reply #20 on: 30 / October / 2011, 11:05:07 »
Advertisements
Funnel, I commented the taskCreateHook code but unfortunately it didn't get me any further down the boot process.

I just discovered that the problem is in task_Startup_my().  The camera never returns from sub_FF83C8DC.  Not sure if it's safe to just comment this out since it seems like this code sets up the watchdog timer and also performs the camera "beep".

Code: [Select]
// @ 0xFF81FD28
void __attribute__((naked,noinline)) task_Startup_my() {

asm volatile (
" STMFD SP!, {R4,LR} \n"                   
" BL sub_FF8165DC \n"                     
" BL sub_FF8353D4 \n"                     
" BL sub_FF83355C \n"                     
//" BL sub_FF83C6C0 \n"                     
" BL sub_FF83C8AC \n"                     
//" BL sub_FF83C754 \n" // Skip starting diskboot.bin again
" BL sub_FF83CA48 \n"                     
" BL sub_FF832364 \n"                     

// sub_FF83C8DC Never Returns!!
" BL sub_FF83C8DC \n"                     

" BL sub_FF839FE8 \n"                     
" BL sub_FF83CA4C \n"                     

//" BL sub_FF83415C \n"                     
" BL CreateTask_PhySw \n" // our keyboard task
" BL CreateTask_spytask \n" // chdk initialization

" B sub_FF81FD5C \n" // Return to firmware ----------->
);
}


ROM:FF83C8DC sub_FF83C8DC                            ; CODE XREF: task_Startup+24p
ROM:FF83C8DC                 STMFD   SP!, {R4,LR}
ROM:FF83C8E0                 MOV     R1, #4
ROM:FF83C8E4                 MOV     R0, #2
ROM:FF83C8E8                 BL      sub_FF893974
ROM:FF83C8EC                 BL      StopWDT
ROM:FF83C8F0                 BL      EventProcedure
ROM:FF83C8F4                 BL      sub_FF88CC9C
ROM:FF83C8F8                 BL      sub_FF8627D8
ROM:FF83C8FC                 BL      sub_FF893BFC
ROM:FF83C900                 LDR     R2, =0x12CEA600
ROM:FF83C904                 LDR     R1, =0x7FE8177F
ROM:FF83C908                 BL      sub_FF83A860
ROM:FF83C90C                 BL      sub_FF863BC0
ROM:FF83C910                 BL      sub_FF835CEC
ROM:FF83C914                 BL      sub_FF833BCC
ROM:FF83C918                 BL      sub_FF8697A4
ROM:FF83C91C                 BL      sub_FF86261C
ROM:FF83C920                 MOV     R0, #1
ROM:FF83C924                 BL      sub_FF865A24
ROM:FF83C928                 BL      sub_FF85FBEC
ROM:FF83C92C                 BL      sub_FF84F5C8
ROM:FF83C930                 BL      sub_FF8620B4
ROM:FF83C934                 BL      sub_FF861A90
ROM:FF83C938                 BL      sub_FF868760
ROM:FF83C93C                 BL      sub_FF87B768
ROM:FF83C940                 BL      sub_FF864764
ROM:FF83C944                 BL      sub_FF8949D0
ROM:FF83C948                 BL      sub_FF87A3C8
ROM:FF83C94C                 BL      sub_FF8779D0
ROM:FF83C950                 BL      sub_FF868094
ROM:FF83C954                 BL      sub_FF867450
ROM:FF83C958                 LDMFD   SP!, {R4,LR}
ROM:FF83C95C                 B       sub_FF8640D0
ROM:FF83C95C ; End of function sub_FF83C8DC


sgtrum

*

Offline funnel

  • ****
  • 349
Re: Powershot SX150 IS Porting Thread
« Reply #21 on: 30 / October / 2011, 12:25:59 »
No, it'll not boot without that code, I just tried on my camera.

*

Offline philmoz

  • *****
  • 2936
    • Photos
Re: Powershot SX150 IS Porting Thread
« Reply #22 on: 30 / October / 2011, 17:40:15 »
You could have memory problems like the SX130 did.
Apparently there was not enough heap space on the SX130 to load CHDK using the normal method.
The original developers found that loading CHDK at 0xF00000 worked.
Later we converted it to use EXMEM to get CHDK out of the camera heap space.

This article on EXMEM explains the memory allocation for CHDK - http://chdk.wikia.com/wiki/ExMem_-_enabling_and_loading_CHDK_into_extended_memory.

You can try disabling everything you don't need from the build (games, calendar, scripting, calendar, text reader etc).
The easiest way to do this is to create a localbuildconf.inc file and put overrides in it to turn off features (e.g. 'override OPT_GAME_REVERSI=' will turn off the reversi game).

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)

Re: Powershot SX150 IS Porting Thread
« Reply #23 on: 01 / November / 2011, 21:23:57 »
Thanks for the info Phil.

This is what I've done:

-Found the MAXRAMADDR (0x4000000) and video buffer address (0x3D24C00) at sub_FF88F91C.
-Set the following in makefile.inc (see attachment):
  - overrides for OPT_EXMEM_MALLOC, OPT_CHDK_IN_EXMEM
  - MAXRAMADDR
  - EXMEM_HEAP_SKIP
  - EXMEM_BUFFER_SIZE
  - MEMISOSTART when OPT_CHDK_IN_EXMEM is set
-Modified boot.c to use original heap offset if OPT_CHDK_IN_EXMEM is set (see attachment).
-Disabled optional CHDK features (games)

With these changes, the boot process still doesn't reach CreateTask_PhySw().  I also tried to set OPT_EXMEM_TESTING but the camera did not do anything (tutorial claimed LCD would output addresses).


sgtrum


*

Offline philmoz

  • *****
  • 2936
    • Photos
Re: Powershot SX150 IS Porting Thread
« Reply #24 on: 01 / November / 2011, 21:39:02 »
Thanks for the info Phil.

This is what I've done:

-Found the MAXRAMADDR (0x4000000) and video buffer address (0x3D24C00) at sub_FF88F91C.
-Set the following in makefile.inc (see attachment):
  - overrides for OPT_EXMEM_MALLOC, OPT_CHDK_IN_EXMEM
  - MAXRAMADDR
  - EXMEM_HEAP_SKIP
  - EXMEM_BUFFER_SIZE
  - MEMISOSTART when OPT_CHDK_IN_EXMEM is set
-Modified boot.c to use original heap offset if OPT_CHDK_IN_EXMEM is set (see attachment).
-Disabled optional CHDK features (games)

With these changes, the boot process still doesn't reach CreateTask_PhySw().  I also tried to set OPT_EXMEM_TESTING but the camera did not do anything (tutorial claimed LCD would output addresses).


sgtrum

Sorry if my previous post was confusing; but you really need to disable EXMEM for now. Until you can get CHDK running in the Canon heap memory you won't have much luck getting it to work in EXMEM. The camera can't display the OPT_EXMEM_TESTING information till you have CHDK fully running.

That's why I suggested creating a small a build as possible to have the best chance of it loading at the heap address.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)

Re: Powershot SX150 IS Porting Thread
« Reply #25 on: 06 / November / 2011, 01:50:46 »
A bit more progress.  I have attached all of my changes I've made to date.

To get my camera to boot, I had to temporarily disable all SD card writes in core_spytask() in core/main.c (commented conf_restore() and mkdir commands).  I guess the SD card lock ignore is not working.  Also, when the camera boots it doesn't respond to any key presses.  I still don't get the CHDK logo at start-up either.

Not sure what to do next to resolve the SD card and key issues.  Here's what's on my todo list (unrelated to resolving the above issues?):

- boot.c: Uncomment code in taskCreateHook()
- boot.c: Uncomment "*(int*)0x1938 = (int)taskCreateHook;" and "*(int*)0x193C = (int)taskCreateHook;" at start of sub_FF810358_my() and figure out what values to use
- boot.c: Determine whether dataghost fat32 code in sub_FF875EAC_my() is required for this camera
- capt_seq.c: Finish patching exp_drv_task()
- Perform EXMEM tests and enable EXMEM overrides

Any tips for me?  Maybe someone can spot a mistake I've made in my files.


sgtrum

Re: Powershot SX150 IS Porting Thread
« Reply #26 on: 06 / November / 2011, 10:11:46 »
Any tips for me?  Maybe someone can spot a mistake I've made in my files.
It might not help much, but the signature finder has been updated since the trunk1385 version you are working with.  You might want to download the latest trunk, move your stuff over to it and double check what it finds ?  KEY_SHOOT_FULL_ONLY  is fixed now for example.

Otherwise,  per our IRC discussion yesterday,  keep working on the mykbd_task() stuff - that will get your SD card lock and camera key problems sorted out.  And the code is relatively simple.

Also, your issues with reading the SD card in spy_task are most likely unrelated to being unable to ignore the SD card lock switch position.


Re: Powershot SX150 IS Porting Thread
« Reply #27 on: 06 / November / 2011, 10:30:50 »
Waterwingz, your suggestion was right on target.  I updated to Changeset 1399 and I now don't have to comment the SD card writes in core/main.c.  I also get the CHDK logo at startup.  However, the keys still don't work.


sgtrum


Re: Powershot SX150 IS Porting Thread
« Reply #28 on: 06 / November / 2011, 10:41:17 »
Waterwingz, your suggestion was right on target.  I updated to Changeset 1399 and I now don't have to comment the SD card writes in core/main.c.  I also get the CHDK logo at startup.  However, the keys still don't work.
So spy_task() is working now - good news !    The keys thing should be pretty easy from here.   Like I said, make sure that mykbd_task() is actually running.

UPDATE:  you are also now at the point where you should be able to print debug messages on the LCD screen and leave your LED flasher behind  !
« Last Edit: 06 / November / 2011, 10:45:20 by waterwingz »

Re: Powershot SX150 IS Porting Thread
« Reply #29 on: 07 / November / 2011, 07:22:05 »
Ok, the SD Card lock ignore and the keys are now working.  I had to modify wrap_kbd_p1_f() in kbd.c.  It appears that the SX150 uses different registers in this routine.  Found them @FF8345D0.

The camera now boots with CHDK.  I can toggle <ALT> and can enter the CHDK menu.

Anyone know how to determine what values are used in the following lines in boot.c:

Code: [Select]
*(int*)0x1938 = (int)taskCreateHook;
*(int*)0x193C = (int)taskCreateHook;


Special thanks to waterwingz for his help on IRC.

sgtrum
« Last Edit: 07 / November / 2011, 07:28:22 by sgtrum »

 

Related Topics