<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://miosix.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Andreabont</id>
	<title>Miosix Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://miosix.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Andreabont"/>
	<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Special:Contributions/Andreabont"/>
	<updated>2026-04-14T12:42:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Linux_Debugger_configuration&amp;diff=257</id>
		<title>Linux Debugger configuration</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Linux_Debugger_configuration&amp;diff=257"/>
		<updated>2016-06-26T10:26:30Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The debugging of Miosix on Linux can be done through [http://openocd.net/ OpenOCD], that creates a bridge between GDB and the JTAG device.&lt;br /&gt;
&lt;br /&gt;
== Setting up OpenOCD ==&lt;br /&gt;
&lt;br /&gt;
=== Install OpenOCD ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install openocd # Install OpenOCD for Ubuntu/Debian&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Run OpenOCD ===&lt;br /&gt;
The OpenOCD configuration is included in the official Miosix distribution under the path &#039;miosix/arch&#039;. You must choose the proper config file for the device in use. For example for the stm32f429zi_stm32f4discovery board:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openocd -f miosix/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/stm32f4discovery.cfg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging with GDB ==&lt;br /&gt;
The GDB used is provided by the official [[Miosix_Toolchain|Miosix Toolchain]]. If you haven&#039;t already installed it&#039;s time to do it. The debugger must be launched on the ELF binary file.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
arm-miosix-eabi-gdb main.elf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Connect GDB ===&lt;br /&gt;
OpenOCD provide a network interface for connect the debugger, the follow command is necessary for establish the connection:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote &amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default socket is listening on port 3333 in the loopback interface of your computer. So you can use the default command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote :3333&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reset the board ===&lt;br /&gt;
After the connection (and after each change of configuration) you must reset the board in a safe state:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) monitor reset halt&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Flash a new firmware ===&lt;br /&gt;
If you want to upload to the board a new firmware version you can made it through gdb and OpenOCD, you must indicate the binary file and the address of the flash memory of your board:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) monitor flash write_image erase main.bin 0x08000000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
It&#039;s often necessary to perform a reset of the board before and after the firmware upload.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Linux_Debugger_configuration&amp;diff=256</id>
		<title>Linux Debugger configuration</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Linux_Debugger_configuration&amp;diff=256"/>
		<updated>2016-06-26T10:16:58Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;The debugging of Miosix on Linux can be done through [http://openocd.net/ OpenOCD], that creates a bridge between GDB and the JTAG device.  == Setting up OpenOCD ==  === Insta...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The debugging of Miosix on Linux can be done through [http://openocd.net/ OpenOCD], that creates a bridge between GDB and the JTAG device.&lt;br /&gt;
&lt;br /&gt;
== Setting up OpenOCD ==&lt;br /&gt;
&lt;br /&gt;
=== Install OpenOCD ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install openocd # Install OpenOCD for Ubuntu/Debian&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Run OpenOCD ===&lt;br /&gt;
The OpenOCD configuration is included in the official Miosix distribution under the path &#039;miosix/arch&#039;. You must choose the proper config file for the device in use. For example for the stm32f429zi_stm32f4discovery board:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
openocd -f miosix/arch/cortexM4_stm32f4/stm32f429zi_stm32f4discovery/stm32f4discovery.cfg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Debugging with GDB ==&lt;br /&gt;
The GDB used is provided by the official [[Miosix_Toolchain|Miosix Toolchain]]. If you haven&#039;t already installed it&#039;s time to do it. The debugger must be launched on the ELF binary file.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
arm-miosix-eabi-gdb main.elf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Connect GDB ===&lt;br /&gt;
OpenOCD provide a network interface for connect the debugger, the follow command is necessary for establish the connection:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote &amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The default socket is listening on port 3333 in the loopback interface of your computer. So you can use the default command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) target remote :3333&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reset the board ===&lt;br /&gt;
After the connection (and after each change of configuration) you must reset the board in a safe state:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) monitor reset halt&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Flash a new firmware ===&lt;br /&gt;
If you want to upload to the board a new firmware version you can made it through gdb and OpenOCD, you must indicate the binary file and the address of the flash memory of your board:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
(gdb) monitor flash write_image erase main.bin 0x08000000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Board_list&amp;diff=163</id>
		<title>Board list</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Board_list&amp;diff=163"/>
		<updated>2015-01-22T20:23:45Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Add link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page lists the vaious boards that Miosix supports. The board naming convention used in this list is the same as the one used in [[Makefile.inc|miosix/config/Makefile.inc]], with the name of the microcontroller followed by the board name.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Links&lt;br /&gt;
|-&lt;br /&gt;
| [[lpc2138_miosix_board]] || Official Miosix board || [https://miosix.org/boards/miosix_board-overview.html Overview]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ze_stm3210e-eval]] || || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00178166.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ve_mp3v2]] || || &lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f100rb_stm32vldiscovery]] || The small discovery board with a 24MHz CPU || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00267113.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ve_strive_mini]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ze_redbull_v2]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f407vg_stm32f4discovery]] || The discovery board with an audio connector and a 168MHz CPU || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00039084.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f207ig_stm3220g-eval]] || || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00022972.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f207zg_ethboard_v2]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f207ze_als_camboard]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32l151_als_mainboard]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f407vg_bitsboard]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f205rg_sony-newman]] || A smart watch made by Sony, with an OLED display ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f429zi_stm32f4discovery]] || The new discovery board with a touchscreen display and 8MB of external RAM || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00093903.pdf User Manual]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Boards]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Board_list&amp;diff=162</id>
		<title>Board list</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Board_list&amp;diff=162"/>
		<updated>2015-01-22T20:20:28Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Format with table and add links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page lists the vaious boards that Miosix supports. The board naming convention used in this list is the same as the one used in [[Makefile.inc|miosix/config/Makefile.inc]], with the name of the microcontroller followed by the board name.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Name !! Description !! Links&lt;br /&gt;
|-&lt;br /&gt;
| [[lpc2138_miosix_board]] || Official Miosix board || [https://miosix.org/boards/miosix_board-overview.html Overview]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ze_stm3210e-eval]] || || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00178166.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ve_mp3v2]] || || &lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f100rb_stm32vldiscovery]] || The small discovery board with a 24MHz CPU || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/CD00267113.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ve_strive_mini]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f103ze_redbull_v2]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f407vg_stm32f4discovery]] || The discovery board with an audio connector and a 168MHz CPU || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00039084.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f207ig_stm3220g-eval]] || || [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00022972.pdf User Manual]&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f207zg_ethboard_v2]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f207ze_als_camboard]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32l151_als_mainboard]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f407vg_bitsboard]] || ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f205rg_sony-newman]] || A smart watch made by Sony, with an OLED display ||&lt;br /&gt;
|-&lt;br /&gt;
| [[stm32f429zi_stm32f4discovery]] || The new discovery board with a touchscreen display and 8MB of external RAM ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Boards]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Stm32f407vg_stm32f4discovery&amp;diff=161</id>
		<title>Stm32f407vg stm32f4discovery</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Stm32f407vg_stm32f4discovery&amp;diff=161"/>
		<updated>2015-01-22T20:06:53Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Adding category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
;STM32F4DISCOVERY&lt;br /&gt;
* A [http://www.st.com/web/catalog/tools/PF252419 discovery board] for [http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN11/PF252140 STM32F407VGT6] microcontroller with 168&amp;amp;nbsp;MHz [[ARM Cortex-M4F]] core, 1024&amp;amp;nbsp;KB Flash, 192&amp;amp;nbsp;KB RAM, 4&amp;amp;nbsp;KB battery-backed RAM in [[LQFP]]100 package.&lt;br /&gt;
* This board includes an integrated [http://www.st.com/web/catalog/tools/PF219866 ST-LINK/V2] debugger via [[Mini-USB|Mini-B USB]] connector, [[accelerometer]] (LIS302DL), [[microphone]] (MP45DT02), audio [[codec]] (CS43L22), [[Phone connector (audio)|3.5&amp;amp;nbsp;mm audio jack]], 4 user LEDs, user button, reset button, Full-Speed [[USB On-The-Go|USB OTG]] to second [[MicroUSB|Micro-AB USB]] connector, and two 25x2 male [[pin header]]s.&lt;br /&gt;
* A separate [http://www.farnell.com/datasheets/1671410.pdf STM32F4DIS-BB] baseboard is available.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Configuring the kernel ===&lt;br /&gt;
Unlike the stm32vldiscovery, this board has the STLink/V2 firmware which is much more Linux friendly. All you need is a recent version of OpenOCD and the [https://github.com/fpoussin/QStlink2 QStlink2] tool to support ths board.&lt;br /&gt;
&lt;br /&gt;
First, make sure the correct board is selected in the &#039;&#039;&#039;miosix/config/[http://gitorious.org/miosix-kernel/miosix-kernel/blobs/master/miosix/config/Makefile.inc Makefile.inc]&#039;&#039;&#039; file.&lt;br /&gt;
The line defining the OPT_BOARD variable should be set to &#039;&#039;&#039;OPT_BOARD := stm32f407vg_stm32f4discovery&#039;&#039;&#039;, that is, that line should be uncommented, and the other commented out, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
## Target board, choose one. This also implicitly select the target&lt;br /&gt;
## architecture&lt;br /&gt;
##&lt;br /&gt;
#OPT_BOARD := lpc2138_miosix_board&lt;br /&gt;
#OPT_BOARD := stm32f103ze_stm3210e-eval&lt;br /&gt;
#OPT_BOARD := stm32f103ve_mp3v2&lt;br /&gt;
#OPT_BOARD := stm32f100rb_stm32vldiscovery&lt;br /&gt;
#OPT_BOARD := stm32f103ve_strive_mini&lt;br /&gt;
#OPT_BOARD := stm32f103ze_redbull_v2&lt;br /&gt;
OPT_BOARD := stm32f407vg_stm32f4discovery&lt;br /&gt;
#OPT_BOARD := stm32f207ig_stm3220g-eval&lt;br /&gt;
#OPT_BOARD := stm32f207zg_ethboard_v2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In addition, this board has a couple of board-specific options in the Makefile.inc file. For convenience, the relevant part of that configuration file is reported here so as to be easily located within the file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
##---------------------------------------------------------------------------&lt;br /&gt;
## stm32f407vg_stm32f4discovery&lt;br /&gt;
##&lt;br /&gt;
ifeq ($(OPT_BOARD),stm32f407vg_stm32f4discovery)&lt;br /&gt;
&lt;br /&gt;
  ## Linker script type, there are two options&lt;br /&gt;
  ## 1) Code in FLASH, stack + heap in internal RAM (file *_rom.ld)&lt;br /&gt;
  ## 2) Code + stack + heap in internal RAM (file *_ram.ld)&lt;br /&gt;
  LINKER_SCRIPT_PATH := arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/&lt;br /&gt;
  LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_rom.ld&lt;br /&gt;
  #LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_ram.ld&lt;br /&gt;
&lt;br /&gt;
  ## This causes the interrupt vector table to be relocated in SRAM, must be&lt;br /&gt;
  ## uncommented when using the ram linker script&lt;br /&gt;
  #SRAM_BOOT := -DVECT_TAB_SRAM&lt;br /&gt;
&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As can be seen, the file is made mostly of comments, and defines three options: &#039;&#039;&#039;LINKER_SCRIPT&#039;&#039;&#039; and &#039;&#039;&#039;SRAM_BOOT&#039;&#039;&#039;. The comments explain in detail the meaning of there options, so it isn&#039;t necessary to further explain them. &lt;br /&gt;
&lt;br /&gt;
Then you should disable filesystem support. Since this board lacks a microSD card or other hardware that could support a filesystem, the bsp has no filesystem backend implementation and if you leave the filesystem enabled the kernel will fail to compile saying it can&#039;t find a backend.&lt;br /&gt;
To do so, open the &#039;&#039;&#039;miosix/config/[http://gitorious.org/miosix-kernel/miosix-kernel/blobs/master/miosix/config/miosix_settings.h miosix_settings.h]&#039;&#039;&#039; and comment out the&lt;br /&gt;
&lt;br /&gt;
 #define WITH_FILESYSTEM&lt;br /&gt;
&lt;br /&gt;
After modifying configuration files it is recomended to do a &#039;&#039;&#039;make clean; make&#039;&#039;&#039; (or in the Netbeans IDE, to click on the &amp;quot;Clean and build project&amp;quot; button) to be sure that changes are applied.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Loading code ===&lt;br /&gt;
As explained before, there are more than one linker script for this board, and the selected linker script affects the way code should be loaded on the board.&lt;br /&gt;
*The stm32_1m+192k_rom.ld is the &#039;&#039;&#039;default linker script&#039;&#039;&#039;, and put the code in FLASH, so you need to program the microcontroller&#039;s FLASH every time you change your code, but code will run faster and won&#039;t be lost at each reboot.&amp;lt;br /&amp;gt;A simple way to load code in FLASH is to use the [[QStlink2]] tool. &lt;br /&gt;
*The stm32_1m+192k_ram.ld linker script is very useful for debugging code on this board, as it locates everything (code, stack, heap) in the microcontroller&#039;s RAM.&amp;lt;br /&amp;gt;It has the disadvantage that the loaded code is lost upon reboot (being in a volatile memory), but for debugging,it is not an issue.&lt;br /&gt;
&lt;br /&gt;
=== stdout redirection ===&lt;br /&gt;
&lt;br /&gt;
The board support package of this board is a little different from the other, as by default it will redirect stdout (but not stdin!) through the &#039;&#039;&#039;debug communication channel&#039;&#039;&#039;. This means that if you are debugging your board with OpenOCD+gdb, you&#039;ll see the output of printf directly in your gdb shell. Since the debug communication channel is unidirectional, stdin is redirected nowhere, and attempting to read from it will result in an infinte loop.&lt;br /&gt;
This has been done to keep the board &amp;quot;self contained&amp;quot;, that is, to be able to write and test code without adding additional hardware.&lt;br /&gt;
&lt;br /&gt;
If on the other hand, you have a 3.3V logic level USB to serial adapter, such as one based on the FT232 chip, you can still redirect printf to the serial port USART3 (GPIO PB10 and PB11 on the board). This also has the advantage of making both stdout and stdin work.&lt;br /&gt;
To do so, edit the file &#039;&#039;&#039;miosix/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/[https://gitorious.org/miosix-kernel/miosix-kernel/blobs/master/miosix/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/board_settings.h board_settings.h]&#039;&#039;&#039; and comment out the line #define STDOUT_REDIRECTED_TO_DCC&lt;br /&gt;
&lt;br /&gt;
=== In Circuit Debugging ===&lt;br /&gt;
Before you begin you should note that the Miosix kernel will put the CPU to a &#039;&#039;&#039;low power state&#039;&#039;&#039; when no thread is running. This low power state will usually confuse debuggers and make them lose sync with the CPU. To avoid this you need to edit the &#039;&#039;&#039;miosix/config/[http://gitorious.org/miosix-kernel/miosix-kernel/blobs/master/miosix/config/miosix_settings.h miosix_settings.h]&#039;&#039;&#039; file and uncomment&lt;br /&gt;
 #define JTAG_DISABLE_SLEEP &lt;br /&gt;
This will prevent the kernel from putting the CPU in its low power state making debugging possible.&lt;br /&gt;
Also, to be able to precisely single-step your code you need to &#039;&#039;&#039;disable compiler optimizations&#039;&#039;&#039; as gdb is incapable of reliably debug an optimized code. The option is in the miosix/config/Makefile.inc file and is the OPT_OPTIMIZATION := -O0 that should be uncommented while the other lines related to the same option should be commented out.&lt;br /&gt;
&lt;br /&gt;
After modifying configuration files it is recomended to do a &#039;&#039;&#039;make clean; make&#039;&#039;&#039; (or in the Netbeans IDE, to click on the &amp;quot;Clean and build project&amp;quot; button) to be sure that changes are applied.&lt;br /&gt;
&lt;br /&gt;
Since the board has an on board SWD in circuit debugger, simply &#039;&#039;&#039;plugging the USB cable&#039;&#039;&#039; is all you need from an hardware point of view.&lt;br /&gt;
On the software side, you need to &#039;&#039;&#039;open two shells&#039;&#039;&#039;. In one do a&lt;br /&gt;
&lt;br /&gt;
 sudo openocd -f miosix/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/stm32f4discovery.cfgg &lt;br /&gt;
&lt;br /&gt;
This will &#039;&#039;&#039;start the OpenOCD&#039;&#039;&#039; program that will connect to the board and listen for GDB connections.&lt;br /&gt;
&lt;br /&gt;
In the second shell type the following commands&lt;br /&gt;
&lt;br /&gt;
 arm-miosix-eabi-gdb main.elf&lt;br /&gt;
 target remote :3333&lt;br /&gt;
 monitor soft_reset_halt&lt;br /&gt;
 monitor target_request debugmsgs enable&lt;br /&gt;
 monitor trace point 1&lt;br /&gt;
 break main&lt;br /&gt;
 continue&lt;br /&gt;
&lt;br /&gt;
The first command will &#039;&#039;&#039;start the gdb debugger&#039;&#039;&#039;. The following commands are typed into the gdb console, and tell it to connect to OpenOCD, and reset the board, enable the debug communication channel to redirect printf, and stop the program at the beginning of main()&lt;br /&gt;
To load the program to be debugged, you can either do a make program before and then start debugging, or you can directly write the FLASH memory from within gdb with this command &lt;br /&gt;
 monitor flash write_image erase main.bin 0x08000000 &lt;br /&gt;
From there on, consult a gdb reference on the Internet for information on how to single step code, set breakpoints and inspect variables.&lt;br /&gt;
&lt;br /&gt;
=== (Optional) Configuring the Netbeans IDE ===&lt;br /&gt;
To have a fully working code completion that can also resolve the board-specific symbols, right click on the project, go to Set Configuration and select the right board.&lt;br /&gt;
 [[File: Netbeans-config.png]]&lt;br /&gt;
&lt;br /&gt;
=== Miosix GPIO Mapping ===&lt;br /&gt;
&lt;br /&gt;
==== SD Card ====&lt;br /&gt;
Connect VCC (3V) and GND using a 100nF capacitor between VCC and GND, this will be useful to overcome to current absorption peaks.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! SD !! STM32 !! Optional&lt;br /&gt;
|-&lt;br /&gt;
| CLK || PC12 || &lt;br /&gt;
|-&lt;br /&gt;
| CMD || PD2 || &lt;br /&gt;
|-&lt;br /&gt;
| D0 || PC8 || &lt;br /&gt;
|-&lt;br /&gt;
| D1 || PC9 || Y&lt;br /&gt;
|-&lt;br /&gt;
| D2 || PD10 || Y&lt;br /&gt;
|-&lt;br /&gt;
| D3 || PC11 || Y&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each connection needs a pullup resistor between ~47Kohm and 100Kohm.&lt;br /&gt;
&lt;br /&gt;
Optional GPIOs are used in 4-bit mode.&lt;br /&gt;
&lt;br /&gt;
=== Resource ===&lt;br /&gt;
 stm32f4discovery [http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00039084.pdf Datasheet]&lt;br /&gt;
&lt;br /&gt;
[[Category:Boards]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Optimization&amp;diff=160</id>
		<title>Category:Optimization</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Optimization&amp;diff=160"/>
		<updated>2015-01-22T20:05:25Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Create Category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Optimization&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Miosix_code_size_optimization&amp;diff=159</id>
		<title>Miosix code size optimization</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Miosix_code_size_optimization&amp;diff=159"/>
		<updated>2015-01-22T20:04:57Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Adding Categories&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Miosix is designed with the end goal to become an &amp;quot;unix on a chip&amp;quot; written in C++, so it was built with the idea of packing as much standard compliance as possible, without cutting corners. Things like full support to the C and C++ standard libraries, including full support for the C++ STL, thread-safe exception handling, and seldom used features of the C standard libraries, including stdout redirection via&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
fclose(stdout);&lt;br /&gt;
stdout=fopen(&amp;quot;/sd/log.txt&amp;quot;,&amp;quot;w&amp;quot;);&lt;br /&gt;
puts(&amp;quot;writing to a file\n&amp;quot;);&lt;br /&gt;
fflush(stdout);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
are supported. This obviously comes with a code size penalty, especially considering that most features are enabled by default.&lt;br /&gt;
However, the kernel is very modular, so you don&#039;t have to pay the code size cost of unused features in your application.&lt;br /&gt;
&lt;br /&gt;
This guide lists a number of tips to adapt the Miosix kernel to the needs of code-size constrained embedded applications. The exact figures presented here may change as the kernel is developed further, but the tips are expected to remain valid. Considering the [[stm32f407vg_stm32f4discovery]] which is a common board used with Miosix, compiling an empty &#039;&#039;main()&#039;&#039; with the default settings leads to a code size of over 90KB. With this guide it is possible to reduce code size down to 6KB by removing various features you may not need.&lt;br /&gt;
&lt;br /&gt;
== Compile with Os ==&lt;br /&gt;
&lt;br /&gt;
The default [http://fedetft.wordpress.com/2009/10/01/gcc-optimization-flags GCC optimization flag] used in Miosix is &#039;&#039;-O2&#039;&#039;, which generates code optimized for speed. You can however choose &#039;&#039;-Os&#039;&#039; which optimizes for size by opening the file [[Makefile.inc|miosix/config/Makefile.inc]], commenting out the &#039;&#039;-O2&#039;&#039; line, and uncommenting the &#039;&#039;-Os&#039;&#039; line, like this:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#OPT_OPTIMIZATION := -O0&lt;br /&gt;
#OPT_OPTIMIZATION := -O2&lt;br /&gt;
#OPT_OPTIMIZATION := -O3&lt;br /&gt;
OPT_OPTIMIZATION := -Os&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The code size will usually decrease as a percentage of the total code size, as this option affects how the compiler generates code. 10% decrease is a common figure. Although I haven&#039;t found benchmarks showing how much this affects execution speed, usually the impact isn&#039;t that high, and code runs definitely much faster with respect to disabling optimizations altogether (with &#039;&#039;-O0&#039;&#039;), so if you are tight on code size this is an easy option that does not require to sacrifice any feature of the kernel.&lt;br /&gt;
&lt;br /&gt;
== Disable DevFs ==&lt;br /&gt;
&lt;br /&gt;
Miosix 2.0 comes with an in-memory filesystem, mounted at &#039;&#039;/dev&#039;&#039; where device files can be addes, similarly to how a Linux machine works. The main purpose of this is to allow [[Miosix processes|processes]] to access peripherals, since due to memory protection they can&#039;t just access the peripheral registers. However, processes are currently disabled by default because they&#039;re still an experimental feature, so you can disable DevFs too. This can be done by commenting out the &#039;&#039;WITH_DEVFS&#039;&#039; line in [[miosix_settings.h|miosix/config/miosix_settings.h]], like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
//#define WITH_DEVFS&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This saves aroud 5KB.&lt;br /&gt;
&lt;br /&gt;
== Disable the filesystem entirely ==&lt;br /&gt;
&lt;br /&gt;
Miosix 2.0 has a completely rewritten filesystem subsystem, supporting multiple mountpoints, extensible filesystem types (currently Fat32 and DevFs), unicode UTF8 in file names, directory listing via the standard &#039;&#039;opendir()&#039;&#039;/&#039;&#039;readdir()&#039;&#039;/&#039;&#039;closedir()&#039;&#039; and more POSIX compilance, including inode emulation for Fat32. This comes at a code size cost, though. If your application does not need to read/write from files, you can disable the filesystem subsystem entirely. To do so, open [[miosix_settings.h|miosix/config/miosix_settings.h]] and comment out both the &#039;&#039;WITH_DEVFS&#039;&#039; and &#039;&#039;WITH_FILESYSTEM&#039;&#039; lines. When compared to the default when both filesystem and DevFs are enabled, about 40KB of code size can be saved.&lt;br /&gt;
&lt;br /&gt;
== Use iprintf() instead of printf() in your application ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;iprintf()&#039;&#039; is a non-standard extension of the [https://www.sourceware.org/newlib newlib] C library used by Miosix. It can do all what &#039;&#039;printf()&#039;&#039; can do except printing floating point numbers, and thath&#039;s why its code size is significantly lower, printing floating point numbers is quite complicated. Miosix already uses &#039;&#039;iprintf()&#039;&#039; internally, so to see the code size difference you have to write the following simple code in &#039;&#039;main()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    int i=0;&lt;br /&gt;
    printf(&amp;quot;%d\n&amp;quot;,i);&lt;br /&gt;
    //iprintf(&amp;quot;%d\n&amp;quot;,i);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Trying with &#039;&#039;iprintf()&#039;&#039; instead of &#039;&#039;printf()&#039;&#039;, a 14KB code size reduction is observed. Note that you have to use a format string containing a % argument, such as %d to see the code size difference. If there is no % in the format string, GCC may replace &#039;&#039;printf()&#039;&#039;/&#039;&#039;iprintf()&#039;&#039; with a call to &#039;&#039;puts()&#039;&#039; as an optimization, and no code size difference can be seen.&lt;br /&gt;
&lt;br /&gt;
== Disable boot logs ==&lt;br /&gt;
&lt;br /&gt;
Maybe you&#039;re not using &#039;&#039;printf()&#039;&#039; at all in your application, however in this case you&#039;re still paying for the code size of &#039;&#039;iprintf()&#039;&#039; as the kernel uses it to print boot logs and error logs. To disable them, you can open [[miosix_settings.h|miosix/config/miosix_settings.h]] and uncomment &#039;&#039;WITH_BOOTLOG&#039;&#039; and &#039;&#039;WITH_ERRLOG&#039;&#039;. This allows to save an additional 17KB of code size, but this is only true if there&#039;s no &#039;&#039;printf()&#039;&#039; call in your code, otherewise the code size saving will be minimal.&lt;br /&gt;
&lt;br /&gt;
Also, keep in mind that error logs are a powerful tool to debug crashes of your application or the kernel during code development, so you may want to disable them only in release builds, and keep them enabled during development.&lt;br /&gt;
&lt;br /&gt;
Finally, note that you can still access the serial port without using &#039;&#039;printf()&#039;&#039;, by means of the POSIX calls &#039;&#039;write()&#039;&#039; and &#039;&#039;read()&#039;&#039;, using &#039;&#039;STDOUT_FILENO&#039;&#039; and &#039;&#039;STDIN_FILENO&#039;&#039; as the &#039;&#039;fd&#039;&#039; argument.&lt;br /&gt;
&lt;br /&gt;
== Disable the C++ exception runtime ==&lt;br /&gt;
&lt;br /&gt;
The Miosix kernel is by default compiled with support for C++ exceptions, and unless you&#039;re also enabling [[Miosix processes|processes]] that depend on C++ exceptions, it is possible to disable their support. To di so, open [[Makefile.inc|miosix/config/Makefile.inc]] and uncomment the following line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
OPT_EXCEPT := -fno-exceptions -fno-rtti -D__NO_EXCEPTIONS&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This saves nearly 20KB but comes with quite an important side effect, though: if the heap is full, the kernel will reboot the machine. To explain why it is so, consider that the normal behaviour in Miosix to handle a full heap is that the C &#039;&#039;malloc()&#039;&#039; returns &#039;&#039;NULL&#039;&#039;, while the C++ &#039;&#039;operator new&#039;&#039; throws an exception of type &#039;&#039;bad_alloc&#039;&#039;. Now, when exceptions are disabled, &#039;&#039;new&#039;&#039; can no longer throw, but C++ code doesn&#039;t check for &#039;&#039;NULL&#039;&#039;, as it expects an exception, and that would result in undefined behaviour. The only way to prevent undefined behaviour, is to reboot the machine, and that is what happens.&lt;br /&gt;
&lt;br /&gt;
== Putting it all together ==&lt;br /&gt;
&lt;br /&gt;
With all those tips presented so far applied simultaneously, the code size of an empty &#039;&#039;main()&#039;&#039; for the [[stm32f407vg_stm32f4discovery]] is reduced to around 10KB.&lt;br /&gt;
&lt;br /&gt;
== One more thing, disable the serial port ==&lt;br /&gt;
&lt;br /&gt;
The kernel, during the boot process, configures a serial port on nearly all the supported boards. If you really have no use for the serial port, you can disable it entirely, saving additional code size. To do so there is no configuration option, but you can edit the board support package file of your board. For the [[stm32f407vg_stm32f4discovery]] it&#039;s &#039;&#039;miosix/arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/interfaces-impl/bsp.cpp&#039;&#039;, and comment out the following lines in &#039;&#039;IRQbspInit()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
    DefaultConsole::instance().IRQset(intrusive_ref_ptr&amp;lt;Device&amp;gt;(&lt;br /&gt;
        new STM32Serial(defaultSerial,defaultSerialSpeed,&lt;br /&gt;
        defaultSerialFlowctrl ? STM32Serial::RTSCTS : STM32Serial::NOFLOWCTRL)));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
as well as the following line in &#039;&#039;shutdown()&#039;&#039; and &#039;&#039;reboot()&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
DefaultConsole::instance().get()-&amp;gt;ioctl(IOCTL_SYNC,0);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By applying also this last tip code size can be reduced to around 6KB.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;br /&gt;
[[Category:Optimization]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Libraries&amp;diff=109</id>
		<title>Category:Libraries</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Libraries&amp;diff=109"/>
		<updated>2014-04-22T21:16:28Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here a complete list of libraries: [[Library list]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Library_list&amp;diff=108</id>
		<title>Library list</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Library_list&amp;diff=108"/>
		<updated>2014-04-22T21:16:02Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Libraries are additional components not part of the Miosix kernel that can be downloaded to add functionality to the kernel.&lt;br /&gt;
&lt;br /&gt;
* [[mxgui]] is a GUI library for graphic displays&lt;br /&gt;
* [[mxusb]] is an USB stack, currently targeting stm32f1 microcontrollers only.&lt;br /&gt;
&lt;br /&gt;
[[Category:Libraries]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Library_list&amp;diff=107</id>
		<title>Library list</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Library_list&amp;diff=107"/>
		<updated>2014-04-22T21:15:32Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Category:Libraries&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Libraries]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:API&amp;diff=106</id>
		<title>Category:API</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:API&amp;diff=106"/>
		<updated>2014-04-22T21:14:23Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Replaced content with &amp;quot;Here is a list of some of the Miosix APIs: API list&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a list of some of the Miosix APIs: [[API list]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=API_list&amp;diff=105</id>
		<title>API list</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=API_list&amp;diff=105"/>
		<updated>2014-04-22T21:13:51Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Here is a list of some of the Miosix APIs, currently far form being complete  * The Serial port tutorial explains how to interface to a computer through the C functions &amp;#039;&amp;#039;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a list of some of the Miosix APIs, currently far form being complete&lt;br /&gt;
&lt;br /&gt;
* The [[Serial port tutorial]] explains how to interface to a computer through the C functions &#039;&#039;printf()/scanf()&#039;&#039; or the C++ &#039;&#039;cin/cout&#039;&#039; objects.&lt;br /&gt;
* The [[Filesystem tutorial]] explains how to read/write to files on a SD or MicroSD card using the standard C/C++ API.&lt;br /&gt;
* The [[Pthread tutorial]] shows the basics of multithreading in Miosix using the standard [https://en.wikipedia.org/wiki/Pthread Pthread] API.&lt;br /&gt;
* The [[Native thread tutorial]] shows how to use the Miosix-specific thread API.&lt;br /&gt;
* The [[GPIO tutorial]] shows how to interface with external hardware devices using the GPIO API.&lt;br /&gt;
* The [[HD44780 LCD tutorial]] shows how to connect a standard alphanumeric LCD to a board running Miosix.&lt;br /&gt;
* The [[Servo tutorial]] shows how to interface with servomotors from Miosix.&lt;br /&gt;
&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Boards&amp;diff=103</id>
		<title>Category:Boards</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Boards&amp;diff=103"/>
		<updated>2014-04-22T21:11:55Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Boards.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Boards.&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Libraries&amp;diff=102</id>
		<title>Category:Libraries</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Libraries&amp;diff=102"/>
		<updated>2014-04-22T21:07:13Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Libraries are additional components not part of the Miosix kernel that can be downloaded to add functionality to the kernel.&lt;br /&gt;
&lt;br /&gt;
* [[mxgui]] is a GUI library for graphic displays&lt;br /&gt;
* [[mxusb]] is an USB stack, currently targeting stm32f1 microcontrollers only.&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Libraries&amp;diff=101</id>
		<title>Category:Libraries</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Libraries&amp;diff=101"/>
		<updated>2014-04-22T21:06:50Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Libraries are additional components not part of the Miosix kernel that can be downloaded to add functionality to the kernel.  *mxgui is a GUI library for graphic displays *mxu...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Libraries are additional components not part of the Miosix kernel that can be downloaded to add functionality to the kernel.&lt;br /&gt;
&lt;br /&gt;
*mxgui is a GUI library for graphic displays&lt;br /&gt;
*mxusb is an USB stack, currently targeting stm32f1 microcontrollers only.&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=GPIO_tutorial&amp;diff=100</id>
		<title>GPIO tutorial</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=GPIO_tutorial&amp;diff=100"/>
		<updated>2014-04-22T21:05:42Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: /* Related pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Include statements and namespace required to use this library&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is a C++ library, it cannot be used from a C source file.&lt;br /&gt;
&lt;br /&gt;
A [https://en.wikipedia.org/wiki/GPIO GPIO] or general purpose input-output is a software-controllable pin of a microcontroller. To be able to control multiple GPIOs at the same time, most microcontrollers group GPIOs in ports, so GPIOs are specified by a port name, and a pin number within the port. The STM32 use letters to identify ports, so the GPIO 0 of port A is called PA0. The GPIO port and number are often specified at the pin headers on development boards such as the [[stm32f407vg_stm32f4discovery|STM32F4 Discovery]], in order to make it easy to connect wires to the correct GPIO. On the contrary, NXP uses numbers also for the ports, so the GPIO 0 of port 1 is called P1.0.&lt;br /&gt;
&lt;br /&gt;
== Declaring GPIOs ==&lt;br /&gt;
&lt;br /&gt;
A GPIO in Miosix is accessed using a C++ template class, the rationale behind this choice can be found [http://www.webalice.it/fede.tft/stm32/stm32_gpio_and_template_metaprogramming.html in this article], but in short it provides both optimal performance and a high-level API.&lt;br /&gt;
&lt;br /&gt;
As an example, assume there is a blue LED connected to GPIO PD15 and a button connected to PA0, to control them in software you first have to declare the GPIOs using the following syntax&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; button;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A declaration like this can appear both inside a function, if you are going to use the GPIO only inside that function, or be put at the top of a source file, to access the GPIO from all the functions of that file. Notice how GPIO&#039;&#039;&#039;D&#039;&#039;&#039;_BASE means that this is a GPIO of port &#039;&#039;&#039;D&#039;&#039;&#039;, and 15 is the GPIO number within the port. This declaration introduces a template named blueLed that can later be used to access the GPIO.&lt;br /&gt;
&lt;br /&gt;
A common mistake is to declare the GPIO like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
/* DON&#039;T WRITE CODE LIKE THIS */&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; pd15;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; pa0;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the following code will work, it is discouraged to choose the GPIO id as the name of the template. It is way better to try using a name related to the function that the GPIO will be used for, as it leads to code that is easier to read and understand. For example, the first GPIO is connected to a blue LED, so blueLed is an appropriate name.&lt;br /&gt;
&lt;br /&gt;
== Configuring GPIOs ==&lt;br /&gt;
&lt;br /&gt;
Once you have declared a GPIO, you need to to configure it before using it. The most basic level of configuration is to select the GPIO &#039;&#039;direction&#039;&#039;, i.e, whether it is going to be used as an output, or an input.&lt;br /&gt;
&lt;br /&gt;
If a GPIO is configured as an output software can control the voltage at that pin, by selecting between a logic level 0, which corresponds to 0V, or a logic 1, whose voltage is VDD, which is the voltage used to power the microcontroller, in most cases 3.3V for the typical microcontrollers supported by Miosix.&lt;br /&gt;
&lt;br /&gt;
If a GPIO is configured as an input, software can sense the logic level at the pin, reading a logic level 0 if the voltage is close to 0V, or a logic 1 if it is close to VDD. Note that if the voltage is closed to hald of VDD, or if the GPIO is not connected to anything, the reading could be either 0 or 1, see the discussion about [https://en.wikipedia.org/wiki/Pull-up_resistor pull-up resistors] on Wikipedia for that.&lt;br /&gt;
&lt;br /&gt;
To configure the GPIO you can use the &#039;&#039;mode()&#039;&#039; member function of the GPIO class. For example, in your &#039;&#039;main()&#039;&#039; function you can do&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    button::mode(Mode::INPUT);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that all boards supported by Miosix have the &#039;&#039;OUTPUT&#039;&#039; and &#039;&#039;INPUT&#039;&#039; modes, but may have more options.&lt;br /&gt;
&lt;br /&gt;
Some for example, may have software controllable on-chip pull-up and/or pull-down resistors, or an analog input mode connected to an ADC to read analog voltages. The list of supported modes can be found in the gpio_impl.h file of your microcontroller. For example, for the microcontroller in the [[stm32f407vg_stm32f4discovery|STM32F4 Discovery]] board, the file is in &#039;&#039;miosix/arch/cortexM4_stm32f4/common/interfaces-impl/gpio_impl.h&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
A noteworty example is the ALTERNATE function mode, that when selected connects the GPIO to some device-dependent hardware peripheral, such as an SPI, I2C or UART peripheral. In such a case, the pin stops being a GPIO in the sense that it is no longer software controllable, but is instead driven by the hardware peripheral. This is often used to implement communication protocols like SPI or I2C.&lt;br /&gt;
&lt;br /&gt;
However, these device-specific extensions are not discussed further here.&lt;br /&gt;
&lt;br /&gt;
== GPIO Writing ==&lt;br /&gt;
&lt;br /&gt;
To write to an OUTPUT configured GPIO, you can used the &#039;&#039;high()&#039;&#039; and &#039;&#039;low()&#039;&#039; member functions, as shown in this example that blinks a LED&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        blueLed::high();    //Turn the LED on&lt;br /&gt;
        Thread::sleep(500); //Wait 500ms&lt;br /&gt;
        blueLed::low();     //Turn the LED off&lt;br /&gt;
        Thread::sleep(500); //Wait 500ms&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GPIO Reading ==&lt;br /&gt;
&lt;br /&gt;
Reading from an INPUT configured GPIO is performed by using the &#039;&#039;value()&#039;&#039; member function, as shown in this example that polls a button every 10ms and turns on a LED for 10 seconds once it detects it is pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; button;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    button::mode(Mode::INPUT);&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        //Poll the button every 10ms until it is pressed&lt;br /&gt;
        while(button::value()==0) Thread::sleep(10);&lt;br /&gt;
&lt;br /&gt;
        blueLed::high();      //Turn the LED on&lt;br /&gt;
        Thread::sleep(10000); //Wait 10s&lt;br /&gt;
        blueLed::low();       //Turn the LED off&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A common mistake is to forget the sleep when polling for the button, resulting in a code like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
/* DON&#039;T WRITE CODE LIKE THIS */&lt;br /&gt;
for(;;)&lt;br /&gt;
{&lt;br /&gt;
    //Poll the button until it is pressed&lt;br /&gt;
    while(button::value()==0) ;&lt;br /&gt;
&lt;br /&gt;
    blueLed::high();      //Turn the LED on&lt;br /&gt;
    Thread::sleep(10000); //Wait 10s&lt;br /&gt;
    blueLed::low();       //Turn the LED off&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although this code will work, it is bad. To see why, consider that Miosix is a multithreaded OS, so in the general case there will be other threads running other than your code, so it is not polite to spin in a while loop that may take an undefined time to complete chewing up 100% of the CPU. This will for sure prevent the kernel from putting the CPU in sleep resulting in a higher power consumption, and may slow down other threads that can have more important tasks to do than spinning on a GPIO.&lt;br /&gt;
&lt;br /&gt;
But you may be thinking that your application needs to be notified of the button being pressed &#039;&#039;as soon as possible&#039;&#039; and even a few milliseconds of delay are too much. In this case, this code is &#039;&#039;&#039;even more wrong&#039;&#039;&#039;, because Miosix is a timesharing system, so your code can and will be preempted by the operating system to prevent other threads from starving. If the event that you need to be notified about happens while your code is preempted, there will be a delay of up to a few milliseconds between the actual event and when you notice it anyway.&lt;br /&gt;
&lt;br /&gt;
To deal with situations where you need to be notified of pin change events events as soon as possible you need something more complicated, such as an [[Interrupt on pin change]] that will call an interrupt routine in response to an event, usually offering a time determinism of a few tens of microseconds, or a [[Timer input capture]] channel that provides a timestamp of an event with an accuracy of a few tens of nanoseconds.&lt;br /&gt;
&lt;br /&gt;
== Thread safety considerations ==&lt;br /&gt;
&lt;br /&gt;
All microcontroller, for self-evident reasons, provide hardware support to allow writing to GPIOs configured as OUTPUT in a thread-safe way, so you are free to call the &#039;&#039;high()&#039;&#039; and &#039;&#039;low()&#039;&#039; (and &#039;&#039;value()&#039;&#039; as well) from multiple threads.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, configuring GPIOs is on most microcontrollers not thread-safe. That is, if you call &#039;&#039;mode()&#039;&#039; concurrently from multiple threads on the same GPIO port, you may inadvertently misconfigure some of the pins in that port.&lt;br /&gt;
&lt;br /&gt;
There are two ways to work around that, configuring all GPIOs in the &#039;&#039;main()&#039;&#039; before spawning any thread, and disabling interrupts while configuring GPIOs.&lt;br /&gt;
&lt;br /&gt;
=== Configuring GPIOs in the main() ===&lt;br /&gt;
&lt;br /&gt;
If you configure all the GPIOs in the &#039;&#039;main()&#039;&#039;, before spawning any thread, and later you no longer call &#039;&#039;mode()&#039;&#039; there are no way two threads could call &#039;&#039;mode()&#039;&#039; concurrently, and so there is no problem. However, this often goes against code modularity, and in some circumstances you may need to change a GPIO configuration at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Disabling interrupts while configuring GPIOs ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;mode()&#039;&#039; to be freely called, you have to make sure no two concurrent calls to &#039;&#039;mode()&#039;&#039; can happen. Considering that configuring a GPIO is a very fast operation, it requires just a few clock cycles, this can be achieved by disabling interrupts while configuring the GPIOs. Keep in mind that disabling interrupts must be done with care, and striving as much as possible to minimize the amount of time spent with interrupts disables, so as not to interfere with the real-time capabilities of the Miosix kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
void someFunction()&lt;br /&gt;
{&lt;br /&gt;
    [...] //Some code&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        FastInterruptDisableLock dLock;&lt;br /&gt;
        blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
        button::mode(Mode::INPUT);&lt;br /&gt;
    }&lt;br /&gt;
   &lt;br /&gt;
    [...] //Some other code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the two curly braces surrounding the dLock object, that create a [https://en.wikipedia.org/wiki/Scope_%28computer_science%29 scope] delimiting the lines of code where interrupts are disabled.&lt;br /&gt;
&lt;br /&gt;
As a last note, you could also use a global [https://en.wikipedia.org/wiki/Mutex mutex] instead of disabling interrupts, but as previously mentioned configuring a GPIO is a very fast operation, it requires just a few clock cycles, so using a mutex would introduce a significant overhead.&lt;br /&gt;
&lt;br /&gt;
== Accessing GPIOs from multiple source files ==&lt;br /&gt;
&lt;br /&gt;
When dealing with large projects, it is common to split them in multiple source files. To access the GPIO definitions from multiple source files it is common practice in Miosix to declare them in a C++ header file, and &#039;&#039;#include&#039;&#039; it where needed. If that file contains all the GPIOs of a specific board, is is often called &#039;&#039;hwmapping.h&#039;&#039;. In such a case, [https://en.wikipedia.org/wiki/Namespace#Examples namespaces] can be used to group GPIOs by function. For an example, see the &#039;&#039;hwmapping.h&#039;&#039; file for the Sony smartwatch board [https://gitorious.org/miosix-kernel/miosix-kernel/source/0fb80132cd27fbd48021cd5a9adb21c90a9cb94e:miosix/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/interfaces-impl/hwmapping.h].&lt;br /&gt;
&lt;br /&gt;
== Related pages ==&lt;br /&gt;
* [[Example: Blinking led|Blinking led]]&lt;br /&gt;
&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=GPIO_tutorial&amp;diff=99</id>
		<title>GPIO tutorial</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=GPIO_tutorial&amp;diff=99"/>
		<updated>2014-04-22T21:05:10Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Include statements and namespace required to use this library&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is a C++ library, it cannot be used from a C source file.&lt;br /&gt;
&lt;br /&gt;
A [https://en.wikipedia.org/wiki/GPIO GPIO] or general purpose input-output is a software-controllable pin of a microcontroller. To be able to control multiple GPIOs at the same time, most microcontrollers group GPIOs in ports, so GPIOs are specified by a port name, and a pin number within the port. The STM32 use letters to identify ports, so the GPIO 0 of port A is called PA0. The GPIO port and number are often specified at the pin headers on development boards such as the [[stm32f407vg_stm32f4discovery|STM32F4 Discovery]], in order to make it easy to connect wires to the correct GPIO. On the contrary, NXP uses numbers also for the ports, so the GPIO 0 of port 1 is called P1.0.&lt;br /&gt;
&lt;br /&gt;
== Declaring GPIOs ==&lt;br /&gt;
&lt;br /&gt;
A GPIO in Miosix is accessed using a C++ template class, the rationale behind this choice can be found [http://www.webalice.it/fede.tft/stm32/stm32_gpio_and_template_metaprogramming.html in this article], but in short it provides both optimal performance and a high-level API.&lt;br /&gt;
&lt;br /&gt;
As an example, assume there is a blue LED connected to GPIO PD15 and a button connected to PA0, to control them in software you first have to declare the GPIOs using the following syntax&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; button;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A declaration like this can appear both inside a function, if you are going to use the GPIO only inside that function, or be put at the top of a source file, to access the GPIO from all the functions of that file. Notice how GPIO&#039;&#039;&#039;D&#039;&#039;&#039;_BASE means that this is a GPIO of port &#039;&#039;&#039;D&#039;&#039;&#039;, and 15 is the GPIO number within the port. This declaration introduces a template named blueLed that can later be used to access the GPIO.&lt;br /&gt;
&lt;br /&gt;
A common mistake is to declare the GPIO like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
/* DON&#039;T WRITE CODE LIKE THIS */&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; pd15;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; pa0;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the following code will work, it is discouraged to choose the GPIO id as the name of the template. It is way better to try using a name related to the function that the GPIO will be used for, as it leads to code that is easier to read and understand. For example, the first GPIO is connected to a blue LED, so blueLed is an appropriate name.&lt;br /&gt;
&lt;br /&gt;
== Configuring GPIOs ==&lt;br /&gt;
&lt;br /&gt;
Once you have declared a GPIO, you need to to configure it before using it. The most basic level of configuration is to select the GPIO &#039;&#039;direction&#039;&#039;, i.e, whether it is going to be used as an output, or an input.&lt;br /&gt;
&lt;br /&gt;
If a GPIO is configured as an output software can control the voltage at that pin, by selecting between a logic level 0, which corresponds to 0V, or a logic 1, whose voltage is VDD, which is the voltage used to power the microcontroller, in most cases 3.3V for the typical microcontrollers supported by Miosix.&lt;br /&gt;
&lt;br /&gt;
If a GPIO is configured as an input, software can sense the logic level at the pin, reading a logic level 0 if the voltage is close to 0V, or a logic 1 if it is close to VDD. Note that if the voltage is closed to hald of VDD, or if the GPIO is not connected to anything, the reading could be either 0 or 1, see the discussion about [https://en.wikipedia.org/wiki/Pull-up_resistor pull-up resistors] on Wikipedia for that.&lt;br /&gt;
&lt;br /&gt;
To configure the GPIO you can use the &#039;&#039;mode()&#039;&#039; member function of the GPIO class. For example, in your &#039;&#039;main()&#039;&#039; function you can do&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    button::mode(Mode::INPUT);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that all boards supported by Miosix have the &#039;&#039;OUTPUT&#039;&#039; and &#039;&#039;INPUT&#039;&#039; modes, but may have more options.&lt;br /&gt;
&lt;br /&gt;
Some for example, may have software controllable on-chip pull-up and/or pull-down resistors, or an analog input mode connected to an ADC to read analog voltages. The list of supported modes can be found in the gpio_impl.h file of your microcontroller. For example, for the microcontroller in the [[stm32f407vg_stm32f4discovery|STM32F4 Discovery]] board, the file is in &#039;&#039;miosix/arch/cortexM4_stm32f4/common/interfaces-impl/gpio_impl.h&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
A noteworty example is the ALTERNATE function mode, that when selected connects the GPIO to some device-dependent hardware peripheral, such as an SPI, I2C or UART peripheral. In such a case, the pin stops being a GPIO in the sense that it is no longer software controllable, but is instead driven by the hardware peripheral. This is often used to implement communication protocols like SPI or I2C.&lt;br /&gt;
&lt;br /&gt;
However, these device-specific extensions are not discussed further here.&lt;br /&gt;
&lt;br /&gt;
== GPIO Writing ==&lt;br /&gt;
&lt;br /&gt;
To write to an OUTPUT configured GPIO, you can used the &#039;&#039;high()&#039;&#039; and &#039;&#039;low()&#039;&#039; member functions, as shown in this example that blinks a LED&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        blueLed::high();    //Turn the LED on&lt;br /&gt;
        Thread::sleep(500); //Wait 500ms&lt;br /&gt;
        blueLed::low();     //Turn the LED off&lt;br /&gt;
        Thread::sleep(500); //Wait 500ms&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GPIO Reading ==&lt;br /&gt;
&lt;br /&gt;
Reading from an INPUT configured GPIO is performed by using the &#039;&#039;value()&#039;&#039; member function, as shown in this example that polls a button every 10ms and turns on a LED for 10 seconds once it detects it is pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; button;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    button::mode(Mode::INPUT);&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        //Poll the button every 10ms until it is pressed&lt;br /&gt;
        while(button::value()==0) Thread::sleep(10);&lt;br /&gt;
&lt;br /&gt;
        blueLed::high();      //Turn the LED on&lt;br /&gt;
        Thread::sleep(10000); //Wait 10s&lt;br /&gt;
        blueLed::low();       //Turn the LED off&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A common mistake is to forget the sleep when polling for the button, resulting in a code like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
/* DON&#039;T WRITE CODE LIKE THIS */&lt;br /&gt;
for(;;)&lt;br /&gt;
{&lt;br /&gt;
    //Poll the button until it is pressed&lt;br /&gt;
    while(button::value()==0) ;&lt;br /&gt;
&lt;br /&gt;
    blueLed::high();      //Turn the LED on&lt;br /&gt;
    Thread::sleep(10000); //Wait 10s&lt;br /&gt;
    blueLed::low();       //Turn the LED off&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although this code will work, it is bad. To see why, consider that Miosix is a multithreaded OS, so in the general case there will be other threads running other than your code, so it is not polite to spin in a while loop that may take an undefined time to complete chewing up 100% of the CPU. This will for sure prevent the kernel from putting the CPU in sleep resulting in a higher power consumption, and may slow down other threads that can have more important tasks to do than spinning on a GPIO.&lt;br /&gt;
&lt;br /&gt;
But you may be thinking that your application needs to be notified of the button being pressed &#039;&#039;as soon as possible&#039;&#039; and even a few milliseconds of delay are too much. In this case, this code is &#039;&#039;&#039;even more wrong&#039;&#039;&#039;, because Miosix is a timesharing system, so your code can and will be preempted by the operating system to prevent other threads from starving. If the event that you need to be notified about happens while your code is preempted, there will be a delay of up to a few milliseconds between the actual event and when you notice it anyway.&lt;br /&gt;
&lt;br /&gt;
To deal with situations where you need to be notified of pin change events events as soon as possible you need something more complicated, such as an [[Interrupt on pin change]] that will call an interrupt routine in response to an event, usually offering a time determinism of a few tens of microseconds, or a [[Timer input capture]] channel that provides a timestamp of an event with an accuracy of a few tens of nanoseconds.&lt;br /&gt;
&lt;br /&gt;
== Thread safety considerations ==&lt;br /&gt;
&lt;br /&gt;
All microcontroller, for self-evident reasons, provide hardware support to allow writing to GPIOs configured as OUTPUT in a thread-safe way, so you are free to call the &#039;&#039;high()&#039;&#039; and &#039;&#039;low()&#039;&#039; (and &#039;&#039;value()&#039;&#039; as well) from multiple threads.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, configuring GPIOs is on most microcontrollers not thread-safe. That is, if you call &#039;&#039;mode()&#039;&#039; concurrently from multiple threads on the same GPIO port, you may inadvertently misconfigure some of the pins in that port.&lt;br /&gt;
&lt;br /&gt;
There are two ways to work around that, configuring all GPIOs in the &#039;&#039;main()&#039;&#039; before spawning any thread, and disabling interrupts while configuring GPIOs.&lt;br /&gt;
&lt;br /&gt;
=== Configuring GPIOs in the main() ===&lt;br /&gt;
&lt;br /&gt;
If you configure all the GPIOs in the &#039;&#039;main()&#039;&#039;, before spawning any thread, and later you no longer call &#039;&#039;mode()&#039;&#039; there are no way two threads could call &#039;&#039;mode()&#039;&#039; concurrently, and so there is no problem. However, this often goes against code modularity, and in some circumstances you may need to change a GPIO configuration at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Disabling interrupts while configuring GPIOs ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;mode()&#039;&#039; to be freely called, you have to make sure no two concurrent calls to &#039;&#039;mode()&#039;&#039; can happen. Considering that configuring a GPIO is a very fast operation, it requires just a few clock cycles, this can be achieved by disabling interrupts while configuring the GPIOs. Keep in mind that disabling interrupts must be done with care, and striving as much as possible to minimize the amount of time spent with interrupts disables, so as not to interfere with the real-time capabilities of the Miosix kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
void someFunction()&lt;br /&gt;
{&lt;br /&gt;
    [...] //Some code&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        FastInterruptDisableLock dLock;&lt;br /&gt;
        blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
        button::mode(Mode::INPUT);&lt;br /&gt;
    }&lt;br /&gt;
   &lt;br /&gt;
    [...] //Some other code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the two curly braces surrounding the dLock object, that create a [https://en.wikipedia.org/wiki/Scope_%28computer_science%29 scope] delimiting the lines of code where interrupts are disabled.&lt;br /&gt;
&lt;br /&gt;
As a last note, you could also use a global [https://en.wikipedia.org/wiki/Mutex mutex] instead of disabling interrupts, but as previously mentioned configuring a GPIO is a very fast operation, it requires just a few clock cycles, so using a mutex would introduce a significant overhead.&lt;br /&gt;
&lt;br /&gt;
== Accessing GPIOs from multiple source files ==&lt;br /&gt;
&lt;br /&gt;
When dealing with large projects, it is common to split them in multiple source files. To access the GPIO definitions from multiple source files it is common practice in Miosix to declare them in a C++ header file, and &#039;&#039;#include&#039;&#039; it where needed. If that file contains all the GPIOs of a specific board, is is often called &#039;&#039;hwmapping.h&#039;&#039;. In such a case, [https://en.wikipedia.org/wiki/Namespace#Examples namespaces] can be used to group GPIOs by function. For an example, see the &#039;&#039;hwmapping.h&#039;&#039; file for the Sony smartwatch board [https://gitorious.org/miosix-kernel/miosix-kernel/source/0fb80132cd27fbd48021cd5a9adb21c90a9cb94e:miosix/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/interfaces-impl/hwmapping.h].&lt;br /&gt;
&lt;br /&gt;
== Related pages ==&lt;br /&gt;
* [[Blinking led]]&lt;br /&gt;
&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:API&amp;diff=98</id>
		<title>Category:API</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:API&amp;diff=98"/>
		<updated>2014-04-22T20:47:54Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Here is a list of some of the Miosix APIs, currently far form being complete  * The Serial port tutorial explains how to interface to a computer through the C functions &amp;#039;&amp;#039;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here is a list of some of the Miosix APIs, currently far form being complete&lt;br /&gt;
&lt;br /&gt;
* The [[Serial port tutorial]] explains how to interface to a computer through the C functions &#039;&#039;printf()/scanf()&#039;&#039; or the C++ &#039;&#039;cin/cout&#039;&#039; objects.&lt;br /&gt;
* The [[Filesystem tutorial]] explains how to read/write to files on a SD or MicroSD card using the standard C/C++ API.&lt;br /&gt;
* The [[Pthread tutorial]] shows the basics of multithreading in Miosix using the standard [https://en.wikipedia.org/wiki/Pthread Pthread] API.&lt;br /&gt;
* The [[Native thread tutorial]] shows how to use the Miosix-specific thread API.&lt;br /&gt;
* The [[GPIO tutorial]] shows how to interface with external hardware devices using the GPIO API.&lt;br /&gt;
* The [[HD44780 LCD tutorial]] shows how to connect a standard alphanumeric LCD to a board running Miosix.&lt;br /&gt;
* The [[Servo tutorial]] shows how to interface with servomotors from Miosix.&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Servo_tutorial&amp;diff=97</id>
		<title>Servo tutorial</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Servo_tutorial&amp;diff=97"/>
		<updated>2014-04-22T20:47:02Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Include statements and namespace required to use this library&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;drivers/servo_stm32.h&amp;quot;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is a C++ library, it cannot be used from a C source file.&lt;br /&gt;
&lt;br /&gt;
A servomotor is a device that allows to control the angular position of a shaft, like [https://www.sparkfun.com/products/10333 this one]. Servos work by reading a PWM signal with a fixed frequency, 50Hz by default, and a pulse period proportional to the desired angle.&lt;br /&gt;
&lt;br /&gt;
== Supported boards ==&lt;br /&gt;
&lt;br /&gt;
Miosix has a servo library that supports some boards using STM32 microcontrollers, namely the [[stm32f100rb_stm32vldiscovery]] and [[stm32f407vg_stm32f4discovery]].&lt;br /&gt;
&lt;br /&gt;
== GPIO connection ==&lt;br /&gt;
&lt;br /&gt;
The library supports up to 4 servo outputs, that must be connected to the following GPIOs (that the library configures as TIMER alternate function when the output is enabled).&lt;br /&gt;
&lt;br /&gt;
* PB6 is the output 0&lt;br /&gt;
* PB7 is the output 1&lt;br /&gt;
* PB8 is the output 2&lt;br /&gt;
* PB9 is the output 3&lt;br /&gt;
&lt;br /&gt;
== Library use ==&lt;br /&gt;
&lt;br /&gt;
The library is a C++ class named &#039;&#039;SynchronizedServo&#039;&#039;. It is a [https://en.wikipedia.org/wiki/Singleton_pattern singleton], so to instantiate it you have to call the &#039;&#039;instance()&#039;&#039; member function.&lt;br /&gt;
&lt;br /&gt;
You can find examples on how to use the library in the [https://gitorious.org/miosix-kernel/miosix-kernel/source/0fb80132cd27fbd48021cd5a9adb21c90a9cb94e:miosix/_examples/servo miosix/_examples/servo] directory of the kernel.&lt;br /&gt;
&lt;br /&gt;
=== Closed loop control support ===&lt;br /&gt;
&lt;br /&gt;
If there is the need to run a closed loop control code using the servo as an actuator, the library supports a way to synchronize the controller with the servo waveform generation, using the &#039;&#039;waitForCycleBegin()&#039;&#039; member function in a loop. The value set with &#039;&#039;setPosition()&#039;&#039; will be output at the &#039;&#039;&#039;next&#039;&#039;&#039; cycle, so take into account the existence of a z^-1 in your plant model.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;quot;drivers/servo_stm32.h&amp;quot;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    SynchronizedServo&amp;amp; servo=SynchronizedServo::instance();&lt;br /&gt;
    servo.enable(0); //Enable channel 0 (connect servo to PB6)&lt;br /&gt;
    servo.start();&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        //This loop will be executed 50 times a second, and be synchronized with the waveform generation&lt;br /&gt;
        servo.waitForCycleBegin();&lt;br /&gt;
        float pos=computeServoPosition();&lt;br /&gt;
        servo.setPosition(0,pos);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Thread safety considerations ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;waitForCycleBegin()&#039;&#039; member function can be called by only one thread at a given time, so if you want to control more than one servo, be sure to put all the control code into only one loop. The other member functions are thread safe.&lt;br /&gt;
&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=GPIO_tutorial&amp;diff=96</id>
		<title>GPIO tutorial</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=GPIO_tutorial&amp;diff=96"/>
		<updated>2014-04-22T20:46:54Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Include statements and namespace required to use this library&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This is a C++ library, it cannot be used from a C source file.&lt;br /&gt;
&lt;br /&gt;
A [https://en.wikipedia.org/wiki/GPIO GPIO] or general purpose input-output is a software-controllable pin of a microcontroller. To be able to control multiple GPIOs at the same time, most microcontrollers group GPIOs in ports, so GPIOs are specified by a port name, and a pin number within the port. The STM32 use letters to identify ports, so the GPIO 0 of port A is called PA0. The GPIO port and number are often specified at the pin headers on development boards such as the [[stm32f407vg_stm32f4discovery|STM32F4 Discovery]], in order to make it easy to connect wires to the correct GPIO. On the contrary, NXP uses numbers also for the ports, so the GPIO 0 of port 1 is called P1.0.&lt;br /&gt;
&lt;br /&gt;
== Declaring GPIOs ==&lt;br /&gt;
&lt;br /&gt;
A GPIO in Miosix is accessed using a C++ template class, the rationale behind this choice can be found [http://www.webalice.it/fede.tft/stm32/stm32_gpio_and_template_metaprogramming.html in this article], but in short it provides both optimal performance and a high-level API.&lt;br /&gt;
&lt;br /&gt;
As an example, assume there is a blue LED connected to GPIO PD15 and a button connected to PA0, to control them in software you first have to declare the GPIOs using the following syntax&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; button;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A declaration like this can appear both inside a function, if you are going to use the GPIO only inside that function, or be put at the top of a source file, to access the GPIO from all the functions of that file. Notice how GPIO&#039;&#039;&#039;D&#039;&#039;&#039;_BASE means that this is a GPIO of port &#039;&#039;&#039;D&#039;&#039;&#039;, and 15 is the GPIO number within the port. This declaration introduces a template named blueLed that can later be used to access the GPIO.&lt;br /&gt;
&lt;br /&gt;
A common mistake is to declare the GPIO like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
/* DON&#039;T WRITE CODE LIKE THIS */&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; pd15;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; pa0;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
While the following code will work, it is discouraged to choose the GPIO id as the name of the template. It is way better to try using a name related to the function that the GPIO will be used for, as it leads to code that is easier to read and understand. For example, the first GPIO is connected to a blue LED, so blueLed is an appropriate name.&lt;br /&gt;
&lt;br /&gt;
== Configuring GPIOs ==&lt;br /&gt;
&lt;br /&gt;
Once you have declared a GPIO, you need to to configure it before using it. The most basic level of configuration is to select the GPIO &#039;&#039;direction&#039;&#039;, i.e, whether it is going to be used as an output, or an input.&lt;br /&gt;
&lt;br /&gt;
If a GPIO is configured as an output software can control the voltage at that pin, by selecting between a logic level 0, which corresponds to 0V, or a logic 1, whose voltage is VDD, which is the voltage used to power the microcontroller, in most cases 3.3V for the typical microcontrollers supported by Miosix.&lt;br /&gt;
&lt;br /&gt;
If a GPIO is configured as an input, software can sense the logic level at the pin, reading a logic level 0 if the voltage is close to 0V, or a logic 1 if it is close to VDD. Note that if the voltage is closed to hald of VDD, or if the GPIO is not connected to anything, the reading could be either 0 or 1, see the discussion about [https://en.wikipedia.org/wiki/Pull-up_resistor pull-up resistors] on Wikipedia for that.&lt;br /&gt;
&lt;br /&gt;
To configure the GPIO you can use the &#039;&#039;mode()&#039;&#039; member function of the GPIO class. For example, in your &#039;&#039;main()&#039;&#039; function you can do&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    button::mode(Mode::INPUT);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that all boards supported by Miosix have the &#039;&#039;OUTPUT&#039;&#039; and &#039;&#039;INPUT&#039;&#039; modes, but may have more options.&lt;br /&gt;
&lt;br /&gt;
Some for example, may have software controllable on-chip pull-up and/or pull-down resistors, or an analog input mode connected to an ADC to read analog voltages. The list of supported modes can be found in the gpio_impl.h file of your microcontroller. For example, for the microcontroller in the [[stm32f407vg_stm32f4discovery|STM32F4 Discovery]] board, the file is in &#039;&#039;miosix/arch/cortexM4_stm32f4/common/interfaces-impl/gpio_impl.h&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
A noteworty example is the ALTERNATE function mode, that when selected connects the GPIO to some device-dependent hardware peripheral, such as an SPI, I2C or UART peripheral. In such a case, the pin stops being a GPIO in the sense that it is no longer software controllable, but is instead driven by the hardware peripheral. This is often used to implement communication protocols like SPI or I2C.&lt;br /&gt;
&lt;br /&gt;
However, these device-specific extensions are not discussed further here.&lt;br /&gt;
&lt;br /&gt;
== GPIO Writing ==&lt;br /&gt;
&lt;br /&gt;
To write to an OUTPUT configured GPIO, you can used the &#039;&#039;high()&#039;&#039; and &#039;&#039;low()&#039;&#039; member functions, as shown in this example that blinks a LED&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        blueLed::high();    //Turn the LED on&lt;br /&gt;
        Thread::sleep(500); //Wait 500ms&lt;br /&gt;
        blueLed::low();     //Turn the LED off&lt;br /&gt;
        Thread::sleep(500); //Wait 500ms&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== GPIO Reading ==&lt;br /&gt;
&lt;br /&gt;
Reading from an INPUT configured GPIO is performed by using the &#039;&#039;value()&#039;&#039; member function, as shown in this example that polls a button every 10ms and turns on a LED for 10 seconds once it detects it is pressed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOD_BASE,15&amp;gt; blueLed;&lt;br /&gt;
typedef Gpio&amp;lt;GPIOA_BASE,0&amp;gt; button;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
    button::mode(Mode::INPUT);&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        //Poll the button every 10ms until it is pressed&lt;br /&gt;
        while(button::value()==0) Thread::sleep(10);&lt;br /&gt;
&lt;br /&gt;
        blueLed::high();      //Turn the LED on&lt;br /&gt;
        Thread::sleep(10000); //Wait 10s&lt;br /&gt;
        blueLed::low();       //Turn the LED off&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A common mistake is to forget the sleep when polling for the button, resulting in a code like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
/* DON&#039;T WRITE CODE LIKE THIS */&lt;br /&gt;
for(;;)&lt;br /&gt;
{&lt;br /&gt;
    //Poll the button until it is pressed&lt;br /&gt;
    while(button::value()==0) ;&lt;br /&gt;
&lt;br /&gt;
    blueLed::high();      //Turn the LED on&lt;br /&gt;
    Thread::sleep(10000); //Wait 10s&lt;br /&gt;
    blueLed::low();       //Turn the LED off&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Although this code will work, it is bad. To see why, consider that Miosix is a multithreaded OS, so in the general case there will be other threads running other than your code, so it is not polite to spin in a while loop that may take an undefined time to complete chewing up 100% of the CPU. This will for sure prevent the kernel from putting the CPU in sleep resulting in a higher power consumption, and may slow down other threads that can have more important tasks to do than spinning on a GPIO.&lt;br /&gt;
&lt;br /&gt;
But you may be thinking that your application needs to be notified of the button being pressed &#039;&#039;as soon as possible&#039;&#039; and even a few milliseconds of delay are too much. In this case, this code is &#039;&#039;&#039;even more wrong&#039;&#039;&#039;, because Miosix is a timesharing system, so your code can and will be preempted by the operating system to prevent other threads from starving. If the event that you need to be notified about happens while your code is preempted, there will be a delay of up to a few milliseconds between the actual event and when you notice it anyway.&lt;br /&gt;
&lt;br /&gt;
To deal with situations where you need to be notified of pin change events events as soon as possible you need something more complicated, such as an [[Interrupt on pin change]] that will call an interrupt routine in response to an event, usually offering a time determinism of a few tens of microseconds, or a [[Timer input capture]] channel that provides a timestamp of an event with an accuracy of a few tens of nanoseconds.&lt;br /&gt;
&lt;br /&gt;
== Thread safety considerations ==&lt;br /&gt;
&lt;br /&gt;
All microcontroller, for self-evident reasons, provide hardware support to allow writing to GPIOs configured as OUTPUT in a thread-safe way, so you are free to call the &#039;&#039;high()&#039;&#039; and &#039;&#039;low()&#039;&#039; (and &#039;&#039;value()&#039;&#039; as well) from multiple threads.&lt;br /&gt;
&lt;br /&gt;
Unfortunately, configuring GPIOs is on most microcontrollers not thread-safe. That is, if you call &#039;&#039;mode()&#039;&#039; concurrently from multiple threads on the same GPIO port, you may inadvertently misconfigure some of the pins in that port.&lt;br /&gt;
&lt;br /&gt;
There are two ways to work around that, configuring all GPIOs in the &#039;&#039;main()&#039;&#039; before spawning any thread, and disabling interrupts while configuring GPIOs.&lt;br /&gt;
&lt;br /&gt;
=== Configuring GPIOs in the main() ===&lt;br /&gt;
&lt;br /&gt;
If you configure all the GPIOs in the &#039;&#039;main()&#039;&#039;, before spawning any thread, and later you no longer call &#039;&#039;mode()&#039;&#039; there are no way two threads could call &#039;&#039;mode()&#039;&#039; concurrently, and so there is no problem. However, this often goes against code modularity, and in some circumstances you may need to change a GPIO configuration at runtime.&lt;br /&gt;
&lt;br /&gt;
=== Disabling interrupts while configuring GPIOs ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;mode()&#039;&#039; to be freely called, you have to make sure no two concurrent calls to &#039;&#039;mode()&#039;&#039; can happen. Considering that configuring a GPIO is a very fast operation, it requires just a few clock cycles, this can be achieved by disabling interrupts while configuring the GPIOs. Keep in mind that disabling interrupts must be done with care, and striving as much as possible to minimize the amount of time spent with interrupts disables, so as not to interfere with the real-time capabilities of the Miosix kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
void someFunction()&lt;br /&gt;
{&lt;br /&gt;
    [...] //Some code&lt;br /&gt;
&lt;br /&gt;
    {&lt;br /&gt;
        FastInterruptDisableLock dLock;&lt;br /&gt;
        blueLed::mode(Mode::OUTPUT);&lt;br /&gt;
        button::mode(Mode::INPUT);&lt;br /&gt;
    }&lt;br /&gt;
   &lt;br /&gt;
    [...] //Some other code&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the two curly braces surrounding the dLock object, that create a [https://en.wikipedia.org/wiki/Scope_%28computer_science%29 scope] delimiting the lines of code where interrupts are disabled.&lt;br /&gt;
&lt;br /&gt;
As a last note, you could also use a global [https://en.wikipedia.org/wiki/Mutex mutex] instead of disabling interrupts, but as previously mentioned configuring a GPIO is a very fast operation, it requires just a few clock cycles, so using a mutex would introduce a significant overhead.&lt;br /&gt;
&lt;br /&gt;
== Accessing GPIOs from multiple source files ==&lt;br /&gt;
&lt;br /&gt;
When dealing with large projects, it is common to split them in multiple source files. To access the GPIO definitions from multiple source files it is common practice in Miosix to declare them in a C++ header file, and &#039;&#039;#include&#039;&#039; it where needed. If that file contains all the GPIOs of a specific board, is is often called &#039;&#039;hwmapping.h&#039;&#039;. In such a case, [https://en.wikipedia.org/wiki/Namespace#Examples namespaces] can be used to group GPIOs by function. For an example, see the &#039;&#039;hwmapping.h&#039;&#039; file for the Sony smartwatch board [https://gitorious.org/miosix-kernel/miosix-kernel/source/0fb80132cd27fbd48021cd5a9adb21c90a9cb94e:miosix/arch/cortexM3_stm32f2/stm32f205rg_sony-newman/interfaces-impl/hwmapping.h].&lt;br /&gt;
&lt;br /&gt;
[[Category:API]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Windows_Netbeans_configuration&amp;diff=65</id>
		<title>Windows Netbeans configuration</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Windows_Netbeans_configuration&amp;diff=65"/>
		<updated>2014-04-22T10:37:25Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Installing the IDE ===&lt;br /&gt;
&lt;br /&gt;
Download the [https://netbeans.org/downloads Netbeans IDE]. Among the possible versions choose the C/C++ version.&lt;br /&gt;
Netbeans is an IDE written in Java, so it requires the JDK to function. If you don&#039;t have the JDK installed, download it from [http://www.oracle.com/technetwork/java/index.html here] and install it before installing Netbeans.&lt;br /&gt;
&lt;br /&gt;
=== Configuring the IDE ===&lt;br /&gt;
&lt;br /&gt;
Netbeans is a generic C/C++ IDE, and once installed is not set up by default to develop for ARM microcontrollers and Miosix. So you need to configure it. This is a one-time step that you will have to do again only if you re-install the IDE.&lt;br /&gt;
&lt;br /&gt;
Note: this assumes you have already installed the Miosix toolchain, if not read the [[Windows Quick Start]] tutorial first.&lt;br /&gt;
&lt;br /&gt;
Open the Netbeans IDE (there should be an icon on the Desktop after installation) and click on &amp;quot;Tools &amp;gt; Options&amp;quot;. From the top of the options window select the C/C++ panel, and click the &amp;quot;Add&amp;quot; button to add a compiler to Netbeans. As &amp;quot;Base directory&amp;quot; choose &amp;quot;C:\arm-miosix-eabi\arm-miosix-eabi\bin&amp;quot;. Choose &amp;quot;GNU MinGW&amp;quot; as &amp;quot;Tool collection family&amp;quot;, and &amp;quot;ARM_MIOSIX_EABI&amp;quot; as &amp;quot;Tool collection name&amp;quot;.&lt;br /&gt;
Note that you &#039;&#039;&#039;must&#039;&#039;&#039; use the &amp;quot;ARM_MIOSIX_EABI&amp;quot; name, or you&#039;ll have problems later.&lt;br /&gt;
The C and C++ compiler should be automatically filled in by Netbeans, if not copy them from the screenshot below. Please note that make.exe should have &#039;&#039;&#039;no path&#039;&#039;&#039; otherwise compiling will fail.&lt;br /&gt;
&lt;br /&gt;
[[File:Nbsetup1-windows.png]]&lt;br /&gt;
&lt;br /&gt;
Last, you will need to set up the paths with the compiler libraries for code completion to work. Click on the &amp;quot;Code assistance&amp;quot; tab, and &amp;quot;C compiler&amp;quot; sub-tab. The list of folders and macro definitions should look like in this screenshot, if not, add the paths manually.&lt;br /&gt;
&lt;br /&gt;
[[File:Nbsetup2-windows.png]]&lt;br /&gt;
&lt;br /&gt;
Then click th &amp;quot;C++ compiler&amp;quot; sub-tab and check if the paths and macro definitions are correct. If not add the missing paths manually as in the next screenshot.&lt;br /&gt;
&lt;br /&gt;
[[File:Nbsetup3-windows.png]]&lt;br /&gt;
&lt;br /&gt;
Configuration is now complete. You can close the Options windows by clicking &amp;quot;Ok&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Building the Miosix kernel with Netbeans ===&lt;br /&gt;
&lt;br /&gt;
Select &amp;quot;File &amp;gt; Open project&amp;quot; and select the &amp;quot;miosix_np_2&amp;quot; directory withn the Miosix top level directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Nbsetup4-windows.png]]&lt;br /&gt;
&lt;br /&gt;
You may want to rename the project from the default &amp;quot;miosix_np_2&amp;quot; to the name of the project you are going to develop, by right clicking on the project name and selecting &amp;quot;Rename&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Miosix supports different boards, each of which has different board support packages and peripheral drivers. To get code completion support for your board you need to select it within the IDE, as in the following image&lt;br /&gt;
&lt;br /&gt;
[[File:Nbsetup5-windows.png]]&lt;br /&gt;
&lt;br /&gt;
Please note that in the [[Windows Quick Start]] you had to select the board to compile for by editing the [[Makefile.inc|miosix/config/Makefile.inc]]. The board selection within the IDE &#039;&#039;&#039;does not replace&#039;&#039;&#039; the need to edit Makefile.inc, they serve two different purposes:&lt;br /&gt;
* Board selection within the IDE is used by the IDE to set up code completion for your board&lt;br /&gt;
* Board selection in Makefile.inc tells the kernel for which board it needs to be compiled.&lt;br /&gt;
However, please note that you can edit Makefile.inc and [[miosix_settingls.h|miosix/config/miosix_settings.h]] as regular source files within the IDE, without the need to use Notepad++.&lt;br /&gt;
&lt;br /&gt;
You can open main.cpp (double click on it from the left pane), ant start typing your code. Code completion is invoked by typing the first letters of the function, variable, class or member function and hitting &amp;quot;Ctrl-space&amp;quot;. Netbeans also integrates with Doxygen documentation, so you can see the documentation for Miosix classes and functions directly from the IDE.&lt;br /&gt;
&lt;br /&gt;
[[File:Nbsetup6-windows.png]]&lt;br /&gt;
&lt;br /&gt;
Building is performed by clicking the hammer icon above the source code editor. The Output window will appear below the source editor showing the compilation progress and eventual compiler errors.&lt;br /&gt;
There is no known way to transfer the compiled program on a microcontroller board directly from the IDE, for this you will have to use the QSTLink2 tools as explained in [[Windows Quick Start]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Example:_Thread&amp;diff=47</id>
		<title>Example: Thread</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Example:_Thread&amp;diff=47"/>
		<updated>2014-04-13T21:12:20Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Native ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;miosix.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
Mutex mutex;&lt;br /&gt;
ConditionVariable cond,ack;&lt;br /&gt;
char c=0;&lt;br /&gt;
&lt;br /&gt;
void threadfunc(void *argv)&lt;br /&gt;
{&lt;br /&gt;
    Lock&amp;lt;Mutex&amp;gt; lock(mutex);&lt;br /&gt;
    for(int i=0;i&amp;lt;(int)argv;i++)&lt;br /&gt;
    {&lt;br /&gt;
        ack.signal();&lt;br /&gt;
        while(c==0) cond.wait(lock);&lt;br /&gt;
        printf(&amp;quot;%c&amp;quot;,c);&lt;br /&gt;
        c=0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    const char str[]=&amp;quot;Hello world\n&amp;quot;;&lt;br /&gt;
    Thread *thread;&lt;br /&gt;
    thread=Thread::create(threadfunc,2048,1,(void*)strlen(str),Thread::JOINABLE);&lt;br /&gt;
    {&lt;br /&gt;
        Lock&amp;lt;Mutex&amp;gt; lock(mutex);&lt;br /&gt;
        for(int i=0;i&amp;lt;strlen(str);i++)&lt;br /&gt;
        {&lt;br /&gt;
            c=str[i];&lt;br /&gt;
            cond.signal();&lt;br /&gt;
            if(i&amp;lt;strlen(str)-1) ack.wait(lock);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    thread-&amp;gt;join();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pthread ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;pthread.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;&lt;br /&gt;
pthread_cond_t cond=PTHREAD_COND_INITIALIZER;&lt;br /&gt;
pthread_cond_t ack=PTHREAD_COND_INITIALIZER;&lt;br /&gt;
char c=0;&lt;br /&gt;
&lt;br /&gt;
void *threadfunc(void *argv)&lt;br /&gt;
{&lt;br /&gt;
    pthread_mutex_lock(&amp;amp;mutex);&lt;br /&gt;
    for(int i=0;i&amp;lt;(int)argv;i++)&lt;br /&gt;
    {&lt;br /&gt;
        pthread_cond_signal(&amp;amp;ack);&lt;br /&gt;
        while(c==0) pthread_cond_wait(&amp;amp;cond,&amp;amp;mutex);&lt;br /&gt;
        printf(&amp;quot;%c&amp;quot;,c);&lt;br /&gt;
        c=0;&lt;br /&gt;
    }&lt;br /&gt;
    pthread_mutex_unlock(&amp;amp;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    getchar();&lt;br /&gt;
    const char str[]=&amp;quot;Hello world\n&amp;quot;;&lt;br /&gt;
    pthread_t thread;&lt;br /&gt;
    pthread_create(&amp;amp;thread,NULL,threadfunc,(void*)strlen(str));&lt;br /&gt;
    pthread_mutex_lock(&amp;amp;mutex);&lt;br /&gt;
    for(int i=0;i&amp;lt;strlen(str);i++)&lt;br /&gt;
    {&lt;br /&gt;
        c=str[i];&lt;br /&gt;
        pthread_cond_signal(&amp;amp;cond);&lt;br /&gt;
        if(i&amp;lt;strlen(str)-1) pthread_cond_wait(&amp;amp;ack,&amp;amp;mutex);&lt;br /&gt;
    }&lt;br /&gt;
    pthread_mutex_unlock(&amp;amp;mutex);&lt;br /&gt;
    pthread_join(thread,NULL);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Example:_Thread&amp;diff=46</id>
		<title>Example: Thread</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Example:_Thread&amp;diff=46"/>
		<updated>2014-04-13T21:10:35Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;=== Native === &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; // // To build this example modify the Makefile so that // SRC := native_thread_example.cpp //  #include &amp;lt;stdio.h&amp;gt; #include &amp;lt;string.h&amp;gt; #incl...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Native ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//&lt;br /&gt;
// To build this example modify the Makefile so that&lt;br /&gt;
// SRC := native_thread_example.cpp&lt;br /&gt;
//&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;quot;miosix.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
Mutex mutex;&lt;br /&gt;
ConditionVariable cond,ack;&lt;br /&gt;
char c=0;&lt;br /&gt;
&lt;br /&gt;
void threadfunc(void *argv)&lt;br /&gt;
{&lt;br /&gt;
    Lock&amp;lt;Mutex&amp;gt; lock(mutex);&lt;br /&gt;
    for(int i=0;i&amp;lt;(int)argv;i++)&lt;br /&gt;
    {&lt;br /&gt;
        ack.signal();&lt;br /&gt;
        while(c==0) cond.wait(lock);&lt;br /&gt;
        printf(&amp;quot;%c&amp;quot;,c);&lt;br /&gt;
        c=0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    const char str[]=&amp;quot;Hello world\n&amp;quot;;&lt;br /&gt;
    Thread *thread;&lt;br /&gt;
    thread=Thread::create(threadfunc,2048,1,(void*)strlen(str),Thread::JOINABLE);&lt;br /&gt;
    {&lt;br /&gt;
        Lock&amp;lt;Mutex&amp;gt; lock(mutex);&lt;br /&gt;
        for(int i=0;i&amp;lt;strlen(str);i++)&lt;br /&gt;
        {&lt;br /&gt;
            c=str[i];&lt;br /&gt;
            cond.signal();&lt;br /&gt;
            if(i&amp;lt;strlen(str)-1) ack.wait(lock);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    thread-&amp;gt;join();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pthread ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
//&lt;br /&gt;
// To build this example modify the Makefile so that&lt;br /&gt;
// SRC := pthread_example.cpp&lt;br /&gt;
//&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;string.h&amp;gt;&lt;br /&gt;
#include &amp;lt;pthread.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;&lt;br /&gt;
pthread_cond_t cond=PTHREAD_COND_INITIALIZER;&lt;br /&gt;
pthread_cond_t ack=PTHREAD_COND_INITIALIZER;&lt;br /&gt;
char c=0;&lt;br /&gt;
&lt;br /&gt;
void *threadfunc(void *argv)&lt;br /&gt;
{&lt;br /&gt;
    pthread_mutex_lock(&amp;amp;mutex);&lt;br /&gt;
    for(int i=0;i&amp;lt;(int)argv;i++)&lt;br /&gt;
    {&lt;br /&gt;
        pthread_cond_signal(&amp;amp;ack);&lt;br /&gt;
        while(c==0) pthread_cond_wait(&amp;amp;cond,&amp;amp;mutex);&lt;br /&gt;
        printf(&amp;quot;%c&amp;quot;,c);&lt;br /&gt;
        c=0;&lt;br /&gt;
    }&lt;br /&gt;
    pthread_mutex_unlock(&amp;amp;mutex);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    getchar();&lt;br /&gt;
    const char str[]=&amp;quot;Hello world\n&amp;quot;;&lt;br /&gt;
    pthread_t thread;&lt;br /&gt;
    pthread_create(&amp;amp;thread,NULL,threadfunc,(void*)strlen(str));&lt;br /&gt;
    pthread_mutex_lock(&amp;amp;mutex);&lt;br /&gt;
    for(int i=0;i&amp;lt;strlen(str);i++)&lt;br /&gt;
    {&lt;br /&gt;
        c=str[i];&lt;br /&gt;
        pthread_cond_signal(&amp;amp;cond);&lt;br /&gt;
        if(i&amp;lt;strlen(str)-1) pthread_cond_wait(&amp;amp;ack,&amp;amp;mutex);&lt;br /&gt;
    }&lt;br /&gt;
    pthread_mutex_unlock(&amp;amp;mutex);&lt;br /&gt;
    pthread_join(thread,NULL);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=User_talk:Fede.tft&amp;diff=45</id>
		<title>User talk:Fede.tft</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=User_talk:Fede.tft&amp;diff=45"/>
		<updated>2014-04-13T21:07:32Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: /* Remove redirect */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Remove redirect ==&lt;br /&gt;
&lt;br /&gt;
This redirect is useful:&amp;lt;br /&amp;gt;&lt;br /&gt;
https://miosix.org/wiki/index.php?title=Blinking_led&amp;amp;redirect=no&amp;lt;br /&amp;gt;&lt;br /&gt;
I moved the page, but I can&#039;t suppress or remove the redirect.&amp;lt;br /&amp;gt;&lt;br /&gt;
--[[User:Andreabont|Andreabont]] ([[User talk:Andreabont|talk]]) 23:07, 13 April 2014 (CEST)&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Example:_Blinking_led&amp;diff=43</id>
		<title>Example: Blinking led</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Example:_Blinking_led&amp;diff=43"/>
		<updated>2014-04-13T21:03:50Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Andreabont moved page Blinking led to Example: Blinking led&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Simple blink ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdio&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;quot;miosix.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOC_BASE,7&amp;gt;  led;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  &lt;br /&gt;
  led::mode(Mode::OUTPUT);&lt;br /&gt;
  &lt;br /&gt;
  for(;;) {&lt;br /&gt;
    led::high();&lt;br /&gt;
    sleep(1);&lt;br /&gt;
    led::low();&lt;br /&gt;
    sleep(1);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Example:_Blinking_led&amp;diff=42</id>
		<title>Example: Blinking led</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Example:_Blinking_led&amp;diff=42"/>
		<updated>2014-04-13T21:01:42Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Simple blink ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdio&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;quot;miosix.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOC_BASE,7&amp;gt;  led;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  &lt;br /&gt;
  led::mode(Mode::OUTPUT);&lt;br /&gt;
  &lt;br /&gt;
  for(;;) {&lt;br /&gt;
    led::high();&lt;br /&gt;
    sleep(1);&lt;br /&gt;
    led::low();&lt;br /&gt;
    sleep(1);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Windows_Quick_Start&amp;diff=41</id>
		<title>Windows Quick Start</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Windows_Quick_Start&amp;diff=41"/>
		<updated>2014-04-13T20:54:40Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Before you begin ===&lt;br /&gt;
&lt;br /&gt;
Before you can install the Miosix Toolchain on Windows, you will need to install [https://en.wikipedia.org/wiki/Git_%28software%29 git], which is necessary to download the Miosix kernel and keep it up to date, [https://en.wikipedia.org/wiki/Perl Perl], which is a scripting language used when compiling the kernel, and the STLink drivers if you want to program stm32 boards that have an USB-based STLinkV2 programmer/debugger.&lt;br /&gt;
&lt;br /&gt;
* For git, it is recomended to install it from [http://www.git-scm.com/download/win git-scm.com]. Please &#039;&#039;&#039;do not&#039;&#039;&#039; uncheck the &#039;&#039;Windows Explorer integration&#039;&#039; feature during the installation, as you will need it to install the kernel sources.&lt;br /&gt;
* [http://strawberryperl.com Strawberry perl] is the recomended perl version for Miosix on Windows&lt;br /&gt;
* The STLink drivers can be found on the [http://www.st.com/web/en/catalog/tools/PF258168# ST website].&lt;br /&gt;
&lt;br /&gt;
Finally, it is recomended to download a better text editor than Notepad or WordPad, as you will need it to edit the Miosix configuration files. [http://www.notepad-plus-plus.org/ Notepad++] is a good option, but many other options exist. Just &#039;&#039;&#039;don&#039;t use notepad&#039;&#039;&#039;, because it does not recognize Unix [https://en.wikipedia.org/wiki/Line_ending line-endings] and will show you Miosix source files as if they were composed of a single line of text.&lt;br /&gt;
&lt;br /&gt;
Once you have downloaded and installed the aforementioned software, you can proceed with the installation of the Miosix Toolchain.&lt;br /&gt;
&lt;br /&gt;
=== Install the Miosix Toolchain ===&lt;br /&gt;
&lt;br /&gt;
Download the [http://miosix.org/toolchain/MiosixToolchainInstaller.exe Miosix Toolchain installer] and run it. At the end you will need to reboot your computer (sorry, it&#039;s Windows...)&lt;br /&gt;
&lt;br /&gt;
=== Get the Miosix kernel sources ===&lt;br /&gt;
&lt;br /&gt;
Go to the directory where you want to dowload the Miosix kernel, for example the Documents directory, and right-click on it. Select &#039;&#039;Git bash&#039;&#039; to open a git shell. There you can type the commands to download the kernel.&lt;br /&gt;
&lt;br /&gt;
[[File:Gitbashwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Currently, Miosix 2.0 is in the &#039;&#039;testing&#039;&#039; branch of the git repository, while the default one, the &#039;&#039;master&#039;&#039; branch, contains Miosix 1.x. So, you need to explicitly switch to the testing branch after downloading the kernel. To do so, type the following commands in the git shell.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://git.gitorious.org/miosix-kernel/miosix-kernel.git&lt;br /&gt;
cd miosix-kernel&lt;br /&gt;
git fetch origin&lt;br /&gt;
git checkout -b testing origin/testing&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that it is possible to paste commands in the shell (so as to avoid typing them, which can be tedious and lead to typos), but you have to do it one line of text at a time, and to paste you need to use the &#039;&#039;Shift+Ins&#039;&#039; shortcut, not the usual &#039;&#039;Ctrl+v&#039;&#039; one. The last command, &#039;&#039;exit&#039;&#039;, will close the shell.&lt;br /&gt;
&lt;br /&gt;
Note that there is also a &#039;Git GUI&#039; in the right click menu, but since I don&#039;t know how to use it, you&#039;re on your own if you choose that route.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and compiling the kernel ===&lt;br /&gt;
&lt;br /&gt;
More in-depth information on how th configure the kernel for your board can be found in the [[Board List]], but for now we will assume you have an stm32f4discovery, which is a common board, and briefly show how to get to a blinking LED example.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Top-level directory&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First of all the miosix-kernel directory is often referred to as the &#039;&#039;&#039;top-level directory&#039;&#039;&#039; of the kernel. It contains, among other, the &#039;&#039;main.cpp&#039;&#039; file which is where you can start writing your application code, the &#039;&#039;Makefile&#039;&#039; where you can add additional C++ and C source files to be compiled, and the &#039;&#039;miosix&#039;&#039; directory which contains the kernel.&lt;br /&gt;
&lt;br /&gt;
[[File:Miosixtopleveldirectorywindows.png]]&lt;br /&gt;
&lt;br /&gt;
All paths in this wiki, unless they start with a &#039;/&#039; (for Linux) or &#039;C:\&#039; (For Windows), are intended relative to Miosix&#039;s top-level directory, so if we&#039;re talking about the &#039;miosix/config/Makefile.inc&#039; file you can find it within the directory where you have downloaded the kernel from git.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Configuring the kernel&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The kernel is configured by editing two files, named [[Makefile.inc|miosix/config/Makefile.inc]] and [[miosix_settingls.h|miosix/config/miosix_settings.h]]. Open the first one in Notepad++, and select your board. To do so, look for the &#039;&#039;OPT_BOARD&#039;&#039; section of the file, which looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
## Target board, choose one. This also implicitly select the target&lt;br /&gt;
## architecture&lt;br /&gt;
##&lt;br /&gt;
#OPT_BOARD := lpc2138_miosix_board&lt;br /&gt;
OPT_BOARD := stm32f103ze_stm3210e-eval&lt;br /&gt;
#OPT_BOARD := stm32f103ve_mp3v2&lt;br /&gt;
#OPT_BOARD := stm32f100rb_stm32vldiscovery&lt;br /&gt;
#OPT_BOARD := stm32f103ve_strive_mini&lt;br /&gt;
#OPT_BOARD := stm32f103ze_redbull_v2&lt;br /&gt;
#OPT_BOARD := stm32f407vg_stm32f4discovery&lt;br /&gt;
#OPT_BOARD := stm32f207ig_stm3220g-eval&lt;br /&gt;
#OPT_BOARD := stm32f207zg_ethboard_v2&lt;br /&gt;
#OPT_BOARD := stm32f207ze_als_camboard&lt;br /&gt;
#OPT_BOARD := stm32l151_als_mainboard&lt;br /&gt;
#OPT_BOARD := stm32f407vg_bitsboard&lt;br /&gt;
#OPT_BOARD := stm32f205rg_sony-newman&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In Makefile syntax a &#039;#&#039; sign denotes a comment, so to select a board you have to comment out (by prepending a &#039;#&#039;) the default board selected, and uncomment (by removing the &#039;#&#039; at the start of the line) your board, which in this example is the &#039;&#039;stm32f407vg_stm32f4discovery&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, edit the &#039;&#039;miosix_settings.h&#039;&#039; file using Notepad++ and uncomment (by removing the &#039;//&#039; at the start of the line) the following line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
//#define JTAG_DISABLE_SLEEP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(which is towards the end of the file). This is a C++ header file, so the comment syntax is &#039;//&#039;. More information on the meaning of this line can be found in [[miosix_settings.h]], but a short summary is that this line prevents the kernel from shutting down the CPU when it has nothing to do, which saves power but interferes with the programming/debugging protocol used to program the board via QSTLink2.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Blink a LED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;main.cpp&#039;&#039; file in the top-level directory using Notepad++, and replace its content with the following program:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        ledOn();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
        ledOff();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The Miosix board support package defines the &#039;&#039;ledOn()&#039;&#039; and &#039;&#039;ledOff()&#039;&#039; functions to control a LED on the board for all the boards that have at least one software-accessible LED.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Compiling&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To compile the kernel, open a DOS shell in the Miosix top-level directory (you can &#039;Shift+Right click&#039; in the top-level directory and choose &#039;Open command window here&#039; in modern versions of Windows), otherwise you will have to &#039;&#039;cd&#039;&#039; your way into that directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Openterminalwindows.png]]&lt;br /&gt;
&lt;br /&gt;
To compile the kernel type &#039;&#039;make&#039;&#039; in the DOS prompt. If all goes well, the result should look like this.&lt;br /&gt;
&lt;br /&gt;
[[File:Makeoutputwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Otherwise, compiler errors will appear in the DOS prompt. The number that appears under &#039;&#039;text&#039;&#039; in the make output is the size in bytes of your application plus the kernel. If you think that 90KBytes is a bit too much for a blinking led, don&#039;t worry. The kernel by default includes support for C stdio functions, filesystem code including Unicode support and the C++ exception handling runtime, all of which can be disabled to significantly [[Miosix code size optimization|reduce code size]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are two ways to program the stm32f4discovery board. One is to use QSTLink2 directly from the DOS prompt you already have open by typing &#039;make program&#039; (connect the USB cable first!), the other is through QSTLink2&#039;s GUI. You can find QSTLink2 in the start menu&lt;br /&gt;
&lt;br /&gt;
[[File:Qstlink2startmenuwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Once you start it, you have to click on &#039;&#039;Connect&#039;&#039;, and it should find your &#039;&#039;stm32f4discovery&#039;&#039; board. After that, click on &#039;&#039;Send&#039;&#039; and select the &#039;&#039;main.bin&#039;&#039; file in the Miosix top-level directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Qstlink2flashingwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Note that, regardless of using QSTLink2 form the DOS prompt or the GUI, there is a bug that in some circumstances blocks the microcontroller until the next powercycle. Therefore, after having programmed the microcontroller, it is recomended to unplug and reconnect the USB cable to powercycle the &#039;&#039;stm32f4discovery&#039;&#039; board. At that point, you shuold see the red LED blinking.&lt;br /&gt;
&lt;br /&gt;
=== What&#039;s next? ===&lt;br /&gt;
&lt;br /&gt;
You have finished the installation of the Miosix Toolchain. You may want to [[Quick start#IDE Configuration|install and configure an IDE]], or the [[Quick start#In-circuit debugger|debugger]].&lt;br /&gt;
&lt;br /&gt;
=== Uninstall the Miosix Toolchain ===&lt;br /&gt;
&lt;br /&gt;
To uninstall the Miosix Toolchain, you can find the uninstaller in the start menu under &#039;&#039;Miosix Toolchain&#039;&#039;. Note that Git, Perl and the STLink drivers have their own uninstallers. Also, the &#039;&#039;miosix-kernel&#039;&#039; in the &#039;&#039;Documents&#039;&#039; directory will not be removed.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Quick_start&amp;diff=39</id>
		<title>Quick start</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Quick_start&amp;diff=39"/>
		<updated>2014-04-13T13:11:48Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Add category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To start using Miosix you need a patched version of the GCC compiler to support the Miosix thread model and git to download the kernel sources. Optionally you can also use an IDE to simplify code development, and an in-circuit debugger to speed up bug fixing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Changes with respect to Miosix 1.x &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A word of warning if you are a long-time user of Miosix: please note that in Miosix 2.0 there were significant changes.&lt;br /&gt;
First of all, Miosix 2.0 uses GCC 4.7.3 and is no longer compatible with the old GCC 4.5.2 used in Miosix 1.x, so you need to upgrade your compiler.&lt;br /&gt;
Second, the preferred way to install the compiler is through a precompiled installer available for both Linux and Windows. If you want, though, you can still build the compiler from sources.&lt;br /&gt;
Last, keep in mind that the compiler patches are still a work in progress. When doing a &#039;git pull&#039; you may need to upgrade the compiler too.&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the installation of the minimum requirements to start using Miosix: installing the compiler, and downloading the kernel.&lt;br /&gt;
&lt;br /&gt;
* [[Linux Quick Start|Getting Started on Linux]]&lt;br /&gt;
* [[Windows Quick Start|Getting Started on Windows]]&lt;br /&gt;
&lt;br /&gt;
=== IDE Configuration ===&lt;br /&gt;
&lt;br /&gt;
The default IDE to develop for Miosix is [https://netbeans.org/ Netbeans]. However, it does not come with Miosix support out of the box, so you have to configure it first.&lt;br /&gt;
&lt;br /&gt;
* [[Linux Netbeans configuration]]&lt;br /&gt;
* [[Windows Netbeans configuration]]&lt;br /&gt;
&lt;br /&gt;
Another alternative is Eclipse, which has the added feature to allow in-circuit debugging directly from the IDE.&lt;br /&gt;
&lt;br /&gt;
TODO: How to set up Eclipse&lt;br /&gt;
&lt;br /&gt;
=== In-circuit debugger ===&lt;br /&gt;
&lt;br /&gt;
An in-circuit debugger allows to physically halt the CPU inside a microcontroller, single-step it and view all the variables at any given time. It is a powerful tool to debug software running on a microcontroller. Miosix uses GDB and [http://openocd.sourceforge.net openocd] for in-circuit debugging.&lt;br /&gt;
&lt;br /&gt;
* [[Linux Debugger configuration]]&lt;br /&gt;
* [[Windows Debugger configuration]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Installation_and_Configuration&amp;diff=38</id>
		<title>Category:Installation and Configuration</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Installation_and_Configuration&amp;diff=38"/>
		<updated>2014-04-13T13:11:17Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Installation and Configuration:&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Installation and Configuration:&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Windows_Quick_Start&amp;diff=37</id>
		<title>Windows Quick Start</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Windows_Quick_Start&amp;diff=37"/>
		<updated>2014-04-13T13:10:56Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Add category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Before you begin ===&lt;br /&gt;
&lt;br /&gt;
Before you can install the Miosix Toolchain on Windows, you will need to install [[https://en.wikipedia.org/wiki/Git_%28software%29 git]], which is necessary to download the Miosix kernel and keep it up to date, [[https://en.wikipedia.org/wiki/Perl Perl]], which is a scripting language used when compiling the kernel, and the STLink drivers if you want to program stm32 boards that have an USB-based STLinkV2 programmer/debugger.&lt;br /&gt;
&lt;br /&gt;
* For git, it is recomended to install it from [[http://www.git-scm.com/download/win git-scm.com]]. Please &#039;&#039;&#039;do not&#039;&#039;&#039; uncheck the &#039;&#039;Windows Explorer integration&#039;&#039; feature during the installation, as you will need it to install the kernel sources.&lt;br /&gt;
* [[http://strawberryperl.com Strawberry perl]] is the recomended perl version for Miosix on Windows&lt;br /&gt;
* The STLink drivers can be found on the [[http://www.st.com/web/en/catalog/tools/PF258168# ST website]].&lt;br /&gt;
&lt;br /&gt;
Finally, it is recomended to download a better text editor than Notepad or WordPad, as you will need it to edit the Miosix configuration files. [[http://www.notepad-plus-plus.org/ Notepad++]] is a good option, but many other options exist. Just &#039;&#039;&#039;don&#039;t use notepad&#039;&#039;&#039;, because it does not recognize Unix [[https://en.wikipedia.org/wiki/Line_ending line-endings]] and will show you Miosix source files as if they were composed of a single line of text.&lt;br /&gt;
&lt;br /&gt;
Once you have downloaded and installed the aforementioned software, you can proceed with the installation of the Miosix Toolchain.&lt;br /&gt;
&lt;br /&gt;
=== Install the Miosix Toolchain ===&lt;br /&gt;
&lt;br /&gt;
Download the [[http://miosix.org/toolchain/MiosixToolchainInstaller.exe Miosix Toolchain installer]] and run it. At the end you will need to reboot your computer (sorry, it&#039;s Windows...)&lt;br /&gt;
&lt;br /&gt;
=== Get the Miosix kernel sources ===&lt;br /&gt;
&lt;br /&gt;
Go to the directory where you want to dowload the Miosix kernel, for example the Documents directory, and right-click on it. Select &#039;&#039;Git bash&#039;&#039; to open a git shell. There you can type the commands to download the kernel.&lt;br /&gt;
&lt;br /&gt;
[[File:Gitbashwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Currently, Miosix 2.0 is in the &#039;&#039;testing&#039;&#039; branch of the git repository, while the default one, the &#039;&#039;master&#039;&#039; branch, contains Miosix 1.x. So, you need to explicitly switch to the testing branch after downloading the kernel. To do so, type the following commands in the git shell.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://git.gitorious.org/miosix-kernel/miosix-kernel.git&lt;br /&gt;
cd miosix-kernel&lt;br /&gt;
git fetch origin&lt;br /&gt;
git checkout -b testing origin/testing&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that it is possible to paste commands in the shell (so as to avoid typing them, which can be tedious and lead to typos), but you have to do it one line of text at a time, and to paste you need to use the &#039;&#039;Shift+Ins&#039;&#039; shortcut, not the usual &#039;&#039;Ctrl+v&#039;&#039; one. The last command, &#039;&#039;exit&#039;&#039;, will close the shell.&lt;br /&gt;
&lt;br /&gt;
Note that there is also a &#039;Git GUI&#039; in the right click menu, but since I don&#039;t know how to use it, you&#039;re on your own if you choose that route.&lt;br /&gt;
&lt;br /&gt;
=== Configuring and compiling the kernel ===&lt;br /&gt;
&lt;br /&gt;
More in-depth information on how th configure the kernel for your board can be found in the [[Board List]], but for now we will assume you have an stm32f4discovery, which is a common board, and briefly show how to get to a blinking LED example.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Top-level directory&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First of all the miosix-kernel directory is often referred to as the &#039;&#039;&#039;top-level directory&#039;&#039;&#039; of the kernel. It contains, among other, the &#039;&#039;main.cpp&#039;&#039; file which is where you can start writing your application code, the &#039;&#039;Makefile&#039;&#039; where you can add additional C++ and C source files to be compiled, and the &#039;&#039;miosix&#039;&#039; directory which contains the kernel.&lt;br /&gt;
&lt;br /&gt;
[[File:Miosixtopleveldirectorywindows.png]]&lt;br /&gt;
&lt;br /&gt;
All paths in this wiki, unless they start with a &#039;/&#039; (for Linux) or &#039;C:\&#039; (For Windows), are intended relative to Miosix&#039;s top-level directory, so if we&#039;re talking about the &#039;miosix/config/Makefile.inc&#039; file you can find it within the directory where you have downloaded the kernel from git.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Configuring the kernel&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The kernel is configured by editing two files, named [[Makefile.inc|miosix/config/Makefile.inc]] and [[miosix_settingls.h|miosix/config/miosix_settings.h]]. Open the first one in Notepad++, and select your board. To do so, look for the &#039;&#039;OPT_BOARD&#039;&#039; section of the file, which looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
## Target board, choose one. This also implicitly select the target&lt;br /&gt;
## architecture&lt;br /&gt;
##&lt;br /&gt;
#OPT_BOARD := lpc2138_miosix_board&lt;br /&gt;
OPT_BOARD := stm32f103ze_stm3210e-eval&lt;br /&gt;
#OPT_BOARD := stm32f103ve_mp3v2&lt;br /&gt;
#OPT_BOARD := stm32f100rb_stm32vldiscovery&lt;br /&gt;
#OPT_BOARD := stm32f103ve_strive_mini&lt;br /&gt;
#OPT_BOARD := stm32f103ze_redbull_v2&lt;br /&gt;
#OPT_BOARD := stm32f407vg_stm32f4discovery&lt;br /&gt;
#OPT_BOARD := stm32f207ig_stm3220g-eval&lt;br /&gt;
#OPT_BOARD := stm32f207zg_ethboard_v2&lt;br /&gt;
#OPT_BOARD := stm32f207ze_als_camboard&lt;br /&gt;
#OPT_BOARD := stm32l151_als_mainboard&lt;br /&gt;
#OPT_BOARD := stm32f407vg_bitsboard&lt;br /&gt;
#OPT_BOARD := stm32f205rg_sony-newman&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In Makefile syntax a &#039;#&#039; sign denotes a comment, so to select a board you have to comment out (by prepending a &#039;#&#039;) the default board selected, and uncomment (by removing the &#039;#&#039; at the start of the line) your board, in this case, which in this example will assume is the &#039;&#039;stm32f407vg_stm32f4discovery&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, edit the &#039;&#039;miosix_settings.h&#039;&#039; using Notepad++ and uncomment (by removing the &#039;//&#039; at the start of the line) the following line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
//#define JTAG_DISABLE_SLEEP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(which is towards the end of the file). This is a C++ header file, so the comment syntax is &#039;//&#039;. More information on the meaning of this line can be found in [[miosix_settings.h]], but a short summary is that this line prevents the kernel from putting shutting down the CPU when it has nothing to do, which saves power but interferes with the programming/debugging protocol used to program the board via QSTLink2.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Blink a LED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;main.cpp&#039;&#039; file in the top-level directory using Notepad++, and replace its content with the following program:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        ledOn();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
        ledOff();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The Miosix board support package defines the &#039;&#039;ledOn()&#039;&#039; and &#039;&#039;ledOff()&#039;&#039; functions to control a LED on the board for all the boards that have at least one software-accessible LED.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Compiling&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To compile the kernel, open a DOS shell in the Miosix top-level directory (you can &#039;Shift+Right click&#039; in the top-level directory and choose &#039;Open command window here&#039; in modern versions of Windows), otherwise you will have to &#039;&#039;cd&#039;&#039; your way into that directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Openterminalwindows.png]]&lt;br /&gt;
&lt;br /&gt;
To compile the kernel type &#039;&#039;make&#039;&#039; in the DOS prompt. If all goes well, the result should look like this.&lt;br /&gt;
&lt;br /&gt;
[[File:Makeoutputwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Otherwise, compiler errors will appear in the DOS prompt. The number that appears under &#039;&#039;text&#039;&#039; in the make output is the size in bytes of your application plus the kernel. If you think that 90KBytes is a bit too much for a blinking led, don&#039;t worry. The kernel by default includes support for C stdio functions, filesystem code including Unicode support and the C++ exception handling runtime, all of which can be disabled to significantly [[Miosix code size optimization|reduce code size]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are two ways to program the stm32f4discovery board. One is to use QSTLink2 directly from the DOS prompt you already have open by typing &#039;make program&#039; (connect the USB cable first!), the other is through QSTLink2&#039;s GUI. You can find QSTLink2 in the start menu&lt;br /&gt;
&lt;br /&gt;
[[File:Qstlink2startmenuwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Once you start it, you have to click on &#039;&#039;Connect&#039;&#039;, and it should find your &#039;&#039;stm32f4discovery&#039;&#039; board. After that, click on &#039;&#039;Send&#039;&#039; and select the &#039;&#039;main.bin&#039;&#039; file in the Miosix top-level directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Qstlink2flashingwindows.png]]&lt;br /&gt;
&lt;br /&gt;
Note that, regardless of using QSTLink2 form the DOS prompt or the GUI, there is a bug that in some circumstances blocks the microcontroller until the next powercycle. Therefore, after having programmed the microcontroller, is is recomended to unplug and reconnect the USB cable to powercycle the &#039;&#039;stm32f4discovery&#039;&#039; board. At that point, you shuold see the red LED blinking.&lt;br /&gt;
&lt;br /&gt;
=== What&#039;s next? ===&lt;br /&gt;
&lt;br /&gt;
You have finished the installation of the Miosix Toolchain. You may want to [[Quick start#IDE Configuration|install and configure an IDE]], or the [[Quick start#In-circuit debugger|debugger]].&lt;br /&gt;
&lt;br /&gt;
=== Uninstall the Miosix Toolchain ===&lt;br /&gt;
&lt;br /&gt;
To uninstall the Miosix Toolchain, you can find the uninstaller in the start menu under &#039;&#039;Miosix Toolchain&#039;&#039;. Note that Git, Perl and the STLink drivers have their own uninstallers. Also, the &#039;&#039;miosix-kernel&#039;&#039; in the &#039;&#039;Documents&#039;&#039; directory will not be removed.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Linux_Quick_Start&amp;diff=36</id>
		<title>Linux Quick Start</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Linux_Quick_Start&amp;diff=36"/>
		<updated>2014-04-13T13:09:47Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Add category&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page explains how to install the precompiled Miosix Toolchain. If you prefer compiling GCC from sources, see [[Building GCC from sources]].&lt;br /&gt;
&lt;br /&gt;
=== Before you begin ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;64 bit Linux distros&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The precompiled Miosix Toolchain is compiled for 32bit x86, to be compatible with as many Linux installations as possible. If you have a 64bit OS, you need to install a few 32bit libraries to be able to use it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install libstdc++6:i386 # Install 32bit compatibility libraries for Ubuntu/Debian&lt;br /&gt;
sudo pacman -S lib32-libstdc++5      # Install 32bit compatibility libraries for Arch Linux&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; QSTLink2 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you want to program STM32 microcontrollers, you will also need a tool to the transfer your programs to the microcontroller. A popular choice for boards like the &#039;&#039;stm32f4discovery&#039;&#039; that have an embedded STLinkV2 USB programmer/debugger is [https://code.google.com/p/qstlink2 QSTLink2]. The installation on Ubuntu/Debian requires to add a &#039;&#039;ppa&#039;&#039; and install it via &#039;&#039;apt-get&#039;&#039;. Also, it is recomended to install the udev rules, which allow QSTLink2 to connect to the USB port without the need to run it from root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:mobyfab/qstlink2&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install qstlink2&lt;br /&gt;
wget https://raw.githubusercontent.com/mobyfab/QStlink2/master/res/49-stlinkv2.rules&lt;br /&gt;
sudo mv 49-stlinkv2.rules /etc/udev/rules.d&lt;br /&gt;
sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An alternative tool to program STM32 microcontrollers using the serial port bootloader is [https://code.google.com/p/stm32flash stm32flash]. Finally, for historical reasons, the Miosix Toolchain includes &#039;&#039;lpc21isp&#039;&#039;, a tool to program LPC2000 microcontrollers using their serial bootloader.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Serial port setup &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Miosix redirects &#039;&#039;stdin&#039;&#039;/&#039;&#039;stdout&#039;&#039; to a serial port by default on most boards, so it is important to set up serial ports correctly on your development machine. On most Linux distros serial ports, both the physical ones like &#039;&#039;/dev/ttyS0&#039;&#039; and the USB to serial adapters like &#039;&#039;/dev/ttyUSB0&#039;&#039; are owned by the &#039;&#039;dialout&#039;&#039; group, so you need to add your user to that group before you can access them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo usermod -a -G dialout `id -un` # Add yourself to the dialout group&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you may need to reboot your computer before the change takes effect. Also, you need a program to interact with the serial port, like &#039;&#039;GNU screen&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install screen # For Ubuntu/Debian&lt;br /&gt;
sudo pacman -S screen       # For Arch Linux&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install the Miosix Toolchain ===&lt;br /&gt;
&lt;br /&gt;
Download the latest version of the [http://miosix.org/toolchain/MiosixToolchainInstaller.run Miosix Toolchain] and launch it. The installer will ask for your root password to copy the compiler to the &#039;&#039;/opt/arm-miosix-eabi&#039;&#039; directory, and put symlinks to &#039;&#039;/usr/bin&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
wget http://miosix.org/toolchain/MiosixToolchainInstaller.run&lt;br /&gt;
sh MiosixToolchainInstaller.run&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do not trust the installer and want to verify its content, or you want to install it locally, it is possible to extract the content of the installer with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sh MiosixToolchainInstaller.run --noexec --target arm-miosix-eabi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that for a local install you will need to set the &#039;&#039;PATH&#039;&#039; environment variable to the &#039;&#039;arm-miosix-eabi/bin&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
=== Get the Miosix kernel sources ===&lt;br /&gt;
&lt;br /&gt;
The preferred way to download the Miosix kernel is through [https://en.wikipedia.org/wiki/Git_%28software%29 git]. If you do not already have it installed you can install it now&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install git # For Ubuntu/Debian&lt;br /&gt;
sudo pacman -S git       # For Arch Linux&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, Miosix 2.0 is in the &#039;&#039;testing&#039;&#039; branch of the git repository, while the default one, the &#039;&#039;master&#039;&#039; branch, contains Miosix 1.x. So, you need to explicitly switch to the testing branch after downloading the kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://git.gitorious.org/miosix-kernel/miosix-kernel.git&lt;br /&gt;
cd miosix-kernel&lt;br /&gt;
git fetch origin&lt;br /&gt;
git checkout -b testing origin/testing&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuring and compiling the kernel ===&lt;br /&gt;
&lt;br /&gt;
More in-depth information on how th configure the kernel for your board can be found in the [[Board List]], but for now we will assume you have an stm32f4discovery, which is a common board, and briefly show how to get to a blinking LED example.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Top-level directory&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First of all the miosix-kernel directory is often referred to as the &#039;&#039;&#039;top-level directory&#039;&#039;&#039; of the kernel. It contains, among other, the &#039;&#039;main.cpp&#039;&#039; file which is where you can start writing your application code, the &#039;&#039;Makefile&#039;&#039; where you can add additional C++ and C source files to be compiled, and the &#039;&#039;miosix&#039;&#039; directory which contains the kernel.&lt;br /&gt;
&lt;br /&gt;
[[File:Miosixtopleveldirectorylinux.png]]&lt;br /&gt;
&lt;br /&gt;
All paths in this wiki, unless they start with a &#039;/&#039; (for Linux) or &#039;C:\&#039; (For Windows), are intended relative to Miosix&#039;s top-level directory, so if we&#039;re talking about the &#039;miosix/config/Makefile.inc&#039; file you can find it within the directory where you have downloaded the kernel from git.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Configuring the kernel&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The kernel is configured by editing two files, named [[Makefile.inc|miosix/config/Makefile.inc]] and [[miosix_settings.h|miosix/config/miosix_settings.h]]. Open the first one, and select your board. To do so, look for the &#039;&#039;OPT_BOARD&#039;&#039; section of the file, which looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
## Target board, choose one. This also implicitly select the target&lt;br /&gt;
## architecture&lt;br /&gt;
##&lt;br /&gt;
#OPT_BOARD := lpc2138_miosix_board&lt;br /&gt;
OPT_BOARD := stm32f103ze_stm3210e-eval&lt;br /&gt;
#OPT_BOARD := stm32f103ve_mp3v2&lt;br /&gt;
#OPT_BOARD := stm32f100rb_stm32vldiscovery&lt;br /&gt;
#OPT_BOARD := stm32f103ve_strive_mini&lt;br /&gt;
#OPT_BOARD := stm32f103ze_redbull_v2&lt;br /&gt;
#OPT_BOARD := stm32f407vg_stm32f4discovery&lt;br /&gt;
#OPT_BOARD := stm32f207ig_stm3220g-eval&lt;br /&gt;
#OPT_BOARD := stm32f207zg_ethboard_v2&lt;br /&gt;
#OPT_BOARD := stm32f207ze_als_camboard&lt;br /&gt;
#OPT_BOARD := stm32l151_als_mainboard&lt;br /&gt;
#OPT_BOARD := stm32f407vg_bitsboard&lt;br /&gt;
#OPT_BOARD := stm32f205rg_sony-newman&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In Makefile syntax a &#039;#&#039; sign denotes a comment, so to select a board you have to comment out (by prepending a &#039;#&#039;) the default board selected, and uncomment (by removing the &#039;#&#039; at the start of the line) your board, in this case, which in this example will assume is the &#039;&#039;stm32f407vg_stm32f4discovery&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, edit the &#039;&#039;miosix_settings.h&#039;&#039; file and uncomment (by removing the &#039;//&#039; at the start of the line) the following line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
//#define JTAG_DISABLE_SLEEP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(which is towards the end of the file). This is a C++ header file, so the comment syntax is &#039;//&#039;. More information on the meaning of this line can be found in [[miosix_settings.h]], but a short summary is that this line prevents the kernel from putting shutting down the CPU when it has nothing to do, which saves power but interferes with the programming/debugging protocol used to program the board via QSTLink2.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Blink a LED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;main.cpp&#039;&#039; file in the top-level directory, and replace its content with the following program:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        ledOn();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
        ledOff();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The Miosix board support package defines the &#039;&#039;ledOn()&#039;&#039; and &#039;&#039;ledOff()&#039;&#039; functions to control a LED on the board for all the boards that have at least one software-accessible LED.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Compiling&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To compile the kernel, open a terminal in the Miosix top-level directory and type &#039;&#039;make&#039;&#039;. If all goes well, the result should look like this.&lt;br /&gt;
&lt;br /&gt;
[[File:Makeoutputlinux.png]]&lt;br /&gt;
&lt;br /&gt;
Otherwise, compiler errors will appear in the shell. The number that appears under &#039;&#039;text&#039;&#039; in the make output is the size in bytes of your application plus the kernel. If you think that 90KBytes is a bit too much for a blinking led, don&#039;t worry. The kernel by default includes support for C stdio functions, filesystem code including Unicode support and the C++ exception handling runtime, all of which can be disabled to significantly [[Miosix code size optimization|reduce code size]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are two ways to program the stm32f4discovery board. One is to use QSTLink2 directly from the shell you already have open by typing &#039;make program&#039; (connect the USB cable first!), the other is through QSTLink2&#039;s GUI.&lt;br /&gt;
&lt;br /&gt;
[[File:Findqstlink2guilinux.png]]&lt;br /&gt;
&lt;br /&gt;
Once you start it, you have to click on &#039;&#039;Connect&#039;&#039;, and it should find your &#039;&#039;stm32f4discovery&#039;&#039; board. After that, click on &#039;&#039;Send&#039;&#039; and select the &#039;&#039;main.bin&#039;&#039; file in the Miosix top-level directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Qstlink2flashinglinux.png]]&lt;br /&gt;
&lt;br /&gt;
Note that, regardless of using QSTLink2 form the shell or the GUI, there is a bug that in some circumstances blocks the microcontroller until the next powercycle. Therefore, after having programmed the microcontroller, is is recomended to unplug and reconnect the USB cable to powercycle the &#039;&#039;stm32f4discovery&#039;&#039; board. At that point, you shuold see the red LED blinking.&lt;br /&gt;
&lt;br /&gt;
=== What&#039;s next? ===&lt;br /&gt;
&lt;br /&gt;
You have finished the installation of the Miosix Toolchain. You may want to [[Quick start#IDE Configuration|install and configure an IDE]], or the [[Quick start#In-circuit debugger|debugger]].&lt;br /&gt;
&lt;br /&gt;
=== Uninstall the compiler ===&lt;br /&gt;
&lt;br /&gt;
If for some reason you need to uninstall the compiler, there is an uninstall script in the &#039;&#039;/opt/arm-miosix-eabi&#039;&#039; directory (Note: if you have built the compiler from sources the uninstall script may not be there). Running the script will uninstall the compiler and the symbolic links in the &#039;&#039;/usr/bin&#039;&#039; directory. Just like the install script, the uninstaller will ask for your root password to be able to remove the installed files.&lt;br /&gt;
&lt;br /&gt;
There is no need to uninstall and old compiler to install a new one, the installer will take care of that automatically. However, if you have installed the compiler and now you want to build it from sources, you first need to uninstall the old compiler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd /opt/arm-miosix-eabi&lt;br /&gt;
./uninstall.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have chosen to install the compiler locally (i.e: not in the &#039;/opt/arm-miosix-eabi&#039; directory), simply remove the compiler directory.&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation and Configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Linux_Quick_Start&amp;diff=35</id>
		<title>Linux Quick Start</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Linux_Quick_Start&amp;diff=35"/>
		<updated>2014-04-13T13:08:12Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page explains how to install the precompiled Miosix Toolchain. If you prefer compiling GCC from sources, see [[Building GCC from sources]].&lt;br /&gt;
&lt;br /&gt;
=== Before you begin ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;64 bit Linux distros&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The precompiled Miosix Toolchain is compiled for 32bit x86, to be compatible with as many Linux installations as possible. If you have a 64bit OS, you need to install a few 32bit libraries to be able to use it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install libstdc++6:i386 # Install 32bit compatibility libraries for Ubuntu/Debian&lt;br /&gt;
sudo pacman -S lib32-libstdc++5      # Install 32bit compatibility libraries for Arch Linux&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; QSTLink2 &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you want to program STM32 microcontrollers, you will also need a tool to the transfer your programs to the microcontroller. A popular choice for boards like the &#039;&#039;stm32f4discovery&#039;&#039; that have an embedded STLinkV2 USB programmer/debugger is [https://code.google.com/p/qstlink2 QSTLink2]. The installation on Ubuntu/Debian requires to add a &#039;&#039;ppa&#039;&#039; and install it via &#039;&#039;apt-get&#039;&#039;. Also, it is recomended to install the udev rules, which allow QSTLink2 to connect to the USB port without the need to run it from root.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo add-apt-repository ppa:mobyfab/qstlink2&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install qstlink2&lt;br /&gt;
wget https://raw.githubusercontent.com/mobyfab/QStlink2/master/res/49-stlinkv2.rules&lt;br /&gt;
sudo mv 49-stlinkv2.rules /etc/udev/rules.d&lt;br /&gt;
sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An alternative tool to program STM32 microcontrollers using the serial port bootloader is [https://code.google.com/p/stm32flash stm32flash]. Finally, for historical reasons, the Miosix Toolchain includes &#039;&#039;lpc21isp&#039;&#039;, a tool to program LPC2000 microcontrollers using their serial bootloader.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Serial port setup &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Miosix redirects &#039;&#039;stdin&#039;&#039;/&#039;&#039;stdout&#039;&#039; to a serial port by default on most boards, so it is important to set up serial ports correctly on your development machine. On most Linux distros serial ports, both the physical ones like &#039;&#039;/dev/ttyS0&#039;&#039; and the USB to serial adapters like &#039;&#039;/dev/ttyUSB0&#039;&#039; are owned by the &#039;&#039;dialout&#039;&#039; group, so you need to add your user to that group before you can access them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo usermod -a -G dialout `id -un` # Add yourself to the dialout group&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that you may need to reboot your computer before the change takes effect. Also, you need a program to interact with the serial port, like &#039;&#039;GNU screen&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install screen # For Ubuntu/Debian&lt;br /&gt;
sudo pacman -S screen       # For Arch Linux&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install the Miosix Toolchain ===&lt;br /&gt;
&lt;br /&gt;
Download the latest version of the [http://miosix.org/toolchain/MiosixToolchainInstaller.run Miosix Toolchain] and launch it. The installer will ask for your root password to copy the compiler to the &#039;&#039;/opt/arm-miosix-eabi&#039;&#039; directory, and put symlinks to &#039;&#039;/usr/bin&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
wget http://miosix.org/toolchain/MiosixToolchainInstaller.run&lt;br /&gt;
sh MiosixToolchainInstaller.run&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do not trust the installer and want to verify its content, or you want to install it locally, it is possible to extract the content of the installer with the following command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sh MiosixToolchainInstaller.run --noexec --target arm-miosix-eabi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that for a local install you will need to set the &#039;&#039;PATH&#039;&#039; environment variable to the &#039;&#039;arm-miosix-eabi/bin&#039;&#039; directory.&lt;br /&gt;
&lt;br /&gt;
=== Get the Miosix kernel sources ===&lt;br /&gt;
&lt;br /&gt;
The preferred way to download the Miosix kernel is through [https://en.wikipedia.org/wiki/Git_%28software%29 git]. If you do not already have it installed you can install it now&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install git # For Ubuntu/Debian&lt;br /&gt;
sudo pacman -S git       # For Arch Linux&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Currently, Miosix 2.0 is in the &#039;&#039;testing&#039;&#039; branch of the git repository, while the default one, the &#039;&#039;master&#039;&#039; branch, contains Miosix 1.x. So, you need to explicitly switch to the testing branch after downloading the kernel.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
git clone https://git.gitorious.org/miosix-kernel/miosix-kernel.git&lt;br /&gt;
cd miosix-kernel&lt;br /&gt;
git fetch origin&lt;br /&gt;
git checkout -b testing origin/testing&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Configuring and compiling the kernel ===&lt;br /&gt;
&lt;br /&gt;
More in-depth information on how th configure the kernel for your board can be found in the [[Board List]], but for now we will assume you have an stm32f4discovery, which is a common board, and briefly show how to get to a blinking LED example.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Top-level directory&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
First of all the miosix-kernel directory is often referred to as the &#039;&#039;&#039;top-level directory&#039;&#039;&#039; of the kernel. It contains, among other, the &#039;&#039;main.cpp&#039;&#039; file which is where you can start writing your application code, the &#039;&#039;Makefile&#039;&#039; where you can add additional C++ and C source files to be compiled, and the &#039;&#039;miosix&#039;&#039; directory which contains the kernel.&lt;br /&gt;
&lt;br /&gt;
[[File:Miosixtopleveldirectorylinux.png]]&lt;br /&gt;
&lt;br /&gt;
All paths in this wiki, unless they start with a &#039;/&#039; (for Linux) or &#039;C:\&#039; (For Windows), are intended relative to Miosix&#039;s top-level directory, so if we&#039;re talking about the &#039;miosix/config/Makefile.inc&#039; file you can find it within the directory where you have downloaded the kernel from git.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Configuring the kernel&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The kernel is configured by editing two files, named [[Makefile.inc|miosix/config/Makefile.inc]] and [[miosix_settings.h|miosix/config/miosix_settings.h]]. Open the first one, and select your board. To do so, look for the &#039;&#039;OPT_BOARD&#039;&#039; section of the file, which looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
## Target board, choose one. This also implicitly select the target&lt;br /&gt;
## architecture&lt;br /&gt;
##&lt;br /&gt;
#OPT_BOARD := lpc2138_miosix_board&lt;br /&gt;
OPT_BOARD := stm32f103ze_stm3210e-eval&lt;br /&gt;
#OPT_BOARD := stm32f103ve_mp3v2&lt;br /&gt;
#OPT_BOARD := stm32f100rb_stm32vldiscovery&lt;br /&gt;
#OPT_BOARD := stm32f103ve_strive_mini&lt;br /&gt;
#OPT_BOARD := stm32f103ze_redbull_v2&lt;br /&gt;
#OPT_BOARD := stm32f407vg_stm32f4discovery&lt;br /&gt;
#OPT_BOARD := stm32f207ig_stm3220g-eval&lt;br /&gt;
#OPT_BOARD := stm32f207zg_ethboard_v2&lt;br /&gt;
#OPT_BOARD := stm32f207ze_als_camboard&lt;br /&gt;
#OPT_BOARD := stm32l151_als_mainboard&lt;br /&gt;
#OPT_BOARD := stm32f407vg_bitsboard&lt;br /&gt;
#OPT_BOARD := stm32f205rg_sony-newman&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In Makefile syntax a &#039;#&#039; sign denotes a comment, so to select a board you have to comment out (by prepending a &#039;#&#039;) the default board selected, and uncomment (by removing the &#039;#&#039; at the start of the line) your board, in this case, which in this example will assume is the &#039;&#039;stm32f407vg_stm32f4discovery&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Next, edit the &#039;&#039;miosix_settings.h&#039;&#039; file and uncomment (by removing the &#039;//&#039; at the start of the line) the following line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
//#define JTAG_DISABLE_SLEEP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
(which is towards the end of the file). This is a C++ header file, so the comment syntax is &#039;//&#039;. More information on the meaning of this line can be found in [[miosix_settings.h]], but a short summary is that this line prevents the kernel from putting shutting down the CPU when it has nothing to do, which saves power but interferes with the programming/debugging protocol used to program the board via QSTLink2.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Blink a LED&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Open the &#039;&#039;main.cpp&#039;&#039; file in the top-level directory, and replace its content with the following program:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;CPP&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;miosix.h&amp;gt;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
    for(;;)&lt;br /&gt;
    {&lt;br /&gt;
        ledOn();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
        ledOff();&lt;br /&gt;
        Thread::sleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The Miosix board support package defines the &#039;&#039;ledOn()&#039;&#039; and &#039;&#039;ledOff()&#039;&#039; functions to control a LED on the board for all the boards that have at least one software-accessible LED.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Compiling&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To compile the kernel, open a terminal in the Miosix top-level directory and type &#039;&#039;make&#039;&#039;. If all goes well, the result should look like this.&lt;br /&gt;
&lt;br /&gt;
[[File:Makeoutputlinux.png]]&lt;br /&gt;
&lt;br /&gt;
Otherwise, compiler errors will appear in the shell. The number that appears under &#039;&#039;text&#039;&#039; in the make output is the size in bytes of your application plus the kernel. If you think that 90KBytes is a bit too much for a blinking led, don&#039;t worry. The kernel by default includes support for C stdio functions, filesystem code including Unicode support and the C++ exception handling runtime, all of which can be disabled to significantly [[Miosix code size optimization|reduce code size]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Programming&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
There are two ways to program the stm32f4discovery board. One is to use QSTLink2 directly from the shell you already have open by typing &#039;make program&#039; (connect the USB cable first!), the other is through QSTLink2&#039;s GUI.&lt;br /&gt;
&lt;br /&gt;
[[File:Findqstlink2guilinux.png]]&lt;br /&gt;
&lt;br /&gt;
Once you start it, you have to click on &#039;&#039;Connect&#039;&#039;, and it should find your &#039;&#039;stm32f4discovery&#039;&#039; board. After that, click on &#039;&#039;Send&#039;&#039; and select the &#039;&#039;main.bin&#039;&#039; file in the Miosix top-level directory.&lt;br /&gt;
&lt;br /&gt;
[[File:Qstlink2flashinglinux.png]]&lt;br /&gt;
&lt;br /&gt;
Note that, regardless of using QSTLink2 form the shell or the GUI, there is a bug that in some circumstances blocks the microcontroller until the next powercycle. Therefore, after having programmed the microcontroller, is is recomended to unplug and reconnect the USB cable to powercycle the &#039;&#039;stm32f4discovery&#039;&#039; board. At that point, you shuold see the red LED blinking.&lt;br /&gt;
&lt;br /&gt;
=== What&#039;s next? ===&lt;br /&gt;
&lt;br /&gt;
You have finished the installation of the Miosix Toolchain. You may want to [[Quick start#IDE Configuration|install and configure an IDE]], or the [[Quick start#In-circuit debugger|debugger]].&lt;br /&gt;
&lt;br /&gt;
=== Uninstall the compiler ===&lt;br /&gt;
&lt;br /&gt;
If for some reason you need to uninstall the compiler, there is an uninstall script in the &#039;&#039;/opt/arm-miosix-eabi&#039;&#039; directory (Note: if you have built the compiler from sources the uninstall script may not be there). Running the script will uninstall the compiler and the symbolic links in the &#039;&#039;/usr/bin&#039;&#039; directory. Just like the install script, the uninstaller will ask for your root password to be able to remove the installed files.&lt;br /&gt;
&lt;br /&gt;
There is no need to uninstall and old compiler to install a new one, the installer will take care of that automatically. However, if you have installed the compiler and now you want to build it from sources, you first need to uninstall the old compiler.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd /opt/arm-miosix-eabi&lt;br /&gt;
./uninstall.sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you have chosen to install the compiler locally (i.e: not in the &#039;/opt/arm-miosix-eabi&#039; directory), simply remove the compiler directory.&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Quick_start&amp;diff=34</id>
		<title>Quick start</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Quick_start&amp;diff=34"/>
		<updated>2014-04-13T13:04:15Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To start using Miosix you need a patched version of the GCC compiler to support the Miosix thread model and git to download the kernel sources. Optionally you can also use an IDE to simplify code development, and an in-circuit debugger to speed up bug fixing.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039; Changes with respect to Miosix 1.x &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
A word of warning if you are a long-time user of Miosix: please note that in Miosix 2.0 there were significant changes.&lt;br /&gt;
First of all, Miosix 2.0 uses GCC 4.7.3 and is no longer compatible with the old GCC 4.5.2 used in Miosix 1.x, so you need to upgrade your compiler.&lt;br /&gt;
Second, the preferred way to install the compiler is through a precompiled installer available for both Linux and Windows. If you want, though, you can still build the compiler from sources.&lt;br /&gt;
Last, keep in mind that the compiler patches are still a work in progress. When doing a &#039;git pull&#039; you may need to upgrade the compiler too.&lt;br /&gt;
&lt;br /&gt;
=== Getting started ===&lt;br /&gt;
&lt;br /&gt;
This section will guide you through the installation of the minimum requirements to start using Miosix: installing the compiler, and downloading the kernel.&lt;br /&gt;
&lt;br /&gt;
* [[Linux Quick Start|Getting Started on Linux]]&lt;br /&gt;
* [[Windows Quick Start|Getting Started on Windows]]&lt;br /&gt;
&lt;br /&gt;
=== IDE Configuration ===&lt;br /&gt;
&lt;br /&gt;
The default IDE to develop for Miosix is [https://netbeans.org/ Netbeans]. However, it does not come with Miosix support out of the box, so you have to configure it first.&lt;br /&gt;
&lt;br /&gt;
* [[Linux Netbeans configuration]]&lt;br /&gt;
* [[Windows Netbeans configuration]]&lt;br /&gt;
&lt;br /&gt;
Another alternative is Eclipse, which has the added feature to allow in-circuit debugging directly from the IDE.&lt;br /&gt;
&lt;br /&gt;
TODO: How to set up Eclipse&lt;br /&gt;
&lt;br /&gt;
=== In-circuit debugger ===&lt;br /&gt;
&lt;br /&gt;
An in-circuit debugger allows to physically halt the CPU inside a microcontroller, single-step it and view all the variables at any given time. It is a powerful tool to debug software running on a microcontroller. Miosix uses GDB and [http://openocd.sourceforge.net openocd] for in-circuit debugging.&lt;br /&gt;
&lt;br /&gt;
* [[Linux Debugger configuration]]&lt;br /&gt;
* [[Windows Debugger configuration]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Category:Examples&amp;diff=4</id>
		<title>Category:Examples</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Category:Examples&amp;diff=4"/>
		<updated>2014-04-12T20:32:02Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;Examples:&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Examples:&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
	<entry>
		<id>https://miosix.org/wiki/index.php?title=Example:_Blinking_led&amp;diff=3</id>
		<title>Example: Blinking led</title>
		<link rel="alternate" type="text/html" href="https://miosix.org/wiki/index.php?title=Example:_Blinking_led&amp;diff=3"/>
		<updated>2014-04-12T20:28:08Z</updated>

		<summary type="html">&lt;p&gt;Andreabont: Created page with &amp;quot;== Simple Example == &amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt; #include &amp;lt;cstdio&amp;gt; #include &amp;lt;unistd.h&amp;gt; #include &amp;quot;miosix.h&amp;quot;  using namespace std; using namespace miosix;  typedef Gpio&amp;lt;GPIOC_BASE,7&amp;gt;  l...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Simple Example ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;cstdio&amp;gt;&lt;br /&gt;
#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;
#include &amp;quot;miosix.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
using namespace std;&lt;br /&gt;
using namespace miosix;&lt;br /&gt;
&lt;br /&gt;
typedef Gpio&amp;lt;GPIOC_BASE,7&amp;gt;  led;&lt;br /&gt;
&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  &lt;br /&gt;
  led::mode(Mode::OUTPUT);&lt;br /&gt;
  &lt;br /&gt;
  for(;;) {&lt;br /&gt;
    led::high();&lt;br /&gt;
    sleep(1);&lt;br /&gt;
    led::low();&lt;br /&gt;
    sleep(1);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
  &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Examples]]&lt;/div&gt;</summary>
		<author><name>Andreabont</name></author>
	</entry>
</feed>