Metadata-Version: 2.5
Name: microgoose
Version: 0.1.1
Summary: Run Goose language programs on microcontrollers: ESP32, ESP32-S3 and STM32H7.
Project-URL: Homepage, https://github.com/voodoomods/microgoose
Project-URL: Documentation, https://github.com/voodoomods/microgoose/tree/main/docs
Project-URL: Source, https://github.com/voodoomods/microgoose
Project-URL: Issues, https://github.com/voodoomods/microgoose/issues
Project-URL: Changelog, https://github.com/voodoomods/microgoose/blob/main/CHANGELOG.md
Author: voodoomods
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: compiler,embedded,esp32,esp32-s3,firmware,goose,microcontroller,stm32
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Software Development :: Embedded Systems
Requires-Python: >=3.10
Requires-Dist: platformio<7,>=6.1.16
Requires-Dist: pyserial>=3.5
Description-Content-Type: text/markdown

# MicroGoose

Run [Goose](https://github.com/aardappel/goose) language programs on
microcontrollers. You write ordinary Goose, the unmodified Goose compiler
turns it into C, and MicroGoose builds that C into firmware for your board.

Tested on the ESP32-S3, the ESP32 WROOM-32 and WROVER-E (ESP-IDF), and the
STM32H743 (bare metal). All twelve of Goose's stock samples tested print
exactly what they print on a PC, on every one of those boards.

## Install

```bash
pip install microgoose
```

On first use, MicroGoose downloads the Goose compiler v2026.4 from its
official release and checks its SHA-256. The first build for each board
fetches that board's toolchain through PlatformIO, which takes a few minutes.

## Quick start

```bash
microgoose new blinky --example blink
microgoose run blinky/main.goose                 # ESP32-S3 (the default target)
microgoose run blinky/main.goose --target esp32  # WROOM-32 / WROVER-E
microgoose run blinky/main.goose --target h7     # STM32H743 over ST-Link
```

`run` compiles, builds the firmware, flashes it, then shows the board's
output until the program exits. `build` stops after the firmware.
`--reserve 32K` changes the size of each data stack (the default is 16K).
`MG_PORT=COM5` picks the serial port when there is more than one.

## Writing hardware code

```rust
import esp;

fn main() {
    rgb_init(48);
    for i: i32 in 10 {
        rgb(if i % 2 == 0 { 32 } else { 0 }, 0, 0);
        print("t=", millis(), " temp=", chip_temp_c());
        delay_ms(250);
    }
}
```

`import esp;` provides time, GPIO, the RGB LED, the ADC, the chip temperature
and system information. Each function is a one-line `extern fn` bound
directly to C, so adding a peripheral means one C function plus one line of
Goose.

## How it works

```
app.goose ──goose -o──▶ app.c ──┐
lib/esp.goose (extern fns)      ├─ fixes ─▶ PlatformIO ─▶ firmware
goose --emit-runtime ─▶ runtime ┘               │
                                  port: POSIX shim, HAL, main
```

Goose has no heap: dynamic data lives on bump-pointer *data stacks*.
MicroGoose sizes those stacks to fit SRAM. It guards the end of each one with
whatever the chip has: hardware watchpoints on the ESP32s, MPU regions on the
STM32. It also applies two source fixes, one for Goose's 64-bit struct
layout and one for an Xtensa GCC calling-convention bug this project found.

## Documentation

- [Getting started](https://github.com/voodoomods/microgoose/blob/main/docs/getting-started.md)
- [Boards](https://github.com/voodoomods/microgoose/blob/main/docs/boards.md)
- [Hardware API](https://github.com/voodoomods/microgoose/blob/main/docs/hardware-api.md)
- [How it works](https://github.com/voodoomods/microgoose/blob/main/docs/how-it-works.md)
- [Findings](https://github.com/voodoomods/microgoose/blob/main/docs/findings.md): what works,
  what doesn't (the Arduino Nano), and the compiler bug

The same pages will be published at [microgoose.dev](https://microgoose.dev).

## Developing MicroGoose

```bash
git clone https://github.com/voodoomods/microgoose && cd microgoose
pip install -e . -r requirements-dev.txt
python mg.py run examples/hello.goose   # same as `microgoose`, building in the checkout
python -m pytest && ruff check .
```

`main` only takes changes through pull requests that pass CI. CI runs lint,
unit tests, a 32-bit host conformance run, firmware builds for every target,
an install test of the built package, and a strict docs build. See
[Contributing](https://github.com/voodoomods/microgoose/blob/main/docs/contributing.md).

## License

Apache-2.0. Goose is a separate project by its own authors, and MicroGoose is
not affiliated with it. MicroGoose downloads Goose; it does not redistribute it.
