public override void OnAction(IMFDeployForm form, MFDevice device)
 {
     device.Reboot(false);
 }
예제 #2
0
        /// <summary>
        /// Updates the given public signature key
        /// </summary>
        /// <param name="newKeyInfo">Information that is used to update the key: including the new key,
        /// the new key signature (if the key has already been set), and the key index</param>
        /// <returns>true if successful false otherwise</returns>
        public bool UpdatePublicKey(PublicKeyUpdateInfo newKeyInfo)
        {
            bool fRequiresReboot = false;
            bool retVal          = false;

            _DBG.PublicKeyIndex keyIndex;

            if (!m_init)
            {
                InitializeConfigData();
            }

            if (!m_init)
            {
                throw new MFInvalidConfigurationSectorException();
            }
            if (!m_fStaticCfgOK)
            {
                throw new MFInvalidConfigurationSectorException();
            }
            if ((newKeyInfo.NewPublicKey.Length) != TINYBOOTER_KEY_CONFIG.c_RSAKeyLength)
            {
                throw new MFInvalidKeyLengthException();
            }

            if (newKeyInfo.PublicKeyIndex == PublicKeyUpdateInfo.KeyIndex.DeploymentKey)
            {
                keyIndex        = _DBG.PublicKeyIndex.DeploymentKey;
                fRequiresReboot = m_deployKeyLocked;
            }
            else
            {
                keyIndex        = _DBG.PublicKeyIndex.FirmwareKey;
                fRequiresReboot = m_firmwareKeyLocked;
            }

            if (m_device.DbgEngine.ConnectionSource != Microsoft.SPOT.Debugger.ConnectionSource.TinyBooter)
            {
                if (!m_device.ConnectToTinyBooter())
                {
                    throw new MFDeviceNoResponseException();
                }
            }

            if (m_device.DbgEngine.UpdateSignatureKey(keyIndex, newKeyInfo.NewPublicKeySignature, newKeyInfo.NewPublicKey, null))
            {
                // if the key was previously set it requires an erase and a write which requires a reboot on some devices
                if (fRequiresReboot)
                {
                    m_device.Reboot(true);
                }

                retVal = true;
            }

            PingConnectionType conn = m_device.Ping();

            if (PingConnectionType.TinyBooter == conn)
            {
                m_device.Execute(c_EnumerateAndLaunchAddr);
            }

            return(retVal);
        }