public override YaffsImage GetYaffsImage(FirmwareProject Project)
 {
     // Создание корневой директории
     YaffsDirectory root =
         DefaultFsFactory.CreateDirectory("Root")
                         .Put(DefaultFsFactory, "bin",
                              Project.Modules.Select(m => GetComponentDirectory(Project.Target.CellId, m)))
             // Файлы свойств модулей
                         .Put(DefaultFsFactory, "dat/Loader",
                              Project.Modules.SelectMany(m => new[]
                                                              {
                                                                  DefaultFsFactory.CreateFile(
                                                                      string.Format("{0}-properties.xml",
                                                                                    GetModuleDirectoryName(Project.Target.CellId, m)),
                                                                      GetBootloaderConfigurationFileImage(
                                                                          new CompositePropertiesProvider(
                                                                              new ModulePropertiesProvider(m.Information),
                                                                              new SoftwarePropertiesProvider(m, _stringEncoder, _checksumProvider)))),
                                                                  DefaultFsFactory.CreateFile(
                                                                      string.Format("{0}-files.xml", GetModuleDirectoryName(Project.Target.CellId, m)),
                                                                      GetBootloaderFilesIndexFileImage(m.FirmwareContent.Files))
                                                              }))
             // Файл свойств железа
                         .Put(DefaultFsFactory, "dat/Loader",
                              DefaultFsFactory.CreateFile("hardware-properties.xml",
                                                          GetBootloaderConfigurationFileImage(new DevicePropertiesProvider(Project.Target))))
                         .Put(DefaultFsFactory.CreateFile("start", 0x750, Resources.start))
                         .Put(DefaultFsFactory.CreateFile("init", 0x750, Resources.init));
     return new YaffsImage(root);
 }
        private byte[] GetStartScript(FirmwareProject Project)
        {
            var stream = new MemoryStream();
            stream.Write(Resources.startLoaderless, 0, Resources.startLoaderless.Length);
            TextWriter tw = new StreamWriter(stream) { NewLine = "\n" };

            tw.WriteLine("export CELL_ID={0}", Project.Target.CellId);
            tw.WriteLine("export MODIFICATION_ID={0}", Project.Target.ModificationId);
            tw.WriteLine("export SERIAL={0}", Project.Target.SerialNumber);
            tw.WriteLine("export CHANNEL={0}", Project.Target.ChannelNumber);
            tw.WriteLine("export YEAR={0}", Project.Target.AssemblyDate.Year);
            tw.WriteLine("export MONTH={0}", Project.Target.AssemblyDate.Month);
            tw.WriteLine();

            foreach (ModuleProject module in Project.Modules)
            {
                tw.WriteLine("export BIN=$GLOBAL_BIN/{0}", GetModuleDirectoryName(Project.Target.CellId, module));
                tw.WriteLine("export DAT=$GLOBAL_DAT/{0}", GetModuleDirectoryName(Project.Target.CellId, module));
                tw.WriteLine("export LOG=$GLOBAL_LOG/{0}", GetModuleDirectoryName(Project.Target.CellId, module));

                tw.WriteLine("export VERSION_MAJOR={0}", module.FirmwareInformation.FirmwareVersion.Major);
                tw.WriteLine("export VERSION_MINOR={0}", module.FirmwareInformation.FirmwareVersion.Minor);
                tw.WriteLine("export VERSION_LABEL={0}", module.FirmwareInformation.FirmwareVersionLabel);
                tw.WriteLine("cd $GLOBAL_BIN/{0}", GetModuleDirectoryName(Project.Target.CellId, module));
                tw.WriteLine("chmod +x start");
                tw.WriteLine("export MODULE_ID={0}", module.Information.ModuleId);
                tw.WriteLine("./start");
                tw.WriteLine();
            }
            tw.WriteLine("exit $?");
            tw.WriteLine();
            tw.Flush();
            return stream.ToArray();
        }
 public IAsyncOperationToken BeginBurn(IBurningReceipt Receipt, FirmwareProject Project)
 {
     var token = new BurningAsyncOperationToken(new ProgressProxy());
     RegisterCurrentOperation(token);
     Task.Factory.StartNew(() => Burn(Receipt, Project, token));
     _burningStartedEvent.Publish(new BurningStartedEventArgs(token));
     return token;
 }
 /// <summary>Формирует список FUDP-свойств, связанных с устройством</summary>
 /// <param name="Project">Проект</param>
 /// <param name="ModuleId">Идентификатор модуля</param>
 public IEnumerable<ParamRecord> GetDeviceProperties(FirmwareProject Project, int ModuleId)
 {
     return new List<ParamRecord>
            {
                // Информация о блоке
                new ParamRecord(129, Project.Target.CellId),
                new ParamRecord(131, Project.Target.SerialNumber),
                new ParamRecord(132, Project.Target.AssemblyDate.Year * 100 + Project.Target.AssemblyDate.Month),
                new ParamRecord(133, Project.Target.ChannelNumber),
                new ParamRecord(134, Project.Target.ModificationId),
                new ParamRecord(130, ModuleId),
            };
 }
 public void Burn(FirmwareProject Project, IProgressToken Progress, CancellationToken CancellationToken)
 {
     var r = new Random();
     Progress.Start();
     for (int i = 0; i < 50; i++)
     {
         if (r.Next(1000) < 0.7 * 1000 / 50)
             throw new BurningException(new Exception("Сработала эмуляция ошибки при прошивании"));
         Progress.SetProgress(i / 50.0);
         Thread.Sleep(50);
     }
     Progress.OnCompleated();
 }
 public override YaffsImage GetYaffsImage(FirmwareProject Project)
 {
     // Создание корневой директории
     YaffsDirectory root =
         DefaultFsFactory.CreateDirectory("Root")
             // Директории с модулями
                         .Put(DefaultFsFactory, "bin",
                              Project.Modules.Select(m => GetComponentDirectory(Project.Target.CellId, m)))
             // Директории для данных модулей
                         .Put(DefaultFsFactory, "dat",
                              Project.Modules.Select(m => DefaultFsFactory.CreateDirectory(GetModuleDirectoryName(Project.Target.CellId, m))))
             // Директория для временных файлов
                         .Put(DefaultFsFactory, "share")
                         .Put(DefaultFsFactory.CreateFile("start", 0x750, GetStartScript(Project)))
                         .Put(DefaultFsFactory.CreateFile("init", 0x750, Resources.init));
     return new YaffsImage(root);
 }
 private void Burn(IBurningReceipt Receipt, FirmwareProject Project, BurningAsyncOperationToken OperationToken)
 {
     using (_progressControllerFactory.CreateController(OperationToken.ProgressToken))
     {
         try
         {
             Receipt.Burn(Project, OperationToken.ProgressToken, OperationToken.CancellationToken);
             OperationToken.Success();
         }
         catch (CreateImageException exception)
         {
             OnException("Не удалось составить образ для прошивки", OperationToken, exception.InnerException, Project, Receipt);
         }
         catch (BurningException exception)
         {
             OnException("Не удалось прошить устройство", OperationToken, exception.InnerException, Project, Receipt);
         }
     }
 }
Exemple #8
0
 public void Burn(FirmwareProject Project, IProgressToken Progress, CancellationToken CancellationToken)
 {
 }
 private void OnException(string ExceptionHeader, BurningAsyncOperationToken OperationToken, Exception Exc, FirmwareProject Project,
                          IBurningReceipt Receipt)
 {
     if (!_exceptionSuppressors.Any(s => s(Exc)))
         _exceptionService.PublishException(ExceptionHeader, Exc, Project, Receipt);
     OperationToken.Error(Exc);
 }
 public ILinuxImageSection GetSection(FirmwareProject Project)
 {
     return new LazyLinuxImageSection(_format, _address, _partitionSize, _displayName,
                                      () => File.ReadAllBytes(GetImageFileName(Project.Target)));
 }
 public ILinuxImageSection GetSection(FirmwareProject Project)
 {
     return new LazyLinuxImageSection(SectionFormat.Yaffs2, _address, _partitionSize, _sectionDisplayName,
                                      () => _serializer.Serialize(_imageConstructor.GetYaffsImage(Project)));
 }
 public abstract YaffsImage GetYaffsImage(FirmwareProject Project);