experimental alternate memory allocation

  • 128 Replies
  • 15086 Views
*

Offline reyalp

  • ******
  • 9963
  • Publish
    Re: experimental alternate memory allocation
    « Reply #90 on: 03 / April / 2011, 01:47:24 »
    Advertisements
    Awesome.

    Quote
    Any suggestions on improving these instructions welcome.
    Only one... Put them on the wiki somewhere http://chdk.wikia.com/wiki/CHDK

    Camera RAM size can also be determined by looking at the CP15 MPU/cache setup instructions at the very start of the firmware.
    Don't forget what the H stands for.

    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #91 on: 03 / April / 2011, 01:52:56 »
    Awesome.
    Thanks  :)

    Quote
    Only one... Put them on the wiki somewhere http://chdk.wikia.com/wiki/CHDK
    Good idea, will look at this shortly.

    Quote
    Camera RAM size can also be determined by looking at the CP15 MPU/cache setup instructions at the very start of the firmware.
    Do you know of any good documentation on this? It's one area I haven't much knowledge of.

    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)

    *

    Offline reyalp

    • ******
    • 9963
  • Publish
    Re: experimental alternate memory allocation
    « Reply #92 on: 03 / April / 2011, 02:16:27 »
    Do you know of any good documentation on this? It's one area I haven't much knowledge of.
    ARM946E-S Technical Reference Manual, available freely from the ARM site. 

    http://chdk.wikia.com/wiki/Developer_Technical_Documents has links to this and other useful docs.

    Code: [Select]
    ROM:FF810040 33 00 A0 E3                 MOV     R0, #0x33
    ROM:FF810044 12 0F 06 EE                 MCR     p15, 0, R0,c6,c2
    ROM:FF810048 CD 01 A0 E3                 MOV     R0, #0x40000033
    ROM:FF81004C 13 0F 06 EE                 MCR     p15, 0, R0,c6,c3
    Sets up the cached and uncached regions. Lowest bit is enable, next 5 are region size.

    So 0x32 => 11001  => my D10 has 64 MB according to Table 4-2
    Don't forget what the H stands for.

    *

    Offline whim

    • ******
    • 2013
    • A495/590/620/630 ixus70/115/220/230/300/870 S95
  • Publish
    Re: experimental alternate memory allocation
    « Reply #93 on: 04 / April / 2011, 14:28:13 »
    Hi,

    Not sure if there's a better place to post these exmem_alloc stub addresses, let me know if there is ...

    Found these with IDA, via search for ExMem.AllocCacheable (from reyalp), I have attached
    the .IDB snippets that I used.
     
    Addresses were successfully tested on the bolded firmware versions, by compiling
    with OPT_EXMEM_MALLOC & OPT_CHDK_IN_EXMEM  selected, on vanilla CHDK trunk1127,
    except s95 which was tested on vanilla CHDK-DE trunk608.

    ixus870_sd880 - 100e/101a/102b:  NHSTUB(exmem_alloc, 0xFF86C19C)

    a590 - 100c/101b :  NHSTUB(exmem_alloc, 0xFFC5869C)

    s95 - 100e/100h :  NHSTUB(exmem_alloc, 0xFF890F40)

    wim

    Note that this does not mean that these options are safe to use on these cams !
    See phil's comment below
    « Last Edit: 05 / April / 2011, 08:03:43 by whim »


    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #94 on: 04 / April / 2011, 18:39:15 »
    Addresses were successfully tested on the bolded firmware versions, by compiling
    with OPT_EXMEM_MALLOC & OPT_CHDK_IN_EXMEM  selected, on vanilla CHDK trunk1127,
    except s95 which was tested on vanilla CHDK-DE trunk608.
    Depending on original memory these cams now show 1.6 - 1.8 MB free memory on a 'clean' card.

    OPT_CHDK_IN_EXMEM won't actually load CHDK into the exmem allocated block unless you have also modified MEMISOSTART (using the instructions I posted previously).

    On the S95, enabling OPT_EXMEM_ALLOC on a vanilla CHDK or CHDK-DE version will likely cause problems with video recording (it did on the G12 and SX30 and the S95 has a lot in common with the G12). I don't know about the other two cameras.

    You really need to use the OPT_EXMEM_TESTING option I added to ensure the memory being allocated is safe to use. You may also need to find the video buffer address and use EXMEM_HEAP_SKIP to protect the video memory, as described in the instructions I posted.

    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)

    *

    Offline whim

    • ******
    • 2013
    • A495/590/620/630 ixus70/115/220/230/300/870 S95
  • Publish
    Re: experimental alternate memory allocation
    « Reply #95 on: 05 / April / 2011, 08:03:06 »
    Thanks, Phil - post edited

    wim

    *

    Offline f_m_b

    • **
    • 71
  • Publish
    Re: experimental alternate memory allocation
    « Reply #96 on: 08 / April / 2011, 18:53:29 »
    Thanks to the great "7 point instructions" from philmoz i trust me to do the next steps...

    Size of Memory: The sx20 has the same pattern like reyalp described here:

    Code: [Select]
    ROM:FF810040 33 00 A0 E3                 MOV     R0, #0x33
    ROM:FF810044 12 0F 06 EE                 MCR     p15, 0, R0,c6,c2
    ROM:FF810048 CD 01 A0 E3                 MOV     R0, #0x40000033
    ROM:FF81004C 13 0F 06 EE                 MCR     p15, 0, R0,c6,c3
    Sets up the cached and uncached regions. Lowest bit is enable, next 5 are region size.

    So 0x32 => 11001  => my D10 has 64 MB according to Table 4-2

    So the cam has 64MB RAM and MAXRAMADDR=0x03FFFFFF.

    I dont have access to IDA, so i tried with ARMu...

    exmem_alloc i found at 0xFF889D7C (sx20 1.02b)
    EXMEM_HEAP_SKIP=0x2F7600   #(0x4000000-0x3D08A00) from sub_FF88A064 = size of video buffers in EXMEM area

    MEMISOSTART=0x39089E0      # MAXRAMADDR+1 - EXMEM_HEAP_SKIP - EXMEM_BUFFER_SIZE - 32 (exmem allocates 64 bytes extra, 32 before and 32 after block allocated)

    Code: [Select]
    0x3FFFFFF  MAXRAMADDR
    +0x0000001
    -0x02F7600  EXMEM_HEAP_SKIP
    -0x0400000  EXMEM_BUFFER_SIZE
    -0x0000020
    =========
     0x39089E0

    I tested with this values (with OPT_EXMEM_TESTING) and it seems to be all fine.
    With active OPT_EXMEM_MALLOC the sx20 has 4MB less ~50KB. :D

    Show Memory Info:
    Free Memory = 4144168
    CHDK size = 277380
    loaded at 0x13DD6C

    I am going to test more features like Zebra with buffering, PTP,... this weekend.


    @philmoz: Thank you very much for your great instructions.  :)
    Only point 7 OPT_CHDK_IN_EXMEM doesn't work and crashes the cam (I have to put out the batteries).

    I think the problem is, that the sx20 only can start chdk while booting from SD-Card. But i am not sure.
    Greetings Frank
    SX20 (1.02b)

    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #97 on: 08 / April / 2011, 20:19:47 »
    @philmoz: Thank you very much for your great instructions.  :)
    Only point 7 OPT_CHDK_IN_EXMEM doesn't work and crashes the cam (I have to put out the batteries).

    I think the problem is, that the sx20 only can start chdk while booting from SD-Card. But i am not sure.

    Glad to hear it's working :)

    When you set OPT_CHDK_IN_EXMEM check the main.dump file in the core directory after compiling CHDK (open it with a text editor). Make sure the address of the <_start> location near the top is your modified MEMISOSTART value (39089E0) not the low memory load address (13DD6C). If this value is wrong it means the compile has not used the new MEMISOSTART address for some reason so double check you makefile.inc settings. Also do a clean build so that everything gets recompiled.

    On the G12 and SX30 OPT_CHDK_IN_EXMEM works for both manual boot (PS.FI2) and auto boot (DISKBOOT.BIN).

    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)


    *

    Offline f_m_b

    • **
    • 71
  • Publish
    Re: experimental alternate memory allocation
    « Reply #98 on: 10 / April / 2011, 14:08:13 »
    On the G12 and SX30 OPT_CHDK_IN_EXMEM works for both manual boot (PS.FI2) and auto boot (DISKBOOT.BIN).

    Thanks a lot. I've forgotten to change the boot.c file.
    Now its work with OPT_CHDK_IN_EXMEM.

    If you want to, you can write this info in your 7-point-instructions. ;-)

    Next steps are more testing and find out the addresses for sx20 1.02d and 1.00f. :-)
    « Last Edit: 10 / April / 2011, 14:12:24 by f_m_b »
    Greetings Frank
    SX20 (1.02b)

    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #99 on: 10 / April / 2011, 19:01:14 »
    Thanks a lot. I've forgotten to change the boot.c file.
    Now its work with OPT_CHDK_IN_EXMEM.

    If you want to, you can write this info in your 7-point-instructions. ;-)

    Doh! Forgot about the boot.c changes. Thanks for pointing it out - I will update the instructions soon.

    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)

     

    Related Topics