BERGSONNE

Blink

The simplest possible project. It blinks the onboard LED at 5 Hz — toggling every 100 ms — so it’s the ideal first test to confirm your toolchain, build system, and flash workflow before moving on to anything more complex.

Overview

The firmware is a single main.c of about twenty lines. It depends on core.h plus core_usb.h — the example brings USB up at startup, so the board enumerates over USB when you flash it. There are no external libraries and no host tools; build it with make. Because it only touches the onboard LED and USB — which every Core has — it runs on any Core; just point the config at yours. The bundled config targets Core.ST.L4.1.

Firmware

The complete firmware:

/**
 * Blink — LED blink demo
 *
 * Simplest possible project. Blinks the onboard LED at 5 Hz.
 */

#include "core.h"
#include "core_usb.h"

int main(void)
{
    core_init();
    core_usb_init();
    core_led_init();

    while (1) {
        LED_TOGGLE();
        core_delay_ms(100);
    }
}

Line by line

  • core_init() — brings the system clock up to the maximum for your Core, starts SysTick for millisecond timing, and enables the GPIO clocks. Every project starts here.
  • core_usb_init() — enables the USB peripheral so the board enumerates as a USB device when connected.
  • core_led_init() — configures the onboard LED pad as a push-pull output. The pad is defined in the Core’s board layer, so you don’t need to know which GPIO it maps to.
  • LED_TOGGLE() — flips the LED state. LED_ON() and LED_OFF() are also available.
  • core_delay_ms(100) — a blocking SysTick delay. At 100 ms per toggle the LED completes a full on/off cycle every 200 ms — a 5 Hz blink.
No return needed
The while (1) loop never exits — there’s no OS to return to. The firmware runs forever.

config.json

The project descriptor is as minimal as it gets — a target Core, a clock setting, and an empty pad map. The onboard LED is built into the Core and needs no peripheral setup, so there are no pads to configure.

{
  "core": "Core.ST.L4.1",
  "clock": "max",
  "pads": {}
}
  • core — the bundled config targets Core.ST.L4.1, but any Core works; set this to whichever you’re flashing.
  • clock"max" runs the system clock at the highest supported frequency for the target.
  • pads — empty; the LED pad is handled internally by core_led_init().
make runs coregen
Building invokes coregen, which reads config.json and generates the project headers (core.h, core_init.h, core_board.h, core_config.h) plus the init code — clock tree, flash wait states, vector table. These are build artifacts; don’t edit them.

Build & flash

From the example directory:

cd examples/u2-blink
make            # build firmware
make flash      # flash via SWD

The project Makefile is a thin pass-through to the SDK root; it also exposes make size, make clean, and make generate (run coregen only). The target Core is read from config.json automatically.

Next

With the blink running, try a project that moves data: