Repository navigation
FM1Kit 0.4.0
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 itsfm1-uboot.fwscpackage on an FM-1 running V15, keeping the firmware.BootloaderInstallerreads the package, decompresses its installer and checks every checksum, as the bootloader does before running it, and finds the bootloader it writes;BootloaderImagereads and checks m-bootloader's.bootfiles. 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, andinstall,resumeandcheckrefuse them (FM1UpdateError.notFirmware).InstallProgress: an install's events as one bar that never goes backwards, with four stages.FM1Advice(andFM1UpdateError.advice): any error as a headline, an explanation, whether the FM-1 is still fine, one action and technical details.FM1Updater.summary()andFM1DeviceSummary: 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).SimulatedFM1reports 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,inspectfor installers and.bootfiles, and serial numbers inidentify.- 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;USBDownloadModeConnectiontakes the FM-1 from macOS's disk driver (needs root) and speaks USB mass storage to it;FlashSessionuploads 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.SimulatedDownloadModestands in for the chip. FlashBackup.firmwaresays 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.jsongains M-Flasher'sfirmwareandappfields.FlashBackup(contentsOf:)reads a saved backup.- Writing in download mode, which works whatever the firmware:
FlashPlanworks 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, orinstalling(_: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, andDownloadModeError.flashChanged,writeNotVerified(_:)andwriteInterrupted(at:_:).SimulatedDownloadModeerases and writes as NOR flash does. fm1probe download-modeandfm1probe flash-backup FOLDER, with--traceto print every USB transfer;fm1probe inspectshows the bootloader and firmware in a.binbackup;fm1probe flash-restore,flash-bootloaderandflash-installwrite 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-bootloadershows 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