1- F9 Microkernel
2- ==============
1+ # F9 Microkernel
32
4- This is ` F9 ` , an experimental microkernel used to construct flexible embedded
5- systems inspired by famous [ L4 microkernel] ( http://en.wikipedia.org/wiki/L4_microkernel_family ) .
6- The motivation of F9 microkernel is to deploy modern kernel techniques to
7- support running real-time and time-sharing applications (for example, wireless
8- communications) for ARM Cortex-M series microprocessors with efficiency
9- (performance + power consumption) and security (memory protection + isolated
10- execution) in mind.
11-
12-
13- Characteristics of F9 Microkernel
14- =================================
3+ F9 is an experimental microkernel for building flexible embedded systems,
4+ inspired by the [ L4 microkernel family] ( https://en.wikipedia.org/wiki/L4_microkernel_family ) .
5+ It aims to bring modern kernel techniques to ARM Cortex-M microprocessors,
6+ enabling real-time and time-sharing applications (such as wireless communications)
7+ with a focus on efficiency (performance and power consumption) and security
8+ (memory protection and isolated execution).
159
10+ ## Characteristics
1611* F9 follows the fundamental principles of microkernels in that it implements
1712 address spaces, thread management, and IPC only in the privileged kernel.
18-
1913* Designed and customized for ARM Cortex-M, supporting NVIC (Nested Vectored
2014 Interrupt Controller), Bit Banding, MPU (Memory Protection Unit).
21-
22- * Energy efficient scheduling and tickless timer which allow the ARM Cortex-M
23- to wake up only when needed, either at a scheduled time or on an interrupt
24- event. Therefore, it results in better current consumption than the common
25- approach using the system timer, SysTick, which requires a constantly
26- running and high frequency clock.
27-
28- * KProbes, dynamic instrumentation system inspired by Linux Kernel, allowing
15+ * Energy-efficient scheduling and tickless timer allow the ARM Cortex-M to
16+ wake up only when needed, either at a scheduled time or on an interrupt event.
17+ This results in lower power consumption compared to the traditional SysTick
18+ approach, which requires a constantly running high-frequency clock.
19+ * KProbes, a dynamic instrumentation system inspired by the Linux kernel, allowing
2920 developers to gather additional information about kernel operation without
3021 recompiling or rebooting the kernel. It enables locations in the kernel to
3122 be instrumented with code, and the instrumentation code runs when the ARM
3223 core encounters that probe point. Once the instrumentation code completes
3324 execution, the kernel continues normal execution.
34-
35- * Each thread has its own TCB (Thread Control Block) and addressed by its
36- global id. Also dispatcher is responsible for switching contexts. Threads
37- with the same priority are executed in a round-robin fashion.
38-
25+ * Each thread has its own TCB (Thread Control Block) and is addressed by its
26+ global ID. The dispatcher is responsible for context switching. Threads
27+ with the same priority are scheduled in round-robin fashion.
3928* Memory management is split into three concepts:
40- - Memory pool, which represent area of physical address space with specific
41- attributes.
42- - Flexible page, which describes an always size aligned region of an address
43- space. Unlike other L4 implementations, flexible pages in F9 represent MPU
44- region instead.
45- - Address space, which is made up of these flexible pages.
46-
29+ - Memory pool: an area of physical address space with specific attributes.
30+ - Flexible page: a size-aligned region of an address space. Unlike other L4
31+ implementations, flexible pages in F9 represent MPU regions.
32+ - Address space: composed of flexible pages.
4733* System calls are provided to manage address spaces:
4834 - Grant: The memory page is granted to a new user and cannot be used anymore
4935 by its former user.
5036 - Map: This implements shared memory – the memory page is passed to another
5137 task but can be used by both tasks.
5238 - Flush: The memory page that has been mapped to other users will be flushed
5339 out of their address space.
54-
55- * Regarding the interaction between a user thread and the microkernel, the
56- concept of UTCB (user-level thread-control blocks) is being taken on. A UTCB
57- is a small thread-specific region in the thread's virtual address space,
58- which is always mapped. Therefore, the access to the UTCB can never raise a
59- page fault, which makes it perfect for the kernel to access system-call
60- arguments, in particular IPC payload copied from/to user threads.
61-
62- * The kernel provides synchronous IPC (inter-process communication), for which
63- short IPC carries payload in CPU registers only and full IPC copies message
64- payload via the UTCBs of the communicating parties.
65-
40+ * User threads interact with the microkernel through UTCBs (User-level Thread
41+ Control Blocks). A UTCB is a small thread-specific region in the thread's
42+ virtual address space that is always mapped. Since UTCB access never raises
43+ a page fault, it is ideal for the kernel to access system call arguments,
44+ particularly IPC payload copied from/to user threads.
45+ * The kernel provides synchronous IPC (inter-process communication). Short IPC
46+ carries payload in CPU registers only, while full IPC copies message payload
47+ via the UTCBs of the communicating parties.
6648* Debugging and profiling mechanisms:
6749 - configurable debug console
6850 - memory dump
6951 - thread profiling: name, uptime, stack allocated/current/used
7052 - memory profiling: kernel table, pool free/allocated size, fragmentation
7153
72-
73- Licensing
74- =========
75-
76- F9 Microkernel is freely redistributable under the two-clause BSD License.
77- Use of this source code is governed by a BSD-style license that can be found
78- in the ` LICENSE ` file.
79-
80-
81- Quick Start
82- ===========
83-
54+ ## Quick Start
8455F9 Microkernel supports the following boards:
85- * [ STM32F4DISCOVERY] ( http://www.st.com/web/en/catalog/tools/FM116/SC959/SS1532/PF252419 )
86- * [ 32F429IDISCOVERY] ( http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/PF259090 )
87- - Both are based on ARM Cortex-M4F core, but F9 should work well on any STM32F40x/STM32F429/STM32F439
88- microcontroller.
89- * [ STM32-P103] ( https://www.olimex.com/Products/ARM/ST/STM32-P103/ )
90- - Powered by Cortex-M3 based microcontroller, STM32F103RBT6
91-
92- Building F9 Microkernel requires an arm-none-eabi- toolchain with Cortex-M4F support. The known working toolchains are as following
93- * [ Sourcery CodeBench] ( http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/ )
94- - ARM Processors: EABI Release
95- - Verified versions: arm-2012.03, arm-2013.05, arm-2013.11, arm-2014.05
96- * [ GNU Tools for ARM Embedded Processors] ( https://launchpad.net/gcc-arm-embedded )
97- - Verified versions: 4.8-2013-q4-major, 4.8-2014q2-update
98-
99- Other build dependency includes: (for Debian/Ubuntu)
100- * libncurses5-dev
101-
102- Configuration is the initial step in the build of F9 Microkernel for your
103- target, and you can use ` make config ` to specify the options from which to
104- choose. Regardless of the configuration method you use or the actual
105- configuration options you choose, the build system will generate a ` .config `
106- file at the end of the configuration and will generate a configuration header
107- file, ` include/autoconf.h ` for C programs.
108-
109- Then, just execute ` make ` to get the generated files in directory ` build ` .
110-
111- For flashing and debugging on the STM32F40x, [ stlink] ( https://github.com/texane/stlink ) is required.
112- With ` stlink ` in your path, command "make flash" will flash your
113- STM32F4DISCOVERY board with built F9 binary image.
114-
115- When developing on top of F9 Microkernel, you do not have the luxury of using
116- a source level debugger such as gdb. There are still a number of techniques at
117- your disposal to assist debugging, however. KDB (in-kernel debugger) is built and
118- run at boot by default, and here are the supported commands:
119-
120- * a: dump address spaces
121- * m: dump memory pools
122- * t: dump threads
123- * s: show softirqs
124- * n: show timer (now)
125- * e: dump ktimer events
126- * K: print kernel tables
127-
128- Through USART, KDB can be operated interactively on USART4 (default), USART2,
129- or USART1 of STM32F4DISCOVERY depending on the selected option when you execute
130- ` make config ` :
131- * USART4: PA0 (TX), PA1 (RX)
132- * USART2: PA2 (TX), PA3 (RX)
133- * USART1: PA9 (TX), PX10 (RX)
134-
135- For 32F429IDISCOVERY, the pins are as follows:
136- * USART4: PC11 (TX), PC10 (RX) (default config)
137- * USART2: PD5 (TX), PD6 (RX)
138- * USART1: PA9 (TX), PA10 (RX)
139-
140- You can established serial connection with the board using a serial to USB
141- converter (for STM32F4DISCOVERY):
142- * USB2TTL RX ---> PA0 / PA2 / PA9
143- * USB2TTL TX ---> PA1 / PA3 / PA10
144-
145- or (for 32F429IDISCOVERY):
146- * USB2TTL RX ---> PC11 / PD5 / PA9
147- * USB2TTL TX ---> PC10 / PD6 / PA10
148-
149- Select the appropriate terminal emulator and configure it for 115200 baud,
150- 8 data bits, no parity, one stop bit. For GNU/Linux, program ` screen ` can be
151- used for such purpose. Installation on Ubuntu / Debian based systems:
152-
153- sudo apt-get install screen
154-
155- Then, attach the device file where a serial to USB converter is attached:
56+ * [ STM32F4DISCOVERY] ( https://www.st.com/en/evaluation-tools/stm32f4discovery.html )
57+ * [ STM32F429I-DISC1] ( https://www.st.com/en/evaluation-tools/32f429idiscovery.html )
58+ - Both are based on ARM Cortex-M4F core. F9 should work on any STM32F40x/STM32F429/STM32F439 microcontroller.
59+ * Netduino Plus 2 (STM32F405RGT6)
60+ - Supported by upstream [ QEMU for emulation] ( https://www.qemu.org/docs/master/system/arm/stm32.html ) , making it ideal for development and testing without hardware.
61+
62+ Building F9 Microkernel requires an arm-none-eabi toolchain with Cortex-M4F support:
63+ * [ Arm GNU Toolchain] ( https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads )
64+ - Download the AArch32 bare-metal target (arm-none-eabi) package.
65+
66+ Configuration is the first build step. Run ` make config ` to select options.
67+ The build system generates a ` .config ` file and a configuration header
68+ ` include/autoconf.h ` for C programs.
69+
70+ Run ` make ` to build. Output files are placed in the ` build ` directory.
71+
72+ For flashing and debugging on STM32F4 boards, [ stlink] ( https://github.com/stlink-org/stlink )
73+ is required. With ` st-flash ` in the PATH, ` make flash ` programs the
74+ STM32F4DISCOVERY board with the built F9 binary image.
75+
76+ Source-level debugging with gdb is possible via OpenOCD or stlink, but may be
77+ limited on resource-constrained targets. KDB (in-kernel debugger) is enabled by
78+ default and provides essential kernel inspection. Press ` ? ` to display the menu:
79+
80+ | Key | Function |
81+ | -----| ---------------------------------|
82+ | ` a ` | Dump address spaces |
83+ | ` e ` | Dump ktimer events |
84+ | ` K ` | Print kernel tables |
85+ | ` m ` | Dump memory pools |
86+ | ` M ` | Dump MPU status |
87+ | ` n ` | Show timer (now) |
88+ | ` p ` | Show sampling (requires SYMMAP) |
89+ | ` s ` | Show softirqs |
90+ | ` t ` | Dump threads |
91+ | ` v ` | Show tickless scheduling status |
92+
93+ KDB communicates via USART. The port can be selected during ` make config ` .
94+
95+ For STM32F4DISCOVERY:
96+
97+ | Port | TX Pin | RX Pin |
98+ | --------| --------| --------|
99+ | USART4 | PA0 | PA1 |
100+ | USART2 | PA2 | PA3 |
101+ | USART1 | PA9 | PA10 |
102+
103+ For STM32F429I-DISC1:
104+
105+ | Port | TX Pin | RX Pin |
106+ | --------| --------| --------|
107+ | USART4 | PC11 | PC10 |
108+ | USART2 | PD5 | PD6 |
109+ | USART1 | PA9 | PA10 |
110+
111+ For Netduino Plus 2 under QEMU, the default configuration uses USART1, which
112+ QEMU routes to the console. Run with:
113+
114+ qemu-system-arm -M netduinoplus2 -nographic -serial mon:stdio \
115+ -kernel build/netduinoplus2/f9.elf
116+
117+ For physical boards, connect a USB-to-serial adapter and use a terminal emulator
118+ at 115200 baud, 8N1. For example, with ` screen ` :
156119
157120 screen /dev/ttyUSB0 115200 8n1
158121
159- Once you want to quit screen, press: Ctrl-a k
122+ Press Ctrl-a k to exit screen.
160123
161-
162- Build Configurations
163- ====================
164-
165- F9 Microkernel deploys Linux Kernel style build system, and the corresponding
166- files are described as following:
124+ ## Build Configurations
125+ F9 Microkernel uses a Linux kernel-style build system (Kconfig/Kconfiglib).
126+ The key build files are:
167127
168128* toolchain.mk:
169129 - toolchain-specific configurations; common cflags and ldflags
@@ -173,28 +133,31 @@ files are described as following:
173133 - board-specific configurations; CHIP model, peripherals
174134* rules.mk: the magic of build system
175135
176- You can modify source file board/` <BOARD_NAME> ` /board.[ ch] to specify the
177- preferable resource assignment. To get acquainted with the configuration of
178- F9 Microkernel internals, file ` include/autoconf.h ` is the entry point:
136+ Board-specific resource assignments can be modified in ` board/<BOARD_NAME>/board.[ch] ` .
137+ The configuration header ` include/autoconf.h ` documents the available options:
179138
180139* ` CONFIG_DEBUG `
181- - Enable serial input/out for debugging purpose . An additional service for
182- serial I/O character operations will be included.
140+ - Enable serial I/O for debugging. An additional service for serial character
141+ operations will be included.
183142* ` CONFIG_KDB `
184143 - Enable in-kernel debugger.
185144* ` CONFIG_KPROBES `
186- - Enable kernel probes, the lightweight dynamic instrumentation system.
187- * ` CONFIG_BITMAP_BITBAND `
188- - Generate bitmap address in bit-band region
189- - Bit-banding maps a complete word of memory onto a single bit in the
190- bit-band region. For example, writing to one of the alias words will set
191- or clear the corresponding bit in the bitband region.
192- - When writing to the alias regions bit 0 of the 32 bit word is used to set
193- the value at the bit-banding region. Reading from the alias address will
194- return the value from the bit-band region in bit 0 and the other bits will
195- be cleared.
145+ - Enable KProbes, the lightweight dynamic instrumentation system.
146+ * ` CONFIG_SYMMAP `
147+ - Generate symbol map for KProbes and profiling support.
148+ * ` CONFIG_KTIMER_TICKLESS `
149+ - Enable tickless scheduling for improved power efficiency.
150+ * ` CONFIG_KTIMER_TICKLESS_VERIFY `
151+ - Track and verify tickless scheduling status (depends on KTIMER_TICKLESS).
196152* ` CONFIG_MAX_ ` xxx series
197- - limits of threads, ktimer events, async events, address spaces, flexible
198- pages.
153+ - Limits for threads, ktimer events, async events, address spaces, and
154+ flexible pages.
199155* ` CONFIG_PANIC_DUMP_STACK `
200- - Dump kernel stack while panic.
156+ - Dump kernel stack on panic.
157+ * ` CONFIG_QEMU `
158+ - Enable workarounds for QEMU emulation (auto-enabled for Netduino Plus 2).
159+
160+ ## Licensing
161+ F9 Microkernel is freely redistributable under the two-clause BSD License.
162+ Use of this source code is governed by a BSD-style license that can be found
163+ in the ` LICENSE ` file.
0 commit comments