Is it possible to compile and run C code directly on PicoCalc?

I’m wondering if it’s possible to go through the entire development process — writing, compiling, and running C code — all on the PicoCalc itself, without needing cross-compilation from another device.

I’ve looked through the Fuzix source and wiki but couldn’t find any clear information about this. Has anyone tried this or know if it’s feasible?

2 Likes

Fuzix and the Luckfox Lyra port of of Linux are both complete(?) operating systems. I don’t know much about either, but if they have a C compiler, you should be able to at least build small simple utilities. Beyond that, the answer is no, you need to cross compile from another device to build the uf2 images which are then flashed to the Pico. I suppose hypothetically, someone could port a C interpreter like Cling or CINT to run similarly to how PicoMite, uLisp or MicroPython run on the PicoCalc.

I have been developing on the Luckfox Lyra which includes vi, gcc, headers for SDL… It is fun. You have to copy documentation on it if you really want to be independent from other devices (or make a wifi addon work).

I haven’t seen a working compiler toolchain on smaller devices like the pico2, maybe Fuzix can do that, but optimizing compilers require ram, probably more than 500k.

2 Likes

This could be a fun thing if someone were to adapt it for the device.

4 Likes

This is so cool. No time now, but I will look into it.

1 Like

That would be great. Unfortunately, I don’t have enough experience doing something like that.
But it would be awesome if that would work on picocalc.

Gave pshell a try. It compiles but I get nothing though uart / usb. I will need to find a solder iron to add those SWD debug pins to my pico2…

1 Like

I tried the precompiled uf2 file on a pico 2. I can connect via minicom over USB. And it works great (shell-commands, vi, cc, …). But I have no clue how to integrate the display driver or keyboard driver and make it work on picocalc.

2 Likes

Fuzix at the moment only supports compiling stuff natively on a few targets and needs under 64K but it’s very much early days. At the moment there isn’t an ARM target for the fcc compiler but it would in theory be easy to produce a bad compiler. A good one would need some work.
It’s certainly theoretically possible to do. CP/M had a non C friendly CPU architecture and native compilers. ARM is a much more C friendly architecture.

I’m also very interested in this. Having Python and BASIC available out of the box is cool, but making small console programs with C would be great, too.

The “hard” part is to build the ARM C compiler natively for the RP2040/2350.
And that already an issue about the size (in the best case that ~100 MB) and need probably more than 512 KB of RAM to run properly!

A custom one, written from scratch can probably fit in the tiny spec of the RPxxxx chip. Welcome to wonderful world of embedded (limited) system! :smiley:

Using a more powerful MCU like one from the luckfox lyra remove this contraints as the flash/ram is sufficient to run the official ARM compiler.

1 Like

The pshell port to the PicoCalc seems to mostly work. I wasn’t able to get it to mount my SD card, but it works with the u2floader. I didn’t really spend much time with it though, as I was mostly interested in just seeing what worked with the loader, but it might be useful to folks looking for a PicoCalc C compiler. (Also, I only tried it on a pico2w.)

Yeah, the port is quite rough. The editor is bearly usable but I was able to write and compile short programs on device. Given the device memory, it will definitely not scale to building large projects with lots of includes, but for playing around it’s fun. With some work, one could create an environment and library similar to the MMBasic one.