Member | Action | Date |
---|---|---|
|
Updated
Adding Micrium OS on a Flex Gecko on Blog
This blog post has been closed for comments due to it being out-of-date with the latest Gecko SDK and no longer relevant. ------------------------------------------------------------------------------------------------------------------------------------ This blog should serve as a guide to adding Micrium OS on a Flex Gecko and get at least one task running on the device. I will now share with you my experience while going through this exercise. Getting StartedI decided to perform a clean installation of Simplicity Studio in order to avoid conflicts inflicted by software updates over time. After installing the tool, before even attempting to add anything, I first had to make sure that I had the necessary SDKs. Here's what I installed:
I then mounted a Flex Gecko, EFR32FG12 in my case, onto a Wireless Started Kit Mainboard (BRD4001A). After that, I connected it to the PC using the provided USB cable. Simplicity Studio recognized a Flex Gecko connected to a WSTK and displayed the link to examples from the Flex SDK (see Figure 1). ![]() Loading a Basic Flex SDK ExampleAs a starting point, I decided to go with the "RAIL: Simple RAIL without HAL" example from the Flex SDK. You can find this by expanding the list of projects under the "Silicon Labs Flex SDK Examples" link: ![]() Then find and click the example shown in Figure 3 to add it to your workspace:
After the example loads on your workspace, you might get a notice as shown in Figure 4. Just click "OK". ![]()
You will then be presented with simple_rail_without_hal.isc opened where you can configure RAIL. In my case, I left everything in its default values and simply clicked on "Generate" as shown in Figure 5. ![]() At this point, you should now be set with a basic Flex Gecko example that builds and runs. However, I did find that the default project settings have compiler optimization set to "Optimize for size (-Os)" which will eventually make debugging the project rather difficult. Therefore, I switched optimizations to "None (-O0)". ![]() Adding Micrium OS to the WorkspaceNow that you have a basic Flex Gecko example that builds and runs, let's go ahead and start adding the Micrium OS source files into the workspace. First, locate the Micrium OS directory, it should be in:
Now drag and drop the "micrium_os" folder into your project (simple_rail_without_hal) in Simplicity Studio. When doing this, make sure that you have "Copy files and folders" selected before clicking "OK" as shown in Figure 7. ![]()
You will then have to remove all the unnecessary files that get added with Micrium OS (this was tedious). Here's how your "micrium_os" folder should end up looking: ![]() Finally, the compiler needs to know where to look for the header files so we have to add two compiler include paths to the project settings:
![]() Configuring Micrium OSNow that you have Micrium OS as part of your project, let's go ahead and make some minor adjustments to the default Micrium OS configuration.
Modifying main.cWe'll be making modifications to the default main.c generated by the "RAIL: Simple RAIL without HAL" example. Micrium OS requires the following include paths in main.c so go ahead and add them as shown below:
We'll be modifying main.c to initialize Micrium OS and create a start task. For that, you'll need to specify a task stack size and a priority. We typically do this by defining them as constants and passing those in the call to OSTaskCreate(). The start task also requires its own Stack and Task Control Block (OS_TCB) as well as its function prototype. Therefore, add the following to main.c:
Here's the body of the StartTask function where the kernel tick gets initialize and as well as the Common module. Note that the function includes an infinite loop at the end with a time delay of 1 second. This is done to yield CPU time to other tasks that are or will eventually run on your system. You can copy and paste the following in your main.c:
Let's now modify main() to initialize the CPU, the kernel create the Start Task, and start the OS. Here's how main() should end up looking:
Finally, since Micrium OS makes use of an assembly-optimized memory copy function, you must enable it in common_cfg.h
You are now set to build and run the project. You can put a breakpoint on the Start Task inside the while loop and notice that you'll be hitting that every second (or as specified by the delay you configure in OSTimeDly()). Please do understand that this is a very basic guide that resembles more a hack rather than an official solution from Silicon Labs. Hopefully, Micrium OS can be part of the Flex SDK in the future, but in the meantime, this is a start. I hope this was useful to you. Feel free to post any comments or questions regarding this blog post. |
Sep 02 2020, 3:25 PM |
|
close
Adding Micrium OS on a Flex Gecko on blog
This blog should serve as a guide to adding Micrium OS on a Flex Gecko and get at least one task running on the device. I will now share with you my experience while going through this exercise. Getting StartedI decided to perform a clean installation of Simplicity Studio in order to avoid conflicts inflicted by software updates over time. After installing the tool, before even attempting to add anything, I first had to make sure that I had the necessary SDKs. Here's what I installed:
I then mounted a Flex Gecko, EFR32FG12 in my case, onto a Wireless Started Kit Mainboard (BRD4001A). After that, I connected it to the PC using the provided USB cable. Simplicity Studio recognized a Flex Gecko connected to a WSTK and displayed the link to examples from the Flex SDK (see Figure 1). ![]() Loading a Basic Flex SDK ExampleAs a starting point, I decided to go with the "RAIL: Simple RAIL without HAL" example from the Flex SDK. You can find this by expanding the list of projects under the "Silicon Labs Flex SDK Examples" link: ![]() Then find and click the example shown in Figure 3 to add it to your workspace:
After the example loads on your workspace, you might get a notice as shown in Figure 4. Just click "OK". ![]()
You will then be presented with simple_rail_without_hal.isc opened where you can configure RAIL. In my case, I left everything in its default values and simply clicked on "Generate" as shown in Figure 5. ![]() At this point, you should now be set with a basic Flex Gecko example that builds and runs. However, I did find that the default project settings have compiler optimization set to "Optimize for size (-Os)" which will eventually make debugging the project rather difficult. Therefore, I switched optimizations to "None (-O0)". ![]() Adding Micrium OS to the WorkspaceNow that you have a basic Flex Gecko example that builds and runs, let's go ahead and start adding the Micrium OS source files into the workspace. First, locate the Micrium OS directory, it should be in:
Now drag and drop the "micrium_os" folder into your project (simple_rail_without_hal) in Simplicity Studio. When doing this, make sure that you have "Copy files and folders" selected before clicking "OK" as shown in Figure 7. ![]()
You will then have to remove all the unnecessary files that get added with Micrium OS (this was tedious). Here's how your "micrium_os" folder should end up looking: ![]() Finally, the compiler needs to know where to look for the header files so we have to add two compiler include paths to the project settings:
![]() Configuring Micrium OSNow that you have Micrium OS as part of your project, let's go ahead and make some minor adjustments to the default Micrium OS configuration.
Modifying main.cWe'll be making modifications to the default main.c generated by the "RAIL: Simple RAIL without HAL" example. Micrium OS requires the following include paths in main.c so go ahead and add them as shown below:
We'll be modifying main.c to initialize Micrium OS and create a start task. For that, you'll need to specify a task stack size and a priority. We typically do this by defining them as constants and passing those in the call to OSTaskCreate(). The start task also requires its own Stack and Task Control Block (OS_TCB) as well as its function prototype. Therefore, add the following to main.c:
Here's the body of the StartTask function where the kernel tick gets initialize and as well as the Common module. Note that the function includes an infinite loop at the end with a time delay of 1 second. This is done to yield CPU time to other tasks that are or will eventually run on your system. You can copy and paste the following in your main.c:
Let's now modify main() to initialize the CPU, the kernel create the Start Task, and start the OS. Here's how main() should end up looking:
Finally, since Micrium OS makes use of an assembly-optimized memory copy function, you must enable it in common_cfg.h
You are now set to build and run the project. You can put a breakpoint on the Start Task inside the while loop and notice that you'll be hitting that every second (or as specified by the delay you configure in OSTimeDly()). Please do understand that this is a very basic guide that resembles more a hack rather than an official solution from Silicon Labs. Hopefully, Micrium OS can be part of the Flex SDK in the future, but in the meantime, this is a start. I hope this was useful to you. Feel free to post any comments or questions regarding this blog post. |
Sep 02 2020, 3:24 PM |
|
Replied
to
Adding Micrium OS on a Flex Gecko
Hi David, the biggest issue with this blog is that it's old and no longer relevant since the SDK as evolved so much since I wrote it. Rather than me patching it or adding example code here, I'll just close this and most likely create a new one later on that's more up-to-date with the current SDK.
Show more
|
Sep 02 2020, 3:23 PM |
|
Replied
to
Adding Micrium OS on a Flex Gecko
Hi David, Have you tried the updated project that I uploaded a few replies back? |
Aug 07 2020, 3:01 PM |
|
Replied
to
micrium_os does not work with the EFR32xG22 when create more than 2 tasks
Hi Nan, Please try the clean_main.c file that I attached. Regards, Janos |
Jun 25 2020, 5:38 PM |
|
Replied
to
Adding Micrium OS on a Flex Gecko
Hi Wei,
|
Jun 25 2020, 5:37 PM |
|
Replied
to
Adding Micrium OS on a Flex Gecko
Here's a project on the MG12 using version 2.7 of the SDK:
|
Apr 20 2020, 8:21 PM |
|
Replied
to
Adding Micrium OS to RAIL
You should be able to keep the files. Which ones do you need and to what purpose? Regards, Janos |
Apr 17 2020, 3:54 PM |
|
Replied
to
micrium stack overflow problem
Hi Davide, Can you send me your application file so that I can try and replicate the behavior on my side? Also, was this a project you created from v2.7.0 or is it one that you are migrating from an older SDK and used to work fine? Thanks, Janos |
Feb 07 2020, 10:03 PM |
|
Replied
to
micrium stack overflow problem
Hi Davide, Which version of the Gecko SDK are you using in your project? |
Feb 06 2020, 9:41 PM |