soruced originally from: https://github.com/libopencm3/libopencm3/pull/613 edited to drop the use of bin files, and switch to devices.data