smp rtos) running on risc-v

32
SMP RTOS) running on RISC-V Speaker: JinXing Jiao

Upload: others

Post on 22-Nov-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

(SMP RTOS) running on RISC-V

Speaker: JinXing Jiao

CONTENTS

01 SylixOS brief introduction & history

02 SylixOS application area & user

03 Analysis of RISC-V porting

01brief introduction & history

RTOS, developed by chinese engineers since 2006

Open source, GPL & Commercial license, www.sylixos.com

Multiple processor architecture support, such as(RISC-V, ARM, x86,

MIPS, PowerPC, SPARC, C-SKY)

Support symmetric multi-processor(SMP), such as Freedom U540

POSIX specification

Excellent real-time performance (time complexity of task scheduling

and switching algorithm is O(1))

Support dynamic loading applications, dynamic link libraries, and

kernel modules

Support third-party GUI graphics libraries, such as Qt, MiniGUI, etc

Support for many standard file systems: TpsFs (power safe), FAT,

YAFFS, ROOTFS, PROCFS, NFS, ROMFS, etc

Rich network function, Support AF_UNIX, AF_PACKET, AF_INET,

AF_INET6, AF_ROUTE protocol domain

It can be started in 1 seconds according to project requirements

SylixOS brief introduction

Hardware

BSP & Drivers

LongWing(TM) Kernel

Interrupt Thread Timer ...

2006The SylixOS kernel is

completed, and the

kernel code name

LongWing, provides

the most basic kernel

functions such as

thread scheduling,

interrupt

management, timer,

RMS, semaphore and

so on.

LongWing(TM) Kernel

Interrupt RMS Timer

...Message

Thread

Standard device module

I/O System

Hardware

BSP & Drivers

2007The I/O system was added

to provide standard device

drive modules, such as SPI,

IIC and TTY.

TTY IIC …SPI

Standard device module

File System

I/O System

3rd part software & tools

LongWing(TM) Kernel

Interrupt RMS Timer

...Message

Thread

Hardware

BSP & Drivers

2008Increase support for

network and file systems,

and provide some usefull

third party tools (such as

database); kernel function

is more abundant,

providing message queue,

memory management and

other functions.

TTY

RTC

SPI

Event Memory

Yaffs+

mtd

fatFSrootFS

NFS

nand cache

partition

disk cache

DMA

PTY

IIC

AF_INET/AF_INET6

BSD socket

Ping4/6

IPv4/v6

SQLite3 iniparser

I/O System

Standard device module

File System

3rd part software & tools

LongWing(TM) Kernel

Interrupt RMS Timer

CACHEMessage

Thread

Hardware

BSP & Drivers

2009SylixOS has made major improvements to support MMU and CACHE, so as to Have good support for

high-end processors, more device support and more network functions.

TTY

RTC

SPI

Event Memory

Yaffs+

mtd

fatFS

rootFS

NFS

nand cache

partition

disk cache

DMA

PTY

IIC

AF_INET/AF_INET6

BSD socket

Ping4/6

IPv4/v6

SQLite3 iniparser

MMU

zLib miniXML

procFS

romFS

ramFS

ATA

CAN

PCI

PIPE

FTP Telnet

TCP UDP

PPPoE PPP

POSIX

I/O System

Standard device module

File System

3rd part software & tools

LongWing(TM) Kernel

Interrupt RMS Timer

CACHEMessage

Thread

Hardware

BSP & Drivers

2010Support standard

C++, perfect I/O

system, support

POSIX standard and

further enrich

network function.

From this version,

SylixOS gradually

started the support

of multimedia (SDL,

FFMPEG).

TTY

RTC

SPI

Event Memory

Yaffs+

mtd

fatFS

rootFS

NFS

nand cache

partition

disk cache

DMA

PTY

IIC

AF_INET/AF_INET6

BSD socket

Ping4/6

IPv4/v6

SQLite3 iniparser

MMU

zLib miniXML

procFS

romFS

ramFS

ATA

CAN

PCI

PIPE

FTP syslog

TCP UDP

PPPoE PPP

C++

SHM

SD

BLOCK

Keyboard

Mouse

MII GRAPH …

select

timerfd

poll

signalfd

epoll

Power

eventfd

Hotplug

VPN NAT

Telnet

FFmpeg STL SDL

pthread

dll lib

semaphore

async I/O

sched

multi I/O

mqueue

spwan

mman

fnmatch

Loader & Symbol

2011SylixOS

ushered in two

major leaps:

multi core

support

(kernel code

Gemini) and

dynamic

loading; richer

file systems

and device

support.

Hardware

BSP & Drivers

Architecture

LongWing(TM) Kernel

Interrupt

Memory

MMU

RMS

Coroutine

CACHE

Timer

Thread

Message

Work Queue

C++ Run Time Lib

Event

...

BLOCK

Standard device module

GRAPH

PTY

SHM

CAN

SPI

USB

PIPE

SD

RTC

TTY

GPIO

AHCI

ATA

DMA

IIC

MII

PCI

File System TPS

NFS

romFS

ramFS

fatFS

rootFS

proc FS

Yaffs+

mtdpartition

nandcache

disk cache Keyboard Mouse Sound

select

I/O System

timerfd

poll

signalfd

epoll

Power

eventfd

Hotplug

pthread

POSIX

dll lib

semaphore

async I/O

sched

multi I/O

mqueue

spwan

mman

fnmatch

3rd part software & tools

libc

module.ko

library.so

BSD socket

TFTP Ping4/6 syslog

FTP SNTP Telnet

PPPoE

PPP NAT

VPN

AF_INET/AF_INET6

DNS DHCP

UDP TCP

IPv4/v6 ICMP

SQLite3 iniparser zLib miniXML FFmpeg STL SDL Lua

SMP rt schedule

Loader & Symbol

2012SylixOS

supports the

process.

Hardware

BSP & Drivers

Architecture

LongWing(TM) Kernel

Interrupt

Memory

MMU

RMS

Coroutine

CACHE

Timer

Thread

Message

Work Queue

C++ Run Time Lib

Event

...

BLOCK

Standard device module

GRAPH

PTY

SHM

CAN

SPI

USB

PIPE

SD

RTC

TTY

GPIO

AHCI

ATA

DMA

IIC

MII

PCI

File System TPS

NFS

romFS

ramFS

fatFS

rootFS

proc FS

Yaffs+

mtdpartition

nandcache

disk cache Keyboard Mouse Sound

select

I/O System

timerfd

poll

signalfd

epoll

Power

eventfd

Hotplug

pthread

POSIX

dll lib

semaphore

async I/O

sched

multi I/O

mqueue

spwan

mman

fnmatch

3rd part software & tools

libc

module.ko

library.so

BSD socket

TFTP Ping4/6 syslog

FTP SNTP Telnet

PPPoE

PPP NAT

VPN

AF_INET/AF_INET6

DNS DHCP

UDP TCP

IPv4/v6 ICMP

SQLite3 iniparser zLib miniXML FFmpeg STL SDL Lua

SMP rt schedule

Shell

OpenVPN PolarSSL …

ARP

IGMP

Ad Hoc

2013Add GDB,

debug

application and

dynamic link

library; increase

support for Qt.

More and more

perfect

equipment

support and

network

function.

Hardware

BSP & Drivers

SMP rt schedule

LongWing(TM) Kernel

Interrupt

Memory

MMU

RMS

Coroutine

CACHE

Timer

Thread

Monitor Trace

Message

Work Queue

C++ Run Time Lib

Event

...

BLOCK

Standard device module

GRAPH

PTY

SHM

CAN

SPI

USB

PIPE

SD

RTC

TTY

GPIO

AHCI

ATA

DMA

IIC

MII

PCI

File System TPS

NFS

romFS

ramFS

fatFS

rootFS

proc FS

Yaffs+

mtdpartition

nandcache

disk cache Keyboard Mouse Sound

select

I/O System

timerfd

poll

signalfd

epoll

Power

eventfd

Hotplug

pthread

POSIX

dll lib

semaphore

async I/O

sched

multi I/O

mqueue

spwan

mman

fnmatch

SQLite3

3rd part software & tools

SDL

STL

FFmpeg

GoAHeadWebSever PolarSSL

iniparser

Lua

sypkg

ODBC

OpenVPN

miniXML

osip

zLib

......

libc

module.ko

Shell

library.so

BSD socket

TFTP Ping4/6 syslog

Loader & SymbolFTP SNTP Telnet

P-MIB SunRPC

PPPoE PPP NAT VPN

Net Packet Filter

wireless net framework LoWPAN

AF_INET/AF_INET6 AF_UNIX AF_PACKET

DNS DHCP

UDP TCP

IGMP IPv4/v6 ICMP

ARP Ad Hoc

dual-pipe

cred

fd-trans

mmap

queue

GDB

Qt

2014SylixOS fully

supports ARM,

MIPS,

PowerPC and

x86 four

architectures.

Hardware

BSP & Drivers

SMP rt schedule

LongWing(TM) Kernel

Interrupt

Memory

MMU

RMS

Coroutine

CACHE

Timer

Thread

Monitor Trace

Message

Work Queue

C++ Run Time Lib

Event

...

BLOCK

Standard device module

GRAPH

PTY

SHM

1553B

CAN

SPI

USB

PIPE

SRIO

SD

RTC

TTY

GPIO

AHCI

ATA

DMA

IIC

MII

PCI

File System TPS

NFS

romFS

ramFS

fatFS

rootFS

proc FS

Yaffs+

mtdpartition

nandcache

disk cache Keyboard Mouse Sound

select

I/O System

timerfd

poll

signalfd

epoll

Power

eventfd

Hotplug

pthread

POSIX

dll lib

semaphore

async I/O

sched

multi I/O

mqueue

spwan

mman

fnmatch

SQLite3

3rd part software & tools

SDL

STL

FFmpeg

GoAHeadWebSever

Qt

PolarSSL

iniparser

Lua

sypkg

ODBC

OpenVPN

miniXML

osip

zLib

......

libc

module.ko

Shell

library.so

GDB

BSD socket

TFTP Ping4/6 syslog

Loader & SymbolFTP SNTP Telnet

P-MIB SunRPC

PPPoE PPP NAT VPN

Net Packet Filter

wireless net framework LoWPAN

AF_INET/AF_INET6 AF_UNIX AF_PACKET

DNS DHCP

UDP TCP

IGMP IPv4/v6 ICMP

ARP Ad Hoc

dual-pipe

cred

fd-trans

mmap

queue

Architecture ARM PowerPC MIPS x86

2015年

The new RealEvo series integrated development

environment is introduced around SylixOS, which

integrates design, development, debugging,

simulation, deployment and testing. It is a complete

set of embedded development solutions.

2017Add 64bit CPU support, such as: AMD64, MIPS64…

Add SPARC support due to demand from the satellite industry

2018Add RISC-V support

SylixOS Lite was introduced to support MMU-less MCU, such as Cortex-M7,

Hummingbird E200

2016Add TI C6x DSP support

Developed a Power safe file system: TpsFs

Third party Middleware

SylixOS open source community

02SylixOS application area & user

Electric power

Smart power grids

Remote real-time monitoring

Real-time electric power scheduling

Industrial automation

Real-time Ethernet

Industrial configuration

software

Servo controller

Industrial robot

Defences

Intelligent weapon equipment

Military AD hoc network

communication system

Fire control system

Medical

Ultrasonic acquisition

Life monitor

Real-time imaging

Rail traffic

Railway signal control

ESP

Variable speed control

system

Aerospace

Flight controller

Measurement and control

system

Simulator system

Navigation system

Applicationarea

Typical user

03Analysis of RISC-V porting

Include:

CPU Context Switch

Exception(Interrupt) support

FPU Context Switch

MMU, PAGING support

CACHE support

SMP(Symmetric Multi Processing)

support

Load ELF file(kernel module,

shared libraries, application)

support

Application debug support

Misc: Backtrace, etc…

SylixOS RISC-V arch analysis

STAGE1-SylixOS running on HiFive Unleashed

Running on HiFive Unleashed(SiFive Freedom U540), only CPU context

switch, FPU context switch, Timer and UART interrupt handle implement….

STAGE2-SMP support

Four core activated, running in SMP mode, IPI(Inter-Processor Interrupts),

MMU(Sv48 paging), CACHE support…

STAGE3-kernel module support

Relocate different relocation entry by different relocation function, Can load

kernel module(ELF, Executable and Linking Format)

STAGE4-Modify GCC & Application support

Because SylixOS applications

& shared libraries use

compiler & linker parameter

‘fPIC’

So we must modify the GCC,

add some ‘fPIC’ static libraries:

libgcc.a, libm.a…

STAGE5-C++ support

Because global、local 、static objects of C++

applications should be

constructed and destructed

on the appropriate time,

the construction of static

object should be thread-safe,

must use mutex

provide by OS.

SylixOS provides a runtime

support for C++ applications.

STAGE6-Qt Porting

Now C++ applications on SylixOS is OK, let’s try porting the Qt(4.8.7) to RISC-V…

Later, we'll port the latest Qt5 to RISC-V.

Use our modified GCC to compile Qt:

STAGE7-Modify Qemu

Because the Freedom U540 and Qemu sifive_u virtual machine without

display controller and displayer, can not see the Qt graphical interface, we

have to added LCD screen, touch screen and other devices to the Qemu

sifive_u virtual machine:

STAGE7-Qt running on RISC-V

Because the Freedom U540 and Qemu sifive_u virtual machine without

display controller and displayer, can not see the Qt graphical interface, we

have to added LCD screen, touch screen and other devices to the Qemu

sifive_u virtual machine:

STAGE8-Application debug support

SylixOS has built-in debug server, so the main task is to implement the the

interface of get and set the CPU registers, analyze the current

instruction(especially the jump and branch instruction) to calculate the

position of the jump to the next instruction, break point instruction

exception processing, etc.. The difficulty is mainly to analyze the position

of the current instruction calculation jump to the next instruction.

Compressed Base Integer

C.JAL JAL

C.JALR JALR

C.BEQZ BEQ

C.BNEZ BNE

C.J BLT/BLTU

C.JR BGE/BGEU

THANK YOU