DataGhost, you are my idol!
You probably didn't notice, but I never asked you (or anyone else) when CHDK for S5 will be ported. I didn't want to bother you, because I'm a programmer too, and I KNOW how it is when someone is pushing you. Now that you are so close, I felt that I had to say something, and I want to say "Thank you".
Now, I'm wondering, since I don't know ASM or anything related to firmware porting, how much did you know about all that before you started your work, and is it hard to learn? I work in Delphi, so I can't say that I'm familiar with C/C++ either. Since my S5 FW version is 1.01B, I hope I won't need to know, but the idea of manipulating software of my camera sounds very interesting
Thank you once more!
It's very interesting indeed, I have to keep myself from drifting off and I should concentrate on making at least an initial version available. I was annoyed by not being able to set manual focus through CHDK (camera crashes when setting subject distance with no MF set) and couldn't get it to work through a propertycase, so I accidentally spent the last half hour decoding physw (keyboard handling), a lengthy process which I shouldn't be doing now
Anyway, how much did I know... Well, first of all... I knew what ASM was, and what it looked like. I never really looked into the actual meaning behind ASM code so I always wondered how something was possible in ASM (every code is possible in ASM but I didn't really allow myself to think like that, for some strange reason). Until I started studying CS at the university, I never really bothered to take a look (as almost every other student) and all of a sudden we had to program a device in a simple flavor of ASM. We also had lectures about how computers actually work on the inside (specifically: CPUs, memory and low-level stuff in general) and it all started making sense. Of course, it takes some getting used to, but by just doing it and seeing what happens, I learned a great deal about ASM programming in a very short time.
A couple of months later, I bought my S5, found CHDK and after a while I thought... heck, I can do that. I gathered some documentation (asm dialects/versions are quite different but the basic idea is the same) and started trying to figure out what the firmware did, why simple programs compiled to specific ASM code, and so on. Starting off with
LDR R0, =0xC02200E0
LDR R1, =0x46
STR R1, [R0]
I quickly wrote a couple of very simple programs that would do various things with the AF led. Once I managed to dump the complete firmware I had some trouble getting started but after a week or two I really got the hang of it and things went a lot better. Now ASM isn't really a mystery to me anymore, kinda takes away the magic a bit but it sure is useful to know it and be able to write it.
So basically, if you also want to get started, you could read the DryOS porting thread and eh... just start coding some things, try to figure out what existing code is supposed to do, etc. You'll only master it by working with it, I think. Oh, and it's very important to read this
ARM ASM reference guide, it contains a lot of information about the architecture itself, besides the actual ASM syntax and meaning. You really need to know how the architecture works, why certain things happen/are possible and why certain things won't work. For example, you cannot use the MOV instruction to load an arbitrary 32-bit integer into a register (you have to use LDR for that), because the instruction, register and value have to be stored in ONE 32-bit instruction. You can find more information about
ARM instruction encoding in this document.
If you know the basic ideas behind programming and computers, it's certainly doable within a short time. It worked for me, your mileage may vary, though.
I do think it's at least somewhat useful if you know C/C++ or at least some pointer handling (in Delphi), since that's a concept you'll see a lot. I actually dereferenced a pointer in that snippet of ASM I posted above. By the way, knowing C is useful for normal CHDK code as well, since it's written in C
. Still, if you feel like learning ASM is a lot of work, there is a lot you can also do in C once CHDK is running on your camera.
Anyway, status update:
I cleaned up some of the code, I rewrote the keyboard handling code to something that makes sense to more people than just me, and the camera won't crash anymore when overriding subject distance (however manual focus needs to be set for it to work, else it won't override anything). I still have to do the complete ISO override thing, though. Video override seems to be unnecessary at this time, although I'm not sure if that's because nobody figured out how it works in DryOS or if it's not necessary
I still have to clean up the rest of the platform code, read through, clean up and truncate all 175 kilobytes of currently-hooked ASM code and after that I'll have to make sure that it still works in the current trunk, see if I didn't miss any functionality and add/fix where necessary.
Oh yeah, I'm using a *slightly* different compiler which uses no ARM architecture/CPU in particular (well, I just don't know what the default is). Because of this, it doesn't complain on ASM instructions like STRD <whatever> and BLX R12, which the processor clearly supports (it's used in the firmware, encoded as such (I verified the bits) and it also runs fine in CHDK). In order to be compatible with the default CHDK compiler, I have to find those instructions and replace them by equivalent (more) instructions. I cannot 100% guarantee that I won't run into additional errors because of that.