Brussels / 1 & 2 February 2020

schedule

A free toolchain for 0.01 € - computers

The free toolchain for the Padauk 8-bit microcontrollers


The Taiwanese company Padauk makes small 8-bit microcontrollers, the smallest of which are available at 0.01 € even in small quantities. Even the larger ones are just a few cents; a particularly interestign feature is the hardware multithreading support available in larger devices. Until recently, the only available toolchain was Padauk's non-free toolchain based around their "MINI-C" IDE (which despite, the name, ist just a bit of C-like syntactic sugar coating for assembler, and in no way a C implementation).

In 2019, an effort to provide a free alternative resulted in a full free toolchain. Documentation beyond that provided by Padauk was created by reverse-engineering. A free design for a programmer along with firmware was created. Assembler, simulator and a Small Device C Compiler (SDCC) backend were written.

The Padauk microcontrollers (µC) are small 8-bit Systems-on-a-Chip (SoC). Their program memory (PROM or Flash) is 0.5 KW to 4 KW with word sizes from 13 to 16 bit. Their data memory is 60 B to 256 B with 8-bit Bytes. The µC only have few peripherals; however, some of the larger devices are barrel processors with support for up to 8 hardware threads. This allows the emulation of even timing-critical peripherals in software. Padauk also supplies a programmer and a non-free "MINI-C" IDE. There is a lack of documentation when it comes to aspects not needed for users of MINI-C. In particular, there is no documentation of opcodes and very little information on the programming protocol. There are 4 subarchitectures, which we name by the word size in the program memory pdk13, pdk14, pdk15 and pdk16. There is some variation in the form of optional instructions within the subarchitectures.

In 2019, a full free toolchain for these µC was created. The necessary documentation was reverse-engineered. A free programmer design and firmware was created. For the pdk13, pdk14 and pdk15, we wrote free assemblers and simulators. We also wrote an SDCC backend for these. SDCC is a free C compiler that emphasizes standard-compliance and generating efficient code for small devices; while not up to the level of GCC and LLVM it tends to hold up well against many non-free compilers targetting small devices (see e.g. the FOSDEM 2018 talk "The free toolchain for the STM8"). While stack handling on the Padauk µC is much better than on e.g. small Mirochip PIC devices, it is still not efficient (in particular, there is no stack-pointer-relative addressing mode). Thus SDCC does not place local variables on the stack by default, which makes functions non-reentrant and is not standard-compliant, but a common choice in such cases (see e.g. the mcs51 backend in SDCC or Keil for MCS-51). However, this approach does not work well for devices with hardware-multithreading (i.e. few pdk14 and all pdk16).

Speakers

Philipp Klaus Krause

Attachments

Links