Porting question - assembler - DryOS Development - CHDK Forum

Porting question - assembler

  • 4 Replies
  • 3437 Views
Porting question - assembler
« on: 24 / June / 2010, 09:52:05 »
Advertisements
I would like to "inject" a command in the existing firmware to test camera behavior.

For example, I'd like to insert a command  "MOV R1,0" at location 0x12345678. I don't mind overwriting the existing command.


I need this to insert a jump to my blinker function, to detect where the program hangs.

« Last Edit: 28 / June / 2010, 08:09:21 by Yossar »

Re: Porting question - assembler
« Reply #1 on: 24 / June / 2010, 12:06:43 »
I think the original firmware is just mapped from flash to address space. It is not copied to RAM before it is executed, so it's read only?

Re: Porting question - assembler
« Reply #2 on: 24 / June / 2010, 22:13:32 »
I think the original firmware is just mapped from flash to address space. It is not copied to RAM before it is executed, so it's read only?
Correct. As far as I know the only way to inject code is to change the data structures the firmware constructs in (writable) memory (typically used for "event" handlers). That or flashing new/adapted firmware, which isn't such a good idea.

This is also why there is so many code copied from the firmwares in the platform files; to change a small bit in some firmware function you have to copy and change not only that function but also every function that calls it until you get to a point where a function address is taken from writable memory.

*

Offline reyalp

  • ******
  • 14125
Re: Porting question - assembler
« Reply #3 on: 25 / June / 2010, 18:36:05 »
If the camera actually crashes, you can get a crash log with a stack dump. http://chdk.wikia.com/wiki/LUA/Scripts:Standard/Test/Romlog

You can also install your own exception handlers. You could in theory set up the MPU to trigger an exception on access to certain addresses, but the maximum resolution is 4k.
Don't forget what the H stands for.

Re: Porting question - assembler
« Reply #4 on: 27 / June / 2010, 18:31:32 »
You have all been very helpful.

I am working on SD1200 port, and the camera freezes every time the flash is used. Problem is that my code (in RAM) executes fine, but causes crash somewhere later. The code is identical to the code from firmware (I excluded all extra function calls for debugging).

What would be the easiest way to detect if some part of memory is overwritten? Any other idea?

 

Related Topics


SimplePortal © 2008-2014, SimplePortal