Repository navigation
BasicPlus v8.0
Español · English below ↓
BasicPlus v8.0
En esta versión hemos añadido el soporte de la WiFi y el Bluetooth a la familia de micros ESP32: a las placas con
PSRAM, la S3, la C5 y la P4 de Waveshare, que lleva la radio en su ESP32-C6. La placa se conecta sola a la red al
arrancar, y el IDE trabaja con ella sin cable: sube los ficheros, graba los packs y ejecuta los programas. Del
Bluetooth hemos hecho, de momento, lo que más falta hacía en una placa: el teclado y el ratón. Las dos radios están
apagadas de normal, y se apagan solas tras diez minutos sin uso.
También hemos añadido un nuevo lenguaje, JC, una mezcla de Java y C# con algunas limitaciones, para facilitar el
desarrollo de aplicaciones a los programadores que trabajan habitualmente con esos lenguajes. No hemos pretendido
hacer ni un Java ni un C#, y las librerías no son las de esos lenguajes sino las nuestras. Por dentro es el mismo
lenguaje que BasicPlus, con el mismo compilador y el mismo bytecode, y un programa se traduce de uno a otro con una
orden del IDE.
Con el fin de verificar el compilador y la máquina virtual, hemos aprovechado la batería de pruebas de C# de Mono y
hemos intentado traducirlas, compilarlas y ejecutarlas. De las 2 322 pruebas funcionan 848; el resto no se pueden
traducir por las limitaciones del lenguaje. En general el resultado ha sido muy positivo: han aparecido algunos bugs,
que hemos corregido, y hemos aprovechado para ampliar un poco el lenguaje, tanto BP como JC: algunos operadores (*=,
/=, mod=… y el ternario iif), las interfaces —una clase puede implementar varias: la herencia múltiple de tipos,
no de código— y los genéricos, principalmente. Esas 848 pruebas se quedan como una prueba más de los dos lenguajes, de
caja negra.
También hemos aprovechado para arreglar algunas cosas que teníamos pendientes de la versión 7, y pequeñas cosas que
han ido apareciendo durante el desarrollo de esta versión.
Hemos optimizado y mejorado las operaciones con cadenas, que eran lentas: en la Pico 2, por ejemplo, recorrer una
cadena de 2 KB ha pasado de 535 a 20 ms.
Y hemos puesto a prueba la fiabilidad: cuatro placas, 48 horas seguidas con un programa que lo toca todo, sin un error
ni un reinicio. El objetivo de la prueba era sobre todo que no hubiera una merma de recursos, como la memoria, que con
el tiempo pudiera hacer que un micro se bloquease o se reiniciase. La prueba encontró dos fallos de verdad, que ya
están arreglados. Una página nueva de la documentación cuenta todas las pruebas que pasa BasicPlus.
Para terminar, hemos añadido una imagen para el ESP32-P4X, la nueva revisión del P4, que corrige errores del
silicio. Es casi idéntica a la del ESP32-P4, pero una imagen del P4 no corre en el P4X ni al revés, así que tenemos
una imagen para cada uno de los micros. Con su reloj, 400 MHz frente a 360, los programas tardan entre un 8 y un 10 %
menos.
Poco a poco el proyecto va entrando en su madurez, así que los cambios ya no son tan drásticos, y nos centramos más en
ampliar las librerías y el soporte de más micros.
Lo que no cambia es el invariante de siempre: el mismo bytecode, la misma salida byte a byte en las dos VMs, y todo
verificado en placa.
Lo nuevo
- La WiFi, en la P4 de Waveshare, la S3 y la C5. La placa se conecta sola al arrancar —por DHCP o con IP fija—
y el IDE trabaja con ella por la red como por el cable (Placa (red), o Buscar en la red): los ficheros, los
packs, Run con su salida, el Stop, el log; también con un programa ya en marcha. En la P4, subir 1 MB tarda 16 s
(por la UART, unos 95), y grabarGui,SQLiteyStdlib, 14 s en vez de más de dos minutos. Se configura en
/sys/wifi.json, que escribe el botón WiFi del IDE. Y desde un programa, el módulo nuevoAirla enciende y
la apaga, yNetabre conexiones TCP como cliente, ya también en las placas. - El teclado y el ratón Bluetooth LE, en la P4 de Waveshare, la C5 y la S3: se emparejan una vez y vuelven
solos. En un programa con pantalla funcionan sin escribir nada, también en los de V7 —la flecha y el clic, la rueda
en las listas, el teclado en el campo con el foco—; desde el código, los módulos nuevosKeyboardsyMice, y
Air.Bluetoothpara buscar, conectar y olvidar aparatos. En el PC, un Bluetooth simulado, igual en las dos VMs y
en el micro simulado del IDE, con un «Teclado simulado» y un «Ratón simulado». - JC, BasicPlus con llaves, punto y coma y el tipo delante del nombre: el mismo compilador lee los
.bpy los
.jc, y el mismo programa, escrito en BP o en JC, da el mismo.modbyte a byte. El IDE los abre, compila,
ejecuta y depura, en el PC y en la placa, y los traduce (Edit → Traducir a JC / Traducir a BP), como el
compilador (--escribir-jc,--escribir-bp); y un módulo en JC importa los de BP, y se mezclan en un proyecto.
Y C# como banco de pruebas: un traductor de C# a JC (compat/csharp/cs2jc) pasó por JC las pruebas del
compilador de C# de Mono, y lo que pedían y tenía sentido para BasicPlus entró en los dos lenguajes (abajo). - El sonido: el módulo
Soundreproduce un WAV en paralelo —playvuelve en seguida y el programa sigue—, con
el volumen y el progreso. Suena en la P4 de Waveshare, por su códec ES8311, con la líneaaudio=del Entorno; y en
el PC, en las dos VMs. - Una placa más, la ESP32-P4X (
#846): son nueve imágenes y once placas. La P4X es la revisión v3.x de la
P4, que corrige errores del silicio de la v1.x y con el tiempo la sustituirá. El IDF no deja que una imagen sirva
para las dos revisiones, así que tiene la suya, del mismo código; con la CPU a 400 MHz, los programas tardan entre
un 8 y un 10 % menos que en la P4 de Waveshare. Probada en el kit ESP32-P4X-Function-EV, con la tanda de V8 y la
GUI en su panel de 7", táctil incluido. - En las demás placas: la familia ESP32, al ESP-IDF 6.1; la S3 dice la frecuencia a la que va —160 MHz; decía
240— y sube a 240 concpu.mhzen el Entorno, y con sus cachés al máximo las cadenas tardan del 18 al 27 % menos;
Machine.tempC()lee el sensor de las ESP32, que en V7 daba 0; la C3 pasa de 48 a 96 KB de heap, y la C6, de 61
a 112; la imagen de la RP2350 lleva dos firmwares, y conpsram=1la Metro arranca el que pone lo más usado en la
SRAM —las cadenas, del 25 al 31 % menos— y ya llena sus 6 MB de heap; y las STM32 ya no copian la memoria byte a
byte: ungc()en la Nucleo, de 2,13 a 0,94 ms. - La robustez en el campo. La prueba de resistencia —48 horas en cuatro placas, 61 360 vueltas, sin un error ni
un reinicio— encontró dos fallos de verdad, ya arreglados: elMutexde cadaCollections.Mapno se soltaba
hasta el final del RUN (#831), y un número en una global podía retener un objeto horas, partiendo el heap
(#833). Y de la tabla de la robustez —dieciséis situaciones, del programa sin memoria al corte de corriente—
salieron cinco arreglos: con el log apagado, los avisos urgentes de la VM llegan al log igual; las ESP32 apuntan la
causa de cada reinicio; las STM32 se reinician solas tras un fallo fatal, en vez de quedarse paradas; un RESET con
un programa que no para se sirve a los 2 s; yWdtcon dos runs ya no reinicia una placa sana. - Las cadenas, mucho más rápidas: recorrerlas por índice, compararlas o llenar un
Mapcon muchas claves ya no
tiene un coste cuadrático. En la Pico 2, recorrer una cadena de 2 KB pasa de 535 a 20 ms; un==entre dos de
2 KB, de 22,8 ms a 68 µs; y un JSON de 8 KB, de 16,7 a 2,5 s. Y un string es un invariante:moveya no escribe
dentro de una cadena, y el texto de fuera que no es UTF-8 válido lanzaEncodingErroro, si se pide, se
descodifica con «�». - El lenguaje, en BP y en JC: las interfaces, la herencia múltiple de tipos, no de código; los genéricos, una
orden al compilador:List<Sensor>comprueba lo que entra y convierte lo que sale, y la VM no se entera;x[i]
sobre un objeto, que esx.get(i); los errores de la VM con su tipo —ArithmeticError,NullReferenceError,
IndexError,CastErroreIOError—, clases hijas deRuntimeError;*=,/=,mod=… y el ternarioiif;
los parámetrosvar; los bucles con nombre; y una variablestringpuede valernull, como en C# (#774). - La biblioteca: cinco módulos nuevos,
Air,Keyboards,Mice,SoundyOverlays. Con
Overlays.Overlay, un programa carga otro, lo ejecuta y lo descarga: lo que se usa poco sólo ocupa memoria
mientras corre, como los overlays de MS-DOS. YJson.parseJsonda todos los errores de una vez;/dataes la
carpeta de los datos de los programas, cada uno en la suya; y en las ESP32,Machine.setCpuFreqMHzfunciona. - El código nativo: una
nativeda lo mismo que interpretada cuando un entero da la vuelta, y al dividir por
cero lanza, como interpretada; convertir una referencia dentro de una es un error de compilación, en vez de
construir un objeto sin decir nada; y recorre una cadena por índice en un tiempo lineal. La ABI no cambia: los
.mdnsiguen en la 9. - La interfaz gráfica: el teclado y el ratón Bluetooth, en la P4 de Waveshare y la C5 (arriba), y
scr.onKey; en el PC, la
ventana gira con la pantalla; y en la C5, con la WiFi y el Bluetooth encendidos, la pantalla ya no deja de
refrescarse. Los packs de la GUI están rehechos: el driver de la pantalla podía quedar grabado encima del final del
motor de LVGL. - El IDE: la placa por la red y JC (arriba). Un error en la placa dice dónde (
#582): trae su cadena de
llamadas, y el IDE la traduce a fichero y línea («en Sensor.bp:42»); en V7 sólo salía el mensaje. Y un programa a
la vez; el Stop y el Run dicen qué pasó en la placa; y las dos VMs del PC tienen su flash, una carpeta que hace de
/de la placa. - La ejecución y la memoria: las pilas de los hilos salen del heap, y la VM mira la pila antes de cada
instrucción: lo que en V7 podía escribir fuera de su pila sin aviso es ahora un «desbordamiento de pila». Los
huecos libres van en 48 listas por tamaño: con 4 000 huecos, diezgc()pasan en la Metro de 11,9 s a 0,64. Y
frente a V7, en la Metro,AllocBenchtarda un 38 % menos yPrintBench, la mitad; el cálculo puro, entre un 2 y
un 7 % más. - Probado, en el PC y en placa: la red de paridad dual-VM, de 149 a 217 casos; 117 pruebas de C de la VM (en
V7, 102), las más delicadas con su sabotaje —un interruptor que deshace el arreglo, para ver que la prueba se pone
en rojo—; 404 pruebas del compilador, y 39 programas que tienen que fallar, con 151 comprobaciones; los ejemplos de
la documentación —377 fragmentos de BP y 78 módulos de JC—, compilados; las 848 pruebas de Mono que funcionan, la
caja negra de los dos lenguajes; y en las placas, la tanda de V8, 24 pruebas, en las once —las nueve del lote
final, la P4X y la P4 del kit—, con las imágenes que se publican. Todo, en una página nueva: «Cómo se prueba
BasicPlus». - Y bugs de V7 corregidos: con dos runs, un «No space in heap» falso;
<y>entre dos cadenas daban basura,
distinta en cada VM;a[f()] += 5llamaba dos veces af();super.propiba a la property de la hija; un método
privado llamado sobrenullcorría conthisnulo; el mismo programa podía dar otro.moden otra compilación; y
más — el detalle, en las notas de versión.
⚠️ Al actualizar desde V7
Graba la imagen de V8 antes que nada, y después la stdlib y los packs de V8. El .mod sigue en MOD9 y el código
nativo en la ABI 9, pero lo compilado con V8 —tus programas y la stdlib del Stdlib.pack— usa funciones de la VM que
una imagen de V7 no tiene; y los packs de la GUI y el de SQLite están rehechos. Lo más limpio, en el panel de Packs:
Formatear zona…, y grabar los de V8. En la RP2350, graba siempre el bpvm_pico.uf2 entero: lleva los dos
firmwares, P y M.
La S3 y la C5: la flash, borrada entera, una vez. Su aplicación pasa de 1 a 2 MB para la WiFi, y la tabla de
particiones nueva pide borrar la flash: se pierden el Entorno, el sistema de ficheros y los packs de la placa. Baja
antes lo que quieras conservar; después, graba la imagen de V8 y vuelve a aprovisionarla: las particiones (la C5 se
reparte sola), el Entorno, los packs y tus programas.
La P4 de Waveshare, para la WiFi y el Bluetooth: su C6 necesita el firmware ESP-Hosted 3.0.9 —el de fábrica no
vale para la WiFi—. Va en el ZIP (firmware/p4_c6_esp_hosted_3.0.9_merged.bin) y se graba por el conector P1 de la
placa, con un adaptador USB-serie: hay que soldar los pines del conector y, antes, guardar una copia del firmware de
fábrica. Y en su Entorno, radio=c6 —sin esa línea, ni WiFi ni Bluetooth— y, para el sonido, la línea audio=….
Todo, en INSTALAR_FIRMWARE.md, «La WiFi y el Bluetooth
de la Waveshare».
Recompila los .mod. Un .mod de V7 carga (comprobado en el PC), pero con la VM de V8 debajo: un campo, una
property o una global string sin valor es para él null, y se para con «referencia nula: strlen de un string null»
si llega a un builtin (recompilado, nace ""); y lo que lee texto de fuera ya es estricto, recompilado o no. El IDE
recompila en cada Run; lo que hay que mirar es lo que quedó en /app, sobre todo el programa del autorun. Y
recompila las natives para tener los arreglos del AOT: un .mdn ya compilado sigue como estaba.
Revisa el Entorno. stack= pide ahora sólo la pila del main, no la región de todos los hilos: una línea de V7
le quita heap a la placa —en la Pico 2, stack=90 le quitaba 74 KB—; quítala si no la necesitas. En una placa sin
PSRAM, un programa que no arranca por «no hay memoria del sistema (malloc)…» se arregla con un vmheap= menor. Y lo
nuevo: wifi= y bt= (encender la radio al arrancar), radio=c6 y audio= (la P4 de Waveshare), cpu.mhz= (las ESP32) e
imagen=P (la RP2350).
Lo que rompe fuentes de V7 — el compilador lo dice en cada caso:
- Lo protegido de otra clase, leído por una referencia del padre: desde
B, lo protegido se usa sobre unBo una
hija suya; sobre un objeto que sólo es unA, por su getter. - Una sobrecarga
privateo protegida, llamada desde fuera; y alguna llamada con sobrecargas que, con la regla de
Java, pasa a ser ambigua (el error dice cómo elegir). - Una conversión de referencia dentro de una
native(Perro(a)): se hace fuera. - Una función que se llame
iif, que es el ternario; y un valor por defecto del argumento demainde más de 127
bytes.
Lo que cambia sin que el compilador avise:
print x;, con;al final, ya no salta de línea; y elcontinuede undo … loop cva a la condición: si ya no
se cumple, el bucle acaba.movesobre una cadena lanza;parseIntyparseFloatlanzan con un texto que no es un número limpio, y
charCodeAtfuera de rango, también en la placa; y el texto de fuera que no es UTF-8 válido lanzaEncodingError:
un fichero en Latin-1 necesita el indicador,readFile(ruta, true).- Un
stringsin valor es""; los compuestos sobre unbyteo unint16dan la vuelta (b += 1con 255 da 0); y
super.propva a la property del padre. List.get,setyremove, fuera del tamaño de la lista, lanzan;Json.parseJsonlanza unAggregateErrorcon
todos los errores, y un entero que no cabe en 32 bits ya es un error; una referencia caducada que llega a un
builtin, y elthrowde unnull, lanzanNullReferenceError;IO.rmdireIO.removeFilesólo borran lo suyo;
ysleep(0)cede el turno también en la VM-C.- En las placas: la S3 dice 160 MHz, lo que va de verdad; las STM32, tras un fallo fatal, se reinician y arrancan sin
autorun; y un RESET con un programa que no para reinicia la placa a los 2 s. - En el IDE, un programa a la vez; en el PC, una ruta absoluta va a la flash del PC
(%USERPROFILE%\.basicplus\flash), no a la raíz del disco; y en la VM-Java, sin el «Teclado simulado» conectado,
la GUI no recibe el teclado del PC.
Lo que no rompe: catch e: RuntimeError sigue atrapando todos los errores de la VM, que ahora son sus hijas; el
.mod sigue en MOD9 y el nativo en la ABI 9 (un .mdn de V7 está hecho para cargar en la imagen de V8, pero no lo
hemos probado: mejor recompilarlo); las VMs de V8 siguen ejecutando los 59 .mod de V6 de la cápsula, y sólo uno
cambia, por el string sin valor; e import Core, escrito, sigue compilando.
Descarga
Un solo fichero: BasicPlus-8.0-win.zip (Windows; requiere JDK 8+). Dentro va todo — IDE, compilador, librería
estándar, los cinco packs, ejemplos (y el de JC, en samplesJC/), documentación en español y en inglés —con los
dos volúmenes nuevos, JC y las pruebas—, el micro simulado (con LVGL, y la WiFi y el Bluetooth simulados) y las
nueve imágenes de firmware. Se descomprime y funciona; no hay instalador.
Las imágenes están en firmware/, con su SHA256SUMS.txt al lado y las plantillas de board.json del RP2350 en
firmware/boards/; los packs, en packs/:
| Imagen | Placas |
|---|---|
bpvm_pico.uf2 |
Raspberry Pi Pico 2 y Adafruit Metro RP2350 (BOOTSEL + copiar), con sus dos firmwares, P y M |
bpvm_esp32_merged.bin |
ESP32-S3 (esptool write-flash 0x0 …) |
bpvm_esp32c3_merged.bin |
ESP32-C3 |
bpvm_esp32c5_merged.bin |
Waveshare ESP32-C5-Touch-LCD-2.8 |
bpvm_esp32c6_merged.bin |
ESP32-C6 y Waveshare ESP32-C6-LCD-1.3 |
bpvm_esp32p4_merged.bin |
ESP32-P4-Function-EV y Waveshare ESP32-P4 (display=st7701 en el Entorno) |
bpvm_esp32p4x_merged.bin |
ESP32-P4X-Function-EV, la P4 de la revisión v3.x (por su USB-Serial-JTAG) — nueva |
bpvm_stm32_nucleo.bin |
STM32 Nucleo-U575ZI-Q (ST-LINK / CubeProgrammer) |
bpvm_stm32_dk2.bin |
STM32U5G9J-DK2, con pantalla (ST-LINK / CubeProgrammer) |
Y junto a ellas, p4_c6_esp_hosted_3.0.9_merged.bin: el firmware de la C6 de la P4 de Waveshare, el coprocesador
ESP-Hosted 3.0.9, de Espressif, para su WiFi y su Bluetooth.
c6648f465716bb04d1e49f0ab1bdedae3d54f97c3a4c11d109b6b68a95adf421 BasicPlus-8.0-win.zip
Documentación
- Documentación completa: https://legio-e.github.io/BasicPlus/
- JC, BasicPlus con llaves (nuevo): https://legio-e.github.io/BasicPlus/jc.html
- Cómo se prueba BasicPlus (nuevo): https://legio-e.github.io/BasicPlus/pruebas.html
- Documentation (English): https://legio-e.github.io/BasicPlus/en/
Limitaciones conocidas
- No hay bajo consumo: el micro nunca duerme, y un programa a batería no puede ahorrar hoy; pasa entero a V9.
Lo que sí hay: las radios, apagadas de normal y apagadas solas sin uso. - La WiFi, sólo en la P4 de Waveshare, la S3 y la C5 (en los kits de Espressif, el de la P4 y el de la P4X, sin
probar); no en la C3, la C6, las STM32 ni la Pico 2 W. Y sólo de cliente: no hay servidor (listen/accept), ni
UDP, ni TLS, ni la placa como punto de acceso, ni la hora por NTP. La clave de la red va en claro, en
/sys/wifi.json. - El Bluetooth: sólo el teclado y el ratón BLE, con la distribución americana; el programa de configuración, a
V9. El sonido: WAV, en la P4 de Waveshare y el PC; la C5, a V9; el MP3, fuera. - Un fallo fatal de la VM tumba la placa: se reinicia y arranca sin autorun. Contenerlo en el run que lo tiene, y
el informe del pánico de las ESP32 en el log, a V9. - La imagen de dos núcleos de la RP2350 sigue siendo más lenta con un solo hilo (
#665, a V9): en la Pico 2,
PrintBenchtarda 1 321 ms frente a 745 con la de un núcleo, y el cálculo (fib(26)), un 7,7 % más; en la Metro,
el cálculo, un 3,5 % (en V7, un 35 %). Con dos hilos, la de dos núcleos gana: ×1,68 en la Pico 2 y ×1,75 en la Metro. - Dentro de una
native, un error no dice su línea, sino la de quien la llamó: para verla, quítalenative. - El depurador no despliega los objetos, y en las placas de dos núcleos va con un solo run.
- JC no tiene lo que BP no tiene —las lambdas, los delegados, los
struct, los genéricos propios con<T>…—;
los comentarios no viajan al traducir; un módulo en JC que otro importa hay que compilarlo antes; y los mensajes del
compilador hablan en BP (integer,boolean). - La S3 no tiene AOT (Xtensa), y un
.modlleva el nativo de una sola familia: el multifamilia, a V9.
Y el AOT no mira los packs: unanativede un módulo que importaSQLitecorre interpretada, con un aviso. - La C3 va justa de memoria, con sus 96 KB de heap. Las STM32: su
Wdtlanza (el IWDG no se puede parar) y
no tienen niNeopixelni SD. - Con un run, un
Uart.readque espera para a los demás hilos (el rodeo:available()ysleep); los streams
y los dispositivos son el tema de V9. input()sólo funciona en la VM Java.- La P4 se colgó una vez en
GuiShot, en el lote final (#825): no se repite —200 parejas y 500 capturas
seguidas— y queda apuntado por si vuelve. - La lista completa, en PENDIENTES.md.
BasicPlus v8.0 (English)
In this version we have added WiFi and Bluetooth support to the ESP32 family of micros: to the boards with PSRAM, the
S3, the C5 and the Waveshare P4, which carries its radio in its ESP32-C6. The board joins the network by itself at
boot, and the IDE works with it without a cable: it uploads the files, burns the packs and runs the programs. From
Bluetooth we have done, for now, what a board needed most: the keyboard and the mouse. Both radios are off by
default, and switch themselves off after ten minutes unused.
We have also added a new language, JC, a mix of Java and C# with some limitations, to make application
development easier for programmers who usually work with those languages. We have not tried to make either a Java or
a C#, and the libraries are not theirs but our own. Inside it is the same language as BasicPlus, with the same
compiler and the same bytecode, and a program is translated from one to the other with a single IDE command.
To verify the compiler and the virtual machine, we took Mono's C# test suite and tried to translate, compile and run
its tests. Of the 2,322 tests, 848 work; the rest cannot be translated because of the language's limitations. On the
whole the result has been very positive: a few bugs turned up, which we have fixed, and we took the opportunity to
extend the language a little, both BP and JC: some operators (*=, /=, mod=… and the ternary iif), interfaces
—a class can implement several: multiple inheritance of types, not of code— and generics, mainly. Those 848 tests
stay on as one more test of both languages, a black-box one.
We have also taken the opportunity to fix some things we had pending from version 7, and small things that came up
during the development of this version.
We have optimized and improved string operations, which were slow: on the Pico 2, for example, walking a 2 KB string
has gone from 535 to 20 ms.
And we have put reliability to the test: four boards, 48 hours in a row with a program that touches everything,
without a single error or restart. Above all, the aim of the test was to make sure there was no loss of resources,
such as memory, that over time could make a micro hang or restart. The test found two real bugs, which are now
fixed. A new page in the documentation describes every test BasicPlus passes.
Finally, we have added an image for the ESP32-P4X, the new revision of the P4, which fixes errors in the silicon.
It is almost identical to the ESP32-P4's, but a P4 image does not run on the P4X nor the other way round, so we have
one image for each of the two micros. With its clock, 400 MHz against 360, programs take between 8 and 10% less time.
Little by little the project is reaching maturity, so the changes are no longer so drastic, and we are focusing more
on extending the libraries and supporting more micros.
What doesn't change is the usual invariant: the same bytecode, the same byte-for-byte output on both VMs, and
everything verified on hardware.
What's new
- WiFi, on the Waveshare P4, the S3 and the C5. The board joins the network by itself at boot —by DHCP or with a
fixed IP— and the IDE works with it over the network as over the cable (the Placa (red) backend, or
Buscar en la red, search the network): files, packs, Run with its output, Stop, the log; also with a program
already running. On the P4, uploading 1 MB takes 16 s (about 95 over the UART), and burningGui,SQLiteand
Stdlib, 14 s instead of more than two minutes. It is set up in/sys/wifi.json, which the IDE's WiFi button
writes. And from a program, the newAirmodule turns it on and off, andNetopens TCP connections as a client,
now on the boards too. - Bluetooth LE keyboard and mouse, on the Waveshare P4, the C5 and the S3: they are paired once and come back by
themselves. In a program with a screen they work without writing a line, V7 programs included —the pointer and the
click, the wheel in lists, the keyboard in the field with the focus—; from code, the newKeyboardsandMice
modules, andAir.Bluetoothto scan, connect and forget devices. On the PC, a simulated Bluetooth, the same on
both VMs and in the IDE's simulated micro, with a «Teclado simulado» and a «Ratón simulado» (simulated keyboard and
mouse). - JC, BasicPlus with braces, semicolons and the type before the name: the same compiler reads
.bpand.jc
files, and the same program, written in BP or in JC, gives the same.modbyte for byte. The IDE opens, compiles,
runs and debugs them, on the PC and on the board, and translates them (Edit → Traducir a JC / Traducir a BP),
as the compiler does (--escribir-jc,--escribir-bp); and a JC module imports BP ones, and they mix in one
project. And C# as a test bench: a C# to JC translator (compat/csharp/cs2jc) ran the tests of Mono's C# compiler
through JC, and what they asked for and made sense for BasicPlus went into both languages (below). - Sound: the
Soundmodule plays a WAV in parallel —playreturns at once and the program carries on—, with
volume and progress. It plays on the Waveshare P4, through its ES8311 codec, with theaudio=line in the
Environment; and on the PC, on both VMs. - One more board, the ESP32-P4X (
#846): that makes nine images and eleven boards. The P4X is revision v3.x
of the P4, which fixes errors in the silicon of v1.x and will replace it over time. The IDF does not let one image
serve both revisions, so it has its own, from the same code; with the CPU at 400 MHz, programs take between 8 and
10% less time than on the Waveshare P4. Tested on the ESP32-P4X-Function-EV kit, with the V8 test round and the GUI
on its 7" panel, touch included. - On the other boards: the ESP32 family moves to ESP-IDF 6.1; the S3 reports the frequency it really runs at
—160 MHz; it said 240— and goes up to 240 withcpu.mhzin the Environment, and with its caches at their maximum,
strings take 18 to 27% less time;Machine.tempC()reads the ESP32s' sensor, which gave 0 in V7; the C3 goes from
48 to 96 KB of heap, and the C6 from 61 to 112; the RP2350 image carries two firmwares, and withpsram=1the
Metro boots the one that puts the most used parts in SRAM —strings, 25 to 31% less time— and now fills its 6 MB of
heap; and the STM32s no longer copy memory byte by byte: agc()on the Nucleo, from 2.13 to 0.94 ms. - Robustness in the field. The endurance test —48 hours on four boards, 61,360 laps, without a single error or
restart— found two real bugs, now fixed: theMutexof eachCollections.Mapwas not released until the end of
the RUN (#831), and a number in a global could hold on to an object for hours, fragmenting the heap (#833).
And the robustness table —sixteen situations, from a program out of memory to a power cut— led to five fixes:
with the log off, the VM's urgent warnings reach the log anyway; the ESP32s log the cause of each restart; the
STM32s restart by themselves after a fatal fault, instead of staying halted; a RESET with a program that won't
stop is served after 2 s; andWdtwith two runs no longer restarts a healthy board. - Strings, much faster: walking them by index, comparing them or filling a
Mapwith many keys no longer has a
quadratic cost. On the Pico 2, walking a 2 KB string goes from 535 to 20 ms; an==between two of 2 KB, from
22.8 ms to 68 µs; and an 8 KB JSON, from 16.7 to 2.5 s. And a string is an invariant:moveno longer writes
inside a string, and outside text that is not valid UTF-8 throwsEncodingErroror, if asked to, is decoded with
«�». - The language, in BP and in JC: interfaces, multiple inheritance of types, not of code; generics, an
instruction to the compiler:List<Sensor>checks what goes in and converts what comes out, and the VM never
knows;x[i]on an object, which isx.get(i); the VM's errors with their type —ArithmeticError,
NullReferenceError,IndexError,CastErrorandIOError—, subclasses ofRuntimeError;*=,/=,mod=…
and the ternaryiif;varparameters; named loops; and astringvariable can benull, as in C# (#774). - The library: five new modules,
Air,Keyboards,Mice,SoundandOverlays. WithOverlays.Overlay, a
program loads another, runs it and unloads it: what is rarely used only takes memory while it runs, like MS-DOS
overlays. AndJson.parseJsongives all the errors at once;/datais the folder for programs' data, each in its
own; and on the ESP32s,Machine.setCpuFreqMHzworks. - Native code: a
nativegives the same result as interpreted when an integer wraps around, and throws when
dividing by zero, as interpreted; converting a reference inside one is a compile error, instead of silently
building an object; and it walks a string by index in linear time. The ABI does not change:.mdnfiles stay on
ABI 9. - The graphical interface: the Bluetooth keyboard and mouse, on the Waveshare P4 and the C5 (above), and
scr.onKey; on
the PC, the window rotates with the screen; and on the C5, with WiFi and Bluetooth on, the screen no longer stops
refreshing. The GUI packs are rebuilt: the screen driver could end up burned over the end of the LVGL engine. - The IDE: the board over the network, and JC (above). An error on the board says where (
#582): it brings
its call chain, and the IDE turns it into file and line («en Sensor.bp:42»); in V7 only the message came out. And
one program at a time; Stop and Run say what happened on the board; and both PC VMs have their own flash, a folder
that acts as the board's/. - Execution and memory: threads' stacks come from the heap, and the VM checks the stack before each instruction:
what in V7 could write outside its stack without warning is now a «desbordamiento de pila» (stack overflow). Free
holes go into 48 lists by size: with 4,000 holes, tengc()calls go from 11.9 s to 0.64 on the Metro. And
compared with V7, on the Metro,AllocBenchtakes 38% less time andPrintBenchhalf; pure computation, between
2 and 7% more. - Tested, on the PC and on the boards: the dual-VM parity net, from 149 to 217 cases; 117 C tests of the VM (102
in V7), the most delicate ones with their sabotage —a switch that undoes the fix, to see the test turn red—; 404
compiler tests, and 39 programs that must fail, with 151 checks; the documentation's examples —377 BP snippets and
78 JC modules—, compiled; the 848 Mono tests that work, the black-box test of both languages; and on the boards,
the V8 test round, 24 tests, on all eleven —the nine of the final batch, the P4X and the P4 kit—, with the images
being released.
All of it in a new page: «How BasicPlus is tested». - And V7 bugs fixed: with two runs, a false «No space in heap»;
<and>between two strings gave garbage,
different on each VM;a[f()] += 5calledf()twice;super.propwent to the child's property; a private
method called onnullran with a nullthis; the same program could give a different.modin another
compilation; and more — details in the
release notes (Spanish).
⚠️ Upgrading from V7
Flash the V8 image first of all, and then the V8 stdlib and packs. The .mod is still MOD9 and native code is
still ABI 9, but what is compiled with V8 —your programs and the stdlib in Stdlib.pack— uses VM functions a V7
image does not have; and the GUI packs and the SQLite one are rebuilt. The cleanest way, in the Packs panel:
Formatear zona… (format zone), then burn the V8 ones. On the RP2350, always flash the whole bpvm_pico.uf2: it
carries both firmwares, P and M.
The S3 and the C5: the flash, fully erased, once. Their application grows from 1 to 2 MB for the WiFi, and the
new partition table requires erasing the flash: the Environment, the file system and the board's packs are lost.
First download whatever you want to keep; then flash the V8 image and set the board up again: the partitions (the C5
lays itself out), the Environment, the packs and your programs.
The Waveshare P4, for WiFi and Bluetooth: its C6 needs the ESP-Hosted 3.0.9 firmware —the factory one does not
work for the WiFi—. It ships in the ZIP (firmware/p4_c6_esp_hosted_3.0.9_merged.bin) and is flashed through the
board's P1 connector, with a USB-serial adapter: the connector's pins have to be soldered on and, before that, a
copy of the factory firmware saved. And in its Environment, radio=c6 —without that line, neither WiFi nor
Bluetooth— and, for sound, the audio=… line. All of it in
INSTALAR_FIRMWARE.md, «The WiFi and Bluetooth of the
Waveshare board».
Recompile your .mod files. A V7 .mod loads (checked on the PC), but with the V8 VM underneath: a string
field, property or global with no value is null to it, and it stops with «referencia nula: strlen de un string
null» (null reference) if that reaches a builtin (recompiled, it starts as ""); and whatever reads outside text is
now strict, recompiled or not. The IDE recompiles on every Run; what to check is what was left in /app, above all
the autorun program. And recompile your natives to get the AOT fixes: an already compiled .mdn stays as it was.
Check the Environment. stack= now asks only for the main thread's stack, not the region of all the threads:
a V7 line takes heap away from the board —on the Pico 2, stack=90 took 74 KB—; remove it if you don't need it. On
a board without PSRAM, a program that won't start with «no hay memoria del sistema (malloc)…» (no system memory) is
fixed with a smaller vmheap=. And what is new: wifi= and bt= (turn the radio on at boot), radio=c6 and
audio= (the Waveshare P4), cpu.mhz= (the ESP32s) and imagen=P (the RP2350).
What breaks V7 sources — the compiler says so in each case:
- Something protected from another class, read through a reference of the parent class: from
B, protected members
are used on aBor one of its subclasses; on an object that is only anA, through its getter. - A
privateor protected overload called from outside; and some calls with overloads that, under Java's rule,
become ambiguous (the error says how to choose). - A reference conversion inside a
native(Perro(a)): it is done outside. - A function called
iif, which is the ternary; and a default value of more than 127 bytes formain's argument.
What changes without a compiler warning:
print x;, with a;at the end, no longer ends the line; and thecontinueof ado … loop cgoes to the
condition: if it no longer holds, the loop ends.moveon a string throws;parseIntandparseFloatthrow on text that is not a clean number, and so does
charCodeAtout of range, on the board too; and outside text that is not valid UTF-8 throwsEncodingError: a
Latin-1 file needs the flag,readFile(path, true).- A
stringwith no value is""; compound assignments on abyteor anint16wrap around (b += 1at 255
gives 0); andsuper.propgoes to the parent's property. List.get,setandremovethrow outside the list's size;Json.parseJsonthrows anAggregateErrorwith all
the errors, and an integer that does not fit in 32 bits is now an error; a stale reference reaching a builtin, and
athrowofnull, raiseNullReferenceError;IO.rmdirandIO.removeFileonly delete what is theirs; and
sleep(0)yields the turn on the C VM too.- On the boards: the S3 reports 160 MHz, what it really runs at; the STM32s restart after a fatal fault and boot
without the autorun; and a RESET with a program that won't stop restarts the board after 2 s. - In the IDE, one program at a time; on the PC, an absolute path goes to the PC's flash
(%USERPROFILE%\.basicplus\flash), not to the root of the disk; and on the Java VM, without the «Teclado simulado»
connected, the GUI gets no keyboard from the PC.
What does not break: catch e: RuntimeError still catches all the VM's errors, which are now its subclasses; the
.mod is still MOD9 and native code ABI 9 (a V7 .mdn is made to load on the V8 image, but we have not tested it:
better recompile it); the V8 VMs still run the capsule's 59 V6 .mod files, and only one changes, because of the
string with no value; and a written import Core still compiles.
Download
One file: BasicPlus-8.0-win.zip (Windows; needs JDK 8+). Everything is inside — IDE, compiler, standard
library, the five packs, samples (and the JC one, in samplesJC/), documentation in Spanish and English —with
the two new volumes, JC and testing—, the simulated micro (with LVGL, and simulated WiFi and Bluetooth) and the
nine firmware images. Unzip and run; there is no installer.
The images live in firmware/, next to their SHA256SUMS.txt, with the RP2350 board.json templates in
firmware/boards/; the packs, in packs/:
| Image | Boards |
|---|---|
bpvm_pico.uf2 |
Raspberry Pi Pico 2 and Adafruit Metro RP2350 (BOOTSEL + copy), with both firmwares, P and M |
bpvm_esp32_merged.bin |
ESP32-S3 (esptool write-flash 0x0 …) |
bpvm_esp32c3_merged.bin |
ESP32-C3 |
bpvm_esp32c5_merged.bin |
Waveshare ESP32-C5-Touch-LCD-2.8 |
bpvm_esp32c6_merged.bin |
ESP32-C6 and Waveshare ESP32-C6-LCD-1.3 |
bpvm_esp32p4_merged.bin |
ESP32-P4-Function-EV and Waveshare ESP32-P4 (display=st7701 in the Environment) |
bpvm_esp32p4x_merged.bin |
ESP32-P4X-Function-EV, the P4 of revision v3.x (through its USB-Serial-JTAG) — new |
bpvm_stm32_nucleo.bin |
STM32 Nucleo-U575ZI-Q (ST-LINK / CubeProgrammer) |
bpvm_stm32_dk2.bin |
STM32U5G9J-DK2, with screen (ST-LINK / CubeProgrammer) |
And next to them, p4_c6_esp_hosted_3.0.9_merged.bin: the firmware for the Waveshare P4's C6, Espressif's
ESP-Hosted 3.0.9 coprocessor, for its WiFi and Bluetooth.
c6648f465716bb04d1e49f0ab1bdedae3d54f97c3a4c11d109b6b68a95adf421 BasicPlus-8.0-win.zip
Documentation
- Documentation (English): https://legio-e.github.io/BasicPlus/en/
- JC, BasicPlus with braces (new): https://legio-e.github.io/BasicPlus/en/jc.html
- How BasicPlus is tested (new): https://legio-e.github.io/BasicPlus/en/pruebas.html
- Documentación completa (Spanish): https://legio-e.github.io/BasicPlus/
Known limitations
- No low power: the micro never sleeps, and a battery-powered program cannot save energy today; all of it moves
to V9. What there is: the radios, off by default and switching themselves off when unused. - WiFi, only on the Waveshare P4, the S3 and the C5 (on Espressif's kits, the P4's and the P4X's, untested); not
on the C3, the C6, the STM32s or the Pico 2 W. And only as a client: no server (listen/accept), no UDP, no TLS,
no board as an access point, no NTP time. The network password is stored in plain text, in/sys/wifi.json. - Bluetooth: only the BLE keyboard and mouse, with the US layout; the setup program, in V9. Sound: WAV, on
the Waveshare P4 and the PC; the C5, in V9; MP3, out. - A fatal VM fault takes the board down: it restarts and boots without the autorun. Containing it in the run
that has it, and the ESP32s' panic report in the log, are for V9. - The RP2350 dual-core image is still slower with a single thread (
#665, for V9): on the Pico 2,PrintBench
takes 1,321 ms against 745 with the single-core one, and computation (fib(26)) 7.7% more; on the Metro,
computation 3.5% more (35% in V7).
With two threads, the dual-core one wins: ×1.68 on the Pico 2 and ×1.75 on the Metro. - Inside a
native, an error does not give its line, but its caller's: to see it, removenative. - The debugger does not expand objects, and on dual-core boards it runs with a single run.
- JC lacks what BP lacks —lambdas, delegates,
structs, its own generics with<T>…—; comments do not survive
the translation; a JC module that another one imports has to be compiled first; and the compiler's messages speak
BP (integer,boolean). - The S3 has no AOT (Xtensa), and a
.modcarries the native code of a single family: the multi-family one,
in V9. And the AOT does not look in the packs: anativein a module that importsSQLiteruns interpreted,
with a warning. - The C3 is tight on memory, with its 96 KB of heap. The STM32s: their
Wdtthrows (the IWDG cannot be
stopped) and they have neitherNeopixelnor SD. - With one run, a
Uart.readthat waits stops the other threads (the workaround:available()andsleep);
streams and devices are V9's theme. input()only works on the Java VM.- The P4 hung once in
GuiShot, in the final batch (#825): it does not repeat —200 pairs of runs and 500
captures in a row— and it is noted down in case it comes back. - The full list is in PENDIENTES.md (Spanish).