Coder Social home page Coder Social logo

firmware-updater's Introduction

Firmware-updater

Simple typescript tool for updating firmware. Made for work purposes.

Usage guide

Environment preparation

Download project files

Choose any place where you wanna arrange project, for example /home/username/projects/, go to this folder:

cd /home/username/projects/

Then cloning project files there:

git clone [email protected]:qwerty541/firmware-updater.git

Go to the appeared project folder:

cd ./firmware-updater/

Compile firmware emulator

Important! For this step you need to have installed rust compiler, follow this link for details: https://www.rust-lang.org/tools/install

Now follow to subproject folder:

cd ./fake-firmware-process/

Begin compilation by this command:

cargo build

HTTP firmware update server

After compilation of firmware emulator we need a http server from witch the new firmware version will be downloaded.

Important! For this and future steps you need to have installed nodejs, follow this link for details: https://nodejs.org/

Globally install nodejs package http-server:

sudo npm install -g http-server

After installation we need to prepare a folder for HTTP server where will be placed binary file with "new" version of firmware

Go to the project folder:

cd /home/username/projects/firmware-updater/

Init folder for HTTP server, for example fake-http-server-storage:

mkdir ./fake-http-server-storage/

Copy inside these new folder firmware binary file:

cp ./fake-firmware-process/target/debug/fake_firmware_process ./fake-http-server-storage/

Now we need to give that file a name with contains firmware version, for example firmware-v2. Version 2 because will have version 1 running and we will upgrade it to 2.

mv ./fake-http-server-storage/fake_firmware_process ./fake-http-server-storage/firmware-v2

Now all about HTTP server was read, lets run it:

cd ./fake-http-server-storage/
http-server

The console will show ip address and port of HTTP server. Now we need to move it with firmware binary file path in configuration file:

cd /home/username/projects/firmware-updater/firmware-updater/
mv ./config.example.json ./config.json

Now open config.json with any text editor and change properties remoteFirmwareStorageServer and firmwareFileNameWithoutVersion to your values. After these changes in configuration file these properties should look like:

{
  "firmwareFileNameWithoutVersion": "firmware-v",
  "remoteFirmwareStorageServer": {
      "hostname": "127.0.0.1",
      "port": 8080,
      "path": "/"
  },
}

Firmware storage

In current step will be organize folder for our current firmware binary file and write info about that in config file:

cd /home/username/projects/firmware-updater/
mkdir ./firmware-storage/
cp ./fake-firmware-process/target/debug/fake_firmware_process ./firmware-storage/
mv ./firmware-storage/fake_firmware_process ./firmware-storage/firmware-v1

After that we need to rewrite property firmwareLocalStoragePath in config.json. After changes it should look like:

{
  "firmwareLocalStoragePath": "/home/username/projects/firmware-updater/firmware-storage/",
}

Systemd process

At this step we need to run our current firmware binary /home/username/projects/firmware-updater/firmware-storage/firmware-v1 as systemd process.

For that you need to create .service file from template:

cd /home/username/projects/firmware-updater/
sudo cp ./fake-firmware-process/fake_firmware.service /etc/systemd/system/

Then open this will with text editor and change path to firmware binary file to your actual:

[Service]
ExecStart=/home/username/projects/firmware-updater/firmware-storage/firmware-v1

Now we can launch it with systemctl command:

sudo systemctl daemon-reload
sudo systemctl start fake_firmware

And check its status to be sure that everything went without errors:

sudo systemctl status fake_firmware

It remains only to change systemdFirmwareServiceConfigurationFilePath property in config file. After changes it should look like:

{
  "systemdFirmwareServiceConfigurationFilePath": "/etc/systemd/system/fake_firmware.service"
}

Firmware updater dependencies installation

And the last preparation step, we need to install required dependencies for launching firmware-updater.

Important! For this and future steps you need to have installed yarn package manager, follow this link for details: https://yarnpkg.com/getting-started/install

cd /home/username/projects/firmware-updater/firmware-updater/
yarn install

Firmware updater running

In all previous steps was completed correctly now we can launch firmware-updater.

cd /home/username/projects/firmware-updater/firmware-updater/
sudo yarn update-firmware

After script finished its work check that firmware-storage folder contains binary file firmware-v2 instead firmware-v1, path to binary file inside .service file was changed and sudo systemctl status fake_firmware shows that process active and was run from new binary file.

firmware-updater's People

Contributors

qwerty541 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.