Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: scrax on June 27, 2012, 12:30:43 AM

Title: Development stupid questions
Post by: scrax on June 27, 2012, 12:30:43 AM
I'm total noob in developing for arm, or better developing in general, so I have a lot of confusion and stupid question to do. I hope that this will be the right place.
I'll use this topic to post what I don't understand looking the sources.

First question is what language is written on? I suppose C but I'm not sure.

another (little) more technical question is, in debug.c :

    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/DATA/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/SETTINGS/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/CROPMKS/", 1);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/SCRIPTS/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/PLUGINS/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/DOC/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE "ML/LOGS/", 0);
    CopyMLDirectoryToRAM_BeforeFormat(CARD_DRIVE, 0);

what is the 0 for? and why cropmks have 1? I've put 0 for all the new folders but don't know is it correct. Maybe also data needs 1 or settings?
Title: Re: Development stupid questions
Post by: a1ex on June 27, 2012, 12:42:48 AM
That 0 is cropmarks_flag: it tells ML to copy only bitmaps from that folder, not other files.

Language is C.
Title: Re: Development stupid questions
Post by: scrax on June 27, 2012, 03:44:59 AM
Quote from: a1ex on June 27, 2012, 12:42:48 AM
That 0 is cropmarks_flag: it tells ML to copy only bitmaps from that folder, not other files.

thank's, now I see that with a little more search maybe it was easy to understand:
void CopyMLDirectoryToRAM_BeforeFormat(char* dir, int cropmarks_flag)
.....
        if (cropmarks_flag && !is_valid_cropmark_filename(file.name)) continue;
Title: Re: Development stupid questions
Post by: Harsher on July 21, 2012, 04:10:44 PM
I will up this topic for my own stupid questions;)
I became a bit proficient in Java, but am still not versed enough in C yet.
Is it possible to develop something for ML or the firmware in Java or not?
Title: Re: Development stupid questions
Post by: nanomad on July 21, 2012, 05:56:31 PM
No
Title: Re: Development stupid questions
Post by: Harsher on July 21, 2012, 06:34:11 PM
Thanks. Guess I'll have to learn some more so.
Title: Re: Development stupid questions
Post by: nanomad on July 21, 2012, 06:50:10 PM
Actually, you can probably code tools to make ML usage easier
Title: Re: Development stupid questions
Post by: scrax on November 21, 2012, 10:44:10 PM
I'm reading on the wiki a all what i can found about developing and extending ML, and so I'm back with some new stupid question for going on on what I'm trying to do.

First, I have not yet understood how to use hg well, I don't know how to be sure that I have exactly the exact copy without my modification, so usually I end up with making another clone in another folder, that way I have 5 folder with ML on 2 HD one with the fork I made that i can't sync it anymore, two with the test for 600D audio, one with tragiclantern, and one that was almost untouched from nightly (but today it became the one with my last test, so probably tomorow or in future i'll have another clone for last clean code....)  :-\
My idea is to make a new fork for my test only, add to that what i'll keep from the old fork and then delete it. then make a clone of MLsource and use that just to check it agains my builds (so on that will use hg pull - hg update only, right?).

Another problem I found is if I want to use something like this for example:
ifdef CONFIG_SCRAX
to be able to compile my fork with or without my code, or that:
ifdef CONFIG_NOVIDEO
to remove code used only for video (so to have more memory) or things I don't use.
but I've no clue how to put CONFIG_SCRAX for it to be true, in makefile I suppose but where exactly (under FLAGS probably, but also in the page), and how? I think that some clean-up did by A1ex had this, but when i tried it didn't worked.

about the menu item creations on the wiki (http://magiclantern.wikia.com/wiki/Extending_Magic_Lantern) I suppose that it's about old backend, since with submenu items I found some differences on the actual code.
I found that page very helpful and I'll go on in trying to understand it, just to give me a little hint, where can i find a sort of list of, for example, how all the icons used are called (also in the code, maybe)?
so far to find out those thing i do a search in the src folder   for ".icon_type" and then I manually check each result to understand which is which. If nothing found i usually extend the search to all repo.

Title: Re: Development stupid questions
Post by: ubbut on November 21, 2012, 11:28:26 PM
Quote
but I've no clue how to put CONFIG_SCRAX for it to be true, in makefile I suppose but where exactly (under FLAGS probably, but also in the page), and how?

In the makefile add:  CFLAGS += -D YOURDEFINE=YOURVALUE
Title: Re: Development stupid questions
Post by: scrax on November 22, 2012, 12:44:46 AM
Quote from: ubbut on November 21, 2012, 11:28:26 PM
In the makefile add:  CFLAGS += -D YOURDEFINE=YOURVALUE

Thank's
that means that i can have also just SCRAX without _ in it. for YOURDEFINE and 1 for making it true?
Like this:
CFLAGS += -D SCRAX=1
Title: Re: Development stupid questions
Post by: scrax on November 27, 2012, 05:17:38 PM
Quote from: coutts on November 27, 2012, 02:49:08 AM
0x4D810 --> value=0x11100 when screen isn't being touched, value=0x11101 when 1 finger is held touching the screen
            --> value=0x11102 with 2 fingers touching the screen
            --> value=0x11103 with 3 fingers
            --> value=0x1104 with 4 fingers! Note: only the LSB seems to be used here, other bits seem to change sometimes. but the rightmost bit always changes to match how many fingers are touching the screen.

That part of ML is the most obscure to me, with my little knowledge.
1) 0x4D810 is a memory address in the camera ram where are saved some value used and changed by the firmware, right?
2) In ML for each camera supported we have a consts.h file where a name is given to each one of those understood/discovered ram address (touch_num_fingers_ptr in that case).
3) value=0x11100 each number saved here can have some meaning like how many fingers with the last one
4) It's possible to give a name to the value too saved in consts.h , like:
#define FINGER_TOUCH_NONE 0x11100
#define FINGER_TOUCH_ONE 0x11101
#define FINGER_TOUCH_TWO 0x11102...
memspy in ML is used to find those numbers when pressing buttons, changing options and so on on the camera...
5) stubs.S instead is a file with a list of discovered/understood functions of the firmware, that can be used by ML to perform his tasks
Am I correct?
Title: Re: Development stupid questions
Post by: scrax on November 30, 2012, 02:27:59 AM
how to compile with debug on? so to so mem spy and props?
Title: Re: Development stupid questions
Post by: jplxpto on November 30, 2012, 02:56:43 AM
Quote from: scrax on November 30, 2012, 02:27:59 AM
how to compile with debug on? so to so mem spy and props?

You can create Makefile.user from Makefile.user.default and define this:

CONFIG_DEBUGMSG     = 1
Title: Re: Development stupid questions
Post by: scrax on November 30, 2012, 07:18:35 AM
Quote from: jplxpto on November 30, 2012, 02:56:43 AM
You can create Makefile.user from Makefile.user.default and define this:

CONFIG_DEBUGMSG     = 1

Thanks, I was using -DCONFIG_DEBUGMSG (maybe was just too late or too tired) and so it didn't worked
Title: Re: Development stupid questions
Post by: jplxpto on November 30, 2012, 12:02:38 PM
Quote from: scrax on November 30, 2012, 07:18:35 AM
Thanks, I was using -DCONFIG_DEBUGMSG (maybe was just too late or too tired) and so it didn't worked


you have to do:

make clean
make
Title: Re: Development stupid questions
Post by: scrax on November 30, 2012, 07:17:41 PM
Quote from: jplxpto on November 30, 2012, 12:02:38 PM

you have to do:

make clean
make
thanks, i did that with CONFIG_DEBUGMSG     = 1
make clean; make 600D
it's a bit more quick  :D
now that work time is over I have the time to use it
Title: Re: Development stupid questions
Post by: Greg on November 30, 2012, 08:08:42 PM
Quote from: jplxpto on November 30, 2012, 02:56:43 AM
You can create Makefile.user from Makefile.user.default and define this:

CONFIG_DEBUGMSG     = 1

I did this for the 500D. I received an error.  :o

http://www.youtube.com/watch?v=OZy7N5Yw-3M&feature=youtu.be
Title: Re: Development stupid questions
Post by: scrax on November 30, 2012, 08:28:59 PM
Quote from: Greg on November 30, 2012, 08:08:42 PM
I did this for the 500D. I received an error.  :o

http://www.youtube.com/watch?v=OZy7N5Yw-3M&feature=youtu.be
check the .log file on the card and post it
Title: Re: Development stupid questions
Post by: Greg on November 30, 2012, 08:35:29 PM
ASSERT00ML ASSERT:
PROP_LEN(80050007) = 0
at ../../src/property.c:227 (prop_request_change), task shoot_task
lv:0 mode:0


Magic Lantern version : v2.3.NEXT.2012Nov30.500D111
Mercurial changeset   : 394373540680 (unified) tip
Built on 2012-11-30 18:44:49 by greg@ubuntu.
Free Memory  : 351K + 2869K

CRASH00ASSERT: IS_ERROR( Err ) == FALSE
at Multicast\PropertyMgr.c:49, task PropMgr
lv:0 mode:0


Magic Lantern version : v2.3.NEXT.2012Nov30.500D111
Mercurial changeset   : 394373540680 (unified) tip
Built on 2012-11-30 18:44:49 by greg@ubuntu.
Free Memory  : 351K + 2854K
Title: Re: Development stupid questions
Post by: jplxpto on November 30, 2012, 11:54:48 PM
Quote from: scrax on November 30, 2012, 07:17:41 PM
thanks, i did that with CONFIG_DEBUGMSG     = 1
make clean; make 600D
it's a bit more quick  :D
now that work time is over I have the time to use it

Yes, I know, but I did not know you had a 600D. :)
Title: Re: Development stupid questions
Post by: scrax on December 04, 2012, 07:25:36 PM
Quote from: Greg on November 30, 2012, 08:35:29 PM
ASSERT00ML ASSERT:
PROP_LEN(80050007) = 0
at ../../src/property.c:227 (prop_request_change), task shoot_task
lv:0 mode:0


Magic Lantern version : v2.3.NEXT.2012Nov30.500D111
Mercurial changeset   : 394373540680 (unified) tip
Built on 2012-11-30 18:44:49 by greg@ubuntu.
Free Memory  : 351K + 2869K

CRASH00ASSERT: IS_ERROR( Err ) == FALSE
at Multicast\PropertyMgr.c:49, task PropMgr
lv:0 mode:0


Magic Lantern version : v2.3.NEXT.2012Nov30.500D111
Mercurial changeset   : 394373540680 (unified) tip
Built on 2012-11-30 18:44:49 by greg@ubuntu.
Free Memory  : 351K + 2854K

I have no clue, but have you tryied to comment that definition? trials and errors is the way i learn  :D
from source looks related to ptp, have you it enabled?
#define PROP_LV_AFFRAME         0x80050007 // called by ptp handler 915a
Title: Re: Development stupid questions
Post by: scrax on December 04, 2012, 07:30:19 PM
Also i'm here with another easy/stupid question:
- Is possible to reload ML without restarting the camera from ML?
Maybe facking standby mode for a little?

by the way i can't find anymore the code for loading different autoexec posted here months ago, someone has it?
Title: Re: Development stupid questions
Post by: Pelican on December 29, 2012, 09:43:49 PM
I've tried to print the auto iso range with this line:
bmp_printf(fnt, 455, 92, "%d-%d", raw2iso(auto_iso_range >> 8 ) , raw2iso(auto_iso_range % 0xff));
and I've got strange value for the max.
After I check the raw values I found this
if auto_iso_range is 0x4860
then  auto_iso_range >>8 is 0x48 (good) but auto_iso_range % 0xff is 0xa8 ! (wrong) which is exactly 0x48 + 0x60
I'm not really a hardcore C programmer so I couldn't figure out what circumstances causes this result.
It happens with other values too (between 0x4858 and 0x4878)

Any idea?
Title: Re: Development stupid questions
Post by: Floont on December 29, 2012, 11:10:11 PM
Quote from: Pelican on December 29, 2012, 09:43:49 PM
I've tried to print the auto iso range with this line:
bmp_printf(fnt, 455, 92, "%d-%d", raw2iso(auto_iso_range >> 8 ) , raw2iso(auto_iso_range % 0xff));
and I've got strange value for the max.
After I check the raw values I found this
if auto_iso_range is 0x4860
then  auto_iso_range >>8 is 0x48 (good) but auto_iso_range % 0xff is 0xa8 ! (wrong) which is exactly 0x48 + 0x60
I'm not really a hardcore C programmer so I couldn't figure out what circumstances causes this result.
It happens with other values too (between 0x4858 and 0x4878)

Any idea?
The % sign in C is the modulus operator.  Your code is calculating 0x4860 (18528 decimal) mod 0xff (255 decimal), which is 0xa8 (168 decimal).  What you actually want is the low byte of auto_iso_range, which can be retrieved either by changing 0xff to 0x100 in your existing code or simply using the & operator instead of the "%" operator (my preference), i.e. raw2iso(auto_iso_range & 0xff).
Title: Re: Development stupid questions
Post by: scrax on December 30, 2012, 03:06:58 AM
on 600D:

bg = bmp_getpixel(590, 28);
uint32_t fnt = FONT(FONT_MED, COLOR_FG_NONLV, bg);

if (lens_info.raw_iso == 0) // ISO: AUTO
{
            int maxiso=(auto_iso_range %  0xFF) - (auto_iso_range >> 8);
            bmp_printf(fnt, 590, 28, "MAX:%d",raw2iso(maxiso) );
}
   

this:
(http://images.wikia.com/magiclantern/images/4/45/Max_iso.png)
Title: Re: Development stupid questions
Post by: 1% on December 30, 2012, 03:52:52 AM
Code for autoexec loading is:

https://bitbucket.org/OtherOnePercent/tragic-lantern/src/28c47618ad8f/src/debug.c?at=unified
Title: Re: Development stupid questions
Post by: Pelican on December 30, 2012, 08:59:05 PM
Quote from: Floont on December 29, 2012, 11:10:11 PM
The % sign in C is the modulus operator.  Your code is calculating 0x4860 (18528 decimal) mod 0xff (255 decimal), which is 0xa8 (168 decimal).  What you actually want is the low byte of auto_iso_range, which can be retrieved either by changing 0xff to 0x100 in your existing code or simply using the & operator instead of the "%" operator (my preference), i.e. raw2iso(auto_iso_range & 0xff).
Yes, you are right, thank you!
I've figured out last night...
Title: Re: Development stupid questions
Post by: meeok on January 03, 2013, 04:22:09 PM
Seems like a waste to start a new thread... so here is my question:

Why doesn't %15s work when %s does?
snprintf(buf,1024,"%15s : %08X", "My Register", data);
I understand our stdio.c is a bit hacked but the underlying function is still canon... surely it implements this feature?

Title: Re: Development stupid questions
Post by: nanomad on January 03, 2013, 04:37:36 PM
It should but maybe it doesn't
Title: Re: Development stupid questions
Post by: 1% on January 03, 2013, 10:03:24 PM
I've got another stupid question.

Why am I getting assertions when conditions like this are met:

ASSERT(len == 0x2f);

Isn't 2f the correct length, that's what everything else is using.

or this

ASSERT(buf[0] == 1 || buf[0] == 5 || buf[0] == 10);
   


Title: Re: Development stupid questions
Post by: meeok on January 04, 2013, 01:21:05 AM
static int8_t some_cfn[0x2f];
PROP_HANDLER(0x80010007)
{
    ASSERT(len == 0x2f);
    memcpy(some_cfn, buf, 0x2f);
}

Can we have more context?
Title: Re: Development stupid questions
Post by: 1% on January 04, 2013, 04:30:25 AM
I'm working on the 6D port and these asserts keep getting dropped.

One is from shoot.c the other is from 5dIII cfn that works for 6D too.

In that second one it looks like the length is supposed to be 2f so why does it assert? Or is len not 2f and that's why it asserts?
Title: Re: Development stupid questions
Post by: a1ex on January 04, 2013, 11:17:08 AM
The one with 1/5/10 is LiveView zoom; does the 6D use other values? (print them).

The 2f is camera-specific; print it and change it. If it's in CFn, just hardcode the new length.
Title: Re: Development stupid questions
Post by: meeok on January 05, 2013, 08:05:42 AM
Quote from: meeok on January 03, 2013, 04:22:09 PM
Why doesn't %15s work when %s does?
snprintf(buf,1024,"%15s : %08X", "My Register", data);
I understand our stdio.c is a bit hacked but the underlying function is still canon... surely it implements this feature?
What I ended up using:
void debug_intercept()
{
static int fidx = 0;
char name[30];
snprintf(name,30,CARD_DRIVE"dm%d.log",fidx);
if (!buf) {
buf = alloc_dma_memory(BUF_SIZE);
}
len = dump_cache(buf,BUF_SIZE);
dump_seg(buf, len, name);
NotifyBox(5000, "Saved %d bytes in %s.", len, name);
fidx++;
    beep();
}
static uint32_t dump_data(char* buf, uint32_t max_len, char* header, uint32_t data) {
if (!buf || !header) return 0;
/*uint32_t len1 = snprintf(buf, max_len, "                      : %08X ", data);
*(snprintf(buf,22,"%s",header)+buf)=":";*/
[b]#define SPACE10 "          "
uint32_t len1 = snprintf(buf, max_len, SPACE10 SPACE10 SPACE10 " : %08X ", data);
for (uint32_t i = 0; i <= len1 && header[i]; i++) buf[i] = header[i];[/b]
buf += len1;
uint32_t len2 = snprintf(buf,max_len-len1,"XXXX,XXXX XXXX,XXXX XXXX,XXXX XXXX,XXXX\n");
    for (int i = MIN(39-1,len2); i >= 0; i--) {
        *(buf+i) = ((data & 0x1) != 0) ? '1' : '0';
        data >>= 1;
        if (((i)%5) == 0) i--;
    }
    return len1 + len2;
}


static uint32_t dump_cache(char* buf, uint32_t max_len) {
if (!buf) return 0;

uint32_t data;
uint32_t len = 0;


#define dump_cacheMRC(op1, cIdx, cIdx2, op2, name) \
{asm volatile ("MRC p15, "#op1", %0, c"#cIdx", c"#cIdx2", "#op2 : "=r"(data)); \
len += dump_data(buf+len, max_len-len, #op1":c"#cIdx",c"#cIdx2":"#op2" "name, data);}

dump_cacheMRC(0,0,0,0, "ID");
dump_cacheMRC(0,0,0,1, "Cache Type");
dump_cacheMRC(0,0,0,2, "TCM Size");

dump_cacheMRC(0,1,0,0, "Control");

dump_cacheMRC(0,2,0,0, "DCache Cfg");
dump_cacheMRC(0,2,0,1, "ICache Cfg");

dump_cacheMRC(0,3,0,0, "Wr Buf Ctl");

dump_cacheMRC(0,5,0,0, "AccPerm D");
dump_cacheMRC(0,5,0,1, "AccPerm I");
dump_cacheMRC(0,5,0,2, "AccPerm Dx");
dump_cacheMRC(0,5,0,3, "AccPerm Ix");

dump_cacheMRC(0,6,0,0, "Protection");
dump_cacheMRC(0,6,1,0, "Protection");
dump_cacheMRC(0,6,2,0, "Protection");
dump_cacheMRC(0,6,3,0, "Protection");
dump_cacheMRC(0,6,4,0, "Protection");
dump_cacheMRC(0,6,5,0, "Protection");
dump_cacheMRC(0,6,6,0, "Protection");
dump_cacheMRC(0,6,7,0, "Protection");

dump_cacheMRC(0,7,5,0, "IC  Flush");
dump_cacheMRC(0,7,5,1, "IC1 Flush");
dump_cacheMRC(0,7,13,1,"IC Preftch");
dump_cacheMRC(0,7,6,0, "DC  Flush");
dump_cacheMRC(0,7,6,1, "DC1 Flush");
dump_cacheMRC(0,7,10,1,"DC  Clean");
dump_cacheMRC(0,7,14,1,"DC1 C/F");
dump_cacheMRC(0,7,10,2,"DC1 Clean");
dump_cacheMRC(0,7,14,2,"DC1 C/F");
dump_cacheMRC(0,7,10,4,"Drain");
dump_cacheMRC(0,7,0,4, "Sleep");
dump_cacheMRC(0,15,8,2,"SleepOld");

dump_cacheMRC(0,9,0,0, "DC Lock");
dump_cacheMRC(0,9,0,1, "IC Lock");
dump_cacheMRC(0,9,1,0, "DTCM");
dump_cacheMRC(0,9,1,1, "ITCM");

dump_cacheMRC(0,13,0,1,"PID");
dump_cacheMRC(0,13,1,1,"PID Old");

dump_cacheMRC(0,15,0,1,"TAG B Ctl");
dump_cacheMRC(1,15,1,1,"TCM B Ctl");
dump_cacheMRC(2,15,1,1,"CRM B Ctl");
dump_cacheMRC(0,15,0,2,"ITAG B Add");
dump_cacheMRC(0,15,0,3,"ITAG B Gen");
dump_cacheMRC(0,15,0,6,"DTAG B Add");
dump_cacheMRC(0,15,0,7,"DTAG B Gen");
dump_cacheMRC(1,15,0,2,"ITCM B Add");
dump_cacheMRC(1,15,0,3,"ITCM B Gen");
dump_cacheMRC(1,15,0,6,"DTCM B Add");
dump_cacheMRC(1,15,0,7,"DTCM B Gen");
dump_cacheMRC(2,15,0,2,"ICRM B Add");
dump_cacheMRC(2,15,0,3,"ICRM B Gen");
dump_cacheMRC(2,15,0,6,"DCRM B Add");
dump_cacheMRC(2,15,0,7,"DCRM B Gen");

dump_cacheMRC(0,15,0,0,"Test State");

dump_cacheMRC(3,15,0,0,"C Dbg Idx");
dump_cacheMRC(3,15,1,0,"I TAG");
dump_cacheMRC(3,15,2,0,"D TAG");
dump_cacheMRC(3,15,3,0,"I Cache");
dump_cacheMRC(3,15,4,0,"D Cache");

dump_cacheMRC(1,15,1,0,"Trace Ctrl");

#undef dump_cacheMRC

return len;
}

Let me know if it is worth committing.
Title: Re: Development stupid questions
Post by: 1% on January 05, 2013, 09:36:09 PM
ASSERT(len == 0x2f); - Not sure how to find the correct button code. Used event spy but af button, half shutter and star key give same event. What should I set them to to get the correct button code.

ASSERT(buf[0] == 1 || buf[0] == 5 || buf[0] == 10);- fixed. Camera has "X1" zoom mode that is supposed to be 1:1? It gives value of 129.

How do I find Frame ISO offsets? What functions should I look in. I'd like to get HDR working. Dunno how much more can get enabled only running the the small allocate memory. I tried jumping to the second memory pool but I think GUI task and slightly different setup prevent it from happening. Those register values in init_task_patched_for_600D are 0 in the 6D firmware. Even finding the right offsets led to camera booting without any GUI (but still taking pics, hheheh)
Title: Re: Development stupid questions
Post by: meeok on January 06, 2013, 03:03:14 PM

void draw_page_number(int page)
{
char pg[3];
snprintf(pg, sizeof(pg), "%3d", page);
bfnt_puts(pg, 650+(page<10 ? 14 : page<100 ? 4 : 0) , 2, COLOR_FG_NONLV, COLOR_BG);
}


My understanding is that snprintf will dump sizeof(pg)=3 characters in to pg. It will then write a 4th character of '\0'.
Does that mean "char pg[3];" allocates an array of length 3 or 4?
An integer array would logically be only 3 elements long. Hence with the char situation I think snprintf would overflow the array. Is this correct?

Bonus question: Would pg be allocated on the stack? Since no other variables were initialised would it overwrite the return address?
Title: Re: Development stupid questions
Post by: nanomad on January 06, 2013, 03:32:40 PM
Quote from: meeok on January 06, 2013, 03:03:14 PM
Does that mean "char pg[3];" allocates an array of length 3 or 4?
An integer array would logically be only 3 elements long. Hence with the char situation I think snprintf would overflow the array. Is this correct?
Correct, it's a common C mistake
Title: Re: Development stupid questions
Post by: g3gg0 on January 06, 2013, 03:45:34 PM
Quote from: meeok on January 06, 2013, 03:03:14 PM
Bonus question: Would pg be allocated on the stack? Since no other variables were initialised would it overwrite the return address?

yes, its on stack and yes, it will overwrite return address or R0,.... partially ;)
(it depends on the compiler output, if it saves R0, ...on stack)
Title: Re: Development stupid questions
Post by: meeok on January 06, 2013, 04:21:57 PM
Quote from: g3gg0 on January 06, 2013, 03:45:34 PM
yes, its on stack and yes, it will overwrite return address or R0,.... partially ;)
(it depends on the compiler output, if it saves R0, ...on stack)
Quote from: nanomad on January 06, 2013, 03:32:40 PM
Correct, it's a common C mistake
Thanks
There is a LOT of this in the code. I'm surprised ML doesn't crash instantly. Or are we missing something?

.text
#define NSTUB(addr,name) \
.global name; \
name = addr
NSTUB(0xFF2C12A8, shamem_read)

Am I correct in assuming assembly defined functions such as shamem_read don't have any kind of type safety? shamem_read(x,45678,"gfdfgs")  compiles :-/
Title: Re: Development stupid questions
Post by: a1ex on January 06, 2013, 06:16:02 PM
For assembly functions, you can define a prototype in dryos.h and get type safety. If not, it uses an implicit declarations (all parameters are int).

Edit: did some tests for snprintf, it doesn't behave as described in http://pubs.opengroup.org/onlinepubs/9699919799/functions/snprintf.html


    char x[4];
    snprintf(x, sizeof(x), "%d", 1234);
    printf("'%s'\n", x);


gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5) displays '123'.

ML displays '1234'.

Edit 2: snprintf now behaves correctly :)
Title: Re: Development stupid questions
Post by: meeok on January 10, 2013, 11:45:29 AM
Nice a1ex.

Is alexdu still around? Last commit to https://github.com/alexdu/ARM-console was 6months ago.
Title: Re: Development stupid questions
Post by: g3gg0 on January 10, 2013, 12:49:34 PM
alexdu changed his gender and his name and is called now a1lex ;P
Title: Re: Development stupid questions
Post by: meeok on January 10, 2013, 12:54:33 PM
Quote from: g3gg0 on January 10, 2013, 12:49:34 PM
alexdu changed his gender and his name and is called now a1lex ;P
Excellent! So any pointers on getting ARM_Console running?

I'm having memory problems: My virtual machine with 1GB of memory is crying.

With regards to function naming etc: Are there any updates that I've missed? I don't want to reinvent the wheel.
Title: Re: Development stupid questions
Post by: nanomad on January 10, 2013, 07:43:27 PM
My VM with 4 gigs gives up when analyzing EOSM+650D. I feel your pain  :'(

The best suggestion is to stick with Ubuntu 10.01 (or something like that). ARM-Console works fine there (I spent too much time figuring out how to run it on a newer distro and just gave up)
Title: Re: Development stupid questions
Post by: eduperez on January 11, 2013, 08:32:24 AM
Quote from: nanomad on January 06, 2013, 03:32:40 PM
Correct, it's a common C mistake

Quote from: meeok on January 06, 2013, 04:21:57 PM
There is a LOT of this in the code. I'm surprised ML doesn't crash instantly. Or are we missing something?

The compiler probably aligns every variable to a 4-byte boundary; so while the fourth byte is not properly reserved, it is not used, either.
Title: Re: Development stupid questions
Post by: meeok on January 11, 2013, 09:24:54 AM
Anyone have function names etc for 550D.119?
Title: Re: Development stupid questions
Post by: 1% on January 11, 2013, 06:20:27 PM
I got console running on mint 13. I think you need 2 older versions of some python things.

Anyways, the function naming can be done automatically with a script from a1ex.

My 16GB quad didn't do any better than my 4gb core2 32 bit. It will take days... took a long time to do the 6D firmware. Some functions are too big or lead the emulator to dead ends so I had to watch it and occasionally ctrl-C when it got stuck. I'm guessing if you just prod around on individual functions they'll either decompile or get stuck. Some stuff says too comlex or just cuts off in the HTML. I tried re-doing some of those for 600D and it sometimes did better but usually not. It will also overwrite HTML if you do this so unless you're just doing one function or have a backup, be careful to not lose days of work.
Title: Re: Development stupid questions
Post by: scrax on February 03, 2013, 01:28:48 PM
I'm having a little problem showing Kelvin values with this code:
bfnt_puts( lens_info.kelvin, 300, 166, fc, bg);
instead of numbers I got characters on screen, so probably it needs something like this:
int str = convert_to_string(lens_info.kelvin);
bfnt_puts( str, 300, 166, fc, bg);


but I don't know the correct name for convert_to_string or for the right way to do this.
Any help?
[/s]

solved:

                        char msg[6];
                        snprintf(msg, sizeof(msg), "%d", lens_info.kelvin);
                        bfnt_puts("Kelvin", 320, 111, fc, bg);
                        bfnt_puts(msg, 300, 166, fc, bg);

How it is now was before:
(https://dl.dropbox.com/u/123918/MagicLantern/bleeding-edge/kelvin.png)

now time to center it better
Title: Re: Development stupid questions
Post by: eduperez on February 03, 2013, 01:53:55 PM
Quote from: scrax on February 03, 2013, 01:28:48 PM
I'm having a little problem showing Kelvin values with this code:
bfnt_puts( lens_info.kelvin, 300, 166, fc, bg);
instead of numbers I got characters on screen, so probably it needs something like this:
int str = convert_to_string(lens_info.kelvin);
bfnt_puts( str, 300, 166, fc, bg);


but I don't know the correct name for convert_to_string or for the right way to do this.
Any help?

What you need is bmp_printf:

bmp_printf(uint32_t fontspec, int x, int y, const char *fmt, ...);

First parameters should be familiar to you; then comes a string with the output format, and then the values you want to print. The format follows the standard for the "printf" family. For example:

bmp_printf(FONT_SMALL, 0, 0, "%i", lens_info.kevin);

should do what you need (but I haven't tested it myself, however).
Title: Re: Development stupid questions
Post by: scrax on February 03, 2013, 02:15:33 PM
Quote from: eduperez on February 03, 2013, 01:53:55 PM
What you need is bmp_printf:

bmp_printf(uint32_t fontspec, int x, int y, const char *fmt, ...);

First parameters should be familiar to you; then comes a string with the output format, and then the values you want to print. The format follows the standard for the "printf" family. For example:

bmp_printf(FONT_SMALL, 0, 0, "%i", lens_info.kevin);

should do what you need (but I haven't tested it myself, however).
Thank's Edu,
Yes with this I have the numbers like in the screenshoot, but I wanted to have the more rounded and bigger one like Kelvin text, that's why I want to use bfnt_puts

Is there maybe a FONT_HUGE or some fontspec that works without use bfnt_puts?

that worked for me:

                        char msg[6];
                        snprintf(msg, sizeof(msg), "%d", lens_info.kelvin);
                        bfnt_puts("Kelvin", 320, 111, fc, bg);
                        bfnt_puts(msg, 300, 166, fc, bg);
Title: Re: Development stupid questions
Post by: eduperez on February 03, 2013, 04:44:20 PM
Quote from: scrax on February 03, 2013, 02:15:33 PM
Thank's Edu,
Yes with this I have the numbers like in the screenshoot, but I wanted to have the more rounded and bigger one like Kelvin text, that's why I want to use bfnt_puts

Is there maybe a FONT_HUGE or some fontspec that works without use bfnt_puts?

that worked for me:

                        char msg[6];
                        snprintf(msg, sizeof(msg), "%d", lens_info.kelvin);
                        bfnt_puts("Kelvin", 320, 111, fc, bg);
                        bfnt_puts(msg, 300, 166, fc, bg);


Sorry, I though you where using "bmp_puts" instead of "bfnt_puts"... Anyway, "bmp_fprintf" does a "vsnprintf" and then calls "bmp_puts"; so what you do looks like the most natural thing, if there isn't a "bfnt_printf" available.
Title: Re: Development stupid questions
Post by: nanomad on February 03, 2013, 07:23:03 PM
I've added a bfnt_printf, let me know how it works  ;)
Title: Re: Development stupid questions
Post by: scrax on May 05, 2013, 02:35:02 PM
NOw that I can play with the 5DC code I want to find out the pics shutter counts. My first idea, in theory, is to make a dump of the ROM then take a pic make another dump and compare them. But if it was so easy it will be already there. So I probably need some suggestions (not too technical) on how to start the research. For now I'll take a look into 400Dplus code if I can understand how it's done here.