// cd /blog/picomite-v7

PicoMite MMBasic V7.00.00 is released

Version 7 of MMBasic for the RP2040 and the RP2350 is out, the first full release since V6.03.01 in August. It runs programs faster on every board and gives them more memory. On the RP2350 it adds a compiler that runs most of a program as native code without changing a line of it. It also has a new USB host, more Bluetooth, and two new builds, one of them for the Pico Computer 3.

In short

  • Faster on every board. Names are looked up as symbols instead of searched for, local variables live on a stack, and an armed interrupt costs almost nothing until it fires. A DO loop on an RP2040 PicoMiteVGA went from 1.50 s to 0.60 s.
  • A compiler on the RP2350. Type OPTION COMPILE ON, then RUN. Whatever the compiler can take runs as native code, from 1.4 to 5.2 times faster in the tests below, and the program stays exactly as you wrote it.
  • More memory. Variables now take memory only when they're made, so the old fixed block is heap: 364 KB on the RP2350 PicoMite and 120 KB on the RP2040 PicoMiteVGA.
  • Back up before you upgrade. The first boot of V7.00.00 resets the board: options, flash slots, program memory and the A: drive. Save them first.

On this page

  1. Speed and the compiler
  2. The language
  3. Graphics, sound, files and the console
  4. USB and Bluetooth
  5. The builds
  6. Upgrading from V6
  7. Downloads and manuals

Speed and the compiler

Every build runs the same programs faster. When a program is saved, each variable, SUB, FUNCTION and label name becomes a short symbol that the interpreter follows directly, and LIST and EDIT still show the names as you typed them. A SUB's parameters and LOCAL variables are made on a stack and dropped on return, so loops of calls are 12% to 39% quicker on a Pico Computer 3 and 17% to 55% on an RP2040. Interrupt sources now signal when they're ready instead of being checked after every statement, which takes about 30% off a loop that has SETTICK armed. MATH FFT is about 20% faster.

The compiler (RP2350)

With OPTION COMPILE ON, MMBasic compiles the program, and its library, when you type RUN. It compiles again only after an edit, which costs about 0.3 s for a 110 KB program. Statements it can't compile stay in place and run on the interpreter between the compiled ones, so a program doesn't have to be entirely compilable to gain. LIST, EDIT, error messages, line numbers, TRACE, ON ERROR, interrupts and CHAIN all behave as before. Afterwards, PRINT MM.INFO(COMPILE) shows how much ran compiled, and OPTION COMPILE SHADOW checks every compiled value against the interpreter, to find the line if a program ever behaves differently.

Program, on a Pico Computer 3 at 378 MHzInterpretedCompiledFaster
torus (nested loops, IF and PIXEL)40.5 s7.8 s5.2×
landscape (a FUNCTION in the inner loop)78.5 s21 s3.7×
galaxy (SIN and COS per point), per point255 µs80 µs3.2×
reference benchmark15.4 s7.1 s2.2×
Elite, per frame22.6 ms11.0 ms2.1×
PETSCII Robots, frame update36.0 ms23.4 ms1.5×
Prince of Persia port, per frame9.7 ms6.7 ms1.4×

Where the gain is smaller, the time goes on work no compiler can speed up: the maths library, the drawing itself, and statements that stay interpreted.

mmb2csub: one routine as machine code, on either chip

For the routine that matters most, a new tool, mmb2csub, takes one SUB or FUNCTION out of your program, compiles it to machine code and puts it back as a CSUB. Your calls don't change. Loops, arithmetic and array work run 10 to 35 times faster: the Julia set demo renders in 5.9 s instead of 119 s on an RP2040. The same converted program runs on the RP2040 and the RP2350, on every build.

The language

  • Whole arrays at once. b%() = a%() copies one array into another in a single move, and a FUNCTION can return an array: m%() = f(3). An array dimension can hold a single element, so row vectors, column vectors and 1×1 results can be declared.
  • A program can bring its own library. LIBRARY LOAD as a program's first statement installs a library from up to eight files, and touches nothing if the same library is already there. On an RP2350 with PSRAM, the RAM keyword loads it into RAM for that run only, leaving the flash library alone. READ goes on into the library's DATA when the program's runs out.
  • Old programs keep their names. A variable can now have a command's name, so fm% = 0 in a program written before the FM command came along still runs.
  • Errors say more. MM.ERRLINE gives the line of the last error, and "Not enough memory" names the size that was asked for.
  • New functions, such as MATH CLAMP to limit an array to a range and BASE$ for numbers in any base from 2 to 36.

Graphics, sound, files and the console

  • Pictures. SAVE IMAGE now picks the smallest exact BMP for the picture. On the RP2350, SAVE PNG saves the screen as a compressed PNG, typically ten to fifty times smaller than a BMP, PNGs of any size load and crop, FRAMEBUFFER MERGE puts a second framebuffer over the main one on VGA and HDMI in one pass without tearing, and image slots can be kept in PSRAM. TILEMAP LOAD reads a tile map from a file, and a DRAW3D scene holds 32 objects instead of 8.
  • Print Screen. The Print Screen key, or Ctrl-\ on any keyboard or terminal, saves the display at the prompt, in the editor and in the file manager, to a file named from the date and time.
  • Sound. PLAY BBC SOUND and PLAY BBC ENVELOPE bring back the BBC Micro's sound commands. The file manager plays a list of marked tracks, and an album may mix WAV, FLAC, MP3 and MIDI files.
  • Files. ZMODEM, in every build, moves files and batches of files to and from a PC, and recovers from errors instead of failing. The A: drive moves to littlefs 2.11.3, with three years of its fixes: a write cut short by a power failure is now caught instead of read back as good data.
  • Help at the prompt. HELP looks a command up in a help file on the A: drive. The release comes with three, of different sizes, to suit the space you have.
  • Listings anywhere. LIST ALL, LIST PINS, FILES, OPTION LIST and others take #n, as PRINT does, to send their output to a printer, a serial port or a file.

USB and Bluetooth

The USB host builds have a new USB stack, based on TinyUSB's current version, which makes hubs, flash drives and serial adapters faster and more reliable:

  • A USB flash drive reads at several hundred KB/s instead of about 64 KB/s, faster than the SD card.
  • More USB serial adapters work, Prolific PL2303 ones among them, and one can feed the GPS parser.
  • More gamepads, the Nintendo Switch Pro Controller among them, and every mouse button is reported.
  • A hub has room for more devices at once, and USB faults are recovered from and reported.

The Bluetooth host builds go well beyond BLE keyboards:

  • Speakers and headphones. OPTION AUDIO BLUETOOTH sends everything PLAY makes to a Bluetooth speaker, and the board reconnects to it by itself after a reset.
  • Bluetooth Classic keyboards, the cheap tablet keyboards among them, and BLE keyboards that pair and reconnect more easily.
  • Serial devices on COM7. A Bluetooth GPS receiver, or a BLE serial module such as an HM-10, opens as a serial port, with a buffer and an interrupt like any other.

The builds

There are two new builds:

  • PicoMitePC3: everything the Pico Computer 3 can do in one firmware. It has the HDMI PicoMite's video and USB, the WebMite's WiFi and the Bluetooth host's keyboards, speakers and serial devices, with room for a 256 KB program. It also runs the Pico Computer 2 and Olimex's RP2350pc, and sets itself up for whichever of the three it finds itself on.
  • PicoMiteHDMIBTH: the HDMI PicoMite with USB, plus Bluetooth keyboards, mice and speakers.
KindRP2040RP2350
PicoMitePicoMiteRP2040, PicoMiteRP2040USB, PicoMiteRP2040MINPicoMiteRP2350, PicoMiteRP2350USB
VGAPicoMiteRP2040VGA, PicoMiteRP2040VGAUSBPicoMiteRP2350VGA, PicoMiteRP2350VGAUSB
HDMI—PicoMiteHDMI, PicoMiteHDMIUSB, PicoMiteHDMIWEB, PicoMiteHDMIBTH (new)
WiFi and BluetoothWebMiteRP2040WebMiteRP2350, PicoMiteRP2350BT, PicoMiteRP2350BTH, PicoMitePC3 (new)

The Colour Maximite 2's MMBasic V8 is the same MMBasic, so PicoMite programs run on it too.

Upgrading from V6

The first boot of V7.00.00 resets the board. The options go back to their defaults, saved variables and the three flash slots are erased, program memory is cleared and the A: drive is reformatted. So, while the board still runs V6.03.01:

  1. Copy everything on A: to the SD card or your PC.
  2. Save your program to the SD card, B:, and your options too, since A: will be reformatted:
OPTION DISK SAVE "B:/myoptions.txt"
  1. Flash V7.00.00, then put the options back with OPTION DISK LOAD "B:/myoptions.txt" and check them with OPTION LIST. A file saved by V6.03.01 can bring a mouse sensitivity or touch calibration back wrong, so set those again if they're off.

This is the last time: from V7.00.00 on, a later firmware of the same build resets nothing unless its release notes say so. If you followed the release candidates, coming from RC9 every build keeps everything.

A few changes can make an existing program behave differently. Most are MMBasic now enforcing rules the manual has always given:

  • -2^2 is now -4, as in mathematics. Write (-2)^2 for the old answer.
  • /* and */ must start their line and be followed by a space, so write a banner as /* ***** rather than /*****.
  • Text after a SUB's bracketed arguments, as in MySub (a), b, is now an error instead of being silently dropped.
  • A label used twice, or a name longer than 31 characters, is now an error.
  • MATH RANDOMIZE now seeds the standard Mersenne Twister, so a given seed gives different numbers.

The changes document lists every one of them, with what to change. One limitation is known: on the RP2350, STEPPER arcs run faster than their feed rate away from the axes. Straight moves are not affected, and a fix will come in a later release.

Downloads and manuals

Everything is on the V7.00.00 release page:

  • The firmware: one .uf2 file for each of the 18 builds. Hold BOOTSEL, plug the Pico in and drag the file onto the drive that appears, or type UPDATE FIRMWARE, which is now in every build.
  • The User Manual, which covers everything in this release.
  • What has changed since V6.03.01, the full list of what's new, what's changed and what's fixed.
  • The supplementary manuals: 26 guides, among them the new MMBasic Performance Guide, which answers "how do I make it faster" with measurements, and the guides to sprites, tile maps, game input, Bluetooth and mmb2csub.
  • The help files for the HELP command, and mmb2csub in its own zip.

Please report problems on The Back Shed forum or as an issue on GitHub. The PicoMite page has more on the firmware and its source.

← All articles