Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question/bug: recent CMSIS RTOS initialisation/memory/behaviour change (possible issue with #2642) #2786

Closed
RobMeades opened this issue Sep 22, 2016 · 7 comments

Comments

@RobMeades
Copy link
Contributor

I'm in the process of integrating a new target into mbed-os. A week ago, at #7669d7f, I had a working Pull Request that passed all the htrun tests ready to go. Because of RTX file change collisions I've had to rebase to #c1c1492 and now CMSIS RTOS doesn't even get into mbed_sdk_init(): rt_tsk_create() returns 0.

Can anyone point me at any recent changes to do with memory configuration, initialisation or RTOS behaviour before I start diffing the world and tearing my hair out?

Rob

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 23, 2016

Looking at the history, https://github.com/ARMmbed/mbed-os/commits/master/rtos , there's stack check enabled, some targets fixes, Thread class clean up.

@RobMeades
Copy link
Contributor Author

Thanks Martin. It's definitely one of those as, if I revert the changes in that directory, my target works again. Digging...

@RobMeades
Copy link
Contributor Author

RobMeades commented Sep 23, 2016

It appears to be the Add RTX API to report stack usage commit, #2642, that's causing my problem. Investigating...

@RobMeades
Copy link
Contributor Author

If I include the void *argv parameter in the OS_TCB struct in rt_TypeDef.h, rt_task_create() fails (even if I comment out all uses of argv) , if I add it back in then rt_task_create() returns 1 and things work. So something doesn't fit with these extra 4 bytes in the TCB.

@RobMeades RobMeades changed the title Question: have there been any recent CMSIS RTOS initialisation/memory/behaviour changes? Question/bug: recent CMSIS RTOS initialisation/memory/behaviour change Sep 23, 2016
@RobMeades
Copy link
Contributor Author

RobMeades commented Sep 23, 2016

It looks as though there might be an issue with #2642 (at least, there is for me). With the void *argv pointer added to the OS_TCB struct it is now 64 bytes in size. In RTX_CM_lib.h I see #define OS_TCB_SIZE 60, which I'm guessing defines the size of this struct (why not use sizeof()?). From the map file, with this pointer added, the struct is now 64 bytes big. With the #define left as it is rt_task_create() returns 0, if I increase the #define to 64 rt_task_create() returns 1 and the RTOS starts.

Now I'm not exactly sure what I'm doing here as this code is somewhat obtuse, and I've no idea why this isn't a problem for anyone else (possibly only those with MBED_RTOS_SINGLE_THREAD, of which I'm guessing there are some on CI?), so I'm very happy to be told that it's actually my problem but I do think I need someone else to take a look now.

Help!

@RobMeades RobMeades changed the title Question/bug: recent CMSIS RTOS initialisation/memory/behaviour change Question/bug: recent CMSIS RTOS initialisation/memory/behaviour change (possible issue with #2642) Sep 23, 2016
@RobMeades
Copy link
Contributor Author

I've proposed changing OS_TCB_SIZE to 64 in the above pull request. If a different fix is required, please feel free to reject the pull request.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 26, 2016

Thanks for resolving this.

@0xc0170 0xc0170 closed this as completed Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants