SD980 port - page 8 - DryOS Development - CHDK Forum

SD980 port

  • 169 Replies
  • 65388 Views
*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #70 on: 27 / September / 2009, 02:13:22 »
Advertisements
Now I am pissed.. I added a global variable to check the value of the pointer across functions, and now the problem doesn't happen anymore, so I am pretty sure it was some sort of buffer underrun..
I also noticed that strncpy is just a partial match, and so is strncmp... I guess that could have caused the problem.

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #71 on: 27 / September / 2009, 03:03:20 »
Yeah, I narrowed it down to strncpy, which does not appear to do a length checking, so it must be a different function.
And while I was at it, I checked strcpy too, which was a perfect match, but not the right function. In fact, it was in the middle of some other function :/

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #72 on: 27 / September / 2009, 03:27:36 »
Well, searching for those functions takes a lot of time, I could have written my own implementation 10 times faster, which I think I am going to end up doing. Any idea where I should put my own function versions, in such a way to not interfere with the rest of the project, and how should I define them?

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #73 on: 27 / September / 2009, 21:35:33 »
Ok, after implementing my own versions of strrchr and strncpy, it worked fine, no more crashing.
I tried to do detect an invalid function pointer in wrappers.c, like this:
Code: [Select]
if(_strncpy==(void*)0xDEADC0DE)
{
//my code
}

In stubs_2 I have: NHSTUB(strncpy, 0xDEADC0DE)
But for some reason it didn't work, no clue what was wrong.

*

Offline reyalp

  • ******
  • 14128
Re: SD980 port
« Reply #74 on: 27 / September / 2009, 21:56:45 »
Not sure why it doesn't work but it seems like a really kludgey way to do it.

I would suggest
1) don't put strncpy in stubs_entry_2.S (leave a comment)
2) define _strncpy in one of your platform C files (say wrappers.c). This should leave the generic code completely alone (it will still pick up _strncpy) , and your C code should override the weak version in stubs_entry.S

I've verified that this compiles OK, but you'll probably want to blink an LED in a function defined this way to make sure it actually gets linked right.
Don't forget what the H stands for.

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #75 on: 27 / September / 2009, 22:15:16 »
Great, it worked, thanks!

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #76 on: 28 / September / 2009, 01:07:09 »
Wow, I managed to get the splash logo working, and I can also print debug text on the screen. Such a huge PITA, but now I can finally forget about the LED debugging (well, at least for most of the stuff) :D

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #77 on: 28 / September / 2009, 02:17:40 »
Now I am trying to get the keyboard to work.
For now, I have commented out the whole taskCreateHook, but of course, I need to uncomment it and add the pointer to my keyboard task.

I have a question though:
Code: [Select]
void taskCreateHook(int *p) {
 p-=17;

What exactly is this pointer? I guess it is to some function table, but how do I find that table? And why -17?

*

Offline RaduP

  • *****
  • 926
Re: SD980 port
« Reply #78 on: 28 / September / 2009, 05:00:30 »
Well, my *(int*)0x1930=(int)taskCreateHook; didn't seem to do anything, taskCreateHook() was never executed..
So what I did was to find the memory location that needed to be replaced with mykbd_task, and I did the replacement instead of hooking taskCreateHook..

I put my led blinking code in mykbd_task_proceed(), and it doesn't seem to get there.. Any ideas?

*

Offline reyalp

  • ******
  • 14128
Re: SD980 port
« Reply #79 on: 28 / September / 2009, 05:04:54 »
http://chdk.setepontos.com/index.php/topic,4194.0.html

as always, search for the old constant in working port, find the equivalent constant in your port.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal