SD980 port

  • 162 Replies
  • 19257 Views
*

Offline RaduP

  • *****
  • 856
  • Publish
    SD980 port
    « on: 17 / September / 2009, 21:57:36 »
    Advertisements
    Ok, I am thinking to start the SD980 port.
    I won't have a lot of time to work at it, maybe 10 hours a week or so, and will probably need a lot of help and advice, but I hope to get something working this year.
    Anyway, I was wondering, which camera do you think I should use as a reference model thing?

    *

    Offline reyalp

    • ******
    • 9801
  • Publish
    Re: SD980 port
    « Reply #1 on: 17 / September / 2009, 22:04:27 »
    Don't forget what the H stands for.

    *

    Offline RaduP

    • *****
    • 856
  • Publish
    Re: SD980 port
    « Reply #2 on: 17 / September / 2009, 22:16:38 »
    Great, thanks!

    *

    Offline RaduP

    • *****
    • 856
  • Publish
    Re: SD980 port
    « Reply #3 on: 21 / September / 2009, 02:48:54 »
    Ok, now it seems that I hit a dead end.

    I have the following values in the makefile.inc:
    MEMBASEADDR=0x1900
    RESTARTSTART=0x50000
    MEMISOSTART=0x153E84
    ROMBASEADDR=0xFF810000

    I am not sure that MEMISOSTART is right, the documentation on how to find this value is very ambiguous, but I looked at the SX10 firmware, found where it is, then looked at my firmware and found a similar code, so I used the value that I found. If someone else can confirm that, it would be nice.

    The my_restart() function looks like this:

    Code: [Select]
    void __attribute__((noreturn)) my_restart()
    {
        void __attribute__((noreturn)) (*copy_and_restart)(char *dst, char *src, long length);
        int i;

    *((volatile int *) 0xc0223030) = 0x46; // Turn on LED
    for (i=0; i<10000000; i++) // Wait a while
    {
        asm volatile ( "nop\n" );
    }

        for (i=0; i<(blob_copy_and_reset_size/sizeof(long)); i++){
    ((long*)(RESTARTSTART))[i] = blob_copy_and_reset[i];
        }

    *((volatile int *) 0xc0223030) = 0x46; // Turn on LED
    for (i=0; i<100000; i++) // Wait a while
    {
        asm volatile ( "nop\n" );
    }

        copy_and_restart = (void*)RESTARTSTART;
        copy_and_restart((void*)MEMISOSTART, (char*)blob_chdk_core, blob_chdk_core_size);
    }

    No LED blinking, camera freezes. I tried both the boot and firmware update methods, same result. Any ideas?


    *

    Offline reyalp

    • ******
    • 9801
  • Publish
    Re: SD980 port
    « Reply #4 on: 21 / September / 2009, 03:38:13 »
    You can try turning on your LED earlier, in entry.S. Most cameras turn of the SD card (using an MMIO address that must be determined from the firmware dump) and a delay loop there.

    You've already built a blinker that works, so it might be productive to compare that with the early stages of the loader.

    You can look at the disassembly of your CHDK image, which will appear in loader/<camera>/main.dump
    You should be able to clearly see the entry.S code and my_restart. If you have toolchain problems, they may be visible here. You can also look at main.bin, which should be your CHDK image exactly as it will be loaded.
    Don't forget what the H stands for.

    *

    Offline RaduP

    • *****
    • 856
  • Publish
    Re: SD980 port
    « Reply #5 on: 21 / September / 2009, 04:01:12 »
    The problem is, the entry.S of CHDK is totally different than the entry.S of the blinker (which is much bigger).
    I did already look at main.bin and I can clearly see the LED blinking code, which is very near the beginning, and I can't see why the code wouldn't get there if the camera starts to actually execute it. There are no conditional jumps or anything, so the execution SHOULD get there.
    What exactly is the purpose of turning off the card power? If it's just to support the restart, it shouldn't matter, as my LED blinking code is before the restart thing.

    Could it be that for some reason the diskboot.bin and the ps.fi2 are not encoded properly by the toolchain? Would the camera still attempt to run the ps.fi2 if the encoding is not right?

    *

    Offline reyalp

    • ******
    • 9801
  • Publish
    Re: SD980 port
    « Reply #6 on: 21 / September / 2009, 04:23:52 »
    The problem is, the entry.S of CHDK is totally different than the entry.S of the blinker (which is much bigger).
    The MMIO address poked in entry.S could be wrong (and almost certainly is, if you haven't corrected it). As I said before, try turning on the LED in entry.S, or try skipping that code. You say the entry.S of the blinker is much bigger... OK, what does it do ?
    Quote
    Could it be that for some reason the diskboot.bin and the ps.fi2 are not encoded properly by the toolchain? Would the camera still attempt to run the ps.fi2 if the encoding is not right?
    I'm fairly sure that the camera won't load an incorrectly encoded FI2, but not 100% certain.

    You know how your blinker is encoded right ? Figure out if your CHDK image is encoded in the same way.

    For diskboot, setting NEED_ENCODED_DISKBOOT=3 in your makefile.inc should use the right diskboot encoding for your camera (assuming you are working from the latest SVN) but obviously I haven't tested that.
    Don't forget what the H stands for.

    *

    Offline RaduP

    • *****
    • 856
  • Publish
    Re: SD980 port
    « Reply #7 on: 21 / September / 2009, 04:37:38 »
    Ok, got the SOB to work :D
    So.. NEED_ENCODED_DISKBOOT needs to be removed.
    The the diskboot.bin needs to be transformed into a ps.fi2 with the fi2encdec tool.
    Afterwards, I can use the firmware update method and it works (previously it didn't, if I had NEED_ENCODED_DISKBOOT set as 1 or 2). However, the diskboot.bin method does not work, as expected.

    I use a 3 weeks old SVN, and the only valid methods for NEED_ENCODED_DISKBOOT are 1 and 2.
    « Last Edit: 21 / September / 2009, 04:39:19 by RaduP »


    *

    Offline reyalp

    • ******
    • 9801
  • Publish
    Re: SD980 port
    « Reply #8 on: 21 / September / 2009, 04:45:28 »
    Ok, got the SOB to work :D
    So.. NEED_ENCODED_DISKBOOT needs to be removed.
    The the diskboot.bin needs to be transformed into a ps.fi2 with the fi2encdec tool.
    Afterwards, I can use the firmware update method and it works (previously it didn't, if I had NEED_ENCODED_DISKBOOT set as 1 or 2). However, the diskboot.bin method does not work, as expected.
    You've broken something horribly in the makefiles then, since the FI2 is normally made from the unencoded main.bin, not the encoded diskboot.bin.
    Quote
    I use a 3 weeks old SVN, and the only valid methods for NEED_ENCODED_DISKBOOT are 1 and 2.
    Don't forget what the H stands for.

    *

    Offline RaduP

    • *****
    • 856
  • Publish
    Re: SD980 port
    « Reply #9 on: 21 / September / 2009, 04:52:01 »
    From looking at the makefile, you have to explicitly enable the FI2, and you need some keys that I didn't understand how to get (yes, I did read the thread, but maybe I am too tired).
    And I am not making the FI2 with the makefile, I am making it with a bat that I also used with the blinker. But it is made from the diskboot.bin

     

    Related Topics