6 ms·
Piccolo OS, a Small Multitasking OS for the Raspberry Pi Pico
- bsimpson 2y ago> Since the Internet seems to be full of people with way too much time on their hands, I would just like to kindly shoo away any C/C++ pedants out there. Yes, I am sure there are a million different ways to achieve many of the same results. Yes, I am sure there are some fine points of language semantics that could be argued about. Yes, I am sure you have a more efficient way of writing some of the functions. > To be honest, I am not interested. I respect this so much.
- andai 2y ago>Piccolo OS [...] is designed primarily as a teaching tool. This means you must carefully balance teaching the right thing (a realistic system implemented skillfully) against teaching the right way (simplification for didactic purposes).
- KerrAvon 2y agoYou shouldn't. This is what hardware people always say, and then when the result is an unmaintainable mess, they want software people to bail them out.
- KerrAvon 2y agothat said, there's not really a lot here, so I'm not sure what anyone would take issue with
- bsimpson 2y agoIt's a totally fine and respectable boundary to have: "I'm going to share some stuff I did for free for other people to learn from, but not if I get a bunch of bitchy/pedantic notifications about it."
- tredre3 2y ago> I respect this so much. You really shouldn't, Gary is extremely pedantic himself. He really really dislikes criticism or being corrected. For example on youtube, in many of his video comment's, he's engaged in long fights with anyone who claims that Arduino code is C++. In his mind it isn't, therefore that's that.
- ladyanita22 2y agoI have found him to say some incorrect stuff and being extremely reluctant to even reflect on it. I dislike him quite a lot to be honest...
- nine_k 2y agoIn short: it's a toy OS built primarily for teaching, and it's a cooperative multitasking OS, without process isolation. So it's more like Node.js (or win16, or macOS classic) than like what we usually call an OS.
- abelsson 2y agoIt’s also running on a microcontroller with a few hundred kb of memory so even win16 or macOS classic would be a bit heavy.
- Someone 2y ago> so even win16 or macOS classic would be a bit heavy. Speed-wise, both would run exceptionally well on that hardware. The first Mac had 128kB memory, about 32 of which were taken by its video and audio buffers. It ran at about 8MHz. The first version of Windows ran on similar hardware, requiring a 8088 and 256kB of memory. The pico has at least that amount of memory, at top speed 16 times the clock frequency, and two cores.
- teejmya 2y agohttps://axio.ms/projects/2024/06/16/MicroMac.html https://axio.ms/projects/2024/06/16/MicroMac.html
- rvense 2y agoThe Pico doesn't have an external memory bus, but something like MacOS Classic for an STM32 with a chunk of SDRAM and VGAish video would be fun.
- drrotmos 2y agoThe Pico 1 (i.e. the RP2040) doesn't. The Pico 2 (RP2350) does, albeit a fair bit slower (since it's QSPI PSRAM) than the internal SRAM.
- 2y ago
- jollerina 2y agostruct { // ... } typedef piccolo_os_internals_t; int typedef Int; // also works. You always learn some new quirk of C. I guess typedef works like const, can put it on the left or the right.
- formerly_proven 2y agoTIL and looked it up, typedef is indeed just a specifier like any other in a declaration.
- extraduder_ire 2y agoAren't those the same thing? <type> typedef <name> My c is pretty rusty, admittedly.
- akovaski 2y agoThe interesting thing being pointed out is that you can do both `typedef <type> <name>;` (the common way, I think) and `<type> typedef <name>;`.
- dariosalvi78 2y agofor a less toy example, it seems like FreeRTOS can be used also on the Rpi pico: https://freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/Raspberry-Pi/smp-demos-for-the-raspberry-pi-pico-board https://freertos.org/Documentation/02-Kernel/03-Supported-de...
- pkphilip 2y agoThis is cool! works well as a way of understanding how to get an OS going on Pico
- rbanffy 2y agoI remember Linux (and NetBSD) running on outrageously low-end hardware (even hardware without an MMU). While modern Linux is a no-go, would there any existing and relatively popular OS be viable?
- hackernudes 2y agoYou can run modern Linux without an MMU! But other popular embedded OSes I've heard about are FreeRTOS and Zephyr.
- jsheard 2y agoAnd someone has in fact managed to get MMU-less Linux running on the newer Pico 2: https://github.com/Mr-Bossman/pi-pico2-linux https://github.com/Mr-Bossman/pi-pico2-linux That's with an 8MB external PSRAM though, fitting modern Linux in the internal SRAM is probably a step too far.
- joezydeco 2y agoI used to work with a Cortex-M3 port of uCLinux, but it was kind of a pain to manage. The biggest problem being every executable had to be statically linked to all of its dependencies.
- crest 2y agoYou can run uC Linux without an MMU, but you won't get memory safety. Better microcontrollers (that includes the RP2040 and RP2350) have an MPU (memory protection unit) to implement memory safety, but almost no microcontroller has a real MMU (only the MIPS derived PIC32 come to mind). An MPU is far more visibly exposed to the programmer than a paging MMU that combines access control with address space virtualisation. To make it even more annoying the ARMv6M architecture isn't intended to recover from memory usage faults. You have to use really dirty tricks to "fake it" (return from the hard fault into an unimplemented exception, infer the address and cause the fault before you can recover), but it's possible. It's not even that slow. Depending on your usecase a fast warm-start of the whole chip may be preferable to restarting single tasks (e.g. just set the hardware watchdog countdown timer to 1 and spin until it happens).
- jacobmarble 2y agoI've been using protothreads on the RP2040 (Pico MCU) for task management. https://dunkels.com/adam/pt/ https://dunkels.com/adam/pt/ The extensions available from Hunter Adams at Cornell are also very useful. In particular, PT_YIELD_INTERVAL() has been very useful for me. https://people.ece.cornell.edu/land/courses/ece4760/RP2040/C_SDK_protothreads/index_Protothreads.html https://people.ece.cornell.edu/land/courses/ece4760/RP2040/C...
- fsiefken 2y agoFuzix works as well... https://www.reddit.com/r/raspberrypipico/comments/15si3ow/fuzix_os_with_w5500_and_raspberry_pi_pico/ https://www.reddit.com/r/raspberrypipico/comments/15si3ow/fu...
- childintime 2y agoIt would be interesting to run each task (likely in simulation), measure the stack size they need, and pre-allocate. That would alleviate the downside of giving each task a stack a lot. Worth reminding that lots of tasks don't need their own stack, so detecting (or hinting) that would be extremely worthwhile.