issue with usb_serial.sh in official image

Started by thom_nic, January 18, 2017, 11:42:28 PM

Previous topic - Next topic

thom_nic

Following the instructions for building the image, you're writing out `usb_serial.sh` using a heredoc, however the contents containing shell vars are being interpreted in the host shell instead of being written out to the script.  Thus the resulting script looks like this:


# Set strings
mkdir strings/0x409
echo  > strings/0x409/serialnumber
echo  > strings/0x409/manufacturer
echo  > strings/0x409/product

# Create configuration
mkdir configs/c.1
mkdir configs/c.1/strings/0x409
echo "120" > configs/c.1/MaxPower
echo  > configs/c.1/strings/0x409/configuration

# Creating functions
mkdir functions/acm.usb0

# Associate function with comfiguration
ln -s functions/acm.usb0 configs/c.1

# Enable UDC
echo  > UDC


Note all the `echo` lines that should be echoing a value from a variable are just echoing an empty string.  Should want to fix this in the next release of the official image. 

thom_nic

#1
I realized the issue is the first line:


cat << __EOF__ > /usr/bin/usb_serial.sh


The heredoc delimiter must be quoted to disable immediate evaluation of the contents, like so:


cat <<"__EOF__" > /usr/bin/usb_serial.sh

thom_nic

#2
Also the very first line reads

#/bin/sh

instead of

#!/bin/sh