A thought - if we can safely use all this 'exmem' memory why not load CHDK itself into this address space?That way there would be more memory available to add features and the default camera heap would be left untouched.Regards,Phil.
"LDR R3, =0x00400000 \n" // buffer start "LDR R1, =0x08000000 \n" // buffer end "LDR R2, =0xDEADBEEF \n" // guard value"fill_guard: \n" "CMP R3, R1\n" "STRCC R2, [R3],#4\n" "BCC fill_guard\n"
if (gui_mode==GUI_MODE_ALT) { unsigned long* p = (unsigned long*)0x00400000; unsigned long *first = 0, *last = 0; unsigned long *lstart = 0, *lend = 0; long len = 0; long cnt = 0; int state = 0; while (p < (unsigned long*)0x08000000) { if (*p != 0xDEADBEEF) { if (state == 1) { if (cnt > len) { lstart = first; lend = last; len = cnt; } state = 0; cnt = 0; } } else { if (state == 1) { last = p; cnt++; } else { first = last = p; cnt = 1; state = 1; } } p++; } if (cnt > len) { lstart = first; lend = last; cnt = len; } sprintf(osd_buf, "f:%8x l:%8x c:%d", lstart, lend, len); draw_txt_string(2, 10, osd_buf, conf.osd_color); }
I test now in IX10008 megabyte is what i test and work.16 megabyte and more crash on shoot, (i use this new memory not for chdk).so seem the camera report then too low mem and exit.when i records a 19280*1028 video, there are always 1,7 megabyte at front overwritten.when show a video there are 900 kb overwritten.this are the largest overwritten space i get.when record video at 1280*720 or show, overwritten memspace is smaller.same happen on highspeed mode.nightshoot mode overwrite no memory.also the other shoot modes that take several pictures and calc do not overwrite mem and work with 8 megabyte.so in theory can say, when alloc 8 megabyte and set the mem start to + 4 megabyte it should work and we have 4 megabyte for chdk and 2.3 megabyte security gap on beginning.I see address of memfree are same as on SX30 when alloc 4 megabyte.but for 8 megabyte, i get this addresses 77ffffe0 7fffffe0I do more test with that setting 8 megabyte and 2 megabyte gap on start for test worst case, and see if on more use the membounds get overwritten.if that after longer testing not happen, then this seem work stable and even more when the gap is set to 4 megabyte.I have a little enhance the testcode by use global var so i need no absolute addresses, to make more easy to test several sizes.[code=c]#ifdef OPT_EXMEM_MALLOC void *mem_exmem_heap; // I set this up to 16 mb and it still booted... // on IX1000 1,7 meg max get overwritten on start and 8 megabyte of mem alloc work. #define EXMEM_HEAP_SIZE (1024*1024*8) // these aren't currently needed elsewhere /* void * exmem_alloc(unsigned pool_id, unsigned size) { return _exmem_alloc(pool_id,size,0); } void exmem_free(unsigned pool_id) { _exmem_free(pool_id); } */ static void *exmem_heap; void *suba_init(void *heap, unsigned size, unsigned rst, unsigned mincell); void *suba_alloc(void *heap, unsigned size, unsigned zero); int suba_free(void *heap, void *p); void exmem_malloc_init() { // pool zero is EXMEM_RAMDISK on d10 void *mem = _exmem_alloc(0,EXMEM_HEAP_SIZE,0); mem_exmem_heap = mem;
extern void *mem_exmem_heap;void gui_draw_debug_vals_osd() {#ifdef OPT_DEBUGGING // check exmem allocated memory for corruption (assumes 8MB allocated) unsigned long* p = mem_exmem_heap;//(unsigned long*)0x07BFFFE0;// strcpy(osd_buf,"OK"); sprintf(osd_buf,"Start %8x End%8x ok",p,mem_exmem_heap +(1024*1024*8)); unsigned long *f = 0; long cnt = 0; while (p <= (unsigned long*)( mem_exmem_heap+ (1024*1024*8))) { if (p[0] != 0xDEADBEEF) { if (f == 0) f = p; cnt++; } p++; } if (cnt != 0)sprintf(osd_buf, "%8x %8x %8x", &f[0], f[0], cnt); draw_txt_string(2, 10, osd_buf, conf.osd_color); // end of check
Unless my testing method is wrong (which I would be happy if it were), it looks like most of the available memory is used at some time or other during normal camera operations.
Quote from: philmoz on 04 / January / 2011, 04:20:00Unless my testing method is wrong (which I would be happy if it were), it looks like most of the available memory is used at some time or other during normal camera operations.In general, I'd expect the canon firmware to use most of the memory. However, just because it's touched doesn't mean that it's all in use simultaneously, or that the camera would necessarily need it all if you allocated some of it.Another idea:It might be possible to change where the firmware thinks exmem starts/ends, as we do with the malloc heap.background:CHDK loads where the normal heap would start, the new_sa bit in boot.c modifies that, effectively taking away from malloc memory without ever using malloc. Note that the camera memShow() eventproc does *not* reflect the the CHDK change, because the heap start is presumably a compile time constant in the canon code. It just so happens that we can change it one place and have it work. Depending on how exmem is setup, this may not be possible.
After reading your post it occurred to me that if the camera is using a memory manager then the camera may have crashed because I had allocated too much memory and it couldn't get enough when I pressed the shutter. I'll do some more testing to see if this is the case.
void free(void *p) { if(exmem_heap && (p >= exmem_heap)) suba_free(exmem_heap,p); else _free(p);}
So now the problem is what extra initialisation is needed, and where can the call to exmem_malloc_init be done that works all the time?
A suggestion for the exmem version of free. If the code is changed to:Code: [Select]void free(void *p) { if(exmem_heap && (p >= exmem_heap)) suba_free(exmem_heap,p); else _free(p);}then if a _malloc allocated address is passed in it will use _free instead of suba_free.
@reyalp>In general, I'd expect the canon firmware to use most of the memory.maybe on new camera not.its maybe more easy, cheaper and need less power, to add a 64 megabyte mem chip instead add a 32 mb+ 4 mb chip, if you need only 35 MB.
Started by Microfunguy General Discussion and Assistance
Started by mp9_sit Script Writing
Started by Barney Fife Completed and Working Scripts
Started by Lebeau General Discussion and Assistance
Started by CanonBlue General Help and Assistance on using CHDK stable releases