Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A minimum preemptive OS on Cortex-M3 (specially on blue-pill board) written in Rust.

NotificationsYou must be signed in to change notification settings

andylokandy/preemptive

Repository files navigation

A minimum preemptive OS on Cortex-M3 (specially on blue-pill board) written in Rust. It is for the purpose ofresearching and showing how the fundamental runtime of Cortex-M3 works.

What is preemptive OS

In computing, preemption is the act of temporarily interrupting a task being carried out by a computer system,without requiring its cooperation, and with the intention of resuming the task at a later time. Such changes ofthe executed task are known as context switches. ---- Wikipedia

In breif, the kernel of non-preemptive OS can not interrupt a task, while the kernel of preemptive OS can takethe control back without informing the task.

Prerequisite

  • Make sure you have ablue-pill board and a serial port reciever.
  • Make sure you havearm-none-eabi toolchain andopenocd installed on your platform.
  • Install the latest nightly rust toolchain. The compiler version used when this project is beening written isrustc 1.37.0-nightly (17e62f77f 2019-07-01).

Project Structure

This project is collections of several stages of building a preliminary preemptive OS from sketch. I'll makesure all code of each chapter can compile and run onblue-pill.

Build and Run

  • EnterChapter5-MultiTasking
cd Chapter5-MultiTasking
  • Connect theblue-pill to your laptop.

  • Connect pinPA2 to a serial reciever, with 115200 baudrate, 8 data bits, 1 stop bits, no parity and no flow control.

  • Runopenocd:

> openocd...Info : using stlink api v2Info : Target voltage: 3.175214Info : stm32f1x.cpu: hardware has 6 breakpoints, 4 watchpoints
  • Run the application:
> cargo run    Finished dev [unoptimized + debuginfo] target(s) in 0.93s    Running `target\thumbv7m-none-eabi\debug\preemptive`Reading symbols from target\thumbv7m-none-eabi\debug\preemptive...done.target halted due to debug-request, current mode: ThreadxPSR: 0x01000000 pc: 0x080008fc msp: 0x20005000Loading section .isr_vector, size 0x40 lma 0x8000000Loading section .text, size 0x2a08 lma 0x8000040Start address 0x80008fc, load size 10824Transfer rate: 14 KB/sec, 5412 bytes/write.(gdb) continueContinuing.

As the result, you would see the output from the serial reciever like this:

Executing task1!task1: fib(0)=1task1: fib(1)=1task1: fib(2)=2Executing task2!task2: is_prime(1)=truetask2: is_prime(2)=truetask2: is_prime(3)=trueExecuting task1!task1: fib(3)=3task1: fib(4)=5task1: fib(5)=8Executing task2!task2: is_prime(4)=falsetask2: is_prime(5)=truetask2: is_prime(6)=false...

Reference

About

A minimum preemptive OS on Cortex-M3 (specially on blue-pill board) written in Rust.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp