A2100IS Porting - page 2 - General Discussion and Assistance - CHDK Forum

A2100IS Porting

  • 62 Replies
  • 15713 Views
*

Offline reyalp

  • ******
  • 13501
Re: A2100IS Porting
« Reply #10 on: 17 / January / 2012, 21:14:02 »
Advertisements
Can anyone confirm, if it's enough to fix boot.c to see something on the screen ? Because I don't know in which direction should I move, so please help who is able.
To see something on the screen you also need to find the bitmap buffers, and to see the chdk splash screen, you have to start spytask. To start spytask, you need a lot of functions correctly found.

If you are autobooting, make sure you aren't getting into a boot loop. The call that loads diskboot.bin must be commented out. If you get to that point and then jump back into the firmware, the camera should boot normally. You can also start your own task that blinks LEDs to make sure you code really is booting (there's a commented example in d10 boot.c)

Initially, you should comment the hooks for additional task. You need kbd_task (aka task_PhySw) to send input to chdk.

If the camera is crashing on startup, it may be generating a crash log.  See http://chdk.wikia.com/wiki/Debugging#Camera_crash_logs_.28romlog.29

You can obtain the romlog using canon basic, you don't need a working CHDK: http://chdk.wikia.com/wiki/Canon_Basic/Scripts/Romlog

You should leave the exmem stuff disabled until you've got chdk booting.

Don't forget what the H stands for.

Re: A2100IS Porting
« Reply #11 on: 18 / January / 2012, 04:25:33 »
reyalp, thank you for helping with this!

Let me answer in reverse order:
1) Boot loop is not a problem - place where diskboot.bin called - located and commented. (For debug I've tried to place blinkcode and uncomment diskboot - it was blinking in cycle, with commented code - it's blinking only once - so I think it's resolved)

2) I've fixed and checked all functions in boot.c - all of them except last one was blinking with test code, so I think they are OK. Last function, which executes Fat32 code - was not executed, because of SD Disable routine at previous function - so I commented our that code for SD disable, and last one function of boot.c was also executed (at least blinked).

I also was able to blink leds from each _CreateTask function of boot.c - not sure that it's created, but at least it's blinking from that section. Also I have task_blinker enabled, but it's not blinking - so it's definitely something with _CreateTask - but I don't know what :(

3) Framebuffers. If I understand correctly, they are defined in lib.c.
This part was from stubs_entry.S:
Code: [Select]
void *vid_get_bitmap_fb()        { return (void*)0x403f1000; } // Found @0xffc2c5cc
void *vid_get_viewport_fb()      { return (void*)0x4076fcc0; } // Found @0xffe441f8
And I think I've found correct addresses for these functions:
Code: [Select]
vid_get_viewport_fb_d();
vid_get_viewport_live_fb();

The only problem with lib.c is that I can't figure where to get first address of:

Code: [Select]
char *hook_raw_image_addr(){
if (*((int*)0x2860) != 0)
return (char*)0x40E166C0; // I don't know where to get this one
else
return (char*)0x4139E56C; // This one is 100% correct
}

Here is table from G10, where 0x413245A0 and 0x43164D80 were used:
Code: [Select]
ROM:FFB1017C dword_FFB1017C  DCD 1, 0x42794E92, 0x413245A0, 0x41516720, 0, 0, 0
ROM:FFB10198                 DCD 2, 0x42794E92, 0x413245A0, 0x41516720, 0x4463ABF2, 0x43164D80, 0x42902100
ROM:FFB10198                 DCD 1, 0x42794E92, 0x413245A0, 0x41516720, 0, 0, 0
ROM:FFB101D0                 DCD 1, 0x42794E92, 0x413245A0, 0x41516720, 0, 0, 0
ROM:FFB101EC                 DCD 1, 0x42794E92, 0x413245A0, 0x41516720, 0, 0, 0

And here is the same table from A2100 FW:
Code: [Select]
ROM:FFE79074 dword_FFE79074  DCD 1, 0x424A951E, 0x4139E56C, 0x40CED8C0, 
1, 0x424A951E, 0x4139E56C, 0x40CED8C0
ROM:FFE79074                 DCD 1, 0x424A951E, 0x4139E56C, 0x40CED8C0
ROM:FFE79074                 DCD

What should I use here ?

4) exmem is disabled in Compiler Options - is that correct and enough?

Thanks in advance.

Re: A2100IS Porting
« Reply #12 on: 18 / January / 2012, 09:33:31 »
2) I've fixed and checked all functions in boot.c - all of them except last one was blinking with test code, so I think they are OK. Last function, which executes Fat32 code - was not executed, because of SD Disable routine at previous function - so I commented our that code for SD disable, and last one function of boot.c was also executed (at least blinked).
Try a "C" version of your blinking LED test starting at the beginning of spy_task()?  Spy_task is in core/main.c   It seems likely its  crashing before the other tasks can get going - if so, your create_task is okay. 

You did comment out the other tasks to prevent them from starting, right ?


Quote
Also I have task_blinker enabled, but it's not blinking - so it's definitely something with _CreateTask - but I don't know what :(
FYI ... task_blinker() is not standard in most CHDK ports. Its something I put into the G10 so that I would know CHDK was still running even if I lost access to the screen & keyboard during debugging.



Ported :   A1200    SD940   G10    Powershot N    G16

Re: A2100IS Porting
« Reply #13 on: 19 / January / 2012, 04:43:33 »
waterwingz, thanks for help!

Quote
You did comment out the other tasks to prevent them from starting, right ?

Yes, in my boot.c I have now:
Code: [Select]
void __attribute__((naked,noinline)) task_Startup_my(  ) {
// *((volatile int *) LED_PWR) = 0x46;
asm volatile (
"STMFD   SP!, {R4,LR}\n"
...
 // "BL      sub_FFC187AC\n" // // Skip starting diskboot.bin again  \n"
...
);
CreateTask_spytask(); // +
//  CreateTask_PhySw(); // +
//  CreateTask_Blinker(); // +
    asm volatile (
"BL      sub_FFC146C0\n"
"BL      sub_FFC18AB4\n"
"BL      sub_FFC0EFB4\n" // nullsub_2\n"
...

Blinkcode (was found in g10 src, works perfect :)):
Code: [Select]
// volatile long *p1 = (void*)LED_PWR;
// volatile long *p2 = (void*)LED_DP;
// int counter;
// // DEBUG: blink led
// counter = DELAY; *p1 = 0x46;*p2 = 0x46;  while (counter--) { asm("nop\n nop\n"); };
// counter = DELAY; *p1 = 0x44;*p2 = 0x44;  while (counter--) { asm("nop\n nop\n"); };


And here are news:
with blinkcode at the beginning of core_spytask() - it's blinking, and I see how screen is flashing for 0.1sec (seems these "nop"-es make it possible to notice while powering on/off screen)
with blinkcode in the middle of core_spytask() - it's not blinking. That means it's crashing somewhere in used functions :( 


Re: A2100IS Porting
« Reply #14 on: 19 / January / 2012, 09:24:47 »
It's stuck on started() function inside of core_spytask(); :(

Upd: I can't believe that I missed debug_led() fixup. started() is a macros for debug_led(1) - and It was shutting down camera :)

Upd2: Now I can't believe that it's getting stuck on msleep() function. What can cause this problem?

Code: [Select]
void core_spytask() {
    int cnt = 1;
    int i=0;
    raw_need_postprocess = 0;
    spytask_can_start=0;
#ifdef OPT_EXMEM_MALLOC
exmem_malloc_init();
#endif
#ifdef CAM_CHDK_PTP
    init_chdk_ptp_task();
#endif
    while((i++<400) && !spytask_can_start) msleep(10);
    started();
// blinks here
 //   msleep(50);
// not blinks here, until commented msleep(50)

msleep() defined as external function at stdlib.h, what can be done ? I'm using CDK-Shell 3.4.2

Code: [Select]
extern void msleep(long msec);
« Last Edit: 19 / January / 2012, 10:00:27 by ac.n1bs »

Re: A2100IS Porting
« Reply #15 on: 19 / January / 2012, 12:25:03 »
msleep() defined as external function at stdlib.h, what can be done ?
msleep() is define in platform\generic\wrapper.s.  It calls the firmware function SleepTask, which is defined in the subs_entry.S file for you firmware version.  Check and make sure it has been defined correctly.
Ported :   A1200    SD940   G10    Powershot N    G16

Re: A2100IS Porting
« Reply #16 on: 19 / January / 2012, 16:07:49 »
waterwingz, thanks again!

I missed this function at wrappers... from start, but correct address was set at stubs_entry_2.s

Here is full content of my stubs_entry_2.S
Code: [Select]
#include "stubs_asm.h"

NSTUB(RefreshPhysicalScreen                 ,0xffd6be30) //104        *** != 0xff9dae58
NSTUB(kbd_pwr_off                           ,0xffc30bd4) //  2 64%    *** != 0xff84b174
NSTUB(kbd_pwr_on                            ,0xffc30b94) //  2 82%    *** != 0xff81093c


// Misc stuff
DEF(ctypes, 0xffe70516)

NHSTUB(ScreenLock,0xFFD6BDDC)
NHSTUB(ScreenUnlock,0xFFD6BE30)
NHSTUB(SleepTask,0xffc16b1c) //101

// FFDECE54 SetZoomActuatorSpeedPPS
NHSTUB(SetZoomActuatorSpeedPercent, 0xFFDECE54)

And here is part of FW for sleep():

Code: [Select]
ROM:FFC16B1C                 EXPORT eventproc_export_SleepTask
ROM:FFC16B1C eventproc_export_SleepTask              ; CODE XREF: sub_FFC100CC+74p
ROM:FFC16B1C                                         ; task_PhySw+10p ...
ROM:FFC16B1C                 STMFD   SP!, {R2-R4,LR}
ROM:FFC16B20                 MOV     R4, R0
ROM:FFC16B24                 LDR     R0, =loc_FFC00210
ROM:FFC16B28                 LDR     R0, [R0]
ROM:FFC16B2C                 LDR     R0, [R0]
ROM:FFC16B30                 CMP     R0, #0
ROM:FFC16B34                 LDRGT   R1, =0x1CA
ROM:FFC16B38                 ADRGT   R0, aKersys_c   ; "KerSys.c"
ROM:FFC16B3C                 BLGT    DebugAssert
ROM:FFC16B40                 CMP     R4, #0
ROM:FFC16B44                 BNE     loc_FFC16B50
ROM:FFC16B48
ROM:FFC16B48 loc_FFC16B48                            ; CODE XREF: eventproc_export_SleepTask+44j
ROM:FFC16B48                 MOV     R0, #0
ROM:FFC16B4C                 LDMFD   SP!, {R2-R4,PC}
ROM:FFC16B50 ; ---------------------------------------------------------------------------
ROM:FFC16B50
ROM:FFC16B50 loc_FFC16B50                            ; CODE XREF: eventproc_export_SleepTask+28j
ROM:FFC16B50                 MOV     R1, R4
ROM:FFC16B54                 MOV     R0, SP
ROM:FFC16B58                 BL      sub_FFC16200
ROM:FFC16B5C                 BL      sub_FFC01F0C
ROM:FFC16B60                 B       loc_FFC16B48
ROM:FFC16B60 ; End of function eventproc_export_SleepTask

No errors from gcc, everything compiled successfully, but it's not blinking after msleep() :(

Re: A2100IS Porting
« Reply #17 on: 19 / January / 2012, 16:35:34 »
What does it say in stubs_entry.S that the address should be ?
Ported :   A1200    SD940   G10    Powershot N    G16


Re: A2100IS Porting
« Reply #18 on: 19 / January / 2012, 16:44:11 »
What does it say in stubs_entry.S that the address should be ?

I've copied this address from stubs_entry.S and then checked with FW.
stubs_entry.S currently looks like:

Code: [Select]
...
NSTUB(SetLogicalEventActive                   ,0xffc5c8c0) //101
NSTUB(SetParameterData                        ,0xffd1cf1c) //101
NSTUB(SetPropertyCase                         ,0xffc59148) //102
NSTUB(SetScriptMode                           ,0xffc5c910) //101
//NSTUB(SleepTask                             ,0xffc16b1c) //101            == 0xffc16b1c
NSTUB(TakeSemaphore                           ,0xffc167e4) //101
NSTUB(TurnOffBackLight                        ,0xffc67d2c) //104
NSTUB(TurnOnBackLight                         ,0xffc67d14) //104
...

Re: A2100IS Porting
« Reply #19 on: 22 / January / 2012, 07:28:39 »
Just update: I was able to boot CHDK on A2100, but without keyboard and FAT32 loader at boot.c.
Working on...


Currently camera getting stuck the following code at kbd.c:
Code: [Select]
if (wrap_kbd_p1_f() == 1){ // autorepeat ?
_kbd_p2_f();
}

If I comment _kbd_p2_f(); - then camera boots OK and shows CHDK OSD.

Any comments ?

Thanks in advance.

 

Related Topics