Skip to content

BasicPlus v5.0 — los datos

Choose a tag to compare

@legio-e legio-e released this 22 Aug 15:05
· 1723 commits to main since this release

Español · English below ↓

BasicPlus v5.0 — «los datos»

V4 arregló los cimientos. V5 va de lo que un microcontrolador no sabía hacer todavía:
guardar datos de verdad.
Una tarjeta SD con gigabytes, una base de datos SQLite
corriendo dentro del micro, un ORM que escribe el SQL por ti, y los packs, que son lo
que hace posible meter algo tan grande como SQLite sin que lo pague quien no lo usa.

Y lo de siempre, que no cambia: el mismo bytecode corre byte-idéntico en el PC y en el
micro
.

Lo nuevo

  • Tarjeta SD. Un micro con tarjeta deja de estar limitado a los pocos megas de su
    flash, y se usa sin aprender nada: es una ruta más (writeFile("/sd/medidas.csv", …)).
    La monta el firmware al arrancar, y los pines se declaran en el entorno de la placa, no
    en el código. Debajo hay FatFs, así que la tarjeta se saca y se lee en el PC.
  • SQLite dentro del micro. El motor de verdad, la versión 3.53.4. El mismo fichero
    .db y el mismo código en el PC y en la placa. Se pueden anidar consultas sobre una
    sola conexión, cosa que sorprende a quien viene de JDBC.
  • Un ORM. Anotas la clase con @BD y el compilador genera el DAO: insert, update,
    delete, loadById, list… sin escribir SQL. Las condiciones se construyen con
    Where, que escapa los valores. Y si el proyecto declara su base de datos, el
    compilador contrasta tus entidades con el esquema real y avisa de lo que no cuadra —
    avisos, nunca errores.
  • Packs. Un contenedor que se graba en la placa con módulos, recursos y, si hace falta,
    código nativo. Lo importante no es que ahorren flash sino RAM: un módulo que vive en
    un pack se ejecuta desde la flash, en el sitio, en vez de cargarse entero en memoria.
    En una placa con unos cientos de kilobytes, eso es la diferencia entre que una librería
    quepa o no quepa.
  • El lenguaje. List y sus parientes ya no las sintetiza el compilador: están
    escritas en BasicPlus, en Core, junto a los envoltorios (Integer, Long, Double,
    Float, Boolean) y Comparable. Los nuevos captadores tipados (getInteger,
    getLong, getDouble…) no castean: convierten y protegen — un long que no cabe en
    un integer lanza en vez de recortar en silencio.
  • Código nativo. Las funciones native aceptan ahora long. Y dividir por cero
    desde código nativo lanza un error atrapable
    en vez de reiniciar la placa, que es lo que
    convierte native en algo que se puede usar sin miedo.
  • Diagnóstico. El log post-mortem sobrevive al reinicio: vive en una zona de RAM que
    el arranque no borra, así que la autopsia trae las líneas de antes del cuelgue.

⚠️ Al actualizar desde V4 — un paso obligatorio

Borra /lib y /app de la placa, y reflashea el firmware (la stdlib va embebida en la
imagen). El firmware repone lo suyo al arrancar.

La stdlib de V5 cambió —Object sustituyó a any como raíz—, así que un módulo de V4 que
sobreviva en la placa tapa al nuevo, y el síntoma es un error al ejecutar del estilo
exit 11 (lib 'Core' presente pero no exporta …; ¿version vieja?). Son las dos carpetas
y no sólo /lib, porque el IDE deja en /app las dependencias del programa y lo que hay
ahí tiene preferencia.

Descarga

Un solo fichero: BasicPlus-5.0-win.zip (Windows; requiere JDK 8+). Dentro va todo —
IDE, compilador, librería estándar, ejemplos, documentación, el micro simulado y las cinco
imágenes de firmware. Se descomprime y funciona; no hay instalador.

Las imágenes están en la carpeta firmware/, con su SHA256SUMS.txt al lado:

Imagen Placas
bpvm_pico.uf2 Raspberry Pi Pico 2 y Adafruit Metro RP2350 (BOOTSEL + copiar)
bpvm_esp32_merged.bin ESP32-S3 (esptool write_flash 0x0 …)
bpvm_esp32p4_merged.bin ESP32-P4-Function-EV y Waveshare ESP32-P4
bpvm_stm32_nucleo.bin STM32 Nucleo-U575ZI-Q (ST-LINK / CubeProgrammer)
bpvm_stm32_dk2.bin STM32U5G9J-DK2, con pantalla (ST-LINK / CubeProgrammer)
093789a60badf4d28a0a3bb43f2ab05f6bd26761c9b0c8135c6cfd4841e2a5f9  BasicPlus-5.0-win.zip

Documentación

Limitaciones conocidas

Dicho sin adornos, porque conviene saberlo antes de empezar:

  • Las bases de datos necesitan placa. El motor va en un pack de código nativo y todavía
    no hay uno para PC, así que un programa con SQLite no se puede probar en el PC.
  • La tarjeta SD no llega al STM32 todavía. Y exFAT no está soportado: formatea las
    tarjetas en FAT32.
  • El ESP32-S3 no tiene AOT: sus funciones native corren interpretadas — el AOT emite
    ARM y RISC-V, no Xtensa. El IDE lo avisa y el programa funciona igual, sólo que sin
    acelerar. El S3 tampoco expone packs; el resto de placas sí.
  • listDir no está en la VM-C: un programa puede listar un directorio en el PC pero no
    en la placa. Es el único verbo de fichero que falta.
  • La sustitución entre interfaces de módulo (un impl de LogApiV2 donde se pide
    LogApi) no funciona todavía.
  • Tras un Stop puede desincronizarse la comunicación y hay que reconectar. Sólo en
    algunas placas (bien en STM32, intermitente en P4).
  • loadFont no puede decir que ha fallado: devuelve un identificador válido siempre.
  • Gui.setRotation no rota en la STM32 Discovery: el evento se dispara y el modelo gira,
    pero el panel no.
  • Sin driver WS2812 fuera del RP2350 — lo dice en vez de pasar en verde sin encender
    nada.

BasicPlus v5.0 — "the data"

Español arriba ↑

V4 fixed the foundations. V5 is about what a microcontroller still could not do: really
store data.
An SD card with gigabytes, a SQLite database running inside the micro, an ORM
that writes the SQL for you, and packs, which are what makes it possible to fit
something as large as SQLite without charging those who never use it.

And the usual thing, which does not change: the same bytecode runs byte-identical on the
PC and on the micro
.

What's new

  • SD card. A micro with a card is no longer limited to the few megabytes of its flash,
    and there is nothing new to learn: it is just another path
    (writeFile("/sd/readings.csv", …)). The firmware mounts it at boot, and the pins are
    declared in the board environment, not in the code. Underneath is FatFs, so you can
    pull the card out and read it on a PC.
  • SQLite inside the micro. The real engine, version 3.53.4. The same .db file and the
    same code on the PC and on the board. You can nest queries on a single connection,
    which surprises people coming from JDBC.
  • An ORM. Annotate the class with @BD and the compiler generates the DAO: insert,
    update, delete, loadById, list… without writing SQL. Conditions are built with
    Where, which escapes values. And if the project declares its database, the compiler
    checks your entities against the real schema and reports what does not match — as
    warnings, never errors.
  • Packs. A container burned onto the board holding modules, resources and, if needed,
    native code. What matters is not saving flash but RAM: a module living in a pack
    runs in place, from flash, instead of being loaded whole into memory. On a board with
    a few hundred kilobytes, that is the difference between a library fitting or not.
  • The language. List and its relatives are no longer synthesised by the compiler:
    they are written in BasicPlus, in Core, alongside the wrappers (Integer, Long,
    Double, Float, Boolean) and Comparable. The new typed getters (getInteger,
    getLong, getDouble…) do not cast: they convert and protect — a long that does
    not fit an integer throws instead of silently truncating.
  • Native code. native functions now accept long. And dividing by zero from
    native code throws a catchable error
    instead of rebooting the board, which is what makes
    native usable without fear.
  • Diagnostics. The post-mortem log survives a reboot: it lives in a RAM area the boot
    does not clear, so the autopsy carries the lines from before the hang.

⚠️ Upgrading from V4 — one mandatory step

Delete /lib and /app from the board, and reflash the firmware (the stdlib is embedded
in the image). The firmware restores its own files at boot.

The V5 stdlib changed —Object replaced any as the root— so a V4 module surviving on the
board shadows the new one, and the symptom is a runtime error like
exit 11 (lib 'Core' present but does not export …; old version?). It is both folders and
not just /lib, because the IDE leaves the program's dependencies in /app and what is
there takes precedence.

Download

A single file: BasicPlus-5.0-win.zip (Windows; requires JDK 8+). Everything is inside —
IDE, compiler, standard library, examples, documentation, the simulated micro and the five
firmware images. Unzip and run; there is no installer.

The images are in the firmware/ folder, with their SHA256SUMS.txt next to them:

Image Boards
bpvm_pico.uf2 Raspberry Pi Pico 2 and Adafruit Metro RP2350 (BOOTSEL + copy)
bpvm_esp32_merged.bin ESP32-S3 (esptool write_flash 0x0 …)
bpvm_esp32p4_merged.bin ESP32-P4-Function-EV and Waveshare ESP32-P4
bpvm_stm32_nucleo.bin STM32 Nucleo-U575ZI-Q (ST-LINK / CubeProgrammer)
bpvm_stm32_dk2.bin STM32U5G9J-DK2, with display (ST-LINK / CubeProgrammer)
093789a60badf4d28a0a3bb43f2ab05f6bd26761c9b0c8135c6cfd4841e2a5f9  BasicPlus-5.0-win.zip

Documentation

Known limitations

Stated plainly, because it is worth knowing before you start:

  • Databases need a board. The engine ships in a native-code pack and there is no PC one
    yet, so a program using SQLite cannot be tested on the PC.
  • The SD card does not reach STM32 yet. And exFAT is not supported: format cards as
    FAT32.
  • The ESP32-S3 has no AOT: its native functions run interpreted — the AOT emits ARM and
    RISC-V, not Xtensa. The IDE says so and the program works the same, just without the
    speed-up. The S3 does not expose packs either; every other board does.
  • listDir is not in the C VM: a program can list a directory on the PC but not on the
    board. It is the only file verb missing.
  • Substitution between module interfaces (an impl of LogApiV2 where LogApi is asked
    for) does not work yet.
  • Communication can desynchronise after a Stop and you have to reconnect. Only on some
    boards (fine on STM32, intermittent on P4).
  • loadFont cannot report failure: it always returns a valid identifier.
  • Gui.setRotation does not rotate on the STM32 Discovery: the event fires and the model
    turns, but the panel does not.
  • No WS2812 driver outside the RP2350 — it says so instead of passing green without
    lighting anything.