Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => AM3352 => Topic started by: thom_nic on January 18, 2017, 11:42:28 PM

Title: issue with usb_serial.sh in official image
Post by: thom_nic on January 18, 2017, 11:42:28 PM
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. 
Title: Re: issue with usb_serial.sh in official image
Post by: thom_nic on February 03, 2017, 10:58:01 PM
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
Title: Re: issue with usb_serial.sh in official image
Post by: thom_nic on February 03, 2017, 11:38:43 PM
Also the very first line reads

#/bin/sh

instead of

#!/bin/sh