element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Pi IoT
  • Challenges & Projects
  • Design Challenges
  • Pi IoT
  • More
  • Cancel
Pi IoT
Blog [Pi IoT] Thuis #6: Installing the Raspberry Pi 3 in practice
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: rhe123
  • Date Created: 26 Jun 2016 1:01 PM Date Created
  • Views 934 views
  • Likes 3 likes
  • Comments 5 comments
  • z-wave
  • piiot
  • chef
  • wildfly
  • raspberrypi3
  • thuis
Related
Recommended

[Pi IoT] Thuis #6: Installing the Raspberry Pi 3 in practice

rhe123
rhe123
26 Jun 2016

Last week I explained how I'm using Chef to provision my Raspberry Pi's and the recipes in my Thuis cookbook. Back then I didn't have a Raspberry Pi 3 yet, so I tested it on an older model. This week the kit arrived, so I'll bring the bootstrapping in practice on the Raspberry Pi 3! Not everything went as expected, so this is a good subject for this blogpost.

 

The Kit

image

 

Installing the Raspberry Pi 3

As mentioned before I'm using raspbian-ua-netinst as a basis for my install, as this gives me a very lean install of Raspbian. The maintainers of the projects didn't update the installer yet for the Raspberry Pi 3, so there are some manual steps to go through for now. This is discussed in issue #375. It boils down to the following steps:

  1. Format the SD card
  2. Copy all files from the latest version to the SD card
  3. Fix the files for the Raspberry Pi 3:
    1. Copy (replace all) the files from the firmware repo using the handy tarball made by @eLvErDe
    2. Edit /boot/config.txt by adding the following at the end:

      [pi3] initramfs installer-rpi2.cpio.gz

  4. Insert the SD card in the Raspberry Pi and power it on
  5. Now wait until the installation finishes (it will take quite some time, when you don't have a screen attached wait until the ethernet connection becomes silent)
  6. SSH into the Raspberry using the default username root and password raspbian
  7. Now fix the kernel by installing and running rpi-update:

    apt-get install rpi-update rpi-update reboot now

  8. Edit /boot/config.txt again by changing [pi2] into [pi3]

 

The Raspberry Pi is now ready to be bootstrapped.

 

Bootstrapping Chef

Bootstrapping Chef is a matter of running one simple command from my workstation:

knife bootstrap 10.0.0.201 -t raspbian-jessie-chef.erb --ssh-user root --ssh-password 'raspbian' --node-name 'thuis-server-core' --run-list 'recipe[thuis::thuis-server-core]'

However I ran into a few complications. During my testing I didn't run into these because of the iterative process and some differences between the hardware of the two Raspberries.

 

Complication 1: systemd needs services to be reloaded

After installing WildFly the recipe tries to start the services; this however fails with a cryptic No such file or directory. The reason for this happens to be that systemd needs to be reloaded after adding new init-scripts. The WildFly recipe doesn't take care of this and therefor runs into the issue. To resolve the issue I forked the cookbook and added a systemctl daemon-reload command to it (see PR #38). This ensures it can start WildFly as expected.

 

Complication 2: For Z-Way bluetooth needs to be turned off

The RazBerry uses the serial IO pins on the Raspberry Pi, the same are used by the built-in Bluetooth connection as well. To be able to use the RazBerry and run Z-Way, Bluetooth has to be disabled. The original install script takes care of this, but after I converted it to be used in a Chef cookbook this didn't work anymore. That's why I converted these commands to Ruby blocks in my Chef recipe now. This looks as follows:image

ruby_block '/etc/inittab' do
 block do
  file = Chef::Util::FileEdit.new('/etc/inittab')
  file.search_file_delete_line(/[^:]*:[^:]*:respawn:\/sbin\/getty[^:]*ttyAMA0[^:]*/)
  file.write_file
 end
end

ruby_block '/boot/cmdline.txt' do
 block do
  file = Chef::Util::FileEdit.new('/boot/cmdline.txt')
  file.search_file_delete(/console=ttyAMA0,115200/)
  file.search_file_delete(/kgdboc=ttyAMA0,115200/)
  file.search_file_delete(/console=serial0,115200/)
  file.write_file
 end
end

ruby_block '/boot/config.txt' do
 block do
  file = Chef::Util::FileEdit.new('/boot/config.txt')
  file.insert_line_if_no_match(/dtoverlay=pi3-miniuart-bt/, 'dtoverlay=pi3-miniuart-bt')
  file.write_file
 end
end

 

Basically this deletes the serial connections from /etc/inittab and /boot/cmdline.txt and adds an option to /boot/config.txt to disable Bluetooth.

 

Complication 3: sudo commands not found

When trying to do a command using sudo, e.g. sudo shutdown now I got a Command not found error. This happens because /sbin and other secure directories are not on the PATH for a non-root user. When you use sudo it should be and for this a small piece of configuration is added for the sudo cookbook:

default['authorization']['sudo']['sudoers_defaults'] = [
  'env_reset',
  'secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"'
]

 

Configuring Z-Way

As I already have a working Z-Way setup at home the configuration is pretty easy. It boils down to:

  1. Browse to http://10.0.0.201:8083 (where 10.0.0.201 is the IP of your Raspberry)
  2. Choose a password of your own choice
  3. Restore the backups:
    1. For the controller (*.zbk): http://10.0.0.201:8083/expert/#/network/control
    2. And for the module automation (*.zab): http://10.0.0.201:8083/smarthome/#/admin
    3. If you used userModules then copy or install these again (their settings are part of the backup, but not the actual files)

 

Deploying an application to WildFly

This is easy as dropping an .ear of .war file to /opt/wildfly/standalone/deployments. Alternatively you can deploy the app as part of a Chef recipe like:

wildfly_deploy 'my-app-1.0.war' do
  url 'http://artifacts.company.com/artifacts/my-app.1.0.war'
  runtime_name 'my-app.war'
end

 

In the upcoming blogs I'll work on the Java app and integrating Z-Way with MQTT, then we'll do the actual deployment.

 

With the complications out of the way, the Raspberry Pi 3 is now fully ready to receive some app deployments, which is what I'll work on now!

  • Sign in to reply

Top Comments

  • fvan
    fvan over 9 years ago in reply to georgekav +3
    Using the "enable_uart" property, as I did, the UART0 can again be used for serial communication with any HAT, like EnOceanPi. The BT is then moved to the miniUART, and is still usable. No need to cripple…
  • fvan
    fvan over 9 years ago +1
    Did you try the "enable_uart" property in the "/boot/config.txt" ? It restores the UART, and keeps the BT operational. The UART interface is then "ttyS0" instead of "ttyAMA0" though. It's described in…
  • georgekav
    georgekav over 9 years ago in reply to fvan +1
    I had also to disable bluetooth and remap uart for the enocean pi to work properly using the hardware uart0 like rhe123 . Also basically the recommended by enocean (paper titled: Raspberry Pi talks EnOcean…
Parents
  • fvan
    fvan over 9 years ago

    Did you try the "enable_uart" property in the "/boot/config.txt"? It restores the UART, and keeps the BT operational. The UART interface is then "ttyS0" instead of "ttyAMA0" though.

    It's described in my EnOceanPi paragraph: https://www.element14.com/community/community/design-challenges/pi-iot/blog/2016/06/14/pi-iot-alarm-clock-05-enocean-sen…

     

    Frederick

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • georgekav
    georgekav over 9 years ago in reply to fvan

    I had also to disable bluetooth and remap uart for the enocean pi to work properly using the hardware uart0 like rhe123.

    Also basically the recommended by enocean (paper titled: Raspberry Pi talks EnOcean dated March 2014 12pages),  "rpi-serial-console disable" command is not any more valid due to /etc/inittab replacement by systemd.

     

    On the contrary I found the white paper "Raspberry Pi talks EnOcean" dated April 2016 14pages that explicitly recommends to disable the bluetooth because it used the uart. So it's not the problem of kernel console to be interfering (which you correctly disables in the boot config) but also the bluetooth pushing asynchronous messages in UART0. From my understanding the new device tree overlays are not only disabling the bluetooth but also remapping the UART0 MPU pins to the usual I/O header pins.

     

    Finally take a look here https://github.com/raspberrypi/firmware/commit/845eb064cb52af00f2ea33c0c9c54136f664a3e4  the maintainers state the need of the dto for use of the regular hardware UART0. Maybe without that fvan you are using the UART1 (according to this https://openenergymonitor.org/emon/node/12311 )?

     

    sorry for the long post image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 9 years ago in reply to georgekav

    Using the "enable_uart" property, as I did, the UART0 can again be used for serial communication with any HAT, like EnOceanPi. The BT is then moved to the miniUART, and is still usable.

     

    No need to cripple the Pi to get both working, as described in the RPi forums: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=141195

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • fvan
    fvan over 9 years ago in reply to georgekav

    Using the "enable_uart" property, as I did, the UART0 can again be used for serial communication with any HAT, like EnOceanPi. The BT is then moved to the miniUART, and is still usable.

     

    No need to cripple the Pi to get both working, as described in the RPi forums: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=141195

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • georgekav
    georgekav over 9 years ago in reply to fvan

    They claim mixed results in that link in fact. For some it is not enough.

    I looked here

    https://www.raspberrypi.org/forums/viewtopic.php?f=107&t=138223

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube