ELPH300HS aka IXUS220HS - Porting Thread - page 17 - DryOS Development - CHDK Forum  

ELPH300HS aka IXUS220HS - Porting Thread

  • 899 Replies
  • 399364 Views
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #160 on: 22 / November / 2011, 03:09:58 »
Advertisements
This is my boot.c and movie_rec.c
« Last Edit: 22 / November / 2011, 05:19:24 by majsi »

*

Offline tommi2water

  • ***
  • 157
  • IXUS 220 HS Firmware: 1.00c
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #161 on: 22 / November / 2011, 07:44:24 »
Majsi, thanks for your files.

Good to see that another person has now started porting.  :)

I looked at least into your first uploaded boot.c and found additional information which I could use.

I'm wondering why you can use all these "ADRLT" instructions in your sub_FF815EE0_my() function. If I try to use them I get an error during compilation. That's the reason why I use "LDRLT".

In line 602 of your boot.c:
Code: [Select]
"BNE   loc_FF81FD2C"and in line 608 of your boot.c:
Code: [Select]
"B   loc_FF81FD18"
Aren't you missing "\n" at the end?


To find out why sub_FF815EE0_my() is not reached, I digged deeper into the disassembled code and found out one thing.
In line 471 of my attached boot.c file:

Code: [Select]
" STRNE R1, [R3, #4] \n"
If this line is commented out, next lines are executed. But if STRNE instruction is executed, no more instructions seem to be executed.

It seems that some kind of linked list / array is changed which was loaded here first (line 432 in attached boot.c):

Code: [Select]
" LDR R0, =0x19F4 \n"
Does anyone has an idea what values are stored at 0x19F4 and why STRNE seems to stop execution?


*

Offline tommi2water

  • ***
  • 157
  • IXUS 220 HS Firmware: 1.00c
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #162 on: 22 / November / 2011, 12:11:31 »
I found another discussion about exactly the same issue which I have:

Grr, I'm not getting very far with my S5... In the function where wHwSetup_my is hooked
Code: [Select]
"LDR     R1, =uHwSetup_my\n"         // followup to own function
a call to sub_FF812D84 is made, which calls ... which calls .. and so on, until I reach sub_FF818BB0 (A720 equiv sub_FFC08C98, identical in both cameras). For some reason execution stops at
Code: [Select]
"STRNE   R1, [R2,#4]\n"
and I don't know why. The addresses it's referencing look quite alike in both firmwares but for some reason it's acting up in the S5. If anyone has any ideas, please :) In the meantime, I guess I'll look over the complete code again to make sure I didn't make an error anywhere.

What makes me happy: Finally they did a successful port of CHDK to S5IS camera.  :)

What makes me sad: I'm not able to find the solution for this issue from reading the followed discussion.  :(

The only thing I see is that they talk about memory settings / addresses.

e.g. comment from jeff666:
Quote
One thing I forgot to mention is that you will need to change platform/<dev>/sub/<rev>/makefile.inc

You need to change
* MEMISOSTART, CHDK gets relocated there
and
* ROMBASEADDR

...

What happens is:

    the firmware copies an amount of memory from ROM to RAM. This happens at FFC00130 (A720). Check the declarations at the beginning of boot() and you will recognize the numbers.
    The firmware code that copies this memory is skipped and instead copied in boot().
    The main memory pool (originally) starts right above this limit. Its address is indicated by R0 in the shown code.
    We move the memory pool a little up by adding 196k (0x30000), thus creating room for CHDK to live. This room is referred to in MEMISOSTART


Originally only 128k were added, but as reported in this thread my code was overwritten. Thus everything is moved up a little more.

So before anything can work, you have to adjust these numbers.

As I don't really know which values have to be used, I would like to ask if someone could review my attached makefile.inc file or tell me how I can find out the correct values by myself.



*

Offline tommi2water

  • ***
  • 157
  • IXUS 220 HS Firmware: 1.00c
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #163 on: 22 / November / 2011, 12:56:24 »
I found another discussion about exactly the same issue which I have:
And another discussion, where they also solved the issue:
http://chdk.setepontos.com/index.php?topic=1132.msg15653#msg15653

Now I have to understand how they solved.



*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #164 on: 22 / November / 2011, 14:44:43 »

As I don't really know which values have to be used, I would like to ask if someone could review my attached makefile.inc file or tell me how I can find out the correct values by myself.


Remove the EXMEM overrides at the start - you need a working CHDK version before you can determine what EXMEM values to use. The chances of the values from the port you started with working are pretty slim.

Get it working in the Canon heap memory first. You should disable games, the calendar and textreader in buildconf.inc (or localbuildconf.inc) to create as small a version as possible initially.

All the functions you've copied into boot.c from line 284 - 510 should not be needed.

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)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline tommi2water

  • ***
  • 157
  • IXUS 220 HS Firmware: 1.00c
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #165 on: 22 / November / 2011, 15:28:23 »
Hello Phil,

thanks, I reduced the DISKBOOT.BIN size from 200KB to 127KB.

I also disabled the EXMEM feature.

But I still have no different behaviour yet.

I was wondering if I would be able to start original firmware via my DISKBOOT.BIN to verify if it is working in general.

Because currently I only verify my local code from boot.c when I look at LEDs blinking.

I tried to use direct firmware call very early in boot.c but I'm still at black screen and no further reaction:
Code: [Select]
    "B       sub_FF810358\n"    //original
//"B       sub_FF810358_my\n"    //patched

How can I start the original firmware from ROM via my DISKBOOT.BIN to verify my stuff at the very beginning?
« Last Edit: 22 / November / 2011, 15:43:06 by tommi2water »

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #166 on: 22 / November / 2011, 15:45:09 »
Hello Phil,

thanks, I reduced the DISKBOOT.BIN size from 200KB to 104KB.

I also disabled the EXMEM feature.

But I still have no different behaviour yet.

I was wondering if I would be able to start original firmware via my DISKBOOT.BIN to verify if it is working in general.

Because currently I only verify my local code from boot.c when I look at LEDs blinking.

I tried to use direct firmware call very early in boot.c but I'm still at black screen and no further reaction:
Code: [Select]
"BL      sub_FF8111B0\n" //original
                 //"BL      sub_FF8111B0_my\n" //patched

How can I start the original firmware from ROM via my DISKBOOT.BIN to verify my stuff at the very beginning?


If you have autoboot enabled and jump back to the original firmware you will get in a loop with the camera repeatedly trying to boot CHDK.

You can use the manual boot method on an unlocked card to get around this.

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)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline tommi2water

  • ***
  • 157
  • IXUS 220 HS Firmware: 1.00c
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #167 on: 22 / November / 2011, 15:55:22 »
Manual boot means using "FirmwareUpdate" menu entry in original Canon Menu? Hmm, then I need to generate a fi2 file first.

I will jump into "fi2 encoder/decorder" topic (http://chdk.setepontos.com/index.php/topic,2995.0.html) to understand how I can generate the necessary file to be able to activate FirmwareUpdate-MenuItem.

Update:
Got the manual boot working with fi2 file. :)
I will do more investigations by tomorrow.
« Last Edit: 22 / November / 2011, 16:19:46 by tommi2water »


*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #168 on: 22 / November / 2011, 16:30:57 »
You should also comment out all the overrides in taskHook (boot.c).
Until you've finished porting each of the override functions you shouldn't replace the firmware ones.

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)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline tommi2water

  • ***
  • 157
  • IXUS 220 HS Firmware: 1.00c
Re: ELPH300HS aka IXUS220HS - Porting Thread
« Reply #169 on: 23 / November / 2011, 13:23:40 »
All,

after falling down in more and more confusion I did a complete new start by today [and this was a good decision].  ;)

Now I used/reviewed code from camera ixus310_elph500hs. Waterwingz inspired me to do this because he wrote a comment regarding this 3 days ago. Thanks for the inspiration!  8)

This time I also adapted my loader files.

Result:
After I start my DISKBOOT.BIN I still get a black screen. But after about 20 seconds I'm able to start the camera again (this works with manual boot and as well with autoboot[verified with LED blinking at startup]). btw: I'm not sure if in my previous version I would have been able to start the camera again after 20 seconds because I never tried that.

What is really new: with LED debugging I found out that it executes much more from boot.c this time. :)

It now reaches the following function and executes it:

Code: [Select]
void __attribute__((naked,noinline)) taskcreatePhySw_my() {
asm volatile (
"                STMFD   SP!, {R3-R5,LR}\n"
"                LDR     R4, =0x1C3C\n"
"                LDR     R0, [R4,#0x4]\n"
"                CMP     R0, #0\n"
"                BNE     sub_FF834A20\n"    // continue in firmware
"                MOV     R3, #0\n"
"                STR     R3, [SP]\n"
"                LDR     R3, =mykbd_task\n" // task_PhySw
"                MOV     R2, #0x2000\n" // stack size for new task_PhySw so we don't have to do stack switch
// this line was reached, verified by LED blinker
"B      sub_FF834A10 \n" // continue in firmware
);
}

But it doesn't get back to the location where the call of taskcreatePhySw_my() was done. Has this something to do with the "mykbd_task"?

I attached the current version of my "project".

New in this version is changed "boot.c" (now based on ixus310_elph500hs code) and changed "resetcode/main.c" from loader.

I'm now wondering what leads the camera to do a shutdown (because it can be started again after 20 seconds I assume that it does a clean shutdown)?

Awaiting your comments/ideas/review.  :)


 

Related Topics