3bos: a flexible and lightweight embedded os operated using only 3 buttons

31
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

Upload: ryohei-kobayashi

Post on 17-Jul-2015

152 views

Category:

Engineering


3 download

TRANSCRIPT

Page 1: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

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

Page 2: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 3: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Introduction

! Design

! Implementation

! Discussion and Conclusion

Outline

2

Page 4: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Introduction

! Design

! Implementation

! Discussion and Conclusion

Outline

3

Page 5: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 6: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! An educational kit " for learning implementation skills and knowledge regarding embedded systems

The MieruEMB system

5 The MieruEMB system

Page 7: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 8: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! view

Experiments on Computer Science

7

Page 9: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 10: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Introduction

! Design

! Implementation

! Discussion and Conclusion

Outline

9

Page 11: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 32-bit MIPS ! Why MIPS?

" simplicity and widespread use " Lots of information

ISA

10

Page 12: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! The contents of the 3bOS binary file are copied to memory when turned on

Storage

11

Page 13: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 14: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! FAT file system (FAT12) ! Why FAT?

" Simplicity and popularity on many platforms

File System

13

Page 15: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Features " Opening a sub/parent directory " Reading contents " Running ELF files

File Explorer

14

Page 16: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Introduction

! Design

! Implementation

! Discussion and Conclusion

Outline

15

Page 17: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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/

Page 18: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Important functions " Text and Display drivers " SD card driver " Execution and Exiting of the ELF files

Implementation of 3bOS

17

Page 19: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 20: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! We made own printf ! accepts patterns such as:

" %d " %s " %x " %b " %% " etc...

! No compile-time type checking

Solution: gprintf

19

Page 21: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 22: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

Debugging by a hex editor

21

Page 23: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 24: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! The Loading Process of an ELF file and Physical Memory Layout

Execution and Exiting of the ELF Files

23

Page 25: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 26: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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

Page 27: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! No need to save stack or video memory!

! “done” is global variable " not in the stack

The Correct Solution

26

Page 28: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

Debugging with the IDA Debugger

27

Page 29: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! Introduction

! Design

! Implementation

! Discussion and Conclusion

Outline

28

Page 30: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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/

Page 31: 3bOS: A flexible and lightweight embedded OS operated using only 3 buttons

! 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