Giter Site home page Giter Site logo

terminalcursor / jobbed Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 369 KB

Jobbed RTOS for Raspberry Pi 2B

License: GNU General Public License v3.0

Makefile 2.78% C 88.85% C++ 1.30% Assembly 5.53% Shell 0.11% Batchfile 1.43%
arm c cortex-a7 kernel operating-system raspberry-pi

jobbed's Introduction

Jobbed

Build Information

  • Cross Compiler: GCC ARM Cross Compiler arm-none-eabi-gcc (15:8-2019-q3-1+b1) 8.3.1 20190703 (release) [gcc-8-branch revision 273027].

Building (Debian, WSL)

  • Clone the repository.
  • Ensure you have the gcc-arm-none-eabi cross compiler installed # apt install gcc-arm-none-eabi.
  • From the root of the directory, i.e. in Jobbed, execute make -f Unix.mk
  • The built image is found in build/kernel7.img and can be copied to the root of the Raspberry Pi SD card's first parition
  • On WSL you may also need to run # apt install build-essential git to get make and git
  • For faster building, it is recommended to run make clean;make -f Unix.mk -j4, where 4 can be adjusted to the amount of parallel jobs that the system can perform

Building on MacOS

  • Clone the repository
  • From the root of the directory, i.e. in Jobbed, execute make -f Mac.mk init default to install the toolchain and build the image
  • Further builds can be achieved by executing make -f Mac.mk
  • The built image is found in build/kernel7.img and can be copied to the root of the Raspberry Pi SD card's first parition

Building (Google Colab)

  • !git clone https://github.com/TerminalCursor/Jobbed.git
  • !cd Jobbed; make -f Colab.mk init
  • !cd Jobbed; make -f Colab.mk
  • The built image is found in Jobbed/build/kernel7.img and can be copied to the root of the Raspberry Pi SD card's first parition
  • Currently, it appears that the Ubuntu Distribution's cross compiler is not properly assembling the binaries. This issue is being looked into

Creating a Bootable SD Card for the Raspberry Pi 2B

  • The Raspberry Pi SD Card Imager can be obtained at https://www.raspberrypi.com/software/
  • After imaging the SD card with the imaging software, delete all of the kernel*.img files in the root directory of the first partition of the SD card
  • After removing all of the image files, copy the built build/kernel7.img file to the root directory of the first partition of the SD card
  • Unmount the SD card, insert the SD into the Raspberry Pi, and apply power to run Jobbed

Running in QEMU Emulator

  • Ensure you have QEMU's ARM package installed on your system
  • Minimum command line arguments to run: qemu-system-arm -M raspi2b -cpu cortex-a7 -m 1G -kernel build/kernel.elf
  • When building build/kernel7.img, build/kernel.elf will also be built and is used to emulate the Raspberry Pi 2B
  • If QEMU is installed, you can run Jobbed with make -f Unix.mk clean run
  • You can also disable the QEMU window from appearing if you only have UART communication in your application with SILENT=1 make -f Unix.mk clean run

Running in QEMU Emulator on WSL

  • Download the QEMU ARM System Package and install it under C:\qemu
  • Run Jobbed in QEMU from WSL with make -f Win.mk clean run

Getting Cross Compiler

Creating RTOS Applications

Jobbed's scheduler puts threads on FIFO queues of various priorities. The number of priorities available can be changed in include/sys/schedule.h.

RTOS Application Source Location

RTOS Applications are written in the usr/ directory. Jobbed, in kernel/core.c adds in the main function at the highest priority, expected to be defined in usr/main.c. This main function, can serve as the initialization function for the RTOS application.

RTOS Application Header Location

Headers for files in usr/ are expected in include/usr/. They can then be included in source files with #include <usr/path/to/file.h>.

Setting IRQ Callbacks

IRQ handles can be initialized with the subscribe_irq(IRQ_NAME, callback_function, pointer to additional IRQ information). Examples can be found in the provided usr/main.c.

  • subscribe_irq(IRQ name, callback, pointer to information) include <cpu/irq.h>
  • unsubscribe_irq(IRQ name) include <cpu/irq.h>

Thread Functions

  • Allow another thread with the same priority to run (i.e. push this thread to the end of the FIFO queue): sys0(SYS_YIELD) include <cpu.h>
  • Add a function to a priority level: add_thread(function, argument, priority) include <sys/schedule.h>

Mutex Functions

  • Create a mutex: create_mutex(address of resource) include <util/mutex.h>
  • Delete a mutex: delete_mutex(address of mutex) include <util/mutex.h>
  • Lock a mutex: lock_mutex(address of mutex) include <util/mutex.h>
  • Unlock a mutex: unlock_mutex(address of mutex) include <util/mutex.h>

Lock Functions

Locks are like mutexes, but they don't carry any reference to a resource and the system does not manage references to them. For the RTOS application designer, this means that there are conditions that locks can cause deadlocks. Thus, it is recommended to use the Mutex objects instead of locks.

  • Lock: lock(address of lock) include <util/lock.h>
  • Unlock: unlock(address of lock) include <util/lock.h>

Semaphore Functions

  • Signal a semaphore: sys1(SYS_SEMAPHORE_V, address of semaphore) include <cpu.h>
  • Wait on a semaphore: sys1(SYS_SEMAPHORE_P, address of semaphore) include <cpu.h>

Other Functions

  • Get time since boot: sys0_64(SYS_TIME, address of uint64 to store the time) include <cpu.h>
  • Draw to the screen (include <graphics/lfb.h>)
    • Strings: draw_string(x, y, string)
    • 32-bit words: draw_hex32(x, y, value)
    • Pixel: draw_cpixel(x, y, RGB color)
    • Box: draw_cbox(x, y, dx, dy, RGB color)

Default RTOS Application

Currently, if you build Jobbed without modifying anything, it will generate the RTOS core testing suite. This testing suite outputs the tracing, thread switch, low and high priority thread creation, mutex creation, mutex destruction, mutex locking contention, mutex locking non-contention, mutex unlocking, semaphore waiting, semaphore signalling at zero, semaphore signalling non-zero timings to a 1920x1080 display output. Currently the graphics driver expects this resolution of display. If you have another resolution, this can be changed in kernel/sys/core.c by modifying lfb_init(1920, 1080) to lfb_init(YOUR WIDTH, YOUR HEIGHT).

C++

C++ sources in this directory are expected to work with a few missing features such as the new and delete keywords since memory is not dynamically allocated on the system.

Misc Information

Future

  • USB Driver
  • Ethernet Driver
  • Move UART Polling Write to another method
  • Make UART Write run as an event-based system
  • Error-Resistant Graphics
  • SPI Driver
  • GPIO Falling Edge IRQ

SVC Calls (In order)

  • 0: Yield to threads in same priority
  • 1: System Clock Time
  • 2: Schedule
  • 3: Add thread
  • 4: Mutex Lock
  • 5: Mutex Unlock
  • 6: Semaphore Decrease
  • 7: Semaphore Increase
  • 8: Semaphore Increase by N
  • 9: Cycle Counter
  • A: Enable ARM Timer
  • B: Disable ARM Timer

Modes

Registers

Note: SYS and USER share registers but differ in privilege

Program Status Registers

Memory Layout

  • 0x00004000 - 0x00008000 MMU Entries
  • 0x00008000 - 0x0000F000 Code
  • 0x0000F000 - 0x00010000 Data
  • 0x00010000 - 0x000A3000 BSS
  • 0x18000000 - 0x20000000 Thread Stacks
  • 0x3F000000 - 0x40000000 MMIO
  • 0x40000000 - 0xFFFFFFFF Local Peripherals

Supplemental Links

jobbed's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.