Building MMBasic for the LuckFox Lyra on the PicoCalc

I have been working on getting MMBasic running on the PicoCalc with the Luckfox Lyra Linux build, and it has been going well.

I now have a working MMBasic binary running directly on the PicoCalc on top of Linux. This means the PicoCalc can run BASIC programs from the Linux side, while still keeping the normal Linux tools available underneath.

The base project I started from is MMB4L, “MMBasic for Linux,” by Thomas Hugo Williams (@thwill1000 on GitHub):

MMB4L turned out to be exactly the right foundation. It is already a very complete Linux version of MMBasic, so instead of starting from scratch, I used it as the core interpreter.

Because this work is specifically for the PicoCalc/Luckfox Lyra hardware, I did not want to fork MMB4L directly and turn it into a PicoCalc-only tree. Instead, the project uses MMB4L as a Git submodule. The PicoCalc/Luckfox work lives in the outer project as a patch queue. During the build, the patches are applied in order on top of upstream MMB4L.

Right now there are 17 patches. That may not sound like many, but some of them are substantial. The largest one is:

0009-auto-create-picocalc-display-surface.patch

It touches 28 files and has 54 hunks.

That patch is a big part of what makes PicoCalc graphics work naturally. PicoMite-style programs expect to be able to draw directly using commands like PIXEL, LINE, BOX, RBOX, TEXT, BLIT, IMAGE, SPRITE, and FRAMEBUFFER without first setting up a desktop-style graphics window. On the Luckfox PicoCalc build, the patched MMBasic automatically creates and selects the 320x320 PicoCalc display when graphics commands are used.

What works now:

  • MMBasic runs on the Luckfox Lyra PicoCalc Linux image.
  • The repo includes a prebuilt ARMv7 binary.
  • There is a no-build release ZIP, so users do not need to compile anything.
  • DirectFB framebuffer setup is documented and packaged.
  • PicoCalc display support is working through SDL2/DirectFB.
  • Graphics primitives work: PIXEL, LINE, BOX, RBOX, CIRCLE, ARC, TRIANGLE, POLYGON, TEXT, RGB, and CLS.
  • Image and sprite features are partially working: LOAD BMP, LOAD PNG, IMAGE RESIZE, IMAGE ROTATE, SAVE IMAGE, BLIT, SPRITE LOAD, SPRITE SHOW, SPRITE MOVE, and related commands.
  • FRAMEBUFFER CREATE and FRAMEBUFFER WRITE F are supported.
  • PRINT @(x,y) now draws positioned text on the PicoCalc screen.
  • MM.HRES and MM.VRES report the PicoCalc display size correctly.
  • MM.INFO(CALLTABLE) works for CSUB support.
  • Real CSUB code has been tested on the PicoCalc.
  • Basic WiFi/network inspection exists through Linux-backed MM.INFO values and WEB SCAN.
  • A target-side test runner is included so users can run health checks directly on the PicoCalc.

The project also includes documentation comparing MMB4L against the PicoMite/WebMite V6 language target. The goal is not just “make BASIC run,” but to keep moving toward the richest practical PicoMite-style MMBasic experience on the Linux-powered PicoCalc.

The install path is intended to be simple for users:

  1. Download the release ZIP.
  2. Copy it to the PicoCalc.
  3. Unzip it.
  4. Run the install script.
  5. Run mmbasic.

This is still a work in progress, but it is already far enough along to run real graphics demos, calculator-style text UI programs, Mandelbrot tests, framebuffer tests, and CSUB examples on the PicoCalc screen.

Take a look.

4 Likes

This looks fantastic! Can’t wait to try it out

Fascinating project!

I jumped in to test it right away.

I am running this within an X11 GUI environment. It appears that basic command execution launches an independent thread using the framebuffer for rendering. In my system, this framebuffer output is captured as a non-resizable window titled “Picocalc” (see attached). Consequently, commands like cls result in a blank window, but there is no way to return to the BASIC REPL afterwards.

When running in a console, it triggers a black screen that remains unresponsive. I have attempted to trigger a “Break” command without success (I am not sure if my custom keyboard mapping is interfering).

Adding a guide for keyboard shortcuts and general usage would be a great improvement.

Thank you again for your work!

What Linux are you using so I can look at what is going on. And yes it is a little rough right now.
I am not running any GUI desktop on my linux. only text mode and writing direct to the screen through directFB. It can “scale” but I am not sure that is ideal. looking at it.

I can run things like this. wondering if you can.

Bubble Universe MMBASICS

FRAMEBUFFER create
FRAMEBUFFER write f
Dim Float t,pf(15) ’ pf: 0=i 1=b 2=v 3=x 4=pi/2 5=xs 6=ys 7=xc 8=yc
Dim Integer c(65),d(65),n(65),m(32,65),nn
Dim Integer a,g,i,j,xc,yc,xs,ys
Dim Integer ct = MM.INFO(CALLTABLE)
Const r=(2Pi)/235,k=255,s=50
CLS RGB(black)
t=Rnd
10
nn=Peek(varaddr n())
'centre and scale factor
xc=MM.HRES\2:yc=MM.VRES\2
xs=MM.HRES/4.2:ys=MM.VRES/4.0 'Oval
pf(2)=0:pf(3)=0:pf(4)=Pi/2 ’ v=0, x=0, half-pi
pf(5)=xs:pf(6)=ys:pf(7)=xc:pf(8)=yc
For a=0 To 65
For g=0 To 65
If a<18 And g<18 Then
n(g)=RGB(0,255,0)
Else
n(g)=RGB(a3.93,g3.93,128*(a+g<65))
EndIf
Next 'g
’ Memory pack nn,Peek(varaddr m(0,a)),66,32
Next 'a
Do
CLS
Inc t,0.035:g=0:Print Timer:Timer=0
For i=60 To 255 Step 3
pf(0)=i:pf(1)=r*i+t
bubblerow c(),d(),pf(),ct ’ recurrence + scale + offset → c(),d()
’ Memory unpack Peek(varaddr m(0,g)),nn,66,32
Pixel c(),d(),n()
Inc g
Next 'i
FRAMEBUFFER copy f,n
Loop
CSUB bubblerow INTEGER, INTEGER, FLOAT, INTEGER
00000000
B5F0681B 001A0014 68123290 9201B09D 32A4001A 33886815 68123A04 9206681B
68229307 920C6863 68A2930D 920E68E3 6922930F 92026963 69A29303 920469E3
6A229305 92086A63 6AA29309 92106AE3 6B229311 92126B63 6BA29313 92146BE3
6C229315 92166C63 23009317 911B901A 9A029300 980C9B03 47A8990D 00069B01
4798000F 9B099A08 91039002 00390030 9B0147A8 9B014798 91199018 99059804
9A084798 900A9B09 9804910B 47A89905 47989B01 9B0B9A0A 000F0006 99039802
003247A8 900A003B 9818910B 47A89919 9B0F9A0E 91039002 990B980A 9A1047A8
90049B11 980A9105 9E06990B 9A1447B0 47A89B15 47989B07 9B1A9A00 189B9E06
60596018 9B139A12 99039802 9A1647B0 47A89B17 47989B07 9B1B9A00 6018189B
00136059 33082284 00929300 D1A04293 9A022000 21009B03 61636122 9B059A04
61E361A2 BDF0B01D
END CSUB

Fixed and pushed on main.

What changed:

  • Added patches/mmb4l/0018-keep-immediate-cls-on-console.patch.
  • Bare CLS at the interactive MMBasic prompt now clears the terminal when no graphics surface exists, instead of opening/blanking the PicoCalc graphics surface.
  • Program-mode CLS still creates/clears the PicoCalc graphics display, so PicoMite-style programs keep working.
  • Added [docs/picocalc-repl-usage.md](C:/Users/georg/Codex_Projects/mmbasic-4-luckfox-lyra/docs/picocalc-repl-usage.md) explaining REPL vs graphics window/framebuffer, CLS CONSOLE, GRAPHICS CLOSE 0, QUIT, Ctrl+C, and DirectFB settings.
  • Refreshed the compiled binary and release .tar.gz / .zip.
1 Like

I am runing ubuntu 24.04,when in console tty(cli mode),when only run cls command in the REPL prompt,you will get a blank screen (wich means the cls command works) but can not quit/back into REPL prompt like the Pico H did;

And in GUI mode X11 will take charge of the real framebuffer,and application try to use framebuffer will handle as a not resizable window.
some scripts will exit after running (means that you will back to BASIC prompt) ,but some seems not.

PicoCalc MMBasic on Luckfox Linux: Progress Update

I wanted to post an update on the MMBasic for PicoCalc/Luckfox Lyra Linux work.

The original goal was to get MMBasic running on the PicoCalc from the Linux side, using Thomas Hugo Williams’ MMB4L project as the base interpreter.

That is still the foundation. MMB4L is kept as a Git submodule, and the PicoCalc/Luckfox-specific work is applied as a patch queue on top of it.

Since the first post, the project has grown quite a bit.

The patch queue has gone from 17 patches to 29 patches. The newer work focuses on compatibility, graphics correctness, packaging, testing, and making old PicoMite-style BASIC programs easier to evaluate.

New since the first post:

  • Added a BASIC compatibility checker: mmb4l-check-basic.
  • Added packaged install bundles with the checker included.
  • Added a prebuilt ARMv7 mmbasic binary in the repo.
  • Added SHA256 checksums for release artifacts.
  • Added more PicoCalc target-side tests.
  • Improved mmb4l-run-tests reporting with pass/fail/skip totals.
  • Added documentation for the checker, patch queue, DirectFB setup, and install process.

The new checker is useful when trying old BASIC programs from different MMBasic variants. You can run:

mmb4l-check-basic somefile.bas

It scans the BASIC source and reports likely compatibility issues before you try to run it. It knows about things like unsupported commands, functions, CSUB blocks, audio no-ops, drive-letter usage, and Linux/PicoCalc platform differences.

It is not a replacement for actually running the program, but it is already useful for sorting programs into:

  • likely to run
  • likely to run with warnings
  • needs changes
  • uses unsupported platform features

A lot of the recent work has been around getting real programs to behave better on the PicoCalc screen.

Fixes and additions since the first post include:

  • CLS behavior was cleaned up so text-mode programs do not accidentally get treated like graphics-only programs.
  • PRINT @(x,y) positioned text was fixed.
  • Font metric aliases were added.
  • Text rendering issues were fixed.
  • PicoMite-style line continuation using _ was fixed.
  • MODE is now handled as a compatibility no-op when the program can otherwise continue.
  • BEEP is accepted as a no-op because audio is not currently supported.
  • DRIVE is accepted as a no-op because Linux does not use PicoMite-style drive letters.
  • FRAMEBUFFER CREATE and FRAMEBUFFER WRITE support was improved.
  • Page write/copy behavior was improved.
  • Pixel fill behavior was fixed.
  • Sprite page ID handling was fixed.
  • CSUB support through MM.INFO(CALLTABLE) was verified with real CSUB code.

Graphics support is also better now. PicoMite-style drawing commands such as PIXEL, LINE, BOX, RBOX, CIRCLE, ARC, TRIANGLE, POLYGON, TEXT, RGB, CLS, BLIT, IMAGE, SPRITE, and framebuffer commands are working much more naturally on the PicoCalc display.

DirectFB setup has also been cleaned up. The project now documents the needed /etc/directfbrc settings, including quieting the DirectFB banner/debug output so it does not fill the BASIC console with noise.

The install package is intended to be simple:

  • download the release ZIP or TAR
  • copy it to the PicoCalc
  • unpack it
  • run the install script
  • run mmbasic

The package includes the binary, install script, DirectFB config, checker, tests, and checksums.

One important limitation: the current target is the PicoCalc running in normal Linux text/console mode, or launched over SSH/ADB while using the PicoCalc framebuffer. Running under a GUI/X11 desktop environment is not the main supported path right now. It may work differently depending on framebuffer access, keyboard handling, DirectFB behavior, permissions, and how the desktop environment captures display output.

So for now, I would say this is best supported as a non-GUI Linux/PicoCalc framebuffer build. Your mileage may vary if you run it from a graphical desktop environment instead of the PicoCalc console/text setup.

Networking is also being handled carefully. Linux remains in charge of WiFi configuration and connection management. The MMBasic side can inspect some network state and has some web/network compatibility work, but things like access point setup, Telnet, TFTP, MQTT, and NTP management are not the current focus. For now, Linux tools should handle those jobs.

The project can now run real graphics demos, calculator-style text UI programs, Mandelbrot tests, framebuffer tests, CSUB examples, and a growing set of older MMBasic programs.

There is still work to do, but this has moved from “MMBasic starts” to a much more usable PicoCalc/Linux BASIC environment.

Project repo:

1 Like