Looking for help with my C++ thread class

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: utzig, lbednarz, tfAteba, barthess, RoccoMarco

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Looking for help with my C++ thread class

Postby JetForMe » Tue Apr 12, 2011 3:22 am

Hi. I've posted a bit about this before. Basically, I have a template C++ class wrapping ChibiOS threads. It works well on AVR, but has issues on ARM. I've written up a blog post with code and explanations here:

http://blog.roderickmann.org/2011/04/using-templates-to-statically-allocate-thread-working-area-in-chibios/

I'm hoping someone can make some suggestions of other things to consider. Thanks!

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Tue Apr 12, 2011 9:40 am

I've figured it out. It's not a problem with my code at all. Instead, constructors for statically-allocated (global) objects are not getting called. I suspect the problem lies somewhere in crt0.s, or perhaps in the linker script, not really sure.

Giovanni, you're the most likely person to know what's going on. You can see a clear explanation here, in the "Update" section near the beginning of the post: http://blog.roderickmann.org/2011/04/using-templates-to-statically-allocate-thread-working-area-in-chibios/

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Tue Apr 12, 2011 11:34 am

Give me a little time to read it all, anyway you are correct, the current crt0.s does not currently invoke static constructors.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Tue Apr 12, 2011 6:19 pm

Thanks, Giovanni. Note that you need not read the whole thing. The update section just shows the result of the ctors not getting called. The rest is a distraction from that issue.

I did a little googling on the matter. The spec only requires that a given file static constructor be called before any other function in that file is called. The easiest thing, I think, is to just call them all in crt0.s, but you may find something else.

Hopefully it's just a simple matter of inserting a single call to a compiler-generated routine.

Thanks!

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Tue Apr 12, 2011 6:30 pm

crt0.s is the proper place for this, I'll try to add the feature in 2.3.2.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Tue Apr 12, 2011 6:53 pm

Thanks, Giovanni. Any timeframe for the release? If it's not a matter of days, do you know how I can modify my local crt0.s to add this support? Thanks!

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Tue Apr 12, 2011 7:11 pm

Sorry I can't promise, releases are usually done in 2-3 weeks intervals.

Changes will involve the startup file and the linker script for sure, I don't know exactly until I will examine the problem.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Tue Apr 12, 2011 7:41 pm

Okay. I think I can work around the problem for now. Thanks.

User avatar
Giovanni
Site Admin
Posts: 13074
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 758 times
Been thanked: 637 times
Contact:

Re: Looking for help with my C++ thread class

Postby Giovanni » Sun Apr 17, 2011 7:30 pm

Hi,

The version currently on the repository fixes the problem for the Cortex-Mx port. It will be released as 2.3.2 sometime next week.

Giovanni

JetForMe
Posts: 99
Joined: Mon Jan 31, 2011 8:12 am

Re: Looking for help with my C++ thread class

Postby JetForMe » Mon Apr 18, 2011 2:22 am

That's good news! I tried looking for the changes you made, but it wasn't entirely clear what you did (plus, the repo browser didn't want to show me the checkin comments (i.e.: http://chibios.svn.sourceforge.net/view ... c?view=log).

I look forward to the update!


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 1 guest