element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
Freedom development platform
  • Products
  • Dev Tools
  • Freedom development platform
  • More
  • Cancel
Freedom development platform
Blog Introduction and demonstration of porting MBED-OS [yotta]on FRDM-K64F Freedom board
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Freedom development platform requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bheemarao
  • Date Created: 1 Mar 2016 7:22 PM Date Created
  • Views 297 views
  • Likes 2 likes
  • Comments 1 comment
  • yotta
  • kinetis
  • frdm-k64f
  • mbedos
  • nxp
Related
Recommended

Introduction and demonstration of porting MBED-OS [yotta]on FRDM-K64F Freedom board

bheemarao
bheemarao
1 Mar 2016

The content of this Tutorial has been extracted from mbed.com

 

Introduction to mbed OS

 

mbed OS is the operating system created for mbed-enabled boards. It allows C++ applications to run on these boards by providing APIs that you can use from your application to control the hardware.

mbed OS designed specifically for constrained devices, so it works behind the scenes to automatically make the most of the limited hardware and network resources available: It’s modular, It’s single-threaded and event-driven, It abstracts the hardware, It efficiently manages power and schedules tasks, It manages both device and communication security using mbed OS uVisor and mbed TLS, It supports multiple networking options

mbed-drivers: Abstract drivers for common hardware peripherals and communications interfaces such as SPI and I2C. Provides a higher level interface than the mbed HAL; these are the APIs that applications should use.

 

mbed OS and yotta

 

yotta is the build system used for mbed OS.whaat you need to understand at this point is that mbed OS applications cannot be built without yotta.

Working with mbed OS means you use yotta to combine your own application code with the mbed OS code base. yotta gets the relevant parts of mbed OS for you from its own registry.

yotta combines our code (application) with the mbed OS code-base and any other module (reusable library) that we may need. To tell yotta what our application needs, we add a list of dependencies to each application we write. The easiest way to add mbed OS to our application when we build it is to describe the component mbed-drivers as a dependency of our application, because mbed-drivers has most other components as its own dependencies, so yotta will build what we need. mbed OS applications are yotta executable modules, as opposed to yotta library modules.

 

What this all means is that to build applications that can run on top of mbed OS, you need:

  • yotta.
  • mbed OS modules and optional additional libraries, which yotta gets for you.
  • Your own application code.

image

We begin our tutorial from here

Yotta Installing on Windows

To install yotta on windows you can either use the one shot windows installer or install all the dependencies and yotta manually.

1.      Download the latest yotta windows installer.

2.      Run the installer.

3.      Click on Run Yotta shortcut on desktop or in start menu to run session with yotta path temporarily pre-pended to system path.

Let us proceed to test blinky example on yotta using  FRDM-K64FFRDM-K64F freedom board

After installing yotta you can see the icon on your desktop as shown

image

Double click on this icon and you will see the command prompt window as shown

 

image

Create an application

First create a directory with the name we want, and cd into it. I have created directory by name “frdm-k64-rgb”

image

Next we need to create module description by typing command

‘yotta init’

Initialize the module with yotta init and fill in the details.

Make sure you select executable as the module type: “yes”

image

You should now have several folders and files in your project directory as shown below

image

  • The module.json file contains all the settings for your application; everything you just entered can be found in that file, so if you want to edit it later, for example to add a repository URL, that’s not a problem.
  • The /source directory contains all the source files.
  • The /test directory contains all tests you’ll write to test your module.
  • The /blinky directory is where header files for your application will be created.

 

Select a target board:

yotta can build the same code for multiple targets it therefore needs to be told which target every build is for. So now that you have created a basic application, you need to set the target.

 

In this example we are going to use the Freescale  FRDM-K64FFRDM-K64F board configured for building with gcc so you use target frdm-k64f-gcc

Type below command to build the target for frdm-K64 board

yotta target frdm-k64f-gcc

image

To check that the target has been set correctly run the ‘target’ command without parameters. It shows what yotta is currently targeting for its builds:

The information for this target has been downloaded to a directory named /yotta_targets. Do not edit or modify files here because they can be modified without your knowledge.

image

Install dependencies:

When you have a dependency, you need to install it before you can build your own project. You need to do this from the module directory.

Now you need to install the dependencies. In this application, you have mbed-drivers as your dependency:

yotta install mbed-drivers

 

You need to be online for the installation to work, because yotta downloads the modules from the yotta Registry.

yotta downloads and installs the modules to a directory named /yotta_modules. Do not edit or modify files here as they can be modified without your knowing.

image

Adding project code

Now that you have an application and its dependencies, you need source code to make the module useful.

In the /source folder, create a file called “rgb_blinky.cpp” with the following contents:

 

#include "mbed-drivers/mbed.h"
static void blinky_red(void) {
    static DigitalOut led1(LED1);
    led1 = 0;
     printf("LED Red = %d \n\r",led1.read());
    wait(1);
    led1 = 1;
     printf("LED Red = %d \n\r",led1.read());
     wait(1);
 }


static void blinky_green(void) {     
    static DigitalOut led2(LED2);
    led2 = 0;
   printf("LED Green = %d \n\r",led2.read());
    wait(1);
   led2 = 1;
   printf("LED Green = %d \n\r",led2.read());
      wait(1);
  }

static void blinky_blue(void) {
      static DigitalOut led3(LED3);
    led3 = 0;
   printf("LED Blue = %d \n\r",led3.read());
     wait(1);
     led3 = 1;
     printf("LED Blue = %d \n\r",led3.read());
     wait(1);
}
void app_start(int, char**){
    // set 115200 baud rate for stdout
    get_stdio_serial().baud(115200);    
 minar::Scheduler::postCallback(blinky_red).period(minar::milliseconds(1000));
 minar::Scheduler::postCallback(blinky_green).period(minar::milliseconds(2000));
 minar::Scheduler::postCallback(blinky_blue).period(minar::milliseconds(4000));
}

 

image

 

To support board-agnostic programming, the mapping of functionality to a pin is handled by board-specific HAL implementations.

static DigitalOut led(LED1);

DigitalOut.h is a header in mbed-drivers. The class DigitalOut in that header creates a digital output connected to a pin specified in the code.

This application causes Red led on-off every 1000 milli seconds (1 sec) defined by minar scheduler by calling blinky_red() function

And Green led on-off every 2000 milli seconds (2 sec) defined by minar scheduler by calling blinky_green() function

And Green led on-off every 4000 milli seconds (4 sec) defined by minar scheduler by calling blinky_blue() function

 

Building the module

The build command (like the target command) must be performed from within the directory of the module you’re trying to build. It must also be performed after selecting a yotta target, as explained above.

To build the application:

Run the

yotta build

command in the top level directory:

 

image

After the build is executed we can see the folder “build” is created which includes all the necessary headers required for the mbed os target. yotta compiles the binary to the /build folder.

 

Run the application on your board

Connect FRDM-K64 (pre loaded with mbed driver) board to your computer over USB. It should appear as removable storage.

Copy the binary “frdm-k64-rgb.bin” or From your file explorer, drag and drop the file onto  your mbed board and see the LED blink.

 

image

The application is now on your board. This boards needs reset to start your application running.

 

Output execution:

The status of RGB led on the board will be as given below:

image

Hence the sequences of the LED are

“(R on/off) (R on/off) (G on/off) (R on/off) (R on/off) (G on/off) (B on/off)” “(R on/off) (R on/off) (G on/off) (R on/off) (R on/off) (G on/off) (B on/off)”... it repeats

 

Same sequence can be seen at the output hyperterminal by opening any hyperterminal of your choice, i am having putty terminal..

  Configure the settings as shown below:

image

You can see the output of the RGB sequence in hyper terminal as shown below:

image

 

The video output of RGB blinking sequence is shown below

 

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Helpful Links:

http://yottadocs.mbed.com/tutorial/tutorial.html

https://docs.mbed.com/docs/getting-started-mbed-os/en/latest/FirstProjectmbedOS/

https://docs.mbed.com/docs/getting-started-mbed-os/en/latest/

 

The project folder is attached along with this for quick evaluation

 

Happy starting mbedos...  image image image image

Attachments:
frdm-k64-rgb.rar
  • Sign in to reply
  • clem57
    clem57 over 6 years ago

    wow!image This is a great blog worthy of time to read and understand. Keep up with you is very hard.

    Thanks,

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube