How SampleBoot works on the MPC Sample, and how to build it. For installing and using it, see the README.
- The stock app runs
autorun/autorun.shonly ifautorun.checkequals sha256(autorun.json+autorun.sh+ a fixed salt). The salt was found by the mpc-sample-plugins project and is also used by sample-base/Melodee. The launcher is signed once and never changes; everything else can be edited. - Firmware 1.4 (1.4.0.8) no longer starts the signed
autorunfolder. With Developer Mode on, the stock app offers to run an unsignedautorun.shat the top of the card (as a transient systemd unit) and asks each time it starts. SampleBoot's top-levelautorun.shonly runsautorun/autorun.sh, so the same launcher starts on both firmwares; 1.3.0.12 ignores the top-level file. When the stock app asks again later, the marker in/runkeeps SampleBoot from starting twice. - Systems are started with
SAMPLE_BASE_ASKED=1. On 1.4, sample-base (and so Melodee 0.8 and later) starts only once per power-on unless that variable says the start was asked for. - The launcher starts
sampleboot/sampleboot.shas its own systemd unit, once per power-on (a marker in/run). The script stops the stock app (ac50.service) and runssampleboot-uifrom RAM. sampleboot-uiis a small static aarch64 program. It writes 320×240 BGRX frames to/dev/fb0and reads the encoder from the raw MIDI port of the ALSA cardSurface(wheel = CC 100 on channel 1, push = note 111). It also readsKEY_POWERfrom therk805 pwrkeyevdev device. It prints the chosen folder and exits, releasing the MIDI port. Text uses an embedded DejaVu Sans font, and images are decoded with stb_image.- The countdown beeps go to the
I2Scard (AK4558), with plain ALSA ioctls, no alsa-lib. The codec clicks when it powers up or changes rate (see sample-base's "Opening and closing without a click"). Sosampleboot-uireads the codec's DAPM state (dapm_widget) and master clock (debugfs). A powered codec is joined at its own rate; a codec that is off is powered up with the built-in speaker held off until its outputs have settled (the jacks are behind the board's mute, which opens on its own 1 s after power-up). - Speaker: on with nothing in the headphone and line-out jacks, off with something plugged, followed while the menu runs. The switch goes back to its previous state before the next app starts.
- Stopping the stock app cuts its output (scaled by its Main Volume) and the
outputs click. So the script first lowers the codec's
Playback Volumeto 0 in small steps (sampleboot-ui --volume-down, old values kept in/run/sampleboot/volume); the menu brings it back the same way once its own silent stream runs, and every error path restores it. - The Main Volume position comes from the surface: the menu sends sample-base's
position request (
F0 47 7F 5C 42 00 00 F7) and follows CC 19. - On opening the surface port the menu switches every light off, as
sample-base's
led off: pads 1–16 and the fader light black (F0 47 7F 5C 65 00 04 I 0 0 0 F7), and channel-1 CC 0 for the pad banks (57–64), the level meters (83, 84) and the 17 buttons that have a light. - Splash:
splash-<SPLASH>.pngis revealed top to bottom in 0.8 s, one frame per change, with a 2-line "beam" (white over a dark image, black over a light one, 43 % opacity) at the edge; it then stays untilSPLASH_TIME. Encoder or POWER events skip it and are not passed on to the menu. The audio opens only after the splash, so the menu's countdown and its click come with the menu. - The browse arrows are open chevrons (18 px high, 2 px stroke, square tip), antialiased with 4×4 samples per pixel.
- A folder in
mods/is an OS when it holds a start script: the firstscripts[].pathof itsautorun.jsonthat names a file in the folder, as the firmware reads it (MPC Simple:launcher.sh), elseautorun.sh(Melodee, SampQOL OS). Absolute paths and..are refused.sampleboot-ui --script DIRprints it. - The script then runs the chosen OS's own start script, unchanged, or
restarts
ac50.servicefor stock. OSes find their card from their own path or/proc/mounts(MPC Simple takes the longest mount point that holds its folder), so they run frommods/<name>/as from the card'sautorun. - One exception: SampQOL 0.3.0 keeps
mpcqol.confat the card root but its start script reads it from${DIR%/*}, the folder above its own, and turns its 16 USB outputs on from it. For each name inROOT_FILESfound at the card root, the script binds that file ontoautorun/mods/<name>(copying it there the first time, to have a file to bind onto), so the OS reads and writes the real one. A bind of the whole OS folder overautorunwas tried in a 1.0.1 build and dropped as the default: it adds<card>/autorunto/proc/mounts, and MPC Simple then takes that for the card root. - That bind is still used, per OS, when the OS folder holds a file named
sampleboot.inplace:mount --bind autorun/mods/<name> autorun, then the start script runs fromautorun/. For OSes that take the card as the parent of their own folder, like MPCTRACKER (CARD=$(dirname "$D"), passed to its app as--card). Such an OS gets noROOT_FILESbinds (since 1.0.3): the folder above its own is the card root, so it finds those files there itself, and an extra writable mount would only get in the way (Am MOD's sandbox check refuses to start with one). - After starting the OS, the script waits up to
GRACEseconds (60) for it to take over, and starts the stock app if nothing did. An OS counts as running whenac50.serviceis active, when a process holds the surface MIDI port, or when a process named inWATCH_PROCSruns.
autorun.sh starts autorun/autorun.sh on firmware 1.4
autorun/
autorun.sh, autorun.json, autorun.check signed launcher (never changes)
sampleboot/
sampleboot.sh start-up script (run from /run)
sampleboot-ui the menu (static aarch64 program, run from /run)
sampleboot.conf settings and colours
sampleboot.original.conf the original settings
splash-dark.png, splash-light.png the splash screens
firmware.txt sha256 of the stock binary -> firmware version
sampleboot.txt, .png optional name and image of the stock entry
last last choice
last-boot.log log of the last boot
boot-history.log logs of the boots before it (BOOT_HISTORY, default 10)
mods/<name>/ one OS each: its own autorun folder, unchanged
sudo apt install gcc-aarch64-linux-gnu # Debian/Ubuntu
make # build/sampleboot-ui
make release # dist/SampleBoot-<version>.zip
make editor # tools/theme-editor.html (also part of make release)
make font # regenerate src/font_data.h (needs Pillow)
The theme editor's renderer (tools/editor/editor.html) is a line-by-line
port of the drawing code in src/sampleboot-ui.c, and its glyphs, test images,
splash screens, logo and defaults are put in by tools/build_editor.py from
src/font_data.h, tools/editor/images.json, card/ and docs/images/.
When the screens change in C, change the port too: comparing sampleboot-ui --render with the editor's
canvases must give identical pixels.
For testing on a PC, sampleboot-ui --render DIR --autorun PATH writes every
screen as a PPM image. Every device path can be overridden; see --help.
qemu-aarch64 runs the binary on x86.
src/ sampleboot-ui.c, font_data.h (generated), stb_image.h
card/ start-up script, settings, firmware list, mods/_template
tools/ make_release.py, add_mod.py, build_editor.py, gen_font.py,
editor/ (theme editor source and test images)
fonts/ DejaVu Sans (for gen_font.py) and its licence
docs/ these notes, the README images and the logo (SVG)