Skip to content

About

Objective-C Framework for Event-Driven Embedded System Development

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

picofuse-objc

Picofuse is an SDK for developing embedded systems. You can use it to build applications that run on various boards and hosts, leveraging Objective-C and the provided frameworks. See the examples for how to get started:

  1. Download the SDK from the releases on GitHub, for your host.
  2. Unpack it in /opt, or another absolute path of your choice.
  3. Set the PICOFUSE_SDK environment variable to the installation path, if it's not /opt/picofuse.
  4. Create your project from a copy of an example in the examples directory, such as helloworld.
  5. Run make to build your project on the host, or make DEVICES=<device> to build for a specific device: one of the project's JSON files, such as presto for presto.json, or a board, such as pico_w.

Documentation

Build it with make doc, which runs Doxygen in Docker and writes it to doc/.

Releases

Each release has a tarball for each host: linux-amd64, linux-arm64 (which covers a Raspberry Pi) and darwin-arm64. Each is a whole picofuse/ tree, to unpack in /opt: picofuse and picofuse-objc for the host, with picotool and testrunner, and for each board in boards.txt, with the examples and the tutorial. A release is built with picofuse's release of the same tag, so picofuse is tagged first.

Building

picofuse-objc is built against an installed copy of picofuse, and is installed into the same place, so that the two make up one installation. That's /opt/picofuse, unless you set PREFIX to another absolute path for both.

This builds and installs the Objective-C runtime and the Foundation, Application, Graphics, Devices and Network frameworks:

  • lib/<target>/libpicofuse-objc-gcc.a, -foundation.a, -application.a, -graphics.a, -devices.a and -network.a, with a pkg-config file for each in lib/<target>/pkgconfig/. <target> is the board, or the host (e.g. darwin-arm64)
  • include/runtime/, include/Foundation/, include/Application/, include/Graphics/, include/Devices/ and include/Network/ - their headers
  • cmake/picofuse_objc.cmake and cmake/picofuse_objc_devices.cmake - what a program builds with
  • examples/ and tutorial/ - the examples, and the tutorial, whose links to them work in the installation too

A program links a framework other than Application with picofuse_objc_executable(... FRAMEWORKS Devices), which links only the parts it uses, and Devices brings Graphics with it. A window on a Mac or Linux needs SDL3, which picofuse finds when it's built.

A program describes its hardware in a JSON file beside its sources, one for each setup, such as examples/bricks/presto.json:

{ "board": "pimoroni_presto",
  "display": { "@class": "PimoroniPresto", "size": 480, "clock": 200 } }
  • DEVICES names the file: make DEVICES=presto, or -D DEVICES=presto
  • without it, it's host.json, with no board, for the host
  • "board" is the board it's built for, so a program doesn't need PICO_BOARD
  • a program without a file, such as helloworld, takes a board: DEVICES=pico_w
  • with NXApplicationFeatureDevices, [[application deviceManager] display] is its display, and only the classes it names are linked
  • on a host, --devices <file> adds settings, such as a panel's "vcom"
  • see cmake/picofuse_objc_devices.cmake

The frameworks themselves are still built for a board with PICO_BOARD, below.

Mac

Requirements:

brew install cmake pkgconf gcc openssl@3 libusb sdl3

Install picofuse, then test and install this:

# In picofuse
make install

# In picofuse-objc
make test
make install
  • This uses the latest version of GCC that Homebrew installed. Set OBJC_COMPILER for another.
  • Apple's clang (and its gcc alias) can't be used: it doesn't support the GCC Objective-C runtime on a Mac.

Linux

Requirements on Debian (tested with trixie), where gobjc is the Objective-C compiler for GCC:

sudo apt install build-essential cmake git pkgconf gobjc libssl-dev libusb-1.0-0-dev libsdl3-dev

Install picofuse, then test and install this:

# In picofuse
make install

# In picofuse-objc
make test
make install

Pico boards

Requirements, in addition to CMake and pkg-config:

  • The Arm GNU Toolchain (arm-none-eabi-gcc), which compiles picofuse and links programs. On a Mac, brew install --cask gcc-arm-embedded
  • Python 3, which the pico-sdk needs.
  • The LLVM Embedded Toolchain for Arm, which compiles Objective-C: the Arm GNU Toolchain has no Objective-C compiler. It's expected in /opt/LLVM-ET-Arm-19.1.5-Darwin-universal

Install picofuse for the board, then this. For example, for a Pico 2 W:

# In picofuse
make PICO_BOARD=pico2_w BUILD_DIR=build-pico2_w install

# In picofuse-objc
make PICO_BOARD=pico2_w BUILD_DIR=build-pico2_w install
  • Setting PICO_BOARD cross-compiles for that board.
  • To flash and run the tests, connect the board through a debug probe, and use make PICO_BOARD=pico2_w BUILD_DIR=build-pico2_w test. This needs openocd, and the host installation of picofuse, for testrunner.
  • If the LLVM toolchain is elsewhere, run cmake -B <build directory> -D PICO_BOARD=<board> -D LLVM_ARM_TOOLCHAIN=<dir> first.
  • Use a separate build directory for each board.
  • Use pico for the Pico, pico_w for the Pico W and pico2 for the Pico 2.

About

Objective-C Framework for Event-Driven Embedded System Development

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages