diff --git a/src/lib/flash-helper.js b/src/lib/flash-helper.js index 370ed576d..b25932e95 100644 --- a/src/lib/flash-helper.js +++ b/src/lib/flash-helper.js @@ -17,20 +17,9 @@ const ensureError = utilities.ensureError; const FLASH_TIMEOUT = 4 * 60000; // Minimum version of Device OS that supports protected modules -const PROTECTED_MINIMUM_VERSION = '6.0.0'; -const PROTECTED_MINIMUM_SYSTEM_VERSION = 6000; -const PROTECTED_MINIMUM_BOOTLOADER_VERSION = 3000; - -// If a Protected Device has a system version of 6101, it can't be downgraded to 6100 or 6000 -const INCOMPATIBLE_PROTECTED_SYSTEM_VERSIONS = { - 6101: [6100, 6000], - 6100: [6000], -}; - -// If a Protected Device has a bootloader version of 3001, it can't be downgraded to 3000 -const INCOMPATIBLE_PROTECTED_BOOTLOADER_VERSIONS = { - 3001: [3000] -}; +const PROTECTED_MINIMUM_VERSION = '6.1.1'; +const PROTECTED_MINIMUM_SYSTEM_VERSION = 6101; +const PROTECTED_MINIMUM_BOOTLOADER_VERSION = 3001; async function flashFiles({ device, flashSteps, resetAfterFlash = true, ui, verbose=true }) { let progress = null; @@ -394,31 +383,6 @@ async function maintainDeviceProtection({ modules, device }) { throw new Error(`Cannot downgrade Device OS below version ${PROTECTED_MINIMUM_VERSION} on a Protected Device`); } - // Check for compatibility with current Device OS version for Protected Devices - // Firmware module info is only available when the device is not in DFU mode - // If the device was in DFU mode, allow the flashing to continue and fail midway if the device is not compatible - if (!device.isInDfuMode) { - let currentModules, incompatSystem, incompatBootloader, currentSystem, currentBootloader; - try { - currentModules = await device.getFirmwareModuleInfo({ timeout: 5000 }); - currentSystem = currentModules.find(m => m.type === 'SYSTEM_PART'); - currentBootloader = currentModules.find(m => m.type === 'BOOTLOADER' && m.index === 0); - incompatSystem = currentSystem && INCOMPATIBLE_PROTECTED_SYSTEM_VERSIONS[currentSystem.version] && - INCOMPATIBLE_PROTECTED_SYSTEM_VERSIONS[currentSystem.version].includes(moduleVersion); - incompatBootloader = currentBootloader && INCOMPATIBLE_PROTECTED_BOOTLOADER_VERSIONS[currentBootloader.version] && - INCOMPATIBLE_PROTECTED_BOOTLOADER_VERSIONS[currentBootloader.version].includes(moduleVersion); - } catch (error) { - // ignore error, as it may simply mean the module info couldn't be retrieved - } - - if (incompatSystem) { - throw new Error(`Device OS system version ${currentSystem.version} cannot be downgraded to ${moduleVersion} on a Protected Device. Please refer to https://docs.particle.io/ for more details.`); - } - if (incompatBootloader) { - throw new Error(`Device OS bootloader version ${currentBootloader.version} cannot be downgraded to ${moduleVersion} on a Protected Device. Please refer to https://docs.particle.io/ for more details.`); - } - } - // Enable Device Protection on the bootloader when flashing a Protected Device if (moduleFunction === ModuleInfo.FunctionType.BOOTLOADER && moduleIndex === 0) { const protectedBuffer = await createProtectedModule(module.fileBuffer); diff --git a/src/lib/flash-helper.test.js b/src/lib/flash-helper.test.js index eec3b531a..51b940b4f 100644 --- a/src/lib/flash-helper.test.js +++ b/src/lib/flash-helper.test.js @@ -674,12 +674,7 @@ describe('flash-helper', () => { beforeEach(async () => { device = { - getProtectionState: sinon.stub(), - isInDfuMode: false, - getFirmwareModuleInfo: sinon.stub().resolves([ - { type: 'BOOTLOADER', index: 0, version: 3000 }, - { type: 'SYSTEM_PART', index: 1, version: 6000 }, - ]) + getProtectionState: sinon.stub() }; const oldBootloaderBuffer = await firmwareTestHelper.createFirmwareBinary({ @@ -704,13 +699,13 @@ describe('flash-helper', () => { moduleFunction: ModuleInfo.FunctionType.BOOTLOADER, platformId: 12, moduleIndex: 0, - moduleVersion: 3000 + moduleVersion: 3001 }); const newSystemPartBuffer = await firmwareTestHelper.createFirmwareBinary({ moduleFunction: ModuleInfo.FunctionType.SYSTEM_PART, platformId: 12, moduleIndex: 0, - moduleVersion: 6000 + moduleVersion: 6101 }); newBootloader = await new HalModuleParser().parseBuffer({ fileBuffer: newBootloaderBuffer }); newSystemPart = await new HalModuleParser().parseBuffer({ fileBuffer: newSystemPartBuffer }); @@ -762,7 +757,7 @@ describe('flash-helper', () => { } catch (_error) { error = _error; } - expect(error).to.have.property('message').that.eql('Cannot downgrade Device OS below version 6.0.0 on a Protected Device'); + expect(error).to.have.property('message').that.eql('Cannot downgrade Device OS below version 6.1.1 on a Protected Device'); }); it('throws an exception if the system part is too old', async () => { @@ -772,7 +767,7 @@ describe('flash-helper', () => { } catch (_error) { error = _error; } - expect(error).to.have.property('message').that.eql('Cannot downgrade Device OS below version 6.0.0 on a Protected Device'); + expect(error).to.have.property('message').that.eql('Cannot downgrade Device OS below version 6.1.1 on a Protected Device'); }); it('does does not reject new modules', async () => {