Problems with running the blinker program - General Discussion and Assistance - CHDK Forum supplierdeeply

Problems with running the blinker program

  • 12 Replies
  • 4991 Views
*

Offline RaduP

  • *****
  • 908
Problems with running the blinker program
« on: 16 / August / 2009, 00:35:38 »
Advertisements
I am trying to play with a broken a550, and tryig to execute arbitrary code.
I think modifying the blinker program would be best, since it's supposed to be the tried and tested way. I used the make.bat file which compiled it and did the dirty tricks, placed it on the card, but the camera won't load it.
The message I get is: "Update file error!!!"

I think this is because of "pakwif PS.FIR main 0x3117" line in the bat file, the number 0x3117 being the targeted camera ID or something, right? How would I get the ID for the a550? Is therer anything else I'd need to do?

*

Offline reyalp

  • ******
  • 14003
Re: Problems with running the blinker program
« Reply #1 on: 16 / August / 2009, 01:52:50 »
The number is the platform ID, which can be found using the ver.req trick, the makefile.inc from that platforms CHDK port, or the cameras WIKI page http://chdk.wikia.com/wiki/A550

Since a port already exists for that camera, I would personally start from the CHDK source, since it already has a working build process etc. You can easily leave everything but the loader out of the build, or just run whatever you want in the loader and ignore the rest. It also provides you with an easy framework if you need to do something more complicated later on.
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 908
Re: Problems with running the blinker program
« Reply #2 on: 16 / August / 2009, 02:06:40 »
Thanks a lot, now it works!
I was thinking to do what you suggested, but the reason why I wanted the blinker is the simplicity. I wanted something very easy so that I can look at the code and understand how things are done.
Now that I managed to blink the LED, I'll try to play with slightly harder stuff, such as the frame buffer, and then see what else I can do.

I'll like to try to port Linux on it, so will start with a bootloader. Probably I won't get far, but I am doing this mostly for learning.

*

Offline RaduP

  • *****
  • 908
Re: Problems with running the blinker program
« Reply #3 on: 16 / August / 2009, 04:11:48 »
I don't want to open another topic, but I was wondering if you guys know how to initialize the screen, without using Canon functions.
I tried to write stuff in the frame buffer, but the screen is blank, backlight off, and can't see anything. So probably it needs to be turned on some way or another.


*

Offline reyalp

  • ******
  • 14003
Re: Problems with running the blinker program
« Reply #4 on: 16 / August / 2009, 19:03:07 »
I don't want to open another topic, but I was wondering if you guys know how to initialize the screen, without using Canon functions.
I tried to write stuff in the frame buffer, but the screen is blank, backlight off, and can't see anything. So probably it needs to be turned on some way or another.
You will have to dig through the canon startup code to figure out that. There should be some strings to give you hints. CHDK has no need to know this, so it's unlikely anyone here has dug through this.

As I've said earlier, running your own OS from scratch is *much harder* than running something within the canon OS. You'll have to write all your device drivers yourself, and the devices are completely undocumented.
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 908
Re: Problems with running the blinker program
« Reply #5 on: 16 / August / 2009, 19:25:26 »
Yes, I was hoping someone did more digging into it and might know more about directly addressing the hardware. But I disagree that CHDK has no need for this, it could be used for all kinds of debugging information, before CHDK is started, maybe for porting new cameras and stuff.

*

Offline reyalp

  • ******
  • 14003
Re: Problems with running the blinker program
« Reply #6 on: 16 / August / 2009, 19:50:53 »
But I disagree that CHDK has no need for this, it could be used for all kinds of debugging information, before CHDK is started, maybe for porting new cameras and stuff.
I said there was no need. As in, this knowledge is not required to make CHDK work. That doesn't it couldn't be useful.

In any case, the canon hardware (or at least the MMIO addresses) changes frequently between cameras, so it's unlikely that it would be much use for porting new cameras. You'd have to dig through the firmware dump either way.
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 908
Re: Problems with running the blinker program
« Reply #7 on: 16 / August / 2009, 20:03:32 »
Digging through the dump is not the issue, so long as I know what to dig for :)
I found some strings, such as LcdCon_SetLcdDriver, TurnOnDisplay, TurnOnDisplayForStartup, DispCon_SetDisplayType, etc.
But is is highly likely that most of them do not work by themselves, so I'd have to reverse engineer all of them, which is a lot of time :/


*

Offline RaduP

  • *****
  • 908
Re: Problems with running the blinker program
« Reply #8 on: 16 / August / 2009, 23:21:33 »
Ok, I have another question.
Say I want to call a function from the firmware, can I do it this way?

Code: [Select]
void TurnOnDisplayForStartup()
{
    asm("bl 0xff993ac4\n");
}

Or am I doing something wrong?

I use the LEDs to debug it, and after I call this function it does not return the execution control. I know that a lot of things can go wrong, so I just wanted to make sure I am at least calling it right.
« Last Edit: 16 / August / 2009, 23:23:20 by RaduP »

*

Offline reyalp

  • ******
  • 14003
Re: Problems with running the blinker program
« Reply #9 on: 17 / August / 2009, 03:54:52 »
Ok, I have another question.
Say I want to call a function from the firmware, can I do it this way?

Code: [Select]
void TurnOnDisplayForStartup()
{
    asm("bl 0xff993ac4\n");
}
I suspect the assembler will not do what you want with that, since BL is a 24 bit PC relative jump. I suspect ff* will just be treated as a negative offset. You can always disassemble the output to make sure it's doing the right thing.

otherwise,
Code: [Select]
MOV LR,PC
LDR PC, =0xff993ac4
should do what you want.

That said, I would expect many functions to not work if the OS isn't running.
Don't forget what the H stands for.

 

Related Topics