Post on 17-Jul-2015
transcript
3bOS: A flexible and lightweight embedded OS operated using only 3 buttons
Encarnacion, Immanuel V†
Ryohei Kobayashi‡
Kenji Kise‡
†University of the Philippines, Philippines ‡Tokyo Institute of Technology, Japan
11:40‒12:00, October 24, 2014 ESS2014@NYC Tokyo
! 3bOS " a simple and easily customizable embedded OS " running on the MieruEMB system " using only three push buttons
This Presentation is about...
1 3bOS running on the MieruEMB system
Three push buttons
! Introduction
! Design
! Implementation
! Discussion and Conclusion
Outline
2
! Introduction
! Design
! Implementation
! Discussion and Conclusion
Outline
3
! Being used in a lot of fields ! Having skills and knowledge about embedded systems is required
The Growth in Popularity of Embedded Systems
4
Car electronics Medical products
Communication devices
! An educational kit " for learning implementation skills and knowledge regarding embedded systems
The MieruEMB system
5 The MieruEMB system
! An educational kit " for learning implementation skills and knowledge regarding embedded systems
The MieruEMB system
6 The MieruEMB system
Spartan XC3S500E
512KB SRAM
SD card slot
LCD screen (128 x 128 pixel16-bit color)
Three push buttons
! view
Experiments on Computer Science
7
! Characteristics " Running on the MieruEMB system " Only three push buttons interface " Simplicity � A few # lines of code
" Flexibility � Users can easily implement their desired features
! Features " The OS itself is loaded from the SD card " Reading FAT-formatted SD card � Reading contents in SD card � Running ELF files in SD card
3bOS
8
! Introduction
! Design
! Implementation
! Discussion and Conclusion
Outline
9
! 32-bit MIPS ! Why MIPS?
" simplicity and widespread use " Lots of information
ISA
10
! The contents of the 3bOS binary file are copied to memory when turned on
Storage
11
! Memory-mapped I/O ! 32-bit address space
I/O
12
512KB
1KB
16KB
SRAM 0x000000
0x07FFFF
19-bit Physical Address Space
General MMIO MMC MMIO
MMIO: Memory Mapped I/O MMC : Multi Media Card
0x800000
0x8003FF
Video Memory
0x900000
0x903FFF
4GB
! FAT file system (FAT12) ! Why FAT?
" Simplicity and popularity on many platforms
File System
13
! Features " Opening a sub/parent directory " Reading contents " Running ELF files
File Explorer
14
! Introduction
! Design
! Implementation
! Discussion and Conclusion
Outline
15
! The OS is mostly coded in C " Containing some assembly code
! Compiled with gcc for MIPS*
Implementation of 3bOS
16 *Buildroot: http://buildroot.uclibc.org/
! Important functions " Text and Display drivers " SD card driver " Execution and Exiting of the ELF files
Implementation of 3bOS
17
! Display text (and/or) graphics
! Problems " It is hard to use basic libraries(stdio.h, stdlib.h) in MIPS GCC (ver 4.3) � printf, malloc, free, memcpy, etc... � very limited sprintf
Text and Display Drivers
18
! We made own printf ! accepts patterns such as:
" %d " %s " %x " %b " %% " etc...
! No compile-time type checking
Solution: gprintf
19
! Reads raw data from the SD card ! Sends control signals to read/write from the SD card
! Only a 512-byte sector can be read at a time
! A Minor Problem: Physical and Logical sectors " Hardware reads physical sector addresses " Windows can only read logical sector addresses � Logical Sector #0 = Physical Sector #25
SD Card Driver
20
Debugging by a hex editor
21
! A pre-execution menu is first displayed " Whenever the user wants to execute an ELF file in the 3bOS
! After the executable exits, 3bOS returns to the pre-execution menu
Execution and Exiting of the ELF Files
22
! The Loading Process of an ELF file and Physical Memory Layout
Execution and Exiting of the ELF Files
23
! State is restored imperfectly " Processor state � Program counter � Registers($sp, $gp, $ra, etc...)
" Video memory � Video memory would be overwritten when the new executable runs � But, the pre-execution menu should be restored after the executable exits
Main Problem
24
! To save state before the pre-execution menu UI is drawn
! But, the stack in the restored state is different...
The Wrong Solution
Please choose how to open the ELF file.
^%& &*^() )*#
Pre-execution Menu
An app runs & exits
25
! No need to save stack or video memory!
! “done” is global variable " not in the stack
The Correct Solution
26
Debugging with the IDA Debugger
27
! Introduction
! Design
! Implementation
! Discussion and Conclusion
Outline
28
! 3bOS’s Important points " Simplicity and Flexibility � Just around 800 lines total (about one-eighth the size of FreeRTOS*) � Users can easily understand how 3bOS runs on the MieruEMB system � Users can easily implement their desired features
" Low Memory Usage � 3bOS leaves around 400KB of usable space for running programs (80% of the total size of the main memory)
! It is suitable to use 3bOS as an educational material
Discussion
29 *FreeRTOS: http://www.freertos.org/
! 3bOS " A simple and customizable embedded OS operated using only 3 buttons
" Running on the MieruEMB system
! 3bOS is suitable for educational purposes " A Few # lines of code " Users who want to learn OS programming can easily understand it
" Its flexibility makes it simple for users to modify, add, or remove features
Conclusion
30