EOS M3 porting

  • 497 Replies
  • 175426 Views
*

Offline Ant

  • ****
  • 369
Re: EOS M3 porting
« Reply #20 on: 11 / September / 2015, 14:09:01 »
Advertisements
I corrected code but it still not works:
Code: [Select]
args[0] = (unsigned)"LCDMsg_Create";
args[1] = (unsigned) 60;
args[2] = (unsigned) 300;
args[3] = (unsigned) 0;
message = call_func_ptr(_ExecuteEventProcedure,args,4);

args[0] = (unsigned)"LCDMsg_SetStr";
args[1] = message;
args[2] = (unsigned)"Hello World";
call_func_ptr(_ExecuteEventProcedure,args,3);

But one time from approx. 30 attempts I've got the message - I have no idea how...

*

Offline srsa_4c

  • ******
  • 3728
Re: EOS M3 porting
« Reply #21 on: 11 / September / 2015, 14:37:51 »
But one time from approx. 30 attempts I've got the message - I have no idea how...
If you do the same from an AdditionAgentTask based test program (without using any CHDK code), does it work?
Since using ExecuteEventProcedure from bare C (or asm) code is less convenient, just call the LCDMsg functions directly (by address). Then, if you find it working, place the same code in save_romlog2() and repeat the experiment from within CHDK. If the latter still isn't working reliably, then, as I already mentioned, you may have RAM corruption.
Remember to use the appropriate calling convention on the LCDMsg functions.

*

Offline Ant

  • ****
  • 369
Re: EOS M3 porting
« Reply #22 on: 12 / September / 2015, 05:06:53 »
I replaced LCDMsg calls by:
Code: [Select]
args[0] = (unsigned)"AdditionAgentRAM";
args[1] = (unsigned)"A/VBATT.BIN";
args[2] = (unsigned)"WHAT";
call_func_ptr(_ExecuteEventProcedure,args,3);
Binary is the same that loaded by script.
It starts and works normaly from Playback mode. Starting from Shooting mode messages are not shown or camera crashes. After I removed battery camera crashes sporadically and sometimes message "Test" appears.

P.S. can you give me makefile for binary that written on C instead assembler?
« Last Edit: 12 / September / 2015, 05:27:00 by Ant »

*

Offline srsa_4c

  • ******
  • 3728
Re: EOS M3 porting
« Reply #23 on: 12 / September / 2015, 14:52:47 »
After I removed battery camera crashes sporadically and sometimes message "Test" appears.
Don't quite understand, do you mean the camera got permanently damaged or it's just this test that doesn't work anymore?
Binary is the same that loaded by script.
Is that the test binary you made that displays battery voltage?

Anyway, if it's working reliably when loaded from Canon Basic, but doesn't when loaded from that half-running CHDK, then something is definitely not OK.
Quote
P.S. can you give me makefile for binary that written on C instead assembler?
I've never tried doing that. If you need that, the "udumper" source may give some hints, you might be able to create something simple by adding macros found in include/stubs_asm.h .
You can find the udumper source in an archive inside CardTricks-144-SFX.exe (which can be downloaded from the tools folder of this box repo).


*

Offline Ant

  • ****
  • 369
Re: EOS M3 porting
« Reply #24 on: 12 / September / 2015, 17:25:39 »
My camera is not damaged. But I was not trying to start CHDK core yet.

I did some experiments since my last post. Now I found stable combination that works:
Code: [Select]
extern unsigned _ExecuteEventProcedure(const char *name,...);
extern unsigned _sprintf(char *stream, const char *format,...);

extern unsigned _LCDMsg_Create (unsigned, unsigned, unsigned);
extern void _LCDMsg_SetStr (unsigned, char * );
static unsigned message;

void save_romlog2(void)
{

    unsigned args[4];
    args[0] = (unsigned)"SystemEventInit";
call_func_ptr(_ExecuteEventProcedure,args,1);
args[0] = (unsigned)"UI.CreatePublic";
call_func_ptr(_ExecuteEventProcedure,args,1);
args[0] = (unsigned)"System.Create";
call_func_ptr(_ExecuteEventProcedure,args,1);
args[0] = (unsigned)"Driver.Create";
call_func_ptr(_ExecuteEventProcedure,args,1);

args[0] = (unsigned)"BeepDrive";
args[1] = (unsigned) 0x02;
call_func_ptr(_ExecuteEventProcedure,args,2);

args[0] = (unsigned)"GetLogToFile";
args[1] = (unsigned)"A/ROMLOG.LOG";
args[2] = 1;
call_func_ptr(_ExecuteEventProcedure,args,3);
}

/*----------------------------------------------------------------------
    spytask
-----------------------------------------------------------------------*/
void spytask(long ua, long ub, long uc, long ud, long ue, long uf)
{
int a = 1;
long voltage;
//    core_spytask();
char voltagestr [10];
_SleepTask(800);
while (1){
_SleepTask(300);
if ((physw_status[1] & 0x00002000) == 0){ 
if (a) {
a = 0;
save_romlog2();
message = _LCDMsg_Create(10,360, 0);
}
}
if (a == 0) {
voltage = _VbattGet();
_sprintf (voltagestr, "%04dmV  0x%08X", voltage, *(int*)(0x9e50+0x0c));
_LCDMsg_SetStr(message, voltagestr);
}
}
}
LCDMsg functions work stable if they called after executing GetLogToFile procedure. Without GetLogToFile they work only from Shooting mode.
And another strange thing is that sprintf from stdio.h causes crash.  I used _sprintf from firmware instead.

Re: EOS M3 porting
« Reply #25 on: 12 / September / 2015, 18:29:19 »
And another strange thing is that sprintf from stdio.h causes crash.  I used _sprintf from firmware instead.
I've often wondered as we go spelunking into the Canon firmware whether we will occasionally hit non-re-entrant routines? Which would of course appear to work sometimes and not others if you don't enter through the correct wrapper shell.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline srsa_4c

  • ******
  • 3728
Re: EOS M3 porting
« Reply #26 on: 12 / September / 2015, 18:55:12 »
And another strange thing is that sprintf from stdio.h causes crash.  I used _sprintf from firmware instead.
The CHDK sprintf implementation uses the firmware's vsprintf function. Did you identify that correctly? (CHDK doesn't include proper system libraries to save space, we're usually using functions from the firmware.)
Quote
LCDMsg functions work stable if they called after executing GetLogToFile procedure. Without GetLogToFile they work only from Shooting mode.
I still think you're just experiencing corrupted memory.

*

Offline Ant

  • ****
  • 369
Re: EOS M3 porting
« Reply #27 on: 13 / September / 2015, 03:27:43 »
The CHDK sprintf implementation uses the firmware's vsprintf function. Did you identify that correctly?
Not yet. I am finding the stubs as  I guess  they needed.
Are all the stubs from "stubs_entry_2.S" used in SX280HS port?


*

Offline srsa_4c

  • ******
  • 3728
Re: EOS M3 porting
« Reply #28 on: 13 / September / 2015, 07:55:03 »
Are all the stubs from "stubs_entry_2.S" used in SX280HS port?
Yes. Additional addresses (informational only) are in the csv file attached to a post on the second page of the sx280 porting thread.
stubs_min.S is also important as some fw variables are written by CHDK.

*

Offline Ant

  • ****
  • 369
Re: EOS M3 porting
« Reply #29 on: 13 / September / 2015, 15:06:21 »
I undefined CAM_CHDK_PTP, commented conf_restore(), shooting_init(), mode_get() in core_spytask function.
Camera starts normally and creates CHDK directories on SD card. But there is no signs of CHDK on display.

 

Related Topics