Skip to content

Hardware Platforms

Stefan Lenz edited this page Dec 28, 2022 · 144 revisions

A word on hardware platforms

The BASIC code is in basic.c with basic.h being the header file for most of the interpreter variables. It was intended from the start to be multi platform. Hardware dependent functions are mostly (but not completely) in hardware-arduino.h. As the different target platforms have different cores and different libraries, precautions are needed. An SD file system library on Arduino 8bit and ESP8266 is different in some aspects. The hardware layer of the interpreter deals with these differences. This part of the code is complex with a lot of heuristics in it. Currently 16 different cores are supported.

Main platforms are

  • Mac
  • Arduino AVR
  • Arduino 32 bit SAMB and Mbed
  • ESP8266
  • ESP32

Platforms I occasionally use and test against are

  • Mighty core AVR
  • Mega core AVR
  • ESP32 VGA Fablib systems

Platforms that work but that I test only in major release

  • Linux
  • Windows
  • DOS
  • Seeed Studio Mbed
  • Raspberry PI Pico

Platforms that have been never tested but could work

  • STM32 (I don't use them right now)

Arduino

Most genuine Arduino board and their clones are supported. I admire the solid work the Arduino engineers have done to build and integrate these boards with the software.

Diecimila 168 (EEPROM): 512 byte of BASIC memory. Runs a real tiny BASIC.

Diecimila 168 - real small

The first Arduino board I owned. It has only 1kB of RAM and 512 bytes of EEPROM. It is my test board for real frugal code. For this board the Picoserial library should be downloaded and activated. This saves buffer space and memory. Picoserial can be found here: https://github.com/slviajero/PicoSerial

Uno with 328P (EEPROM and LCD Shield), Nano and Nano Wifi with 328 (EEPROM, no Wifi): 1024 bytes BASIC memory.

Arduino UNO and a LCD Shield

Pretzel Board

For the LCD shield the standard Arduino Liquidcrystal library is used. (https://www.arduino.cc/en/Reference/LiquidCrystal). See the projects page (https://github.com/slviajero/tinybasic/wiki/Projects:-2.-LCD-shield-based-systems) for more. The Pretzel board libraries for networking are not supported and never will be. There is much better stuff on the market for networking now.

Larduino with a LTG8F328P Chip aka WEMOS XI aka other names: These boards have no real EEPROM. They use a flash EEPROM emulation. Supported now as well, PICOSERIAL does not work on them.

Nano Clone

All the UNO and Nano based board work really well and are fun to use with BASIC.

Nano Every 4 kB of BASIC memory.

The Every (https://docs.arduino.cc/hardware/nano-every) has received little love in the community but for running BASIC it is a great system. With its 6 kB of memory and 48 kB of flash, a lot of features can be added to the BASIC interpreter and you still have a computer with 4kB RAM. It is the ideal system for small wearables and applications.

Nano Every

Mega 2560 (EEPROM): 6 kB BASIC memory, ideal for a standalone 8bit system.

Arduino Mega256

The MEGA256 is ideal for standalone systems with a small display. It has enough program memory for the PS2 keyboard library (https://github.com/slviajero/PS2Keyboard) and the I2C Liquidcrystal libraries (https://github.com/slviajero/LiquidCrystal_I2C). Look at the project page https://github.com/slviajero/tinybasic/wiki/Projects:-How-to-use-BASIC-on-Arduinos for more.

MKR 1010 Wifi 28 kB BASIC memory, Wifi and MQTT supported

Arduino MKR1010

This board required the Arduino SAMD board extension in the board manager menu. Wifi and MQTT is fully supported just as well as sleep modes. This board is the basis of an IoT display board I build.

For SAMD boards, the RTCZero library has to be installed from the Arduino library manager.

Arduino DUE, 64 kb BASIC memory

Arduino DUE

The 32 bit workhorse of the Arduinos. Ideal for TFT based standalone systems. See https://github.com/slviajero/tinybasic/wiki/Projects:-How-to-use-BASIC-on-Arduinos for an example of a TFT screen. This board requires the Arduino SAM board extension from board manager.

Arduino RP2040 aka Raspberry PI Pico, generic Arduino model with 64 kb BASIC memory.

Arduino rp2040

This board is ideal for a small standalone computer.

Supports LittleFS now for an internal filesystem with BASIC. Wifi and MQTT supported.

ESP8266 and ESP32

The Chinese competition to the Arduino boards. Fast, low cost. Sometimes tricky to use but with a lot of possibilities. Endless hardware variants available. On all ESP boards SPIFFs and Wifi are fully supported. SLEEP works as well. They are ideal to build sensor devices or small standalone computers.

ESP8266 NodeMCU

ESP8266 Module

These boards are very popular and only cost a few Euros. They can be mounted on breadboards or other prototype boards.

Wemos D1 R1

These boards with a UNO form factor are also really cheap and very useful. They are not really compatible with UNOs and can't be used with many shields.

Wemos D1 board

Read this tutorial to see what can be done with BASIC and one of these boards: https://create.arduino.cc/projecthub/sl001/the-10-euro-iot-computer-with-esp-8266-e93681

ESP32 Wroom and C3

ESP32 Dev Board

both variants of ESP32 modules are supported. In addition to this, the interpreter also runs on Espduino modules which are similar to UNOs again.

ESP01

ESP01

Depending on the memory of the board and the features activated up to 64 kB of memory is possible. I tested on ESP01 in the 8266 and ESP32 variant as sensor boards.

TTGO ESP32 with VGA and PS/2

TTGO

Here is the hardware spec http://www.lilygo.cn/prod_view.aspx?TypeId=50033&Id=1083 and this is the software https://github.com/slviajero/FabGL. Plain 16 color VGA including graphics with PS2 keyboard and SD card running supported. Wifi also supported.

Please use the new FABLib version with the newest ESP32 core, version 2.0.2 and above.

64kB of BASIC memory without Wifi.

With Wifi the system cannot be stably powered any more from a standard USB port. It will crash periodically through the brownout detection mechanism. Use a sufficiently powerful external power source instead. Memory management is broken. Only small BASIC memories of 8kB are currently supported with the full VGA resolution.

VGA ESP32 system

Seeed Studio hardware

Seeeduino Xiao 24 kB of BASIC memory

Seeeduino

A super cheap, super small but powerful board. Fully supported with BASIC. Projects in preparation.

https://wiki.seeedstudio.com/Seeeduino-XIAO/

Raspberry PI Pico

The genuine Raspberry PI Pico is a great and powerful board for standalone computers.

Raspberry Pi Pico

It has a lot of memory, is fast and many I/O pins. Fully supported with BASIC with the genuine Raspberry PI Pico core.

Non Arduino AVR systems

A few of the very useful AVR controllers never made it into Arduino board. One has to build ones own board for them. A 644 is a great chip as it has 64kB flash and 4kB of RAM. Ideal for BASIC.

Low energy board can be build with it:

AVR do it yourself board

BASIC supports AVR644 and AVR1284 with these boards.

Bare bone board with AVR128 are ideal for BASIC. Many pins and enough memory.

AVR bare bone board

Use the Mighty core (https://github.com/MCUdude/MightyCore) and Mega core (https://github.com/MCUdude/MegaCore) with these systems

Infineon XMC system

A rudimentary support for the XMC1100 has been added to the code. These microcontrollers are SAMD based, have 32kB or 64KB of flash.

XMC1100 with external EEPROM

Special features of the system like the built-in EEPROM/flash emulation and RTC are not yet supported.

Not yet supported but in preparation

STM32F4VE

STM32F4VE

Powerful boards, see docs here https://www.st.com/en/microcontrollers-microprocessors/stm32f407ve.html#overview or here https://os.mbed.com/users/hudakz/code/STM32F407VET6_Hello/shortlog/ or here https://stm32-base.org/boards/STM32F407VET6-STM32-F4VE-V2.0

OS information in this repo https://github.com/stm32duino/Arduino_Core_STM32

EPaper with ESP32

EPaper

A small board with Wifi and an Epaper display. Great device for digital signage.

Supported Arduino / ESP peripherals

The hardware abstraction file hardware-arduino.h has become as big as the BASIC interpreter itself in the meantime. It contains a number of predefined drivers for hardware components. There is (almost) no Arduino library code any more in the basic interpreter basic.c. The hardware code includes displays, keyboards and keypads, sensors, networking, filesystems, and other peripherals.

Displays

Small text based LCD displays with and without I2C interface can be connected.

The LCD shield is supported including the keypad. The standard Arduino parallel LCD library is used for this.

Shield

LCD I2C is also supported for any display size.

LCD

SSD1306 based OLEDS are very common. The are supported using the u8g2 drivers. Almost all common monochrome displays can be connected with this and accessed through BASIC by changing the constructor lines in the code.

SSD1306

Larger TFT displays based on the SSD1963 are supported with full graphics.

TFT

SPI based displays like the Nokia 5110 and small ILI9488 can be used. They are really low cost and offer graphics.

Nokia5110

For the Nokia display there is a page mode in the graphics code. It allows drawing and printing into a page buffer and then transfer the data to the display.

ILI9488

The SPI based ILI948x displays are very common. A project with a display like this was published in arduino.cc.

Parallel ILI9886 displays are also supported in the meantime. They are ideal with Arduino Mega256 controllers are they need a lot of pins.

ILI9486

Real Time Clocks

Arduino I2C Real Time clocks with a DC3231, DC3232 or DC1307 are supported. If the clocks have an EEPROM they can be integrated as a small file system using the EFS library.

Input devices

PS2 keyboards and the keypad of the LCD shield are supported. ZX81 keyboards can be used with my ZX81Keyboard library. USB Keyboards are supported on a DUE with a German keymap. This is experimental.

Networking and Radio

ESP Wifi, WifiNINA and Arduino Ethernet are supported as network protocols with MQTT messages.

RF2401 Radio modules are implemented, they can be used are slaves and masters.

Sensors

A generic WIRE access library exists for all kind of I2C devices. Slave mode wire is implemented in BASIC 1.4.

A small number of sensors are integrated, this is active work. Currently DHT11, DHT22, AHT10, SHT3, BMP280, BME280 are supported. In addition to this the LSM6D sensor of the MKR and the MQ2 air quality sensor is integrated into the BASIC code.

Memory and EEPROM

EEPROMS with 4k and 32k size are autodetected on I2C. EEPROMS can be used as direct program storage and programs can run from them. SPI RAM chips are also supported as primary program storage.

Unix

MacOS X with gcc and Xcode

Raspberry PI / raspbian with gcc - Wiring implemented to support I/O pins.

Raspberry PI

Windows

Download MINGW (https://sourceforge.net/projects/mingw/) and set the MINGW macro.

MSDOS

Borland's Turbo C Compiler 2.01 is freely available for MSDOS (see here https://vetusware.com/download/Borland%20Turbo%20C%202.01/?id=168 or here - megapack - https://archive.org/details/msdos_borland_turbo_c_2.01). Use the program dosify in my repo to remove C++ style comments and add the obligatory CR characters at the end of each line. basic.c compiles nicely in DOSBOX including the file IO code. Catalog doesn't work as I didn't take the time to dive into MSDOS header files.

MSDOS / Dosbox

Standalone system

Smallness

A LCD shield / UNO based standalone computer.

Shielded UNO

Further infos on this project: https://create.arduino.cc/projecthub/sl001/basic-on-arduinos-5b4e24

AIM65 lookalike

A standalone computer with a 4x20 display and a thermo printer based on a MEGA 265.

Rockwell AIM65

Further infos on this project: https://create.arduino.cc/projecthub/sl001/aim65-lookalike-computer-from-scratch-8d94d6

The TFT/DUE machine

A standalone computer with a TFT screen based on an Arduino DUE.

TFT Based system

Further infos on this project: https://create.arduino.cc/projecthub/sl001/homecomputer-from-scratch-a04fb9

VGA based computer

The FabGL library makes it possible to build real VGA system based on an ESP32 CPU.

VGA ESP32 system

Further infos on this project: https://create.arduino.cc/projecthub/sl001/a-vga-computer-based-on-esp32-and-fabgl-with-sound-graphics-976894

The 10 Euro IoT computer

A system build on the old Wemos D1 UNO lookalike boards integrated with a low cost SD and clock shield.

Wemos Based computer

Further infos on this project: https://create.arduino.cc/projecthub/sl001/the-10-euro-iot-computer-with-esp-8266-e93681

Speed and performance

Dr. Dobbs method

In one of the old Dr. Dobbs journals the tiny program

10 FOR I=1 TO 10000 : A=5 : NEXT

is called the canonical benchmark. These were simpler times. Here are a few results for Stefan's BASIC. The first number is running as a program, the second interactively. Results differ so much because, like in Apple Integer BASIC, all program lines are tokenised before execution. Any interactive code with a FOR loop has to tokenise the loop over and over again while a program does it only once..

ESP32/VGA: 214 ms / 763 ms

Arduino DUE: 274 ms / 1945 ms

Arduino RP2040: 284 ms / 1223 ms

ESP8266: 374 ms / 1129 ms

Arduino MKR1010 Wifi: 545 ms / 3395 ms

Arduino UNO/MEGA/Diecimila/Nano: 1268 ms / 7316 ms

DOSBox (3000 cycles = 286@12MHz): 4.1 s / 28 s

All this is timed with millis(). Timing also depends on the language features added and other factors.

Run times quotes in the old Dr. Dobbs were between 2.5 minutes and 10 seconds for old 8080 based BASIC interpreters under CP/M with floating point arithmetic. My Apple I clone with a 1 MHz 6502 and Applesoft (floating point) BASIC needs 26 seconds. It doesn't matter if it runs as a program or interactively. An ATMega 644 clocked down to 1 MHz by using the internal oscillator and floating point runs the benchmark in 31 seconds which is roughly comparable with the Apple 1 clone. The main difference is the memory access code. Applesoft BASIC is written in Assembler and optimised for the 8bit memory access of the 6502 CPU. The BASIC interpreter here has a generic memory access method which works for all kind of architectures. Rewriting the memread() and memwrite() code in assembler would probably speed up the code quite a bit.

My Mac runs the program with Stefan's BASIC in 2 ms. This cannot be explained with clock frequency. The bottleneck of the Arduino's is memory access and flash read performance of the interpreter code. My Raspberry Pi 2 needs 35 ms. Both, the Raspberry and the Mac load the interpreter completely into memory or even cache and run it there while the microcontrollers have slow program memories.

The timetester and other benchmarks

Please have a look at the example section of the repo. In chapter 11 there is a number of classical BASIC benchmark and the respective results.

Libraries

Board extension URLs for the Arduino IDE