Difference between revisions of "Custom Software Deployment with EMAC OE"
m (→Manufacturing Boards with a Filesystem Image: Improved) |
m (→Manufacturing Boards with a Filesystem Image: Fixed wording.) |
||
Line 69: | Line 69: | ||
===Manufacturing Boards with a Filesystem Image=== | ===Manufacturing Boards with a Filesystem Image=== | ||
− | Once a custom distribution has been created for you, that distribution can be given a unique part number and kept as a disk image on our server. Subsequent purchases of that part number are guaranteed to contain software identical to the original and the image can be installed on subsequent orders | + | Once a custom distribution has been created for you, that distribution can be given a unique part number and kept as a disk image on our server. Subsequent purchases of that part number are guaranteed to contain software identical to the original and the image can be installed on subsequent orders at no charge. As a value-added service, we can even incorporate your application and utilities and combine them on the disk image, saving you time and effort. If you require an updated build, you would only pay once for the normal build fees and the image could then replace the previous version on our server. Additionally, EMAC can provide integration services for custom products. Please contact EMAC for information on obtaining these services. |
==Other Considerations== | ==Other Considerations== |
Revision as of 19:44, 17 December 2013
There are many considerations to take into account when deploying software. This guide was written to provide guidance regarding the decisions relevant to deployment on EMAC OE systems.
File Locations
Program Files
Configuration Files
Temporary Files
Test Versions of Programs
Filesystem Considerations
There are various important considerations when it comes to the filesystem for an embedded system. Here is a list of some of those considerations, along with recommendations or guidelines for the decisions which need to be made regarding filesystems.
Keeping the Root Filesystem Read-Only
Ensuring that the root filesystem stays read-only the entire time the machine is running is one of the best ways to ensure reliability of the machine. A machine with a writeable filesystem may lose power suddenly while writing to disk, which could cause corruption to the filesystem. A read-only filesystem ensures this type of corruption will not occur.
When software on a machine needs to write data somewhere, there are two good alternatives to writing to the root filesystem:
- Write to a RAM disk.
- Write to a dedicated data storage device.
Data can be written to a RAM disk if it doesn't need to persist across boots. This is perfect for temporary information, such as a device's IP address as assigned by a DHCP server. Writing data to RAM provides the additional benefit of preventing wear of the flash.
When data needs to persist across boots, it can be written to a dedicated storage device. This storage device can be a separate partition on the main flash device, a partition on a removable flash device, a network filesystem, a remote database, a remote FTP server, or something else. Two such storage devices are described below.
Choosing a Filesystem for a Data Partition
There are many filesystems available for Linux. The correct filesystem to use depends upon the application. Here are some guidelines:
-
Determine whether the filesystem needs to be read/write, or if it can be read-only.
-
If read-only, any filesystem can be used so long as it meets the requirements of point 3.
-
If read-write, all other points in this list need to be considered.
-
-
Determine the type of physical storage which will be used.
-
If flash, then a flash friendly filesystem will be needed. A flash friendly filesystem will provide wear leveling, and possibly other features pertaining to flash storage devices. An example is JFFS2.
-
If a hard disk will be used, a traditional filesystem will be a better fit. An example is ext2.
-
-
Determine whether or not Linux filesystem permissions need to be preserved.
-
If so, avoid FAT and NTFS filesystems.
-
If not, any filesystem meeting the other requirements can be chosen.
-
-
Determine whether or not the machine needs to be capable of dealing with sudden power loss (as opposed to a battery backup which initiates auto-shutdown).
-
If so, a journalled filesystem will be required.
-
If not, a filesystem without journalling is an option which might provide higher performance (but not always).
-
Remember, reliability is usually more important in embedded systems than speed. The filesystem should usually be chosen for reliability first, then speed.
Using Removable Flash for Data Storage
Removable flash devices, such as SD cards and USB flash drives, can be used to store data. Using such a device provides the following benefits:
- Storage device can easily be swapped out when full.
- Data can be quickly and easily retrieved, even if no network connection to the board is available or the board is on a low bandwidth connection.
- Wear occurs on a removable and easily replaceable flash rather than on an on-board chip.
- Storage space can be easily upgraded as data demands grow.
For information on mounting a flash device temporarily, see Mounting a Flash Filesystem. When satisfied with a method of mounting the flash, an entry in the /etc/fstab
can be created to ensure that the flash is mounted automatically at boot. Alternatively, udev
can be configured to always mount the flash device at a specific location; this method allows hot-plugging the flash devices.
Preparing a Filesystem for a Snapshot
Prior to taking a snapshot of a filesystem, it must be prepared for deployment. This preparation process involves cleaning up any temporary files and settings, configuring the desired default settings for the machines produced, and removing any machine-specific information (such as SSH keys) from the filesystem. The Deployment Tips section below provides a checklist of items to address prior to taking a snapshot of a filesystem.
Manufacturing Boards with a Filesystem Image
Once a custom distribution has been created for you, that distribution can be given a unique part number and kept as a disk image on our server. Subsequent purchases of that part number are guaranteed to contain software identical to the original and the image can be installed on subsequent orders at no charge. As a value-added service, we can even incorporate your application and utilities and combine them on the disk image, saving you time and effort. If you require an updated build, you would only pay once for the normal build fees and the image could then replace the previous version on our server. Additionally, EMAC can provide integration services for custom products. Please contact EMAC for information on obtaining these services.
Other Considerations
Launching Software Automatically on Boot
When software is created for an embedded system, it is often required for the software to start when the machine boots. The best approach to meeting this requirement is to use the robust initialization system which is part of the Linux filesystem. Configuring the initialization system to launch an application is performed by creating a simple script, placing it in the correct spot in the filesystem, then creating appropriate symbolic links to the script.
For more information on this process, see EMAC_OE_Boot_Process_Customization.
Automatically Sending Code to a Machine
During the development process, development versions of software will typically be sent to a machine many times. An IDE, when configured correctly, will perform this task automatically as part of the build process. An IDE may also be able to send additional files to the machine, such as configuration and data files, automatically as part of a customized build process.
When developing software without an IDE, the process of sending software to a machine can still be automated. The sshpass
program can be used to automate entry of a password to ssh
and related tools, such as scp
. For instance, the following command would send the file, myprogram
, to the board located at 10.0.1.20 and store it in the /usr/local/bin
directory on that machine:
user@ldc:~$ sshpass -p 'emac_inc' scp myprogram root@10.0.1.20:/usr/local/bin/
The following command would then execute myprogram
:
user@ldc:~$ sshpass -p 'emac_inc' ssh -l root 10.0.1.20 "/usr/local/bin/myprogram"
Here, the password is passed to sshpass
as a commandline argument. Since this means it's possible for the password to show up in the output of a command like ps
, there are other, more secure options as well. The sshpass
command can also take the password from any of the following sources: a file, an open file descriptor, or a shell environment variable. Please see the manual for sshpass
for more information.
Note that the sshpass command usually needs to be installed with the package manager of a Linux distribution. On Ubuntu, it can be installed with this command:
user@ldc:~$ sudo apt-get install sshpassFor other distributions, consult the packages available with your package manager. |
Deployment Tips
Here is a checklist of issues which need to be addressed prior to deployment:
-
Does the board boot into the desired state, reliably and repeatedly?
-
Have the ssh keys been removed?
-
Can the image of the filesystem be put on a different machine (with a different MAC address) than the development machine, and boot into the desired state reliably and repeatedly?
-
Is the network configuration of the machine set to the desired default for production machines?
-
Are any errors or warnings appearing in the log files on the machine while it's running? If so, can they be stopped?
-
Does the root filesystem mount read-only after the machine is booted?
-
Has a method to test the boards coming off the production line been determined and accounted for?
-
Are all the passwords set to their desired defaults?
-
Have all of the temporary files from the development process been removed, such as
.tar.gz
files and saved work-in-progress configuration files? -
Is the timezone configured to the desired default timezone?
-
If an
sshd
server is going to run on the machine, is it configured with adequate security? Have all preshared SSH keys on the machine been removed? -
If a static IP is configured for the default, does the
/etc/resolv.conf
file specify appropriate defaults for the DNS servers and the search domain?
Conclusion
There are many considerations to take into account when preparing to deploy an embedded system. Following the recommendations and checklist above will help prevent a developer from forgetting details which need to be addressed prior to final deployment.