freertos on risc-v · © 2019, amazon web services, inc. or its affiliates. all rights reserved....

25
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Richard Barry Founder, FreeRTOS Project Principal Engineer, AWS IoT FreeRTOS on RISC-V

Upload: others

Post on 15-Jun-2020

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Richard Barry

Founder, FreeRTOS Project

Principal Engineer, AWS IoT

FreeRTOS on RISC-V

Page 2: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Agenda

The FreeRTOS Kernel

Running FreeRTOS on RISC-V

Page 3: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

FreeRTOS—Open source real time kernel

Page 4: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

0

2,000

4,000

6,000

8,000

10,000

12,000

14,000

FreeRTOS downloads per month over 15 years D

ow

nlo

ad

s

Date

Official RISC-V port released February 2019

Page 5: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

FreeRTOS kernel

User (application) code

Vendor supplied libraries

Hardware

FreeRTOS

kernel

Third Party Libraries

Page 6: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Use cases

Page 7: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Recent trend - IoT

Fleet onboarding, management and

SW updates

Fleet audit and protection

IoT data analytics and intelligence

Intelligence Insights & Logic → Action

Secure device connectivity

and messaging

Page 8: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Bare metal, assembly or C

User (application) code

Vendor supplied libraries

Hardware

Page 9: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Application view with individual libraries

User (application) code

TLS

Key

manage-

ment

MQTT

TCP/IP

Secure

storage

Vendor supplied libraries

Hardware

Wi-Fi

Provisioning OTA

Page 10: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Introducing a library that implements multithreading

ISR

ISR

ISR

ISR

Application Design Goals:

• Meet real time requirements!

• Maximize responsiveness

• Use as little CPU/Power as possible

• Maximize maintainability

• Maximize portability (hardware change)

• Simplicity!

• Fast to market

• Meet requirements with minimum expenditure

Page 11: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Application view with individual libraries

User (application) code

TLS

Key

manage-

ment

MQTT

TCP/IP

Secure

storage

Vendor supplied libraries

Hardware

Wi-Fi

Provisioning OTA

Page 12: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Application view with security and connectivity libraries

User (application) code

Vendor supplied libraries

Hardware

FreeRTOS

kernel

MQTT agent OTA agent Greengrass discovery

Middleware libraries

Page 13: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

2018

2017

2016

Page 14: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

FreeRTOS on RISC-V: Source Files

Page 15: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Common source files and port specific source files

Blocked Task 2

Top of Stack for Task

Rn Copy

R1 Copy

R0 Copy

Status Register

Program Counter Copy

Stack Variable

Stack Variable

Return Address

Empty Stack Space

Empty Stack Space

Blocked Task 1

Top of Stack for Task

Rn Copy

R1 Copy

R0 Copy

Status Register

Program Counter Copy

Stack Variable

Stack Variable

Return Address

Empty Stack Space

Empty Stack Space

Ready Task 1

Top of Stack for Task

Rn Copy

R1 Copy

R0 Copy

Status Register

Program Counter Copy

Stack Variable

Stack Variable

Return Address

Empty Stack Space

Empty Stack Space

Rn

R1

R0

Stack Pointer

Program Counter

Running Task

Top of Stack for Task

Empty Stack Space

Empty Stack Space

Empty Stack Space

Empty Stack Space

Empty Stack Space

Empty Stack Space

Stack Variable

Stack Variable

Return Address

Empty Stack Space

Empty Stack Space

Page 16: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Example for Arm

Page 17: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Additional header file for RISC-V

Page 18: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

FreeRTOS on RISC-V: Interrupt stack

Page 19: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Defining the interrupt stack

Task 3

Top of Stack

for Task

Max Task

Stack

mpty Stack Space Max IRQ Stack

Top of Stack

for Task

Task 2

Max Task

Stack

Max IRQ Stack

Top of Stack

for Task

Task 1

Max Task

Stack

Max IRQ Stack

Task 3

Max Task

Stack

Top of Stack

for Task

Task 2

Max Task

Stack

Top of Stack

for Task

Task 1

Max Task

Stack

Max IRQ Stack

Max Task

Stack

Max IRQ Stack

Max Task

Stack

Max IRQ Stack

Max Task

Stack

Max IRQ Stack

Max Task

Stack

Max Task

Stack

Max Task

Stack

Max IRQ Stack

Page 20: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

FreeRTOS on RISC-V: Setting CLINT base address

Page 21: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

FreeRTOS on RISC-V: Installing the FreeRTOS trap handler

Page 22: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

FreeRTOS on RISC-V: Calling an external interrupt handler

Page 23: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

Page 24: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Confidential and Trademark

Page 25: FreeRTOS on RISC-V · © 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda The FreeRTOS Kernel Running FreeRTOS on RISC-V

© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Thank You! Download, share and support

https://www.freertos.org

https://github.com/aws/amazon-freertos

@real_FreeRTOS | @ AWSOpen