Send the link below via email or IMCopy
Present to your audienceStart remote presentation
- Invited audience members will follow you as you navigate and present
- People invited to a presentation do not need a Prezi account
- This link expires 10 minutes after you close the presentation
- A maximum of 30 users can follow your presentation
- Learn more about this feature in our knowledge base article
Chibios/RT tutorial by JF
Transcript of Chibios/RT tutorial by JF
1st thing to do:
visit this page to go to the latest version of this prezi
Assuming you already know what Chibios/RT is, having read the basics in www.chibios.org, this Prezi is about making it as easy as possible to you to
Install all tools needed for you to develop (Eclipse, GCC, in circuit debugging tools)
Learn what you need only in the complex Eclipse, Create your first project correctly, write as quickly as possible your first lines of code and see them working, debug and fully enjoy them
Get acquainted to chibios as fast as possible at a knowledge level of more than 60%
then it will be up to you to learn the finer details and it should be easy.
The hard thing on Chibios is to start with its tools and concepts and make it up to 30% of the knowledge. There is no book written for it and doing without a concrete guide is
Install all tools needed for you to develop
(Eclipse, GCC, in circuit debugging tools)
Learn only what you need in the complex Eclipse, Create your first project
Get acquainted to Chibios
This Know-How is for ST's STM32F MCUs with STLINK v2 debugger (covering discovery boards at least (except STM32F100) and any user board). Small changes should be for use of other debugging tools and MCUs. Sorry, but the environment will be Windows7 32/64 bit
As of the date this document is updated, January 2014, the main tools versions used are:
Chibistudio: preview 5 containing:
- Eclipse Juno 4.2 classic (http://www.eclipse.org) with the following
optional components installed:
- Eclipse CDT 8.1.0.
- C/C++ GDB Hardware Debugging 7.0.0.
- Eclipse XML Editors and Tools 3.4.0.
- Target Management Terminal 3.3.0.
- Serial Connector plugin (http://rxtx.qbang.org/eclipse).
- ChibiOS/RT debug plugin 1.0.8.
- ChibiOS/RT configuration plugin 1.1.0.
- Embedded Systems Register View plugin 0.2.1.90
- GCC ARM toolchain (https://launchpad.net/gcc-arm-embedded)
- YAGARTO Tools (http://www.yagarto.de).
- OpenOCD 0.7.0 (http://http://www.freddiechopin.info/).
- ChibiOS/RT 2.6.1.
Start downloading :)
Chibistudio is a great package of tools ready for use, thanks to Chibios developers! It spares us perhaps a day of installations and reading :)
Hardware debugger drivers. For ST-LINK/V2: http://www.st.com/web/catalog/tools/FM146/CL1984/SC724/SS1677/PF251168#
Ensure that you have a late enough Java JRE installed, or to make sure go to http://java.com/en/download/manual.jsp
and get the appropriate binary for your OS.
Start with Java installation (remember the 32bit in case you are 64 bit windows. Unfortunatelly Eclipse Juno 4.2.0 contained in the Chibistudio is 32 bit)
Install the USB debugger (STLINK v2 in our tutorial) driver
Chibistudio does not require installation :) Just unzip and copy directly in the C:\ root (do not use other path for now, if needed do not use one with white characters in it)
Copy the shortcut "C:\ChibiStudio\Chibi Studio" on your desktop.
Use the shortcut to launch ChibiStudio
Very difficult to be easier!!! Thanks to Chibistudio! :) Otherwise it is a marathon to install all you need
or be you to provide it
Introduction & motivation
Lets consider you have not worked in Eclipse before.
Well, thanks to Eclipse, this immense work that great developers have done to make us happy and creative with an ultimate open source IDE, we can be very happy to have an editor with auto completion, project management, all languages supported and most of all a very great debugging system.
But lets face it. As with most projects who have many creators, this big machine has become a huge monster. It is too complicated in the sense of that it does too many more than an average user might ever need. So it is an environment like the cockpit of the space shuttle.
We will focus on what is needed for development of:
projects up to 20 files of user code approximately (+ the many files of the firmware and RTOS), well organized
easy switching from project to project, easy projects cloning (say to new versions)
Full debugging, full usability of the IDE to write code as efficient and as fast as possible
Full use of tools regarding embedded systems, eg. registers watching, code profiling, OS monitoring etc.
The goal is to gain full featured top professional tools and to learn using them as fast as possible (easy things first)
lets have fan and awe
For windows 64 bit you must also install the 32 bit Java !
Eclipse Juno opens if all go well in the Welcome screen:
Close the welcome screen and you are at your first glimpse:
Your projects contained inside your
multi tabbed editor
debug console and watch windows, even a serial terminal
help, objects viewer etc
Connecting to the MCU: Flashing and Debugging
Compiling with GCC
This chapter will be a little bit hard. In these issues Eclipse is an overkill nuclear weapon, but I feel that you need only to chase rabbits
Lets start with the requirement that we shall work on our own choice about the folder where our projects will reside. This is for the case we hate to work on the path C:\ChibiStudio\chibios\ and we hate loosing all our work every time we upgrade our tools.
We choose a folder of our files. For having a reference example lets have it the
d:\Google Drive\my files\ChibiOS\
Make a fresh download of all chibios and extract it in the folder, better named after the version you downloaded. Say now we have this path
d:\Google Drive\my files\ChibiOS\ChibiOS_2.6.1\
containing the following
In this tutorial I will suggest to bind the work done with the RTOS done onto. I mean to place the developed code at the same path as this folder (ChibiOS_2.6.1\) so as to refer to an RTOS file using ../../ChibiOS_2.6.1 In the case a new Chibios is reliesed (and / or a new Chibistudio is installed), I wouldn't like to change the RTOS files which are included in all the developed applications that far and risking that the new ones are back compatible 100%. Instead I would like to create a new folder, say ChibiOS_2.8.1\ and make new applications only to point there. Of course I can port then EACH application to the new Chibios by hand. I believe that is a safe road
So lets make a folder for all our projects next to this folder of Chibios, say we create the folder called "my projects\"
Setup Eclipse to display "Chibios/RT configuration wizard" command on file->new menu:
Open Window->Customize Perpsective
Choose "shortcuts" tab and activate Chibios/RT
After this point the actions are about a new project, Eclipse has been setup
Click File -> new -> Chibios/RT new application Project Wizard
Lets make a project called "blinkyF303v1"
In the case of this example the following discovery board with the STM32F303 MCU will be used
You can adjust to your hardware taking in mind what is different in your case. Please note that the STM32F100 discovery board has STLINK-V1 on it and it has a problem (perhaps a bug) with Chibistudio. There might be solutions, I have tryied a little to make mine work but I had no success.
select the PARENT folder of the new project
RIGHT click "Others" working set and click on Properties
Search for the project and check it
And our project appears!!
YES Eclipse is paranoia
Our project is open
Other projects are closed
You open/close a project by right clicking on it and selecting open/close. All your projects remain in the project explorer, one open at a time. This is a good facility
Our project so far is empty. Lets link to it the Chibios files
Click File -> new -> folder
Select "Link to alternate loacation
Choose the chibios folder
The Chibios/RT files appear in the project's "folder"
Now our project needs the necessary code to build and...
we will see, after building it,
some debugging settings needed for each new project
Our project , so far, contains only the Chibios files. Actually these are linked. It contains only two project settings files created by Eclipse if we look in its folder.
Time to add the minimum essential code. This code has a main.c file and some more Chibios files, all in the "root" directory of the project.
Lets grab a set of files that (as a set) work. Open the Chibios demos folder and pick a board that is close to you, in our case the folder ARMCM4-STM32F303-DISCOVERY, open it and copy all but the project files to your project folder.
Immediately they will appear in the project explorer
We will explain what they contain in the "Get acquainted to chibios" section.
We have some bad news for the guys who are only using the luxury of a fully automated IDE (e.g. Visual Studio) for developing. Well... if you are to use any RTOS you must do it truly, that is YOU MUST MAINTAIN THE MAKE FILE YOURSELF. It is not hard at all. Just need an entry for any new file you add to your project. (OK.. it may be hard in porting large, already made projects, into Chibios).
For our example we set the makefile just for the files we have. Since all Chibios files are well automated inside the makefiles we just need to adjust the path of our Chibios folder. Open the makefile inside Eclipse and go to line 67. Change the folder to ../../ChibiOS_2.6.1 That's all for now.
Note line 64 and 86. After 86 you add your own files (we have no more of our own in this project)
Line 76 is different for other MCUs. Get the makefile from the directory relevant to
your MCU if it is other.
Take a minute to read the makefile. You will understand almost everything in it.
Note that there are also other makefiles inside the Chibios.
This is the overall makefile that makes them all into ch.elf
The output filename of the project when built will be ch.elf
Sources to compile
Ready to build !! :) !!!!
How to build in Eclipse:
First save all unsaved files of code Ctrl + Shift + S
Press Ctrl + B and wait to see no errors in your console
A Console output like this is the desired thing to see:
with nothing red colored
Optional actions to get the
of our build:
1. The easy way but have to do it each time we code:
Open a command prompt on Windows
type in this console
"c:\ChibiStudio\tools\GNU Tools ARM Embedded\4.7 2013q2\bin\arm-none-eabi-size.exe" "d:\Google Drive\my files\ChibiOS\my projects\blinkyF303\build\ch.elf"
the code size (text), constant data (data) and global variables or statically allocated variables (bss), all in decimal. The sum of text+data+bss is shown in dec(imal) and hex(adecimal). FLASH size is text+data, RAM size is bss (not including malloc() calls)
2. How to have this information inside eclipse and not having to open cmd prompt again:
This is useless I believe
Note: With any good RTOS you will expect to begin with a rather big code size and increment slowly (actually slower than the case of not using an OS because your app code is eventually smaller. Do not make hopes for using MCUs as small as 16 or 32 KB flash or less than 8K RAM. After all nowadays they have just become really affordable. Another thought is that the RTOS is for big applications. Last, Chibios can be tuned to occupy less. Non the less, in these great modern times we are living you do no have to be a Neanderthal
Eclipse supports "external tools" you will find in the Run menu
Lets configure them clicking here
C:\ChibiStudio\tools\GNU Tools ARM Embedded\4.7 2013q2\bin\arm-none-eabi-size.exe
Select "Program" and click on the "new" icon
setup as follows:
the build folder path
name it size
From now on when you click on this icon you will see this option
When you click it the project will compile and the size will be seen in the Eclipse console
So far we have tackled the compiler issues.
If you want to see how great GCC is for embedded development take a look here
(it is for ARM7, not Cortex though)
Now we are about to debug in our chip with an overkill tool
Here are the basics:
Eclipse uses the
for debugging that works over a network (via local host) connection ( https://www.gnu.org/software/gdb/ )
. So they name the preset configurations of the User Interface of the IDE. e.g. One perspective may be a configuration for code witting - big multi windows of editors - another perspective may be a configuration for debugging showing many and big watch windows, consoles etc and small window of editor.
means Open On Circuit Debugger, is the open source interface (connection) of the GDB to the board via JTAG, SWD or other hardware protocols, enabling GDB to be aware of the values of variables inside the MCU, registers of the MCU, perform breakpoints, program flash etc ( http://openocd.sourceforge.net/ ). We are going to debug another computer using our PC as if we are debugging a code on our CPU
Setting Debug Configurations:
Click menu Run -> debug configurations:
Select GDB Hardware Debugging and click New
Type the name of the project
Type 3333 for port numb.
set remotetimeout 20
monitor reset init
monitor sleep 50
You should do nothing on this tab
Check the Debug
Then click Close
At this moment we have created a "debug configuration" the only one in our project. It is accessible (do not do this yet) by clicking the drop down arrow of the bug icon
In order to debug, we need to have the OCD running i.e. to start an OCD session. This is an External tool, like the size tool we made by executing the arm-none-eabi-size.exe inside Eclipse.
Chibistudio is already pre-configured for that.
Switch to debug perspective by clicking on the perpsective button
On the drop down of the external tools icon click on your debugger's configuration (In our case I can only test the STLINK-V2)
If you have connected your debugger AND the target MCU is up and running and communicating to your debugger, a debug session will turn into "run mode". You will see red messages in the console window. Red is good here, red are the OCD messages. Allow access to firewall if prompted
Doing so a dialog box appears asking you for a file of a board configuration file. Up to now you must have a real board, working to do the rest. For start lets assume that you have the STM32F303 discovery, or a development kit from the list (we will see shortly how to configure for any other user board)
This is the path of the board configuration files
If this has gone well, we are almost done. Possible troubleshooting actions here are:
Your STLINK V2 debugger needs firmware updating with the STLINK Utility
You have an STLINK V1 e.g. in the STM32F100 discovery kit
Your driver is not well installed
Debugger does not "see" the MCU (check jumpers, supply etc)
Your MCU is not powered or not working due to bad hardware
Retry once more or restart Eclipse.
Start the debug configuration by clicking on the drop down arrow next to the bug
Project rebuilds (this is actually a better way to build it) and you should see the following:
Stopped at he first command to execute
Hit run and enjoy :)
As long as the OCD is running you do not need starting it again
In case you have another board (say your own)
If you are connected by an STlink-V2 or any of the supported ones, edit the board configuration file and make one proper of your own. This is an example that works on me debugging an STM32F103VCT6 on another board that I designed, connected over SWD.
Explore the interface and the target directories of the directory c:\ChibiStudio\tools\openocd\scripts\
Get used and be happy with the debugger. Use breakpoints. When trapped on a breakpoint, hover the mouse over the code of the scope you are inside and you will see the values popping
Lets use some power of the Chibios. Chibios has its own plugin inside the Chibistudio to do extra debugging on the RTOS level.
How to invoke these tools:
The most work already. On the Chibios tab, you may see for example the threads running. Note that you must be paused and click on the refresh icon each time to update the information
In order to use the trace buffer and a threads profiling capability, edit the chconf.h file and turn into TRUE these switches:
Note that trace buffer may take some seconds to display the traced information
It is time to start creating
different for each MCU!
Importing projects into a working set
For every MCU and every board, the makefile is different!! Be careful
A typical main.c