reyalp
Some of ASM code in boot.c enables the CPU caches 😀
Ah OK that makes sense, I sort of overlooked it because it has a comment saying:
// this is a carryover from old dryos ports, may not be useful
Also, I think the loops in the loader also ran at the faster speed, but maybe the caches were enabled there and somehow get disabled again before boot.c.
If you post a snippet of code where the crash happens someone might have an idea.
The
Ixus95 port is quite immature, so I'd definitely suggest referring to other cams as well.
Here is where it crashes, with some context ("..." represents redacted code, to save space):
void boot() {
long *canon_data_src = (void*)0xFFBF837C; //From end of first function
long *canon_data_dst = (void*)0x1900; //From end of first function
long canon_data_len = 0xEBD0 - 0x1900; // data_end - data_start
long *canon_bss_start = (void*)0xEBD0; // just after data
long canon_bss_len = 0x14FE20 - 0xEBD0; //In loop at end of first function
long i;
// enable caches and write buffer... this is a carryover from old dryos ports, may not be useful
asm volatile (
"MRC p15, 0, R0,c1,c0\n"
"ORR R0, R0, #0x1000\n"
"ORR R0, R0, #4\n"
"ORR R0, R0, #1\n"
"MCR p15, 0, R0,c1,c0\n"
:::"r0");
for(i=0;i<canon_data_len/4;i++)
canon_data_dst[i]=canon_data_src[i];
for(i=0;i<canon_bss_len/4;i++)
canon_bss_start[i]=0;
// see [url=https://chdk.setepontos.com/d/2972/47]SD990[/url]
*(int*)0x1934=(int)taskCreateHook;
*(int*)0x1938=(int)taskCreateHook2; //VERIFY_SD780
// IXUS130: see code from FF85F3F0
*(int*)(0x2484)= (*(int*)0xC022012😎&1 ? 0x400000 : 0x200000;
// jump to init-sequence that follows the data-copy-routine
asm volatile ("B sub_FF810354_my\n");
}
void __attribute__((naked,noinline)) sub_FF810354_my() {
asm volatile ("..." // copied from fw dump
" BL sub_FF811198_my\n"
);
}
void __attribute__((naked,noinline)) sub_FF811198_my() {
asm volatile ("..."
" LDR R0, =new_sa\n" //Replaces original start location 0x14FE20
" LDR R0, [R0]\n"
" ..." // Storing lots of things on the stack, including:
" LDR R1, =sub_FF815E58_my\n" // also tried "LDR R1, =0xFF815E58"
// It gets here
" MOV R0, SP\n"
" MOV R2, #0\n"
" BL sub_FF813404\n" // was FF812D68
// It doesn't get here
" ADD SP, SP, #0x74\n"
" LDR PC, [SP],#4\n"
);
}
void __attribute__((naked,noinline)) sub_FF815E58_my() {
asm volatile ( // It doesn't get here
" ..."
" B taskcreate_Startup_my\n" // FF81FAF0
);
}
It is the call to sub_FF813404 that fails. It seems to take a function pointer as an argument, I tried passing in the original function from the firmware instead of the new one from boot.c, but it doesn't make any difference - the call never returns, and the function pointer passed in is never called.
I thought about copying sub_FF813404 into boot.c as well, so that I can find out whereabouts it is failing, but if someone has an idea that will save me the work, all the better 😀