experimental alternate memory allocation

  • 128 Replies
  • 14797 Views
*

Offline reyalp

  • ******
  • 9801
  • Publish
    Re: experimental alternate memory allocation
    « Reply #10 on: 02 / January / 2011, 14:28:56 »
    Advertisements
    ExMem.AllocCacheable and not ExMem.AllocCacheableMemory as stand in your intro post.
    Oops, my mistake. Corrected.

    @Philmoz:
    The video I recorded with using exmem seemed ok. It was short though.

    Edit:
    Another possible test:
    Allocate a bunch of memory and memset it with e.g. 0xDEADBEEF and check later to see if it is corrupted.
    Don't forget what the H stands for.

    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #11 on: 02 / January / 2011, 21:20:57 »
    Some test results from SX30:
    - 512KB, 1MB & 2MB from EXMEM_RAMDISK = corrupt movie and menu font.
    - 4MB from EXMEM_DISK = movies record and menu is not corrupted.
    - 2MB from EXMEM_SCRIPT = corrupt
    - 4MB from EXMEM_SCRIPT = works

    Attached is a screenshot of what the menu looks like after recording a movie with 2MB or less memory.

    EXMEMINF.LOG shows the correct amount from the correct pool being allocated.

    If I try to run the lua script after recording a movie with 2MB or less the camera crashes.

    Also CHDK reports approx 450K less free memory (via Misc --> memory info) than what is allocated.

    Edit:
    Same for G12, 4MB exmem allocation and the movies and menus work. (CHDK reports about 100K more free memory than the SX30).

    Regards,
    Phil.
    « Last Edit: 02 / January / 2011, 21:30:44 by philmoz »
    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 philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #12 on: 02 / January / 2011, 21:51:17 »
    Another thing I've noticed is that the base address of the memory (exmem_heap) is 0x47c00000 (on the SX30 with 4MB allocated).

    Isn't this an non-cacheable address (CAM_UNCACHED_BIT is set)?
    If so, will this have a performance impact?

    Edit:
    I changed the init code to
    Code: [Select]
    exmem_heap = suba_init((void*)(((unsigned long)mem)&~CAM_UNCACHED_BIT),EXMEM_HEAP_SIZE,1,1024);
    and it all still seems to work (can't see any performance difference so maybe not an issue).

    Regards,
    Phil.
    « Last Edit: 02 / January / 2011, 21:56:49 by philmoz »
    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

    • ******
    • 9801
  • Publish
    Re: experimental alternate memory allocation
    « Reply #13 on: 02 / January / 2011, 22:42:24 »
    Another thing I've noticed is that the base address of the memory (exmem_heap) is 0x47c00000 (on the SX30 with 4MB allocated).

    Isn't this an non-cacheable address (CAM_UNCACHED_BIT is set)?
    If so, will this have a performance impact?
    On d10 at least, the camera function twiddles the bits on the returned pointer for you. Exmem View always reports the uncached version.

    As for the other stuff... not sure what to make of it.
    Don't forget what the H stands for.


    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #14 on: 02 / January / 2011, 23:08:28 »
    Another thing I've noticed is that the base address of the memory (exmem_heap) is 0x47c00000 (on the SX30 with 4MB allocated).

    Isn't this an non-cacheable address (CAM_UNCACHED_BIT is set)?
    If so, will this have a performance impact?
    On d10 at least, the camera function twiddles the bits on the returned pointer for you. Exmem View always reports the uncached version.

    As for the other stuff... not sure what to make of it.

    Doh! Had wrong address for exmem_alloc.
    Doesn't fix the movie / menu problems though.

    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 philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #15 on: 03 / January / 2011, 01:12:04 »
    OK a bit more info on the SX30.
    I modified the code to allocate 4MB (exmem_alloc actually gives you 32 bytes more); but not call suba_init so that CHDK grabs the memory but doesn't use it.
    I then filled this memory (starting @ 0x07BFFFE0) with the 0xDEADBEEF value as suggested.
    I added a check at the start of gui_draw_debug_vals_osd to check all the memory and display the first value that was not set to 0xDEADBEEF.

    Everything that I tried, unrelated to movies, leaves this memory alone.
    As soon as I started recording a movie the memory changes from 0x07D08A00, and 748,800 words were changed (2,995,200 bytes).

    I also found that if I start the camera in playback mode and select a movie on the card then it alters 345,600 words (1,382,400 bytes) starting at 0x07E5A200.

    Allocating 2MB using exmem_alloc puts the allocated memory buffer right in the middle of the above movie buffers (0x07DFFFE0) - hence the corruption and crashes.

    Looks like the camera is using this memory without properly allocating it (or there is a bug in the memory allocator).

    Edit: - G12 has the exact same behaviour with same addresses and lengths.

    Regards,
    Phil.


    « Last Edit: 03 / January / 2011, 01:56:15 by philmoz »
    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

    • ******
    • 9801
  • Publish
    Re: experimental alternate memory allocation
    « Reply #16 on: 03 / January / 2011, 02:28:37 »
    Very interesting.

    Quote
    Looks like the camera is using this memory without properly allocating it (or there is a bug in the memory allocator).
    Or there is some subtlety of the exmem api we haven't understood. There is a third param to exmem_alloc. I initially thought it indicated cacheable or not, but it clearly isn't.

    Have you run an exmem.view while recording video ? I noticed (not recording)
     EXMEM_MOVIE_REC      [0x00000000] , [0x00000000]
     EXMEM_MOVIE_PLY      [0x00000000] , [0x00000000]

    Also, when usb is connected, there is
     EXMEM_COM            [0x43CFFFC0] , [0x00100000]
    This might bode ill for recording movies with the PTP interface ...
    Don't forget what the H stands for.

    *

    Offline philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #17 on: 03 / January / 2011, 02:36:12 »
    Have you run an exmem.view while recording video ?

    Not sure how to do this. If I try and run the exmeminf.lua script while the movie is recording the camera stops responding to any buttons (the recording keeps going; but I have to pull the battery to shutdown).

    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 philmoz

    • *****
    • 2936
      • Photos
  • Publish
    Re: experimental alternate memory allocation
    « Reply #18 on: 03 / January / 2011, 02:42:42 »
    Or there is some subtlety of the exmem api we haven't understood. There is a third param to exmem_alloc. I initially thought it indicated cacheable or not, but it clearly isn't.

    In the SX30 firmware this third value looks to be a another memory location where the allocated memory address and size are stored ( STMNEIA R5, {R4,R6}). It looks like it might be recording a list of allocations somewhere, maybe our allocation is getting ignored because we aren't including it in the list.

    Edit: all the calls to exmem_alloc I can find in the SX30 1.00H firmware pass a value of 0 in the third parameter so I don't think that's it.

    Phil.
    « Last Edit: 03 / January / 2011, 02:47:14 by philmoz »
    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)

  • Publish
    Re: experimental alternate memory allocation
    « Reply #19 on: 03 / January / 2011, 10:42:08 »
    I add the code but i get linker error, suba_init suba_free suba_alloc is not find.I see not code in changesets for this functions
    Ixus 1000 HS

     

    Related Topics