changelog of trunk including comments / devtalk - page 26 - General Discussion and Assistance - CHDK Forum

changelog of trunk including comments / devtalk

  • 299 Replies
  • 243203 Views
*

Offline msl

  • *****
  • 1280
  • A720 IS, SX220 HS 1.01a
    • CHDK-DE links
Re: changelog of trunk including comments / devtalk
« Reply #250 on: 14 / September / 2015, 17:33:21 »
Advertisements
It was the same link and also: https://www.assembla.com/spaces/chdk/subversion/source/HEAD/trunk?_format=zip

Now is all fine - strange. Maybe a temporary problem. The zip download on Assembla is very fragile.

msl
CHDK-DE:  CHDK-DE links

*

Offline srsa_4c

  • ******
  • 4451
Re: changelog of trunk including comments / devtalk
« Reply #251 on: 15 / September / 2015, 20:16:06 »
If the module code provides callbacks to _SetHPTimerAfterNow, we'll need verify whether they can be thumb or provide them as ARM for pre-digic 6 cams.
This has turned out to be harder than expected. While there is no problem using Thumb callbacks on DryOS cameras, Vx cams do need ARM callbacks. Providing ARM callback functions (and exporting them to modules) in platform/wrappers.c doesn't seem like a good idea (one may want to use more than one timer).
While I can make a suitable ARM function in module code (by using asm), I do not seem to be able to pass its address correctly to SetHPTimerAfterNow() - the address gets the thumb bit.
Could there be an easy way to solve this?

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: changelog of trunk including comments / devtalk
« Reply #252 on: 15 / September / 2015, 21:27:35 »
While I can make a suitable ARM function in module code (by using asm), I do not seem to be able to pass its address correctly to SetHPTimerAfterNow() - the address gets the thumb bit.

Seems strange. Can you post sample code?

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: changelog of trunk including comments / devtalk
« Reply #253 on: 16 / September / 2015, 13:59:19 »
Seems strange. Can you post sample code?
Sure (found a solution in the meantime).

This is the timer callback (a minimal version actually)
Code: [Select]
int do_sample_on_change(int stime, int param) {
    SetHPTimerAfterNow(sdelay, do_sample_on_change_ARM, do_sample_on_change_ARM, 0);
}
Here's the wrapper:
Code: [Select]
int __attribute__((naked,noinline)) do_sample_on_change_ARM_(int a, int b) {
    asm volatile (
#ifndef THUMB_FW
    ".code 32\n"
"do_sample_on_change_ARM:\n"
    "adr    r3, dsoc_thumb+1\n"
    "bx     r3\n"
    ".code 16\n"
"dsoc_thumb:\n"
#endif
    "push   {lr}\n"
    "bl     do_sample_on_change\n"
    "pop    {pc}\n"
    //"b      do_sample_on_change\n" // no good, generates unsupported "relocation type 102"
    );
    // just to calm down the compiler
    return 0;
}
do_sample_on_change_ARM_() can't be passed to SetHPTimerAfterNow(), because it is treated as a Thumb function. I have come up with a workaround that actually works: the do_sample_on_change_ARM label can be used correctly, probably because it's inside a .code 32 section (do_sample_on_change_ARM is of course declared as the correct type of function).
The wrapper's Thumb section can't be as simple as a b <label> instruction because it generates a relocation type that can't be handled by elf2flt.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: changelog of trunk including comments / devtalk
« Reply #254 on: 16 / September / 2015, 20:02:14 »
Seems strange. Can you post sample code?
Sure (found a solution in the meantime).

This is the timer callback (a minimal version actually)
Code: [Select]
int do_sample_on_change(int stime, int param) {
    SetHPTimerAfterNow(sdelay, do_sample_on_change_ARM, do_sample_on_change_ARM, 0);
}
Here's the wrapper:
Code: [Select]
int __attribute__((naked,noinline)) do_sample_on_change_ARM_(int a, int b) {
    asm volatile (
#ifndef THUMB_FW
    ".code 32\n"
"do_sample_on_change_ARM:\n"
    "adr    r3, dsoc_thumb+1\n"
    "bx     r3\n"
    ".code 16\n"
"dsoc_thumb:\n"
#endif
    "push   {lr}\n"
    "bl     do_sample_on_change\n"
    "pop    {pc}\n"
    //"b      do_sample_on_change\n" // no good, generates unsupported "relocation type 102"
    );
    // just to calm down the compiler
    return 0;
}
do_sample_on_change_ARM_() can't be passed to SetHPTimerAfterNow(), because it is treated as a Thumb function. I have come up with a workaround that actually works: the do_sample_on_change_ARM label can be used correctly, probably because it's inside a .code 32 section (do_sample_on_change_ARM is of course declared as the correct type of function).
The wrapper's Thumb section can't be as simple as a b <label> instruction because it generates a relocation type that can't be handled by elf2flt.

Is 'do_sample_on_change_ARM' in a separate code file with -marm added to the build command?

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: changelog of trunk including comments / devtalk
« Reply #255 on: 16 / September / 2015, 20:32:05 »
Is 'do_sample_on_change_ARM' in a separate code file with -marm added to the build command?
No, that's the kind of thing I wanted to avoid. do_sample_on_change_ARM is a label inside the do_sample_on_change_ARM_() function. I'm using this declaration to make it work like a function: int do_sample_on_change_ARM(int, int)

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: changelog of trunk including comments / devtalk
« Reply #256 on: 16 / September / 2015, 21:49:42 »
Is 'do_sample_on_change_ARM' in a separate code file with -marm added to the build command?
No, that's the kind of thing I wanted to avoid. do_sample_on_change_ARM is a label inside the do_sample_on_change_ARM_() function. I'm using this declaration to make it work like a function: int do_sample_on_change_ARM(int, int)

Your call; but I think a C source file with -marm on the build might be easier to follow (eliminates the asm code and the label workaround).

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: changelog of trunk including comments / devtalk
« Reply #257 on: 10 / November / 2015, 18:45:57 »
This would be the change I mentioned earlier:
Code: [Select]
Index: include/clock.h
===================================================================
--- include/clock.h (revision 4285)
+++ include/clock.h (working copy)
@@ -8,4 +8,8 @@
 
 extern long get_tick_count();
 
+extern int SetHPTimerAfterNow(int delay, int(*good_cb)(int, int), int(*bad_cb)(int, int), int param);
+extern int CancelHPTimer(int handle);
+
+
 #endif
Index: modules/module_exportlist.c
===================================================================
--- modules/module_exportlist.c (revision 4285)
+++ modules/module_exportlist.c (working copy)
@@ -398,6 +398,9 @@
             CreateTask
             ExitTask
 
+            SetHPTimerAfterNow
+            CancelHPTimer
+
             remotecap_get_target_support
             remotecap_set_target
             remotecap_using_dng_module
Index: platform/generic/wrappers.c
===================================================================
--- platform/generic/wrappers.c (revision 4285)
+++ platform/generic/wrappers.c (working copy)
@@ -1730,3 +1730,14 @@
 #endif
     return 0;
 }
+
+// HP timer functions, callbacks need to be ARM on VxWorks
+int SetHPTimerAfterNow(int delay, int(*good_cb)(int, int), int(*bad_cb)(int, int), int param)
+{
+    return _SetHPTimerAfterNow(delay,good_cb,bad_cb,param);
+}
+
+int CancelHPTimer(int handle)
+{
+    return _CancelHPTimer(handle);
+}
The module that needs it can be found here (it's still work-in-progress).

Unless there's objection, I plan to check it in soon (it's a bit embarassing, since my unofficial module is the only reason to have it).

I think a C source file with -marm on the build might be easier to follow (eliminates the asm code and the label workaround).
That's something to consider, should it ever become official.

*

Offline reyalp

  • ******
  • 14126
Re: changelog of trunk including comments / devtalk
« Reply #258 on: 11 / November / 2015, 21:10:00 »
Unless there's objection, I plan to check it in soon (it's a bit embarassing, since my unofficial module is the only reason to have it).
No objection from me.
Don't forget what the H stands for.

*

Offline srsa_4c

  • ******
  • 4451
Re: changelog of trunk including comments / devtalk
« Reply #259 on: 13 / November / 2015, 11:33:38 »

 

Related Topics


SimplePortal © 2008-2014, SimplePortal