Free RAM OSD - page 2 - Feature Requests - CHDK Forum

Free RAM OSD

  • 13 Replies
  • 9166 Views
*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #10 on: 02 / February / 2009, 14:11:49 »
Advertisements
Thanks ewavr, I ment to check check how those min stubs work but forgot all about it ???.

It works now, fixed patch (against trunk 701) attached in case someone wants to play around with it (it can likely be made to work to any vxworks camera pretty easily). Still no dedicated OSD, but for test purposes this can already be easily put into debug misc osd or made replace battery voltage indicator with kiB free, for instance.


It would be nice if someone found a similar function for dryos, and even nicer if we'd have actual free RAM too (instead of just largest available continuous block).


*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #11 on: 04 / February / 2009, 17:35:05 »
Attached a patch tested on trunk 701 (a570 100e). It does apply to trunk 704 and seems to build on a570 100e and s3is 100a (no, not implemented for s3, just tested it builds for a cam that doesn't have the stubs), but didn't try that one yet.

It's similar to my previous patch, but this also adds free RAM OSD (largest continuous, mallocable block in kiB i.e. it shows a number less than total free RAM when RAM is fragmented). It can be turned on in misc->debug menu (this patch adds config values for enable/disable RAM OSD and its position, so be careful with .cfg files in case you use this build in case someone introduces a feature in trunk with different uses for the next two config slots). This is the first time I've touched the config or menu stuff, I hope it's not too screwed up.

Again, only a570 100e/101a, but vxworks cams should only need a stub for memPartFindMax (found by IDA signatures, e.g. from PhyrePhoxes func lists) and partId to lib.c from malloc as suggested by ewavr in earlier post in this thread (see a570 100e lib.c).

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #12 on: 05 / February / 2009, 18:09:47 »
In case someone wants to test it but doesn't have a570, below automatically found stubs (from PhyrePhox's function lists from IDA exports) and addresses (from disassemblies, I'm taking it from memAddToPool instead of malloc because malloc doesn't seem to be as commonly found in the function lists).

grep memPartFindMax platform/*/sub/*/stubs_entry_IDA*.S
platform/a450/sub/100d/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFCCB428)
platform/a460/sub/100d/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFCCB420)
platform/a530/sub/100a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFECA1FC)
platform/a540/sub/100b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEDFC30)
platform/a550/sub/100c/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFCC6E14)
platform/a560/sub/100a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFCD03C4)
platform/a570/sub/100e/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFCD8844)
platform/a570/sub/101a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFCD8844)
platform/a610/sub/100e/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEBDB68)
platform/a610/sub/100f/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEBDEF0)
platform/a620/sub/100f/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEC488C)
platform/a630/sub/100c/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEF1F44)
platform/a640/sub/100b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEFBE6C)
platform/a700/sub/100b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEE7188)
platform/a710/sub/100a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFEFF78C)
platform/g7/sub/100e/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB9D72C)
platform/g7/sub/100g/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB9D8B4)
platform/g7/sub/100i/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB9D904)
platform/g7/sub/100j/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB9D98C)
platform/ixus50_sd400/sub/101a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFABD8AC)
platform/ixus50_sd400/sub/101b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFABD900)
platform/ixus55_sd450/sub/100b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAD5838)
platform/ixus55_sd450/sub/100c/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAD5764)
platform/ixus55_sd450/sub/100d/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAD5AEC)
platform/ixus60_sd600/sub/100a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB0A518)
platform/ixus60_sd600/sub/100d/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB0B0F8)
platform/ixus65_sd630/sub/100a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB141DC)
platform/ixus700_sd500/sub/101a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFABB8E8)
platform/ixus700_sd500/sub/101b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFABB938)
platform/ixus70_sd1000/sub/100c/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF91EE8C)
platform/ixus70_sd1000/sub/101b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF91EE8C)
platform/ixus70_sd1000/sub/102a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF91EE8C)
platform/ixus750_sd550/sub/100f/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAD5340)
platform/ixus750_sd550/sub/100g/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAD5340)
platform/ixus75_sd750/sub/100b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF929270)
platform/ixus75_sd750/sub/101a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF929270)
platform/ixus75_sd750/sub/102a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF929270)
platform/ixus800_sd700/sub/100b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB0DCA4)
platform/ixus800_sd700/sub/101b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB0DC9C)
platform/ixus850_sd800/sub/100e/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB60480)
platform/ixus950_sd850/sub/100c/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF92A6CC)
platform/ixusizoom_sd30/sub/100g/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAD232C)
platform/s2is/sub/100e/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAF61CC)
platform/s2is/sub/100f/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAF624C)
platform/s2is/sub/100g/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFAF5FD8)
platform/s3is/sub/100a/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFFB55EA4)
platform/tx1/sub/100g/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF92A148)
platform/tx1/sub/101b/stubs_entry_IDA_FLIRT.S:NSTUB(IDA_L_memPartFindMax, 0xFF92A148)


grep -A 5 "NSTUB(IDA_L_memAddToPool" platform/*/sub/*/PRIMARY.BIN.dis |grep ldr
platform/a450/sub/100d/PRIMARY.BIN.dis-ffccc74c:    e59f0084    ldr   r0, [pc, #132]   ; ffccc7d8: (000118ac)
platform/a460/sub/100d/PRIMARY.BIN.dis-ffccc744:    e59f0084    ldr   r0, [pc, #132]   ; ffccc7d0: (000118ac)
platform/a530/sub/100a/PRIMARY.BIN.dis-ffecb520:    e59f0084    ldr   r0, [pc, #132]   ; ffecb5ac: (0007443c)
platform/a540/sub/100b/PRIMARY.BIN.dis-ffee0f54:    e59f0084    ldr   r0, [pc, #132]   ; ffee0fe0: (00074574)
platform/a550/sub/100c/PRIMARY.BIN.dis-ffcc8138:    e59f0084    ldr   r0, [pc, #132]   ; ffcc81c4: (00010184)
platform/a560/sub/100a/PRIMARY.BIN.dis-ffcd16e8:    e59f0084    ldr   r0, [pc, #132]   ; ffcd1774: (000115ac)
platform/a570/sub/100e/PRIMARY.BIN.dis-ffcd9b68:    e59f0084    ldr   r0, [pc, #132]   ; ffcd9bf4: (0001197c)
platform/a570/sub/101a/PRIMARY.BIN.dis-ffcd9b68:    e59f0084    ldr   r0, [pc, #132]   ; ffcd9bf4: (0001197c)
platform/a610/sub/100e/PRIMARY.BIN.dis-ffebee8c:    e59f0084    ldr   r0, [pc, #132]   ; ffebef18: (00082e08)
platform/a610/sub/100f/PRIMARY.BIN.dis-ffebf214:    e59f0084    ldr   r0, [pc, #132]   ; ffebf2a0: (00082e08)
platform/a620/sub/100f/PRIMARY.BIN.dis-ffec5bb0:    e59f0084    ldr   r0, [pc, #132]   ; ffec5c3c: (00081c28)
platform/a630/sub/100c/PRIMARY.BIN.dis-ffef3268:    e59f0084    ldr   r0, [pc, #132]   ; ffef32f4: (00076c88)
platform/a640/sub/100b/PRIMARY.BIN.dis-ffefd190:    e59f0084    ldr   r0, [pc, #132]   ; ffefd21c: (000771b0)
platform/a700/sub/100b/PRIMARY.BIN.dis-ffee84ac:    e59f0084    ldr   r0, [pc, #132]   ; ffee8538: (0007e344)
platform/a710/sub/100a/PRIMARY.BIN.dis-fff00ab0:    e59f0084    ldr   r0, [pc, #132]   ; fff00b3c: (00081d20)
platform/g7/sub/100e/PRIMARY.BIN.dis-ffb9ea50:    e59f0084    ldr   r0, [pc, #132]   ; ffb9eadc: (00089a14)
platform/g7/sub/100g/PRIMARY.BIN.dis-ffb9ebd8:    e59f0084    ldr   r0, [pc, #132]   ; ffb9ec64: (00089a14)
platform/g7/sub/100i/PRIMARY.BIN.dis-ffb9ec28:    e59f0084    ldr   r0, [pc, #132]   ; ffb9ecb4: (00089a14)
platform/g7/sub/100j/PRIMARY.BIN.dis-ffb9ecb0:    e59f0084    ldr   r0, [pc, #132]   ; ffb9ed3c: (00089a14)
platform/ixus40_sd300/sub/100j/PRIMARY.BIN.dis-ffac58bc:    e59f0084    ldr   r0, [pc, #132]   ; ffac5948: (0006f4b0)
platform/ixus40_sd300/sub/100k/PRIMARY.BIN.dis-ffac58e4:    e59f0084    ldr   r0, [pc, #132]   ; ffac5970: (0006f4b0)
platform/ixus50_sd400/sub/101a/PRIMARY.BIN.dis-ffabebd0:    e59f0084    ldr   r0, [pc, #132]   ; ffabec5c: (00077e80)
platform/ixus50_sd400/sub/101b/PRIMARY.BIN.dis-ffabec24:    e59f0084    ldr   r0, [pc, #132]   ; ffabecb0: (00077e80)
platform/ixus55_sd450/sub/100b/PRIMARY.BIN.dis-ffad6b5c:    e59f0084    ldr   r0, [pc, #132]   ; ffad6be8: (0008b010)
platform/ixus55_sd450/sub/100c/PRIMARY.BIN.dis-ffad6a88:    e59f0084    ldr   r0, [pc, #132]   ; ffad6b14: (0008b010)
platform/ixus55_sd450/sub/100d/PRIMARY.BIN.dis-ffad6e10:    e59f0084    ldr   r0, [pc, #132]   ; ffad6e9c: (0008b010)
platform/ixus60_sd600/sub/100a/PRIMARY.BIN.dis-ffb0b83c:    e59f0084    ldr   r0, [pc, #132]   ; ffb0b8c8: (0007ecd4)
platform/ixus60_sd600/sub/100d/PRIMARY.BIN.dis-ffb0c41c:    e59f0084    ldr   r0, [pc, #132]   ; ffb0c4a8: (0007ed4c)
platform/ixus65_sd630/sub/100a/PRIMARY.BIN.dis-ffb15500:    e59f0084    ldr   r0, [pc, #132]   ; ffb1558c: (0007ef64)
platform/ixus700_sd500/sub/101a/PRIMARY.BIN.dis-ffabcc0c:    e59f0084    ldr   r0, [pc, #132]   ; ffabcc98: (00077d98)
platform/ixus700_sd500/sub/101b/PRIMARY.BIN.dis-ffabcc5c:    e59f0084    ldr   r0, [pc, #132]   ; ffabcce8: (00077d98)
platform/ixus70_sd1000/sub/100c/PRIMARY.BIN.dis-ff9201b0:    e59f0084    ldr   r0, [pc, #132]   ; ff92023c: (00012c44)
platform/ixus70_sd1000/sub/101b/PRIMARY.BIN.dis-ff9201b0:    e59f0084    ldr   r0, [pc, #132]   ; ff92023c: (00012c44)
platform/ixus70_sd1000/sub/102a/PRIMARY.BIN.dis-ff9201b0:    e59f0084    ldr   r0, [pc, #132]   ; ff92023c: (00012c44)
platform/ixus750_sd550/sub/100f/PRIMARY.BIN.dis-ffad6664:    e59f0084    ldr   r0, [pc, #132]   ; ffad66f0: (000812c0)
platform/ixus750_sd550/sub/100g/PRIMARY.BIN.dis-ffad6664:    e59f0084    ldr   r0, [pc, #132]   ; ffad66f0: (000812c0)
platform/ixus75_sd750/sub/100b/PRIMARY.BIN.dis-ff92a594:    e59f0084    ldr   r0, [pc, #132]   ; ff92a620: (00013094)
platform/ixus75_sd750/sub/101a/PRIMARY.BIN.dis-ff92a594:    e59f0084    ldr   r0, [pc, #132]   ; ff92a620: (00013094)
platform/ixus75_sd750/sub/102a/PRIMARY.BIN.dis-ff92a594:    e59f0084    ldr   r0, [pc, #132]   ; ff92a620: (00013094)
platform/ixus800_sd700/sub/100b/PRIMARY.BIN.dis-ffb0efc8:    e59f0084    ldr   r0, [pc, #132]   ; ffb0f054: (0007ef8c)
platform/ixus800_sd700/sub/101b/PRIMARY.BIN.dis-ffb0efc0:    e59f0084    ldr   r0, [pc, #132]   ; ffb0f04c: (0007ef8c)
platform/ixus850_sd800/sub/100e/PRIMARY.BIN.dis-ffb617a4:    e59f0084    ldr   r0, [pc, #132]   ; ffb61830: (0009ce78)
platform/ixus950_sd850/sub/100c/PRIMARY.BIN.dis-ff92b9f0:    e59f0084    ldr   r0, [pc, #132]   ; ff92ba7c: (00014e64)
platform/ixusizoom_sd30/sub/100g/PRIMARY.BIN.dis-ffad3650:    e59f0084    ldr   r0, [pc, #132]   ; ffad36dc: (0008a348)
platform/s2is/sub/100e/PRIMARY.BIN.dis-ffaf74f0:    e59f0084    ldr   r0, [pc, #132]   ; ffaf757c: (00069b58)
platform/s2is/sub/100f/PRIMARY.BIN.dis-ffaf7570:    e59f0084    ldr   r0, [pc, #132]   ; ffaf75fc: (00069b58)
platform/s2is/sub/100g/PRIMARY.BIN.dis-ffaf72fc:    e59f0084    ldr   r0, [pc, #132]   ; ffaf7388: (00069b78)
platform/s3is/sub/100a/PRIMARY.BIN.dis-ffb571c8:    e59f0084    ldr   r0, [pc, #132]   ; ffb57254: (00077e5c)
platform/tx1/sub/100g/PRIMARY.BIN.dis-ff92b46c:    e59f0084    ldr   r0, [pc, #132]   ; ff92b4f8: (00015818)
platform/tx1/sub/101b/PRIMARY.BIN.dis-ff92b46c:    e59f0084    ldr   r0, [pc, #132]   ; ff92b4f8: (00015818)

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Free RAM OSD
« Reply #13 on: 11 / February / 2009, 17:02:37 »
Attached is a final(?) patch to current trunk (707) and a Lua script to test it. Developers please try it (even if you only have access to a DryOS cam, you can still try it to verify the Lua command works as its supposed to (= partially but usefully).

make batch-zip-complete built fine for me, but I can only test a570 100e.

1) Added free RAM OSD and menu items, config values, and OSD layout editor entry to go with it. This is currently available for VxWorks cameras only (30 cameras, 50 subs... make gave me 51 vxworks subs, I'm too tired to figure out which one is missing if any). There are three modes:

  - Warning (default): Draw only when free RAM falls below threshold (default 128 kiB), use OSD warn color  (red by default).
  - Off: Never drawn.
  - On: Always drawn. When free RAM falls below threshold, draw in OSD warn color (red by default).

The default warning threshold is set so that it's a bit higher than default dynamic zebra requirement. I put these settings to Misc->Debug menu instead of OSD menu because I think this is something that users don't typically need to tweak unless they are low in RAM and are already aware of that.

2) Added new function to Lua to return the amount of free memory (RAM) available (to camera firmware itself and hence CHDK as well), in bytes.

Result does not include RAW or OSD buffers or any other part of RAM that is not readily available to generic use by CHDK, even though they may be writeable. Technically the returned number is not total amount of free RAM, instead it is size of the largest continuous block available for allocation using malloc. When RAM is fragmented, the result returned by this function is smaller than real available RAM. But keep in mind that when CHDK allocates memory, it often requires large continuous blocks (edge overlay and zebra are notorious examples), making this number very relevant.

The VxWorks operating system used in older cameras has a function (memPartFindMax from memPartLib) which returns this number. A matching function has not yet been found in DryOS.

On DryOS the command can only execute a brute force test which attempts to malloc RAM until it finds the limit. Because this test is very brutal and should only be done for debug and test purposes, this RAM test script command has an input parameter to control its operation. For test purposes, malloc test can also be executed on VxWorks cameras.

Usage:

free_RAM_in_bytes = get_free_mem(N)

where

N=0: Call memPartFindMax (VxWorks). If no such function (DryOS), return nil.
N=1: Call memPartFindMax if available (VxWorks), otherwise execute malloc test (DryOS).
N=2: Execute malloc test (all cameras).

Note: I didn't add a command for uBASIC, because we're less likely to run out of RAM with it
and as such it's not a necessity.

3) Moved misc menu malloc test to a separate function  so that it could be reused in scripts.


To enable this properly in any vxworks cam that I may have missed or not yet ported, look at a570 platform source and disassembly for an example when in trouble. In short:
* Find stub for MemPartfindMax, add it to stubs_entry_2.S. IDA finds this from signatures, but it failed on ixus40_sd300 and may fail on others too. Its located after valloc() in disassembly for both cams I had to take a look at.
* Find partition id for MemPartfindMax and add function to lib.c. Look at lib.c of a570 for a hint.
* Add camera.h define (#define CAM_MEMPARTFINDMAX 1) to enable all the code.
* Build, then run ramtst.lua to test the function. ram2 and ram1 should be equal, ram0 should be equal or almost equal.


PS. the patch also changes default zebra mode from blink2 to zebra1.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal