Git Product home page Git Product logo

updatehub / updatehub Goto Github PK

View Code? Open in Web Editor NEW
112.0 11.0 19.0 2.57 MB

A generic and safe Firmware Over-The-Air (FOTA) agent for Embedded and Industrial Linux-based devices

Home Page: https://updatehub.io

License: Mozilla Public License 2.0

Rust 99.62% Nix 0.38%
industrial-linux embedded-linux firmware-updates update-service over-the-air updatehub yocto firmware-updater updatehub-linux-agent

updatehub's Introduction

FOSSA Status Coverage Status

Platform Build Status
Linux - x86_64 build status
Linux - AArch64 build status
Linux - ARMv7 build status

UpdateHub is an enterprise-grade solution which makes simple to remotely update all your embedded devices in the field. It handles all aspects related to sending Firmware Over-the-Air (FOTA) updates with maximum security and efficiency, making your project the center of your attention.

This repository provides the UpdateHub agent for Embedded and Industrial Linux-based devices.

Getting started

To start using UpdateHub, it is suggested that you follow the Getting started guide in the UpdateHub documentation.

Features

The support provided by the UpdateHub for the device includes:

  • Bootloader upgrade support (U-Boot and GRUB)
  • Flash support (NAND, NOR)
  • UBIFS support
  • Update package signature validation for security
  • Automated rollback in case of update fail
  • Conditional installation (content, version and custom pattern support)
  • Callback support for every update step
  • HTTP API to control and inquiry the local agent

To learn more about UpdateHub, check out our documentation.

Building and testing

The UpdateHub agent is developed using Rust programing language due its focus in safety and system level integration. In case you wish to build it, you can:

cargo build --release

Some tests are marked as ignored because they require user previleges. There's a Vagrant file that can be used to run them. To run tests on the virtual machine run:

vagrant up
vagrant ssh

and inside the SSH session, run:

sudo -i
cd /vagrant
cargo test
cargo test -- --ignored

License

Licensed under Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0).

Contributing

UpdateHub is an open source project and we love to receive contributions from our community. If you would like to contribute, please read our contributing guide.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

updatehub's People

Contributors

asakiz avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dlight avatar domarys avatar ghcdr avatar jonathas-conceicao avatar mdrodrigo avatar otavio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

updatehub's Issues

UpdateHub client doesn't show probe response

To reproduce the issue:

root@raspberrypi3:~# updatehub client install-package  http://10.5.3.246:8001/updatehub-image-base-raspberrypi3.uhupkg
Probe

This doesn't show any information about what is going on.

Races in goroutines

There are some races which we need to iron out from our code. The output of:

go test -race $(glide novendor)

is:

?   	github.com/UpdateHub/updatehub/testsmocks	[no test files]
ok  	github.com/UpdateHub/updatehub/metadata	1.017s
==================
WARNING: DATA RACE
Read at 0x00c42011e118 by goroutine 38:
  github.com/UpdateHub/updatehub/utils.(*TimedReader).Read()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:51 +0x1e0
  github.com/UpdateHub/updatehub/utils.ExtendedIO.Copy.func1()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy.go:63 +0x69

Previous write at 0x00c42011e118 by goroutine 36:
  github.com/UpdateHub/updatehub/utils.TestCancelCopy()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:125 +0x45e
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:657 +0x107

Goroutine 38 (running) created at:
  github.com/UpdateHub/updatehub/utils.ExtendedIO.Copy()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy.go:72 +0x16a
  github.com/UpdateHub/updatehub/utils.TestCancelCopy.func1()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:120 +0xb1

Goroutine 36 (running) created at:
  testing.(*T).Run()
      /usr/lib/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/lib/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/lib/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/UpdateHub/updatehub/utils/_test/_testmain.go:114 +0x20f
==================
==================
WARNING: DATA RACE
Read at 0x00c4201142b0 by goroutine 38:
  github.com/UpdateHub/updatehub/utils.TestCancelCopy.func2()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:126 +0x56
  github.com/UpdateHub/updatehub/utils.(*TimedReader).Read()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:51 +0x1f1
  github.com/UpdateHub/updatehub/utils.ExtendedIO.Copy.func1()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy.go:63 +0x69

Previous write at 0x00c4201142b0 by goroutine 36:
  github.com/UpdateHub/updatehub/utils.TestCancelCopy()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:124 +0x384
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:657 +0x107

Goroutine 38 (running) created at:
  github.com/UpdateHub/updatehub/utils.ExtendedIO.Copy()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy.go:72 +0x16a
  github.com/UpdateHub/updatehub/utils.TestCancelCopy.func1()
      /home/otavio/go/src/github.com/UpdateHub/updatehub/utils/copy_test.go:120 +0xb1

Goroutine 36 (running) created at:
  testing.(*T).Run()
      /usr/lib/go/src/testing/testing.go:697 +0x543
  testing.runTests.func1()
      /usr/lib/go/src/testing/testing.go:882 +0xaa
  testing.tRunner()
      /usr/lib/go/src/testing/testing.go:657 +0x107
  testing.runTests()
      /usr/lib/go/src/testing/testing.go:888 +0x4e0
  testing.(*M).Run()
      /usr/lib/go/src/testing/testing.go:822 +0x1c3
  main.main()
      github.com/UpdateHub/updatehub/utils/_test/_testmain.go:114 +0x20f
==================
--- FAIL: TestCancelCopy (0.00s)
	testing.go:610: race detected during execution of test
FAIL
FAIL	github.com/UpdateHub/updatehub/utils	0.122s
ok  	github.com/UpdateHub/updatehub/client	1.016s
ok  	github.com/UpdateHub/updatehub/installmodes	1.019s
ok  	github.com/UpdateHub/updatehub/installmodes/copy	1.018s
ok  	github.com/UpdateHub/updatehub/installmodes/flash	1.015s
ok  	github.com/UpdateHub/updatehub/installmodes/imxkobs	1.016s
?   	github.com/UpdateHub/updatehub/installmodes/internal/testsutils	[no test files]
ok  	github.com/UpdateHub/updatehub/installmodes/raw	1.014s
ok  	github.com/UpdateHub/updatehub/installmodes/tarball	1.013s
ok  	github.com/UpdateHub/updatehub/installmodes/ubifs	1.014s
ok  	github.com/UpdateHub/updatehub/libarchive	1.013s
?   	github.com/UpdateHub/updatehub/handlers	[no test files]
ok  	github.com/UpdateHub/updatehub	1.148s

Sometimes the owner is not retored when extracting using the tarball object type

It seems we are misusing the libarchive to do the extracting of the object. We set few flags at:

https://github.com/UpdateHub/updatehub/blob/v1/libarchive/libarchive.go#L410-L413

However, accordingly to bsdtar implementation, we are lacking ARCHIVE_EXTRACT_OWNER:

https://github.com/libarchive/libarchive/blob/master/tar/bsdtar.c#L213-L224

This solves the problem but in case the id has changed on the new image, it might be an issue. To fix this completely, it seems we need to move to archive_read_extract2() and provide a custom lookup method which does nothing so libarchive uses the numeric owner when extracting.

updatehub.go: UpgradeToInstallation is not being set after an update

On the agent start, both validate and rollback states are ignored
when the "UpgradeToInstallation" is < 0). So even if an new installation
is achieved, UpgradeToInstallation is equal to -1, example:

... "update": { "download-dir": "/tmp/updatehub", "supported-install-modes": [ "tarball" ], "upgrade-to-installation": -1 },

Use partition name when reporting error due to failed install-if-different check

The error message would be more meaningful if we could show the partition (/dev/xxx) doesn't exist.

Jul 21 03:27:14.778 INFO installing update: 21.10-snapshot-20210818-test-image-6 (6897fc1ceeedac1f09b7116986eb43e4945837
facfe794fafd6714e6534ceb09)
Jul 21 03:27:14.846 INFO using installation set as target 1
Jul 21 03:27:14.846 INFO 'tarball' handler Install updatehub-image-base-imx6qdlsabresd.tar.xz (53608a2d80bc046b6298b5f12
c4aa4f61d29868a932e02d7fe480c3bb4c10ed5)
Jul 21 03:27:38.011 INFO 'raw' handler Install u-boot.img (c08a508e6c5fd40bf2c2e6d5dbd2a6d32178cdba7b9b981aad9f864da1f12
af1)
Jul 21 03:27:38.012 ERRO install if different check (pattern(U-Boot equal to '2021.07-rc5+fslc+g587e796995')) check fail
ed, error: No such file or directory (os error 2)

Simplify current HTTP API

Since we are breaking the HTTP API from v1 to v2, it behooves us to simplify what we can in order to achieve simpler code to maintain.

OAuth error confirming email

After registering and trying to confirm my email I got:

400 - Bad request
You have made a bad request to oAuth server and it was propagated to IDP.

Error code
challenge_error
Description
Challenge is not present.

I can login though, so it seems like it was confirmed.

Intermittent failure with "broken pipe"

=== RUN   TestCopyToProcessStdinWithProcessExitError
--- FAIL: TestCopyToProcessStdinWithProcessExitError (0.00s)
	Error Trace:	copy_test.go:1174
	Error:		Not equal: "exit status 1" (expected)
			        != "write |1: broken pipe" (actual)
	Messages:	An error with value "exit status 1" is expected but got "write |1: broken pipe".

Panic when running on a virtual device

In the validation process, I got a panic as below:

panic: runtime error: integer divide by zero        

goroutine 10 [running]:   
panic(0x6c3d40, 0xc42000c0d0)                       
        .../usr/lib/go/src/runtime/panic.go:500 +0x1a1
github.com/UpdateHub/updatehub/updatehub.(*PollState).Handle.func1(0xc4200e4000, 0xc420078780, 0xc4200de400)
        .../github.com/UpdateHub/updatehub/updatehub/states.go:245 +0x24f
created by github.com/UpdateHub/updatehub/updatehub.(*PollState).Handle                                  
        .../github.com/UpdateHub/updatehub/updatehub/states.go:257 +0x90

Idle state being reported when it is not needed

I left the agent running for a while, without a valid server, so we could see how it would handle this case.

I got:

INFO[3600] Checking update at: /upgrades
INFO[3600] Reporting state: idle
INFO[3600] PackageUID:
ERRO[3600] failed to report state. HTTP code: 404
WARN[3600] Failed to report status state=idle

It tried to report the idle state when coming from the probe. This seems wrong as it should report the idle whenever the agent is going to wait for an action (e.g: did not start the download automatically).

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.