Save 37% off PRO during our Black Friday Sale! »

Nervesの新機能mix firmware.patchの(偏った観点からの)ご紹介 / An Introduction to mix firmware.patch from my own view point

Nervesの新機能mix firmware.patchの(偏った観点からの)ご紹介 / An Introduction to mix firmware.patch from my own view point

NervesJP #14 新年LT回
https://nerves-jp.connpass.com/event/199455/

スライド中で紹介しているJupyter Notebookは以下のURLで観られます。
https://github.com/kentaro/deployment-methods-evaluation/blob/main/evaluation.ipynb

23f4d5d797a91b6d17d627b90b5a42d9?s=128

Kentaro Kuribayashi

January 09, 2021
Tweet

Transcript

  1. Nervesͷ৽ػೳ mix firmware.patch ͷ ʢภͬͨ؍఺͔Βͷʣ͝঺հ ܀ྛ ݈ଠ࿠ʢGMOϖύϘגࣜձࣾɺ๺཮ઌ୺Պֶٕज़େֶӃେֶʣ ϥΠτχϯάτʔΫ@NervesJP #14 ৽೥LTճʢ2021೥1݄9೔ʣ

    1
  2. ܀ྛ ݈ଠ࿠ a.k.a. ͋ΜͪΆ https://kentarokuribayashi.com GMOϖύϘגࣜձࣾऔక໾CTO Ұൠࣾஂ๏ਓ೔ຊCTOڠձཧࣄ ๺཮ઌ୺Պֶٕज़େֶӃେֶʢJAISTʣത࢜ લظ՝ఔࡏֶதͷࣾձਓֶੜͰ΋͋Δ IoTؔ࿈ͷݚڀΛ४උ͍ͯ͠Δͱ͜Ζ

    ࣗݾ঺հ 2
  3. • IoTσόΠεͷ։ൃޮ཰޲্ͷͨΊɺ։ൃऀʹΑΔίʔυͷมߋΛͰ͖Δ͚ͩ଎ ͘σόΠεʹద༻͍ͨ͠ • ͦͷͨΊʹɺmix upload.hotswapʢ※ʣ ͱ͍͏mixλεΫΛ։ൃͨ͠ • Nervesͷఏڙ͢Δߋ৽ํࣜͱൺֱݕ౼͍ͨ͠ ◦

    ϑΝʔϜ΢ΣΞΠϝʔδશମͷߋ৽ద༻ ◦ ϑΝʔϜ΢ΣΞύονʹΑΔߋ৽ͷ෦෼ద༻ • ·ͨɺϑΝʔϜ΢ΣΞύονʹΑΔߋ৽ͷ෦෼ద༻͸Nervesͷ৽ػೳͰ΋͋Δ ͨΊɺ঺հ͍ͨ͠ Ϟνϕʔγϣϯ ※: https://hex.pm/packages/mix_tasks_upload_hotswap
  4. ͜ͷεϥΠυͰ࿩࣮ͨ͠ݧ݁Ռ͸ҎԼͷϦϙδτϦ಺ͷJupyter Notebookʹ͋Γ·͢ͷͰɺͦͪΒ΋͝ࢀর͍ͩ͘͞ɻ kentaro/deployment-methods-evaluation https://github.com/kentaro/deployment-methods-evaluation/blob/main/evaluation.ipynb

  5. • ϑΝʔϜ΢ΣΞΠϝʔδͷόΠφϦࠩ෼ʹΑΔύονΛ࡞੒͢Δmix λεΫʢ※1ʣ • v1.6.4Ͱಋೖɺv1.7.0Ͱਖ਼ࣜαϙʔτ͞Εͨʢ※2ʣ • mix uploadίϚϯυͷ--firmwareΦϓγϣϯͰύονΛࢦఆ͠ ͯΞοϓϩʔυ͢Δ͜ͱͰߋ৽Λద༻ mix

    firmware.patchͱ͸ ※1: https://hexdocs.pm/nerves/experimental-features.html#firmware-patches ※2: https://github.com/nerves-project/nerves/releases
  6. ҎԼͷํࣜΛൺֱݕ౼͢Δ 1. ϑΝʔϜ΢ΣΞΠϝʔδશମͷߋ৽ద༻ 2. ϑΝʔϜ΢ΣΞύονʹΑΔߋ৽ͷ෦෼ద༻ 3. ΞϓϦέʔγϣϯίʔυͷ෦෼ద༻ ൺֱݕ౼ͷର৅

  7. มߋΛIoTσόΠεʹద༻͠ɺΞϓϦέʔγϣϯ͕ಈ࡞͢Δ·Ͱͷ࣌ؒΛ ༻͍Δ 1. ϑΝʔϜ΢ΣΞͷϏϧυ 2. ϑΝʔϜ΢ΣΞͷΞοϓϩʔυ 3. ࠶ىಈ͔ͯ͠Β௨৴͕ՄೳʹͳΔ·Ͱͷ࣌ؒ ʢmix upload.hotswapʹ͍ͭͯ͸ɺ1.͓Αͼ2.Λཁ͠ͳ͍ʣ

    ൺֱݕ౼ͷํ๏
  8. 1. ϑΝʔϜ΢ΣΞΠ ϝʔδશମʹΑΔߋ ৽ͷద༻ $ cd target_app && ../measure_firmware_update.sh firmware

    nerves.local is at 172.31.68.221 Time to build firmware (mix firmware) ====================================== real 0m21.927s user 0m6.584s sys 0m2.121s Time to upload firmware ====================================== real 0m14.572s user 0m5.182s sys 0m1.261s Time to reboot ====================================== time: 22.692 sec. ӈͷ௨ΓɺͦΕͧΕ10ʙ20 ඵ΄Ͳͷ࣌ؒΛཁ͍ͯ͠ Δɻ
  9. 2. ϑΝʔϜ΢ΣΞ ύονʹΑΔߋ৽ͷ ෦෼ద༻ʢ1ʣ !cd target_app && ../measure_firmware_update.sh firmware.patch nerves.local

    is at 172.31.68.221 Time to build firmware (mix firmware.patch) ====================================== real 0m27.127s user 0m6.697s sys 0m2.227s Time to upload firmware ====================================== real 0m17.873s user 0m3.897s sys 0m0.952s Time to reboot ====================================== time: 22.534 sec. ӈͷ௨ΓɺͦΕͧΕ10ʙ20 ඵ΄Ͳͷ࣌ؒΛཁ͍ͯ͠Δɻ ϑΝʔϜ΢ΣΞશମͷߋ৽ͱ ΄ͱΜͲมΘͬͯͳ͍ɻ
  10. 2. ϑΝʔϜ΢ΣΞ ύονʹΑΔߋ৽ͷ ෦෼ద༻ʢ2ʣ Finished generating patch firmware Source /Users/antipop/src/github.com/kentaro/deployment-methods-

    evaluation/target_app/_build/rpi3_dev/nerves/images/target_app.fw uuid: cf2963b5-a2a1-596a-a5ee-8e1896ff412b" size: 43707167 bytes Target /Users/antipop/src/github.com/kentaro/deployment-methods- evaluation/target_app/_build/rpi3_dev/nerves/images/patch/target.fw uuid: b5fc7388-d517-5f4d-9247-f8401fecf9b6" size: 43704906 bytes Patch /Users/antipop/src/github.com/kentaro/deployment-methods- evaluation/target_app/_build/rpi3_dev/nerves/images/patch.fw size: 5900267 bytes ݩͷϑΝʔϜ΢ΣΞΠϝʔδ ʹൺ΂ͯɺϑΝΠϧαΠζ͕ ਺෼ͷ1ʹʂ
  11. 3. ΞϓϦέʔγϣ ϯίʔυͷ෦෼ద༻ $ cd target_app && time mix upload.hotswap

    > /dev/null real 0m3.414s user 0m4.708s sys 0m1.322s 3ʙ4ඵ΄ͲͰߋ৽͕׬ྃ͢ Δɻ
  12. • ϑΝʔϜ΢ΣΞΠϝʔδͷύονʹΑΔߋ৽ʹΑΔϝϦοτ ◦ ΠϝʔδͷϑΝΠϧαΠζΛ͓͑͞ΒΕΔ ◦ ௨৴ʹ͔͔Δ࣌ؒΛ୹ॖͰ͖Δ ◦ σόΠε͕ඞཁͱ͢ΔσΟεΫαΠζΛ͓͑͞ΒΕΔ • ։ൃऀʹΑΔ։ൃޮ཰ͷ޲্Λ໨తͱ͢Δ΋ͷͰ͸ͳ͍

    • ͦ΋ͦ΋ɺୡ੒͍ͨ͠໨త͕ҟͳΔͷͰ౰ͨΓલͰ͸͋Δ ։ൃޮ཰޲্ͱ͍͏؍఺ʹΑΔධՁ
  13. ❝ It is important to note that in order to

    generate a firmware patch file, you will need to supply two full firmware update files, the firmware that the target is updating from (currently running) and the firmware the device will be updating to (the desired new firmware). Attempting to apply a firmware patch to a target that is not running the "from" firmware will result in returning an error when attempting to apply it. ❞ mix firmware.patchͷ஫ҙ఺ʢ1ʣ ※: https://hexdocs.pm/nerves/experimental-features.html#firmware-patches
  14. ❝ Yes, you can't run it twice. It's not usable

    for what I think that you're doing. I'll try to finish off that code change that I was talking about so that mix firmware.patch will make more sense. Right now, I think mix firmware.patch is only valuable to see the result of tweaking firmware generation options on patch size. ❞ mix firmware.patchͷ஫ҙ఺ʢ2ʣ ※: https://github.com/nerves-project/nerves/issues/579#issuecomment-753522442
  15. • ࠷ۙͷNervesͰɺmix firmware.patchͱ͍͏mixλεΫ͕௥Ճ͞Εͨ • ϑϧͷΠϝʔδʹൺ΂ͯϑΝΠϧαΠζ͕਺෼ͷ1ʹͳΔ • ։ൃޮ཰޲্ͱ͍͏؍఺Ͱ͸ɺ͋·Γҙຯ͕ͳ͍ʢͦ΋ͦ΋ར༻໨త͕ҧ ͏ʣ • චऀͷϞνϕʔγϣϯ͕ಛघͳͷͰɺެฏͳ঺հʹ͸ͳ͍ͬͯͳ͍͜ͱʹ஫

    ҙ • σόΠε΁ͷΞοϓϩʔυͷ෦෼͸·ͩ׬੒͍ͯ͠ͳ͍Α͏ͳͷͰɺࠓޙʹ ظ଴ ·ͱΊ