content="Install meshctl on Raspberry Pi. Follow these instructions to install… | by Lup Yuen Lee 李立源 | Medium" />
<metadata-rh="true"property="og:title"content="Install meshctl on Raspberry Pi"/>
<metadata-rh="true"property="twitter:title"content="Install meshctl on Raspberry Pi"/>
<metadata-rh="true"name="description"
content="Follow these instructions to install the Bluetooth Mesh provisioning tool meshctl for Raspberry Pi for the article “Bluetooth Mesh with nRF52 and Apache Mynewt” meshctl is part of the open-source…" />
<metadata-rh="true"property="og:description"
content="Follow these instructions to install the Bluetooth Mesh provisioning tool meshctl for Raspberry Pi for the article “Bluetooth Mesh with…" />
<metadata-rh="true"property="twitter:description"
content="Follow these instructions to install the Bluetooth Mesh provisioning tool meshctl for Raspberry Pi for the article “Bluetooth Mesh with…" />
class="bh fw hm hn ho hp" target="_blank" rel="noopener nofollow"><emclass="hl">Developer Study
Guide: Deploying BlueZ v5.50 on Raspberry Pi3, Part 1 — Deployment</em></a><emclass="hl">”</em>
</p>
<pid="a6a6"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Follow the
instructions in the sections…</p>
<pid="45f2"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><em
class="hl">“0. Prerequisite”</em></p>
<pid="8c11"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><em
class="hl">“1. Install BlueZ v5.50”</em></p>
<pid="903b"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><strong
class="gq iy">BUT stop before</strong><emclass="hl">“2. Rebuilding the kernel for BlueZ
v5.50”</em></p>
</div>
</div>
</section>
<hrclass="hq dj hr hs ht hu dg hv hw hx hy hz"/>
<sectionclass="cg ch ci cj ck">
<divclass="n p">
<divclass="z ab ac ae af dl ah ai">
<h1id="1a41"class="ia ib bo bn ic id ie if ig ih ii ij ik il im in io ip iq ir is ef">2. Download Pi
Kernel Source Files</h1>
<pid="4dc0"class="go gp bo gq b gr it gt gu iu gw gx iv gz ha iw hc hd ix hf hg cg ef">We shall
rebuild the Pi kernel now. Why? Because <codeclass="cy hh hi hj hk b">meshctl</code> needs
AEAD-AES_CCM encryption, which runs as a secure service in the kernel. This may take an hour or more
to complete.</p>
<pid="cd37"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Enter the
following at a command prompt…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="c1da"class="ef jh ib bo hk b dk ji jj r jk">cd ~<br/>sudo apt-get install -y git bc bison flex libssl-dev<br/>uname -a</span></pre>
<pid="1020"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">You should see
a message like…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="ffa2"class="ef jh ib bo hk b dk ji jj r jk">Linux raspberrypi <strongclass="hk iy">4.19</strong>.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux</span></pre>
<pid="85c7"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">See the <code
class="cy hh hi hj hk b">4.19</code> part? This is important — it’s the <strong
class="gq iy">Version Number</strong> for your Pi kernel. We need to fetch the kernel source files
for our kernel version, or our Pi won’t boot after rebuilding the kernel.</p>
<pid="76a4"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Enter this
command…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="7f53"class="ef jh ib bo hk b dk ji jj r jk">git clone --depth=1 --branch rpi-<strongclass="hk iy">4.19</strong>.y https://github.com/raspberrypi/linux</span></pre>
<pid="a69a"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><strong
class="gq iy">BUT replace </strong><code
class="cy hh hi hj hk b"><strongclass="gq iy">4.19</strong></code><strongclass="gq iy"> by your Pi
Kernel Version Number</strong>.</p>
</div>
</div>
</section>
<hrclass="hq dj hr hs ht hu dg hv hw hx hy hz"/>
<sectionclass="cg ch ci cj ck">
<divclass="n p">
<divclass="z ab ac ae af dl ah ai">
<h1id="0528"class="ia ib bo bn ic id ie if ig ih ii ij ik il im in io ip iq ir is ef">3. Initialise Pi
Kernel Settings</h1>
<pid="ed14"class="go gp bo gq b gr it gt gu iu gw gx iv gz ha iw hc hd ix hf hg cg ef">We shall now
initialise the new Pi kernel to the default settings…</p>
<pid="2c40"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><strong
class="gq iy"><emclass="hl">For Raspberry Pi 1, Pi Zero, Pi Zero W, and Compute Module,
enter…</em></strong></p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="b0f0"class="ef jh ib bo hk b dk ji jj r jk">cd linux<br/>KERNEL=kernel<br/>make bcmrpi_defconfig</span></pre>
<pid="5dc3"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><strong
class="gq iy"><emclass="hl">For Raspberry Pi 2, Pi 3, Pi 3+, and Compute Module 3,
enter…</em></strong></p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="f3e3"class="ef jh ib bo hk b dk ji jj r jk">cd linux<br/>KERNEL=kernel7<br/>make bcm2709_defconfig</span></pre>
<pid="929b"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef"><strong
class="gq iy"><emclass="hl">For Raspberry Pi 4, enter…</em></strong></p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="b650"class="ef jh ib bo hk b dk ji jj r jk">cd linux<br/>KERNEL=kernel7l<br/>make bcm2711_defconfig</span></pre>
</div>
</div>
</section>
<hrclass="hq dj hr hs ht hu dg hv hw hx hy hz"/>
<sectionclass="cg ch ci cj ck">
<divclass="n p">
<divclass="z ab ac ae af dl ah ai">
<h1id="0fe1"class="ia ib bo bn ic id ie if ig ih ii ij ik il im in io ip iq ir is ef">4. Configure Pi
Kernel</h1>
<pid="d75b"class="go gp bo gq b gr it gt gu iu gw gx iv gz ha iw hc hd ix hf hg cg ef">Let’s configure
the kernel and select the AEAD-AES_CCM encryption needed by <code
class="cy hh hi hj hk b">meshctl</code>. Enter…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="1e0f"class="ef jh ib bo hk b dk ji jj r jk">make menuconfig</span></pre>
<pid="61a5"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Press the arrow
keys to move the cursor to <codeclass="cy hh hi hj hk b">Cryptographic API.</code></p>
<h1id="0c72"class="ia ib bo bn ic id ie if ig ih ii ij ik il im in io ip iq ir is ef">5. Build Pi
Kernel</h1>
<pid="0b9c"class="go gp bo gq b gr it gt gu iu gw gx iv gz ha iw hc hd ix hf hg cg ef">Before building
the kernel, we’ll backup the old kernel into <codeclass="cy hh hi hj hk b">/OLDboot</code> in case
the new kernel fails. Enter…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="09f5"class="ef jh ib bo hk b dk ji jj r jk">sudo cp -r /boot /OLDboot</span></pre>
<pid="4c2f"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Now we build
and install the kernel. Enter…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="a55e"class="ef jh ib bo hk b dk ji jj r jk">make -j4 zImage modules dtbs<br/>sudo make modules_install<br/>sudo cp arch/arm/boot/dts/*.dtb /boot/<br/>sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/<br/>sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/<br/>sudo cp arch/arm/boot/zImage /boot/$KERNEL.img<br/>sudo sync<br/>sudo reboot</span></pre>
<pid="b812"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">This kernel
build may take an hour or more to complete. When it’s done our Pi should reboot with the new kernel.
</p>
</div>
</div>
</section>
<hrclass="hq dj hr hs ht hu dg hv hw hx hy hz"/>
<sectionclass="cg ch ci cj ck">
<divclass="n p">
<divclass="z ab ac ae af dl ah ai">
<h1id="1994"class="ia ib bo bn ic id ie if ig ih ii ij ik il im in io ip iq ir is ef">6. Test meshctl
</h1>
<pid="60eb"class="go gp bo gq b gr it gt gu iu gw gx iv gz ha iw hc hd ix hf hg cg ef">After
rebooting, open a command prompt and enter…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="5461"class="ef jh ib bo hk b dk ji jj r jk">meshctl</span></pre>
<pid="bd1d"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Press <code
class="cy hh hi hj hk b">Enter</code> to see the <codeclass="cy hh hi hj hk b">[meshctl]#</code>
prompt.</p>
<pid="ed4f"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">If you don’t
see any errors, congratulations you have installed <codeclass="cy hh hi hj hk b">meshctl</code>!</p>
<pid="a8ea"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Enter this to
exit <codeclass="cy hh hi hj hk b">meshctl</code>…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="12b0"class="ef jh ib bo hk b dk ji jj r jk">exit</span></pre>
<pid="8874"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">Remember:
Always exit <codeclass="cy hh hi hj hk b">meshctl</code> properly, otherwise it will lock on to the
Bluetooth driver and you would need to reboot the Pi to fix this.</p>
<pid="739a"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">If you see this
message instead…</p>
<pre
class="iz ja jb jc jd je jf jg"><spanid="65fa"class="ef jh ib bo hk b dk ji jj r jk">Failed to parse provisioning database file prov_db.json</span></pre>
<pid="91b7"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg cg ef">It means that
your kernel still doesn’t have AEAD-AES_CCM encryption installed. Carefully redo each step from the
top of this article.</p>
</div>
</div>
</section>
<hrclass="hq dj hr hs ht hu dg hv hw hx hy hz"/>
<sectionclass="cg ch ci cj ck">
<divclass="n p">
<divclass="z ab ac ae af dl ah ai">
<h1id="86ba"class="ia ib bo bn ic id ie if ig ih ii ij ik il im in io ip iq ir is ef">References</h1>
<pid="34d7"class="go gp bo gq b gr it gt gu iu gw gx iv gz ha iw hc hd ix hf hg cg ef">If you have
problems configuring and building the Pi kernel, refer to the official guides…</p>
<olclass="">
<liid="12ce"class="go gp bo gq b gr gs gt gu gv gw gx gy gz ha hb hc hd he hf hg jz ka kb ef"><em