Repository navigation
FM1Kit 0.1.0
FM1Kit's first release: a Swift package for installing firmware on the M-VAVE FM-1 over USB-MIDI, from iOS and macOS.
.package(url: "https://github.com/ocean/FM1Kit.git", .upToNextMinor(from: "0.1.0"))Tested on one FM-1 from a Mac: installing M-VAVE's official V15, Felucca 1.6.1 and M-VAVE's open firmware V12 and switching between them, pulling the cable part-way through writing and resuming, and restoring V15's factory voices. See HARDWARE_TESTING.md for the results. Reports from other devices and hosts are very welcome.
FM1Kit isn't affiliated with M-VAVE, and doesn't include M-VAVE's firmware. Installing custom firmware is at your own risk.
Added
FwscPackage: reads.fwscfirmware packages, their product identity, logical image and SHA-256.OfficialFirmware: recognises M-VAVE's official releases (V15, and Open V12) by size and checksum.FM1Identity: parses what a device or package reports, including theota-update loader.FM1Updater: installs a package over USB-MIDI, resumes an interrupted update or a device in
USB recovery mode, and checks the device reports the new firmware afterwards.CoreMIDITransportfor real devices on iOS and macOS, andSimulatedFM1for the iOS
Simulator and tests.fm1probe, a Mac command-line tool that lists ports, identifies a connected FM-1 (repeatedly,
with timings), monitors SysEx, watches devices come and go, inspects packages, and installs
a firmware after asking to confirm (or rehearses one againstSimulatedFM1).- Installs and resumes support task cancellation.
FM1IdentityisCodable(as its text) and can be made from a model and version.SimulatedFM1refuses a package with the identity it's running, as the real device does.UpdateEvent.checking(fraction:requests:)reports a loader reading the image a second time
after writing, as Felucca's loader does.UpdateEvent.writing's fraction is the share of the
firmware's application area read so far, in any order (V15's loader reads backwards), so
both loaders seen reach 1.SimulatedFM1.Optionscan read backwards (writesBackwards) and
check after writing (checksAfterWriting), as these loaders do.FwscPackagechecks the JieLi container inside a package before anything is sent: the header
and table checksums, the chip (AC791N), each part's checksum, and that there's one firmware
image and one update loader. NewFailurecases say what's wrong (tooLarge,damagedHeader,
unexpectedChip,damagedPart,missingPart).FwscPackage.loaderSHA256identifies the
loader a package brings, andOfficialFirmware.stockLoaderSHA256is M-VAVE's.
fm1probe inspectshows both.FM1UpdateError.unexpectedFinish(phase:): the update stops if the device asks to finish the
other half of the update.- M-VAVE's open firmware (
FM-1_8000012and builds of it,FM1Identity.isOpenFirmware):
the updater asks it for itsFM1Capabilityand arms it with the package'sFM1BuildID
before the upgrade command, and checks the build it reports afterwards. New errors:
capabilityUnavailable,deviceBusy,armRefused(code:)andbuildMismatch.
OfficialFirmwaregainsbuildIDand recognises Open V12 (openV12).SimulatedFM1
simulates open firmware. Tested on one FM-1: installing Open V12 over V15, and arming it to
install V15 back. FM1Updater.check(_:buildID:)says what an install would do (InstallKind: an update, a
switch to a different firmware, or a reinstall) without changing the device.
install(_:options:events:)takesInstallOptions; switching firmware, which can erase
projects and samples, throwsswitchNotConfirmedunlessconfirmsSwitchingFirmwareis set,
and reinstalling the running firmware throwsalreadyInstalledbefore anything is sent.- Installs and resumes refuse to start while more than one FM-1 answers (
multipleDevices).
FM1Updater.findAll(where:)lists every device that answers. - The updater also probes ports named after other firmwares' loaders: SLOOP, Clipper and SINCO.
@_spi(Testing)FwscPackage.sampleFile(product:flashSize:loaderSize:seed:)builds a small
valid package for apps' tests withSimulatedFM1. Never install one on a real FM-1.FM1Identityreads the identity an armed open firmware's update loader reports, such as
ota-FM1C_db1642b2b6fa5c2c(armedBuildPrefix), so the updater finds that loader; an install
checks it names the build it was armed with.FM1Updater.restoreFactoryVoices(from:progress:)rewrites V15's four voice banks with its 128
factory voices from the official V15 package, as M-VAVE's updater does after installing V15
(FwscPackage.hasFactoryVoices,FM1Identity.officialV15). New errors:
factoryVoicesUnavailable,voiceRestoreNeedsV15,voiceRestoreRefusedand
voiceRestoreStalled.SimulatedFM1simulates V15's voice banks (currentVoices), and
fm1probe restore-voicesruns a restore after asking to confirm. Tested on one FM-1.- Updates add no pauses, as M-VAVE's own updater doesn't: the device asks for each block when
it's ready (UpdaterTiming.responseDelayandafterUpgradeCommandare zero by default). - After answering a finish request, the updater keeps the port open for
UpdaterTiming.finishSettle(600 ms), answering any repeat, so the reply isn't cut off. fm1probe installshows what the install would do and warns before switching firmware, and
takes--build-id;fm1probe identifywarns when more than one FM-1 answers.