c Copying a Single File with a Yocto Recipe
Wolin Labs :: fun toys for your iThingy & Droid

Articles

Don't Lose your Garmin GPS!

Cron Job with Random Start Delay

Git Submodule with Local Changes Example

Using Caltopo Maps on your Garmin GPS

Waffle Reuben

Copying a Single File with a Yocto Recipe

Semihosting Debugging on STM32F4

Realtime Audio DSP with the STM32F4

Tuning the Moog Etherwave Theremin

STM32 Discovery Development on Linux

STM32F4 USB Virtual COM Port (VCP)

Editing GoPro Hero2 Video with Cinelerra

Code Browsing with Emacs, GLOBAL, and Speedbar

Use a PC Power Supply as a Bench Supply the Easy Way

Android Activity Bar Framework

Generating an Audio Sine Wave with Java

Android Simple Yes/No MessageBox

Fox Talas 32 Oil/Seal Change Checklist

Creating a Bootloader Environment (Freescale ColdFire Example)

Pentomino Smackdown: Names That Didn't Make the Cut

Copying a Single File with a Yocto Recipe

Ross Wolin - last updated 2014.12.10



What is Yocto?


Yocto is a sophisticated build system that produces a toolchain and builds the bootloader, kernel, and root filesystem for Linux distributions, independent of underlying architecture. Builds are run via Bitbake, which in turn may invoke Python scripts, makefiles, etc.



Copying a Script or File


You would think it would be easy to copy a single script or text file from the source area to the image area, rootfs area, etc with the Yocto build system... but you would be mistaken. =) I found a few samples on the Internet that showed how to do this: they worked when the recipe was run manually with 'bitbake <recipe-name>', but none of them worked when the package was added to the image via IMAGE_INSTALL, etc.

This is a sample recipe (in mksd.bb) which copies a single script file (mksd.sh) from the source area to the deployment area: my script in this case was for making a bootable sd card.


SUMMARY = "Copy mksd.sh script to image deployment area"
SECTION = "devel"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = \
"file://${WORKDIR}/mksd.sh;beginline=4;endline=7;md5=d8d50b7d91345eb72f51bbced7fc791b"
SRC_URI = "file://mksd.sh"

#This package doesn't have any files for the rootfs in it, option needed to create an empty 
# package so when the rootfs image is made it finds the mksd_xxx.deb package and doesn't complain
FILES_${PN} = ""
ALLOW_EMPTY_${PN} = "1"


# Copy script to the deploy area with u-boot, uImage, and rootfs
do_deploy () {
   install -d ${DEPLOY_DIR_IMAGE}
   install -m 0755 ${WORKDIR}/mksd.sh ${DEPLOY_DIR_IMAGE}
}
addtask deploy after do_install

Secret Sauce
The two lines highlighted in yellow comprise the magic "secret sauce" in this recipe.

If you add the mksd package to the image and try the mksd recipe without those lines, when you attempt to build the image you'll get an error like "Package mksd is not available, but is referred to by another package"

The problem is that the script file does not compile to produce an executable or any other output files to package in a .deb, .rpm, etc. Adding those two highlighted lines tells Bitbake to make an empty package, which appeases the Image Build Gods.


Licensing
For simplicity, I included the license in my script file in lines 4-7 (my script is a heavily modified version of Singh's original)


# Author: Brijesh Singh, Texas Instruments Inc.
#       : Adapted for TI816x by Siddharth Heroor, Texas Instruments Inc.
#
# Licensed under terms of GPLv2

I generated the recipe's license md5sum with the command: sed -n '4,7p' mksd.sh | md5sum


File Layout
The mksd.sh script is in a subdirectory named 'files', in the same directory as the mksd.bb recipe, i.e.
$/mksd.bb
$/files/mksd.sh



Links






Send comments, questions, money in large denominations, etc to eng at mysticengineering.com



If you enjoyed this article, please consider buying my products ...

ATX PS Adapter Ultimate Serial Port
ATX PS Adapter

Use an ATX PC power supply as a 5V, 3.3V, and +12V/-12V bench supply the easy way, without cutting the case or mounting external connectors, resistors, LEDs, switches, and fuses.

Provides visual indication when supply is plugged in and turned on, also fuses the power voltage outputs for safety. Run USB powered development boards via the USB connectors on the 5V line.

Ultimate Serial Port (Debug Buddy)

USB serial port with standard, 5V and 3V RS232, plus integrated null modem and gender changer. Implements TX/RX and RTS#/CTS# for optional hardware handshake.

Also includes 3.3V<->5V level shifters, debug LEDs, and 13 clock sources. Valuable tool for hands on problem solving and hacking