Free RAM OSD - Feature Requests - CHDK Forum supplierdeeply

Free RAM OSD

  • 13 Replies
  • 8991 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Free RAM OSD
« on: 25 / December / 2008, 12:45:15 »
Advertisements
I think we need an OSD element for free RAM, with turn-to-red alarm for low RAM (which appears on screen even when not normally enabled).

We now have a dozen features we can enable/disable in menus and/or at build time that take up more or less RAM. We have Lua that allows large scripts to be loaded and it also allows scripts to allocate large amounts of RAM. Add this up with the fact that different camera models have different amounts of available RAM and get pretty weird problem reports...

Failing mallocs should of course cause report visible errors too...now things just fail silently or crash when enabling edge overlay or zebra while low on RAM.

*

Offline reyalp

  • ******
  • 14118
Re: Free RAM OSD
« Reply #1 on: 25 / December / 2008, 18:29:06 »
The current method of calculating free RAM wouldn't really work for this, since it just repeatedly mallocs until malloc fails. This is inefficient, to say the least ;)

It's not clear that there is a cheap way to keep this information up to date. Perhaps the camera already stores totals somewhere.

Alternately, it would be relatively easy to keep track of how much memory CHDK had allocated. You could compare this to a total of what was free on camera startup, but this doesn't account for the fact that the camera uses different amounts in various situations.

Similar problems apply to warnings and failing mallocs: we can do something sane if CHDK fails to malloc, but if something in the original OS tries to malloc and fails, we can't catch that.

There is also the issue of fragmentation. Knowing the total, and the largest contiguous block would useful.
Don't forget what the H stands for.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #2 on: 25 / December / 2008, 18:45:06 »
Ah, didn't know that... we definitely don't want to be mallocing to death constantly. :D

The main problem I have with the RAM indicator is that it's hard to access. I could make a user menu entry out of it, but then again I don't normally want it there, just for devel things. So maybe it could be in debug misc osd and a re-measurement could be triggered by +/- in ALT mode (i.e. the key combo already selectable among a few things like propcase view page switching or mem dump instead of RAW mode)?

One would indeed thing the OS would keep some facts about RAM usage somewhere...

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Free RAM OSD
« Reply #3 on: 25 / December / 2008, 19:16:42 »
In VxWorks largest block:
Quote
memPartFindMax( ) - find the size of the largest available free block

int memPartFindMax
    (
    PART_ID partId /* partition ID */
    )

RETURNS

The size, in bytes, of the largest available block.

Partition ID can be found from malloc() implementation (A570 1.00E):

ROM:FFCD9B78 malloc                             
ROM:FFCD9B78                 MOV     R1, R0
ROM:FFCD9B7C                 LDR     R0, =0x1197C
ROM:FFCD9B80                 B       memPartAlloc

So, for A570 partition ID is 0x1197C.

Tested on A710, result is equal to "Show memory info" dialog.
« Last Edit: 25 / December / 2008, 19:21:51 by ewavr »


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #4 on: 03 / January / 2009, 07:19:11 »
In VxWorks largest block:

Umm... I see memPartFindMax() is part of VxWorks memPartLib but where do you find it in the firmwares? It's not in stubs or strings... I see you also have memPartAlloc labeled but I can't find it either in stubs or strings? Do you have have some magical way of finding VxWorks standard library functions in IDA?

*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Free RAM OSD
« Reply #5 on: 03 / January / 2009, 07:26:48 »
Do you have have some magical way of finding VxWorks standard library functions in IDA?
I have magical IDA signatures for VxWorks (and DryOS) from GrAnd (http://grandag.nm.ru/hdk/CanonFW_A-Series_Signatures_for_IDA.rar) - this link present in CHDK Wiki.

p.s. Signatures for VxWorks were obtained long time ago from official firmware updater (WriteInFir.bin - part of Canon's ps.fir) - it contains many hundreds of function names. We all waiting for FI2 format decryption :D
« Last Edit: 03 / January / 2009, 07:33:37 by ewavr »

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #6 on: 03 / January / 2009, 08:58:44 »
I have magical IDA signatures for VxWorks (and DryOS) from GrAnd (http://grandag.nm.ru/hdk/CanonFW_A-Series_Signatures_for_IDA.rar) - this link present in CHDK Wiki.

Ah that figures... never had IDA so didn't quite know what those signatures had in them, them being all binary. Could results from the idc scripts be exported into stubs so that they could be imported to the GPL tools?

I see scan-event-procedures-list.idc already exports some to stubs_entry_ida.S. Are stubs_entry_ida.S files available somewhere? In trunk there are only ones for ixus65 and 60...

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #7 on: 01 / February / 2009, 16:52:17 »
I tried memPartFindMax with the attached patch, but I always get -1 as result from Lua. Any ideas why? I have assumed PART_ID is int.

The patch adds command get_free_memory() to Lua. It calls memPartFindMax (only on a570 100e/101a) or does the crude misc menu free mem info test (for other cameras, that worked before).


*

Offline ewavr

  • ****
  • 1057
  • A710IS
Re: Free RAM OSD
« Reply #8 on: 01 / February / 2009, 17:33:51 »
I tried memPartFindMax with the attached patch, but I always get -1 as result from Lua. Any ideas why?
Quote
extern int partId_for_memPartFindMax; // camera specific constant, see stubs_min.S
DEF(partId_for_memPartFindMax, 0x1197C)
Incorrect. Do not use variable at specified address at this call, use constant number.
It is big difference between:

some_func(1234)

and

int x; // located at 1234 address
some_func(x);  // x=?

Maybe in sub/nnn/lib.c for  you can define:

int get_number_for_mempartfindmax(void){
 return NNNN;
}

and then call _memPartFindMax(get_number_for_mempartfindmax());

 

*

Offline reyalp

  • ******
  • 14118
Re: Free RAM OSD
« Reply #9 on: 01 / February / 2009, 17:39:30 »
Don't forget what the H stands for.

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal