Geontech / meta-redhawk-sdr

REDHAWK SDR Layer for Yocto/OpenEmbedded -based deployments
http://geontech.com/getting-started-with-meta-redhawk-sdr/
GNU Lesser General Public License v3.0
9 stars 6 forks source link

Make build-image.sh compatible with previous versions #19

Closed btgoodwin closed 5 years ago

btgoodwin commented 7 years ago

To the best of our ability, let's make the build-image.sh script establish some level of backwards compatibility to previous layers. See merge on 06ff489191194292aed6386407602049e07ec887.

rodrigo455 commented 7 years ago

I would think of something like this:

echo MACHINE:     "${MACHINE:?Need to set to an available machine}"
echo BUILD_IMAGE: "${BUILD_IMAGE:?Need to set, e.g., 'redhawk-base-image'}"

META_REDHAWK="../poky/meta-redhawk-sdr"
if ! [[ -d "${META_REDHAWK}" ]]; then
    META_REDHAWK=`find .. -path ./${PWD##*/} -prune -o -name meta-redhawk-sdr -type d`
fi
echo "Meta-REDHAWK-SDR Root found: ${META_REDHAWK}"
if ! [[ -n "${META_REDHAWK}" ]]; then
    echo "Could not find meta-redhawk-sdr folder beginning at the parent directory."
    echo "This will be necessary for calling WKS later."
    exit 1
fi

echo "STEP 1 - Starting Bit Bake ${BUILD_IMAGE}"
if ! bitbake ${BUILD_IMAGE}; then
    echo "Bitbake build image failed"
    exit 1
fi

echo "STEP 2 - Building tools to run wic"
if ! bitbake dosfstools-native mtools-native parted-native; then
    echo "Failed to install tools for building the SD image."
    exit 1
fi
if ! bitbake wic-tools; then
    echo "wic-tools recipe not present or bitbake failed"
    WIC_OUT="images/${MACHINE}"
else
    WIC_OUT="images/${MACHINE}/build"
fi

echo "STEP 3 - Building SD Card Image"
rm -rf images/${MACHINE}/build
if ! wic create ${META_REDHAWK}/contrib/wks/sdimage-8G.wks -e ${BUILD_IMAGE} -o ${WIC_OUT}; then
    echo "Bitbake build image to SD Card build failed"
    exit 1
fi

echo "STEP 4 - Packaging image"
export IMAGE_NAME=`ls images/${MACHINE}/build/sdimage*mmcblk.direct`
xz -k ${IMAGE_NAME}
mv ${IMAGE_NAME}.xz images/${MACHINE}/sdimage-${BUILD_IMAGE}.direct.xz
mv ${IMAGE_NAME} images/${MACHINE}/sdimage-${BUILD_IMAGE}.direct
md5sum images/${MACHINE}/sdimage-${BUILD_IMAGE}.direct.xz > images/${MACHINE}/sdimage-${BUILD_IMAGE}.direct.xz.md5

echo "FINISHED:"
echo    "Archive is at: images/${MACHINE}/sdimage-${BUILD_IMAGE}.direct.xz"
echo    "Next: sudo dd if=images/${MACHINE}/sdimage-${BUILD_IMAGE}.direct of=SD CARD bs=1M"

It's working on pyro...

rodrigo455 commented 6 years ago

is this issue still a thing? balister has updated e310 bsp for rocko. ettus research/national instruments seems to be working on that too.

btgoodwin commented 6 years ago

Probably not, no. Honestly it's a bit end user specific for us at this point. On a current project, I'm using wic as part of my image types rather than using the build script at all. So when I run bitbake my_image, I end up with the disk image in my deploy directory. I believe they're doing that in the e310 layer now too (talked with him the other day on IRC).

The OE documentation is a little sparse on how to set it up. So what I settled on doing is putting the .wks file in the layer's wic directory:

layer/conf
layer/wic
layer/wic/partition_scheme.wks
layer/recipes-...

Then in the machine definition (alternatively, image or local.conf), set:

WKS_FILE = "parition_scheme.wks"
IMAGE_FSTYPES = "wic wic.xz"

The output in tmp/deploy/images/<machine> is a .wic file and a compressed one, .wic.xz. The .wic file can be written to the SD card using dd like the .direct file from this script. The trick was having to specify both wic followed by wic.<one of the IMAGE_TYPES>. The IMAGE_TYPES is defined in poky/meta/classes/image_types.bbclass.

btgoodwin commented 5 years ago

I'm going to close this for now. Most of the projects we're using are wic-based so I think this script is really worth deleting at this point to avoid having to maintain it.