Skip to content

FM1Kit 0.4.0

Choose a tag to compare

@ocean ocean released this 25 Oct 00:29
· 73 commits to main since this release

FM1Kit can now install m-bootloader over USB-MIDI, and its new macOS library, FM1Rescue, backs up, restores and writes the FM-1's whole flash in the chip's USB download mode, whatever firmware is installed.

Added

  • FM1Updater.installBootloader(_:events:) installs m-bootloader from its fm1-uboot.fwsc package on an FM-1 running V15, keeping the firmware. BootloaderInstaller reads the package, decompresses its installer and checks every checksum, as the bootloader does before running it, and finds the bootloader it writes; BootloaderImage reads and checks m-bootloader's .boot files. FM1Kit can't read the bootloader back over USB-MIDI, so the FM-1's screen confirms the result.
  • FwscPackage.isFirmware: packages that hold only an installer are now read, and install, resume and check refuse them (FM1UpdateError.notFirmware).
  • InstallProgress: an install's events as one bar that never goes backwards, with four stages.
  • FM1Advice (and FM1UpdateError.advice): any error as a headline, an explanation, whether the FM-1 is still fine, one action and technical details.
  • FM1Updater.summary() and FM1DeviceSummary: the connected FM-1's firmware name and version (for V15 and open firmware), whether it's waiting mid-update, and its USB serial number (MIDIPortDescriptor.serialNumber).
  • SimulatedFM1 reports a serial number and runs bootloader installers (Options.serialNumber, bootloaderVersion; installedBootloaderVersion), and installing V15 on it puts M-VAVE's bootloader back, as on a real FM-1.
  • fm1probe install-bootloader, inspect for installers and .boot files, and serial numbers in identify.
  • A second library, FM1Rescue (macOS only; empty on iOS), for the chip's USB download mode: FM1Updater.enterDownloadMode() asks V15 or Felucca to switch with a MIDI message; USBDownloadModeConnection takes the FM-1 from macOS's disk driver (needs root) and speaks USB mass storage to it; FlashSession uploads m-bootloader's flash loader (bundled, MIT) and reads the flash; FlashSession.backUp(progress:) reads it twice and checks both reads against the chip's CRC-32; FlashBackup.write(to:) saves it as M-Flasher does. SimulatedDownloadMode stands in for the chip.
  • FlashBackup.firmware says whether the firmware's files in a backup are whole (as m-bootloader's menu reports them), which identities its code names and whether it's V15, naming Felucca 1.6.1 and AMB-1 1.3 too (name), and the backup's .json gains M-Flasher's firmware and app fields. FlashBackup(contentsOf:) reads a saved backup.
  • Writing in download mode, which works whatever the firmware: FlashPlan works out a change against the flash just read (restoring(_:onto:) a backup, installing(_:onto:) m-bootloader, installingBootloader(from:onto:) M-VAVE's bootloader from a firmware package, or installing(_:onto:includingBootloader:erasingSettings:) a firmware), listing the 4 KB sectors that change. FlashSession.write(_:progress:) checks the flash hasn't changed, erases and writes only those sectors, checks each run against the chip's CRC-32 and shows progress on the FM-1's screen. Another FM-1's backup never replaces this one's factory data, and nothing is planned for flash that shows it's another model's (FlashBackup.model; the SMK-37 has the same chip). If writing stops part-way, the error says not to switch the FM-1 off but to restore the backup. New errors: FlashPlanError, and DownloadModeError.flashChanged, writeNotVerified(_:) and writeInterrupted(at:_:). SimulatedDownloadMode erases and writes as NOR flash does.
  • fm1probe download-mode and fm1probe flash-backup FOLDER, with --trace to print every USB transfer; fm1probe inspect shows the bootloader and firmware in a .bin backup; fm1probe flash-restore, flash-bootloader and flash-install write in download mode after saving a backup and asking to confirm, or rehearse with --simulated BACKUP.bin.

Changed

  • When an install stops before the FM-1 restarts, the error explains that a custom firmware's own update code may have refused the package, and that replacing it needs download mode.
  • fm1probe install-bootloader shows staging progress as a count of requests.

Fixed

  • An install could wait forever when the FM-1 stopped asking for data but kept sending other SysEx: only read requests now count as activity, so it stops as stalled after the idle limit.

Tested on hardware

m-bootloader 1.2 installed over USB-MIDI from V15. Then in download mode: a verified 1 MB backup; Felucca 1.6.1 installed over AMB-1 (125 sectors in 8.6 s); a backup of V15 restored over Felucca; M-VAVE's bootloader put back from V15's package and m-bootloader installed again. The final flash was byte for byte the same as the backup from before. See HARDWARE_TESTING.md.

Using it

.package(url: "https://github.com/ocean/FM1Kit.git", .upToNextMinor(from: "0.4.0")),

FM1Rescue needs root to take the FM-1 from macOS's disk driver, so apps reach it through a privileged helper.

Full changelog: 0.3.0...0.4.0