TOC
Introduction
This tutorial comes from the fact that there are several steps where errors can come up. We first install MbedOS cli.
Zephyr is a little easier to setup compared to Mbed OS to setup. This was done on Debian 9 with a FRDM-K64F.
Mbed OS Steps
1. Download the latest toolchain. It can be untar and installed where its more convinient: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads
2. Install mbed-cli with python. This steps are well made from the website. Make your to be using Python3. https://os.mbed.com/docs/mbed-os/v6.3/build-tools/install-and-set-up.html
3. Configure GCC_ARM_PATH and ARM_PATH
$ mbed config -G ARM_PATH "<path to ARM bin\>"
$ mbed config -G GCC_ARM_PATH "<path to ARM bin\>"
Test output:
[mbed] Global config:
ARM_PATH=/home/jaime/programs/gcc-arm-none-eabi-9-2020-q2-update/bin/
GCC_ARM_PATH=/home/jaime/programs/gcc-arm-none-eabi-9-2020-q2-update/bin/
4. Go to the directory to create the MbedOS projects:
$ cd /absolute/path/to/project/dir/
5. Add mbed-os libraries:
$ mbed add mbed-os
You will end up with the mbed-os directory at this location
6. Configure your mbed-os sources:
$ mbed config -G MBED_OS_DIR /absolute/path/to/project/dir/mbed-os
You can test this was done with the command: $ mbed config –list
7. Create your new project
$ mbed new proj1
8. Create a test main.c at this location /absolute/path/to/project/dir/proj1
and use the code below from the blink test project.
/* mbed Microcontroller Library
* Copyright (c) 2019 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*/
#include "mbed.h"
// Blinking rate in milliseconds
#define BLINKING_RATE 100ms
int main()
{
// Initialise the digital pin LED1 as an output
DigitalOut led(LED1);
while (true) {
led = !led;
ThisThread::sleep_for(BLINKING_RATE);
}
}
9. To compile your project, make sure you are at the root location for your projects,
which is /absolute/path/to/project/dir/
From this location you will run the compilation commands.
I created a Makefile to make it easier to run them. Copy, paste and run this Makefile at this root location.
deps:
mbed toolchain GCC_ARM
mbed target K64F
proj1: deps
mbed compile -v -t GCC_ARM -N $@ --source $@ --source mbed-os --build ./BUILD/$@ --flash
Run with:
$ make proj1
Zephyr Steps
1. Install the necessary requirements
sudo apt-get install --no-install-recommends git cmake ninja-build gperf \
ccache dfu-util device-tree-compiler wget \
python3-pip python3-setuptools python3-wheel xz-utils file make gcc
2. Download and Install SDK
wget https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.10.0/zephyr-sdk-0.10.0-setup.run
cd <sdk download directory>
sh zephyr-sdk-0.10.0-setup.run
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
export ZEPHYR_GCC_VARIANT=zephyr
export ZEPHYR_SDK_INSTALL_DIR=<sdk installation directory>
3. Get the kernel
git clone [email protected]:zephyrproject-rtos/zephyr.git
4. Do Hello World
https://docs.zephyrproject.org/latest/boards/arm/frdm_k64f/doc/index.html
git checkout tags/v1.8.0
source zephyr-env.sh
cd $ZEPHYR_BASE/samples/hello_world
make BOARD=frdm-k64f
Common errors
- Install Pyyaml and elftools using the following command:
sudo pip3 install -r scripts/requirements.txt
Final Notes
You can remove the -v option to remove logs and speed it up. And of course the Makefile can be improved. This was done to get it done quick.
When you create another project, just duplicate the last two lines replacing only the project name.
Hope this quick tutorial helps people to get up to speed fast on this environment. The actual website misses explaining some things and lacks in others.