# PicoCalc Shell (Replaces UF2 Loader's menu)

**URL:** <https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508>\
**Category:** PicoCalc\
**Tags:** opensource, firmware\
**Created:** [October 16, 2026, 8:45pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508 "2026-10-16T20:45:08Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlairLeduc](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/blairleduc/32/11808_2.png) [@BlairLeduc](https://forum.clockworkpi.com/u/BlairLeduc)\
**Post date:** [October 16, 2026, 8:45pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/1 "2026-10-16T20:45:08Z")

</div>

Here is a command line shell that lets you manipulate the SD Card between runs of programs (uf2’s). It is a drop in replacement for `BOOT2350.UF2` for @pelrun 's [UF2 Loader](https://github.com/pelrun/uf2loader), which needs to be installed first.

> **You need a RP2350-based board to run the shell.** `BOOT2350.UF2` runs in RAM and there in not enough room in the RP2040’s RAM for it.

There are two flavours of the shell: Unix and DOS. Please choose the flavour you are most comfortable using. There is a user guide for each: [Unix User Guide](https://github.com/BlairLeduc/picocalc-shell/blob/main/docs/user-guide-unix.md) and [Dos User Guide](https://github.com/BlairLeduc/picocalc-shell/blob/main/docs/user-guide-dos.md).

Both support scripting (shell scripts or batch files). They also support redirection (`>`, `>>`, `<`), pipes (`|`), globs (`*`, `?`, …), command history, and so forth.

The Unix flavour comes with `vi` for editing files; DOS comes with `EDIT` (similar to MS-DOS’s EDIT).

To start a UF2, just type it’s name. For example, to play `rogue.uf2`, just type: `rogue`. The path is initialized to `/pico2-apps` or `C:\PICO2-APPS`, but this can be set with the `PATH` variable.

> We are still using @pelrun’s boot loader and have only replaced the menu with a shell, so you can return to the shell using UP/F1, to BOOTSEL with DOWN, just as you always have.

UNIX example:

```sh
/home>ls
notes/ todo.txt
/home>cat todo.txt
buy batteries
/home>cd /
/>
/>man cp
usage: cp [-r] from... to
Copies files, -r directories

```

DOS example:

```bat
C:\HOME>DIR
 Volume in drive C has no label
 Volume Serial Number is 5C23-0000
 Directory of C:\HOME

NOTES <DIR>
TODO TXT 6
    1 file(s) 6 bytes
                  66,040,832 bytes free
C:\HOME>CD ..
C:\>
C:\>HELP COPY
usage: COPY source [destination]
Copy one or more files

```

You can also implement a startup script (Unix: `/etc/profile`; DOS: `C:\AUTOEXEC.BAT`.

Unix example:

```sh
# /etc/profile
phosphor amber
font 5x10
PATH=/pico2-apps:/games
cd /home

```

DOS example:

```bat
@ECHO OFF
PATH C:\PICO2-APPS;C:\GAMES
PROMPT $P$G
PHOSPHOR amber
CD \HOME

```

# Developers

Also, included is a convenience [header file](https://github.com/BlairLeduc/picocalc-shell/blob/main/include/picocalc_shell.h) that shows how you can let users exit their app and return to the shell or uf2loader’s menu.

* * *

> **[Release shell v1.0 · BlairLeduc/picocalc-shell](https://github.com/BlairLeduc/picocalc-shell/releases/tag/v1.0)**
>
> The first release of shell: a command line for the ClockworkPi PicoCalc with an RP2350 board. It manages the files on the SD card, edits text files, and runs the programs in /pico2-apps/ by name. I...

---

<div class="post-metadata">

**Author:** ![dzubin](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/dzubin/32/17992_2.png) [@dzubin](https://forum.clockworkpi.com/u/dzubin)\
**Post date:** [October 16, 2026, 11:51pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/2 "2026-10-16T23:51:35Z")

</div>

Very nice. I particularly like the implementation of PATH so I don’t have to load all of my apps into /pico2-apps that I have to with the old UF2 loader.

---

<div class="post-metadata">

**Author:** ![dzubin](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/dzubin/32/17992_2.png) [@dzubin](https://forum.clockworkpi.com/u/dzubin)\
**Post date:** [October 17, 2026, 11:37pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/3 "2026-10-17T23:37:06Z")

</div>

I’ve opened up a PR on your code to add a new command “select” which displays a menu of programs to run based on a text file with various choices

---

<div class="post-metadata">

**Author:** ![BlairLeduc](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/blairleduc/32/11808_2.png) [@BlairLeduc](https://forum.clockworkpi.com/u/BlairLeduc)\
**Post date:** [October 24, 2026, 9:30pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/4 "2026-10-24T21:30:25Z")

</div>

# Shell V1.1 Release

shell v1.1 adds the date and time, NTP on the Pico 2 W, and menus. A big thank you to @chrisleif for the idea to use the always-on timer to share date and time with the programs launched by the shell. Also, thank @dzubin for the idea to introduce menus, though the final implementation came out differently.

## What’s new

- **Date and time.** The clock is kept in the RP2350’s always-on timer, through reboots and program runs, and in a DS3231 on I2C when the PicoCalc has one, so it survives power-off. File dates are stamped on every write.
  - UNIX: `date`, a POSIX `TZ` in `/etc/profile`, and dates in `ls -l` and from `touch`.
  - DOS: `DATE`, `TIME`, the date formats that `COUNTRY` sets in `CONFIG.SYS`, dates in `DIR`, `$D` and `$T` in `PROMPT`, and `COPY` and `XCOPY` keeping the source file’s date.

- **NTP on the Pico 2 W.** The W builds add `ntp` (DOS: `NTP [/F]`), which runs `ntp.uf2` at most once per power-on, using the network named in `/ntp/ntp.cfg`, to set the clock.
- **Menus.** `select` and `break` for scripts in the UNIX flavour; `CHOICE` in the DOS flavour.
- **The clock for programs.** `include/picocalc_shell.h` adds `picocalc_shell_time()` and `picocalc_shell_set_time()`.
- `info` and `MEM` show the PSRAM. `info`’s lines fit in 40 columns.
- The UNIX flavour has a single font, the Master 512’s, in 40 columns.
- `picocalc_shell_exit()` refuses to run when UF2 Loader did not start the program.

* * *

> **[Release shell v1.1 · BlairLeduc/picocalc-shell](https://github.com/BlairLeduc/picocalc-shell/releases/tag/v1.1)**
>
> shell v1.1 adds the date and time, NTP on the Pico 2 W, and menus. A big thank you to @ctorkildson-netizen for the idea to use the always-on timer to share date and time with the programs launched ...

---

<div class="post-metadata">

**Author:** ![chrisleif](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/chrisleif/32/6199_2.png) [@chrisleif](https://forum.clockworkpi.com/u/chrisleif)\
**Post date:** [October 24, 2026, 10:27pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/5 "2026-10-24T22:27:20Z")

</div>

Thank you, Blair, and for the credit. You took the idea a good deal further than I had: the check record in the POWMAN scratch registers, the local offset from TZ, the DS3231 and NTP. That’s a much sturdier clock than the one I suggested.

I’ll move my programs over to `picocalc_shell_time()` and retire the settime program in picocalc-extras, since the shell’s `date` and `time` (and NTP) do that job properly now.

---

<div class="post-metadata">

**Author:** ![BlairLeduc](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/blairleduc/32/11808_2.png) [@BlairLeduc](https://forum.clockworkpi.com/u/BlairLeduc)\
**Post date:** [October 26, 2026, 8:38pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/6 "2026-10-26T20:38:14Z")

</div>

# Shell v1.2 Release

Shell v1.2 adds booting directly to the shell at power-on, provided by a build of UF2 Loader’s first stage, and a few things for scripts and the DOS flavour.

## What’s new

- **The shell at power-on (optional).** A build of UF2 Loader 2.5’s first stage with a small patch (`patches/uf2loader-boot-shell.patch`) is included:
  - Power on goes straight to the shell, and holding Up, F1 or F5 starts the last program; Down or F3 still give BOOTSEL;
  - running a program and returning to the shell skips the loader’s half-second wait for a key: back from a program to the shell in about 0.85 s, where the stock loader takes about 1.55 s;
  - a program that restarts itself still comes back to itself; hold Up, F1 or F5 through the restart, or switch off and on, for the shell;
  - with no SD Card, switching on starts the last program.

- **`> /dev/null`** (and `>> /dev/null`) throws a command’s output away in the UNIX flavour, as `> NUL` does in the DOS flavour.
- **The clock at power-on.** The guides show how to set the clock in `/etc/profile` or `AUTOEXEC.BAT`: from the DS3231, from NTP, or from NTP only when the DS3231 has no time.
- **DOS flavour:**
  - The switch `/` is now treated as a delimiter so switches work as they do in DOS: `DIR \/W` is `DIR \ /W`.
  - `COPY /B NAME+,,` updates a file’s time, same as `touch` in the Unix flavour. `COPY` accepts `/B`.

* * *

> **[Release shell v1.2 · BlairLeduc/picocalc-shell](https://github.com/BlairLeduc/picocalc-shell/releases/tag/v1.2)**
>
> shell v1.2 adds the shell at power-on, through the shell's own build of UF2 Loader's first stage, and a few things for scripts and the DOS flavour.
> What's new
> 
> The shell at power-on (optional). A b...

---

<div class="post-metadata">

**Author:** ![Giovanni\_Pozzobon](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/giovanni_pozzobon/32/13896_2.png) [@Giovanni\_Pozzobon](https://forum.clockworkpi.com/u/Giovanni_Pozzobon)\
**Post date:** [October 30, 2026, 8:30pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/7 "2026-10-30T20:30:30Z")

</div>

Excited after many months of not touching my PicoCalc, I downloaded the code of project # [PicoCalc Shell](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508)  
With Claude’s help, I then modified the shell code to implement file management via web, drawing inspiration and some code from # [PicoMultiLoader: an ESP32-P4-WIFI brain for the PicoCalc, with an SD-card app loader](https://forum.clockworkpi.com/t/picomultiloader-an-esp32-p4-wifi-brain-for-the-picocalc-with-an-sd-card-app-loader/23532) project.  
Since I really like being able to use a BTE keyboard (I have 3 from Keyrom), I modified the code, drawing [Diamond: a WordStar-style word processor for the PicoCalc (alpha)](https://forum.clockworkpi.com/t/diamond-a-wordstar-style-word-processor-for-the-picocalc-alpha/23592) code, so I could use it in the shell. With a Raspberry Pi Pico 2 W, memory is limited, so I had to make some compromises, but it works, and I’m happy about that.  
Thanks @BlairLeduc, @chrisleif, @Luciano_Faria, @pelrun for letting me have fun.  
I hope there are no issues with my taking inspiration from, or using part of, your code.”

---

<div class="post-metadata">

**Author:** ![chrisleif](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/chrisleif/32/6199_2.png) [@chrisleif](https://forum.clockworkpi.com/u/chrisleif)\
**Post date:** [October 30, 2026, 9:22pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/8 "2026-10-30T21:22:47Z")

</div>

No issues at all, Giovanni: Diamond and picocalc-extras are MIT licensed, so use whatever helps; just keep the licence notice with the code. Glad the keyboards are working in the shell. The Bluetooth code there comes from picocalc-extras, and its latest version, 1.3, has a couple of fixes since Diamond’s copy. Blair suggested today that pairing could live in the shell and programs could use it, so your work is right on topic. I’d be interested to hear what compromises you had to make for memory.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Pozzobon](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/giovanni_pozzobon/32/13896_2.png) [@Giovanni\_Pozzobon](https://forum.clockworkpi.com/u/Giovanni_Pozzobon)\
**Post date:** [October 31, 2026, 6:55am UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/9 "2026-10-31T06:55:16Z")

</div>

## Memory management for Bluetooth in the shell

The shell runs entirely from SRAM: 512 KB (524,288 B) for code and data together. The first count with the Bluetooth stack (BTstack, classic and BLE) and the CYW43 radio firmware came to about **879 KB**. A small optimisation could not close that gap. I needed roughly 360 KB less.

**The choice.** I kept full Bluetooth, BLE included, and took memory out elsewhere, in three places:

| Change | Saving (approx.) |
| --- | --- |
| Radio firmware read from the SD card instead of embedded | 232 KB |
| `-Os` compilation in the W builds | 56 KB |
| 32 KB vi/EDIT buffer in the W builds (was 64 KB) | 45 KB |

The firmware is the largest piece and is used only once, when the radio starts, so it is best kept on the card. Shrinking vi costs little: a text file over 32 KB is rare on this machine.

Measured result (W development build): **495,424 B used, 28,864 B free**. BTstack uses only about 7 KB of heap at run time. The Pico 2 build without Wi-Fi is unchanged (454,416 B).

**How it works.**

- **Firmware from the SD card.** The CYW43 driver expects the firmware as an array in memory. I use a patched copy of `cyw43_ll.c`. The array becomes a virtual address. Every read goes to a function which reads `/bluetooth/cyw43-fw.bin` from the card with a 4 KB read-ahead. The file stays open until the chip is up, then is closed.
- **Targeted `-Os`.** The W builds use `-Os`. The four files that speed depends on, the panel and card drivers (`lcd.c`, `screen.c`, `sd.c`, `diskio.c`), stay at `-O3`.
- **Smaller vi buffers.** Sets vi/EDIT’s text buffer to 32 KB .
- **The radio starts only when needed.** It starts after the shell, and only if `/bluetooth/pairing.dat` exists (created by your program`btpair`). With no pairing the radio does not start and uses no memory. If it fails to start, the shell starts anyway and prints one line: `bluetooth: <reason>`.
- **Only one thread touches the card.** BTstack runs from the asynchronous context. So the pairing file and the card are used only from the main loop, which reads the Bluetooth keys with `btkbd_poll()`.

With the radio on, `usbdisk` reads about 19% slower (497 vs 612 KB/s). Writing is unchanged. I chose to leave it as it is.

---

<div class="post-metadata">

**Author:** ![chrisleif](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/chrisleif/32/6199_2.png) [@chrisleif](https://forum.clockworkpi.com/u/chrisleif)\
**Post date:** [October 31, 2026, 8:02am UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/10 "2026-10-31T08:02:45Z")

</div>

Nice work, Giovanni. Loading the radio firmware from the card is a clever way around the RAM limit. Two things: picocalc-extras 1.3 is the latest Bluetooth code (two BTstack fixes, BLE, and mice); if your copy came from Diamond 0.3 it’s older. And I’m thinking of letting pairing.dat hold a keyboard and a mouse at the same time. Since your shell reads that file too, let’s agree on the new format first, so neither of us breaks the other.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Pozzobon](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/giovanni_pozzobon/32/13896_2.png) [@Giovanni\_Pozzobon](https://forum.clockworkpi.com/u/Giovanni_Pozzobon)\
**Post date:** [October 31, 2026, 5:03pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/11 "2026-10-31T17:03:14Z")

</div>

Yes, my code comes from Diamond 0.3. Handling the keyboard and mouse at the same time is a great idea!! I use your `btpair`) program for pairing, so I’ll go along with your choices. I’ll modify the code so that it conforms to the new file format.

---

<div class="post-metadata">

**Author:** ![chrisleif](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/chrisleif/32/6199_2.png) [@chrisleif](https://forum.clockworkpi.com/u/chrisleif)\
**Post date:** [October 31, 2026, 8:19pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/12 "2026-10-31T20:19:01Z")

</div>

Thanks, Giovanni. One thing first: Diamond 0.3 has picocalc-extras 1.1’s Bluetooth code, which reads the older pairing file (PBK1) and has no BLE. btpair 1.2 and 1.3 write PBK2, so please move your copy to 1.3’s btkbd.c. The keyboard and mouse won’t change the format beyond that: the file stays PBK2, and the mouse gets its own record (tags PTR0 for classic, PTL0 for BLE) next to the keyboard’s (KBD0 and KBL0). Code that doesn’t know the new tags just ignores them, so you can add the mouse whenever it suits you.

---

<div class="post-metadata">

**Author:** ![chrisleif](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/chrisleif/32/6199_2.png) [@chrisleif](https://forum.clockworkpi.com/u/chrisleif)\
**Post date:** [November 3, 2026, 7:13pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/13 "2026-11-03T19:13:10Z")

</div>

Blair, a small housekeeping question when you have a moment. The root of my card is getting crowded with settings files (virtualt.cfg, and now calcterm.cfg from a VT100 terminal I’m working on). I see the shell’s world uses a folder per program (/ntp/ntp.cfg, /atom/pico-atom.cfg) and keeps /etc for /etc/profile, and Diamond already does the same with /diamond/diamond.cfg. Is a folder per program the convention you’d like programs to follow, or would you rather see settings under /etc? I’d just like us all doing the same thing. No hurry at all.

---

<div class="post-metadata">

**Author:** ![BlairLeduc](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/blairleduc/32/11808_2.png) [@BlairLeduc](https://forum.clockworkpi.com/u/BlairLeduc)\
**Post date:** [November 3, 2026, 9:15pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/15 "2026-11-03T21:15:42Z")

</div>

So, I had to encourage some developers to put their files into a folder and not treat the entire card as they owned it. So having all a program’s files in one folder, I consider it a small victory.

First we had BOOTSEL, which one would flash the Pico with one firmware and it was a pain. The the boot loaders came which allowed us to switch firmware much easier, but it still was the concept of switching between firmware. With the patched UF2 loader and always booting to the shell changes things again, where the user considers the firmware as a program that they run, exit back to the shell and run another (although it is not a perfect analogy).

Perhaps this is a community effort if we want to have folders like Unix or DOS where we organize our SD cards like we organized our hard drives in the past.

---

<div class="post-metadata">

**Author:** ![dzubin](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/dzubin/32/17992_2.png) [@dzubin](https://forum.clockworkpi.com/u/dzubin)\
**Post date:** [November 3, 2026, 9:24pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/16 "2026-11-03T21:24:44Z")

</div>

For my various toy projects, I’ve started using folders for their config and save files, so I think that is a great idea.

---

<div class="post-metadata">

**Author:** ![BlairLeduc](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/blairleduc/32/11808_2.png) [@BlairLeduc](https://forum.clockworkpi.com/u/BlairLeduc)\
**Post date:** [November 5, 2026, 5:51pm UTC](https://forum.clockworkpi.com/t/picocalc-shell-replaces-uf2-loaders-menu/23508/17 "2026-11-05T17:51:15Z")

</div>

# Release v1.3

This release passes arguments from the command line to the launched UF2, returns you to your directory after a program or restart, and brings each flavour closer to the system it follows.

## What’s new

- **Passing arguments.** `pico-oric -t game.tap` (DOS: `PICO-ORIC /T GAME.TAP`) finds the file from your directory and gives the program its full path.
  - A program has to declare that it takes arguments. Any other program says `takes no arguments` and isn’t started.
  - Programs need updating to use this. `pico-oric` will support it from its next release.
  - Program authors can find the details in the [README](https://github.com/BlairLeduc/picocalc-shell/blob/v1.3/README.md#adding-an-exit-command-to-a-program) and `picocalc_shell.h`.

- **Back to your directory.** Coming back from a program, a `reboot` or `menu` (DOS: `EXIT`), the shell returns to the directory you left, if it’s still on the card. After `poweroff`, or the power switch at the prompt, it starts as usual.

**UNIX flavour:**

- **Error messages:** `2>`, `2>>`, `2>&1` and `>&2`, plus `2> /dev/null`, `< /dev/null` and `cat /dev/null`.
- **Scripts:** `./backup.sh`, a file whose first line starts `#!`, or a name ending `.sh` on `$PATH`. `exit [N]` ends a script.
- **New commands:** `find`, `sort`, `uniq`, `tee`, `less`, `which`, `test` and `[`, `true`, `false`.
- **Options:** `rm -f`, `-rf` and `-R`; `cp -R` and `-f`; `mv -f`.
- **Line editing and directories:** Ctrl-W, Ctrl-L, `~`, `cd -`, `$PWD` and `$OLDPWD`.
- **Programs:** `./chess`, a path with no extension, and `chess.uf2` found on `$PATH`.

**DOS flavour:**

- **`COPY` devices:** `CON` and `NUL`, so `COPY CON NOTE.TXT` writes what you type, `COPY NOTE.TXT NUL` tests that a file can be read, and `COPY NUL NOTE.TXT`makes an empty file.
- **Programs with their files:** a program can live in any directory, and can be run from there, by its path, or as `NAME.UF2`.

## Changes that may affect you (DOS flavour)

- **`/` no longer separates names.** It only starts a switch, so `CD /HOME` now says `Invalid switch - /HOME`. Use `\` in paths, including in `PATH` and batch files.
- **The shell starts in `C:\`, not `C:\HOME`.** Put a `CD` in `AUTOEXEC.BAT` to start elsewhere.
- **The search order has changed.** In each directory, a program now comes before a batch file of the same name. Type `NAME.BAT` to run the batch file.

* * *

> **[Release shell v1.3 · BlairLeduc/picocalc-shell](https://github.com/BlairLeduc/picocalc-shell/releases/tag/v1.3)**
>
> shell v1.3 lets a program be given a file from the command line, returns you to your directory after a program or restart, and brings each flavour closer to the system it follows.
> What's new
> 
> Givin...
