Rayvert64 / ToInfiniTimeAndBeyond

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS. The goal here is to modernize the C++ used and try to stay bleeding edge on the libraries(like LVGL, the SDK used and more) **I will probably fork this to make my own watch OS. But will probably push the LVGL update I am working on to InfiniTime, then change the RTOS used.**
GNU General Public License v3.0
0 stars 0 forks source link

Trying ChibiOS as base #5

Open Rayvert64 opened 2 weeks ago

Rayvert64 commented 2 weeks ago

I know that LVGL has been used with ChibiOS, all we need to do is have expose the task apis and the mutex, semaphore structures to LVGL.

I think we could do something cool to allow for drop-in RTOSs to work, since all RTOSs use the same basics for scheduling.

I just like ChibiOS since it is modular. From the ChibiOS website:

ChibiOS does not refer to just an RTOS scheduler but to a set of embedded components part of an overall architecture defining a typical embedded system:

RT, the RTOS scheduler. RT is a very high performance RTOS with a complete set of features and small footprint. It is what we cover in this book.

NIL, an alternate RTOS. NIL is compatible with RT but its internal architecture is completely different, It is designed for minimal code size.

OSLIB, an RTOS extension library. It sits on top of RT or NIL and adds an incredible set of higher level services.

HAL, the Hardware Abstraction Layer enclosing abstract drivers for most common peripherals.

SB, an extension for RT or NIL offering isolated sandboxes where to run “unsafe” code. The code in the sandbox is unable to crash the whole system.

Rayvert64 commented 2 weeks ago

Link to #1: Basically I might need to do this ticket(The one this comment is in) in order to get the newer LVGL to Compile.

The FreeRTOS kernel seems to be much bigger than ChibiOSs. 10kB vs 1-3kB in ROM. Which makes sense, I'm pretty sure we dont need half the features of FreeRTOS. https://www.freertos.org/FAQMem.html#ROMUse https://forum.chibios.org/viewtopic.php?t=2449#p19431

At the moment, when compiling, we are going over by a few kB in size depending on the implementation of the STDLIB we use. ChibiOS has ChibiOS-HAL that we can probably use, which is known to use quite a bit less memory on STM32 chips than using the built-in STM libraries. So checking this out could be worth it as well.

For now though I am still focusing on just getting the size smaller on FreeRTOS if FreeRTOS is really too memory hungry, then I'll get started on this and make this fork its own thing.

Rayvert64 commented 2 weeks ago

Looking at the .map files, I noticed that there where some big AF structures in the .bss section which seemed to be the main culprit in making the binary not fit in memory. Simply changing the main so that we don't initialize displayApp and systemTask statically, instead I save a pointers statically and initiallise them in the main which lives for the entire duration of the runtime. Doing this I was able to save TONS of ram, that being said I am still not certain this will work as I still don't have this thing running hahaha 😅.