Skip to content

feat: move odfu example from note-outboard-dfu and update readmes#177

Open
rdlauer wants to merge 3 commits into
mainfrom
add-outboard-dfu-example
Open

feat: move odfu example from note-outboard-dfu and update readmes#177
rdlauer wants to merge 3 commits into
mainfrom
add-outboard-dfu-example

Conversation

@rdlauer

@rdlauer rdlauer commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Migrating ODFU example from note-outboard-dfu repo

@rdlauer rdlauer requested a review from Bucknalla July 2, 2026 17:05
@Bucknalla

Bucknalla commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Let's use the Fluent API which covers all four requests used here (hub.set, card.dfu, card.aux, dfu.status), and it's the target pattern for note-python users (see examples/binary-mode/upload/binary_upload_example.py) instead of hand-building {"req": ...} dicts + card.Transaction().

Suggested rewrite of configure_outboard_dfu (and the related import/var changes) in circuit-python/code.py:

import time
import board
import digitalio
import notecard
from notecard import card, dfu, hub

# The unique Product Identifier for your device. Claim one in a Notehub project.
productUID = "com.your-company.your-project"

# The firmware version reported to Notehub via dfu.status. Bump this (and change
# BLINK_DELAY) when you build a new image to update to.
FIRMWARE_VERSION = "1.0.0"

# Seconds the LED stays on/off. Change this to make the update visually obvious.
BLINK_DELAY = 0.5


def configure_outboard_dfu(nCard):
    """Put the Notecard online and enable Outboard Firmware Update for the host.

    Outboard Firmware Update requires the Notecard to be in "continuous" or
    "periodic" mode. On a Notecarrier F the DFU signals are routed over the
    Notecard's shared AUX pins, so card.dfu uses mode "aux" and card.aux is set
    to "off" to free those pins for DFU.
    """
    hub.set(nCard, product=productUID, mode="continuous", sn="circuitpython-notecard")

    # Enable Outboard Firmware Update and tell the Notecard the host MCU type.
    card.dfu(nCard, name="stm32", on=True, mode="aux")

    # Free the AUX pins so they can be used for Outboard Firmware Update.
    card.aux(nCard, mode="off")

    # Enable host DFU and report the running firmware version to Notehub.
    dfu.status(nCard, on=True, version=FIRMWARE_VERSION)


def main():
    """Enable Outboard DFU, then blink the built-in LED as the update payload."""
    i2c = board.I2C()
    nCard = notecard.OpenI2C(i2c, 0, 0, debug=True)

    configure_outboard_dfu(nCard)

    led = digitalio.DigitalInOut(board.LED)
    led.direction = digitalio.Direction.OUTPUT

    print("Running firmware version {}. Hit CTRL-C to stop.".format(FIRMWARE_VERSION))
    while True:
        led.value = True
        time.sleep(BLINK_DELAY)
        led.value = False
        time.sleep(BLINK_DELAY)


main()

Note the parameter/variable rename from card to nCard (matching the README's fluent API example) — it was renamed to avoid colliding with the notecard.card module import.

@Bucknalla Bucknalla left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment re-changing to Fluent API

@rdlauer

rdlauer commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@Bucknalla I missed your complete code sample but Claude added the fluent API usage for me. Also while in here I updated the github actions to the latest versions to avoid the Node 20 deprecation warnings. Ready for a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants