freertos on risc-v · © 2019, amazon web services, inc. or its affiliates. all rights reserved....
TRANSCRIPT
© 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
© 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
© 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
© 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Use cases
© 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bare metal, assembly or C
User (application) code
Vendor supplied libraries
Hardware
© 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
© 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
© 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
© 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2018
2017
2016
© 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
© 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
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Example for Arm
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Additional header file for 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
© 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
© 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
© 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
© 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
© 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
© 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
© 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