8000 sidekiqz2: add support for new board · analogdevicesinc/buildroot@33f2ba4 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 33f2ba4

Browse files
committed
sidekiqz2: add support for new board
This patch adds support for the Sidekiq Z2 board from Epiq Solutions. It's a copy of Pluto with some adaptations inspired from M2k. Seems that M2k re-uses some Pluto parts. The same thing has been done for SidekiqZ2 to avoid some code duplication. The `msd` folder [which contains files that will be mounted on the user's system] contains only some stub files that may be modified later. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
1 parent a8fcddf commit 33f2ba4

14 files changed

+1459
-1
lines changed

board/sidekiqz2/S23udc

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/bin/sh
2+
3+
source /etc/device_config
4+
5+
CONFIGFS=/sys/kernel/config/usb_gadget
6+
GADGET=$CONFIGFS/composite_gadget
7+
IIOD_OPTS="-D -n $ENDPOINTS -F /dev/iio_ffs"
8+
UDC_HANDLE_SUSPEND=`fw_printenv -n udc_handle_suspend 2> /dev/null || echo 0`
9+
10+
create_iiod_context_attributes() {
11+
model=$1
12+
serial=$2
13+
model_variant=$3
14+
15+
echo "[Context Attributes]" > /etc/libiio.ini
16+
echo "hw_model=$model" >> /etc/libiio.ini
17+
18+
if [ "$model_variant" == "n25q256a" ]
19+
then
20+
echo "hw_model_variant=0" >> /etc/libiio.ini
21+
else
22+
echo "hw_model_variant=1" >> /etc/libiio.ini
23+
fi
24+
25+
echo -e "hw_serial=$serial\n" >> /etc/libiio.ini
26+
echo "fw_version=`grep device-fw /opt/VERSIONS | cut -d ' ' -f 2`" >> /etc/libiio.ini
27+
if [ "$USBPID" == "0x5a32" ]; then
28+
for dev in /sys/bus/iio/devices/*; do
29+
[ `cat ${dev}/name` == "ad9361-phy" ] && DEV_NAME=`basename ${dev}`
30+
done
31+
32+
echo ad9361-phy,xo_correction=`cat /sys/bus/iio/devices/${DEV_NAME}/xo_correction` >> /etc/libiio.ini
33+
echo ad9361-phy,model=`cat /sys/bus/iio/devices/${DEV_NAME}/of_node/compatible` | sed 's/adi,//g' >> /etc/libiio.ini
34+
fi
35+
}
36+
37+
case "$1" in
38+
start)
39+
echo -n "Starting UDC Gadgets: "
40+
mount configfs -t configfs /sys/kernel/config 2> /dev/null
41+
42+
mkdir -p $GADGET
43+
44+
model=`cat /sys/firmware/devicetree/base/model | tr / -`
45+
model_variant=`dmesg | grep m25p80 | grep Kbytes | cut -d ' ' -f 3`
46+
47+
serial=`dmesg | grep SPI-NOR-UniqueID`
48+
serial=${serial#*SPI-NOR-UniqueID }
49+
50+
create_iiod_context_attributes "$model" "$serial" "$model_variant"
51+
52+
echo $serial > /etc/serial
53+
sha1=`echo $serial | sha1sum`
54+
55+
echo 0x0456 > $GADGET/idVendor
56+
echo $USBPID > $GADGET/idProduct
57+
58+
mkdir -p $GADGET/strings/0x409
59+
echo "Epiq Solutions" > $GADGET/strings/0x409/manufacturer
60+
echo $PRODUCT > $GADGET/strings/0x409/product
61+
echo $serial > $GADGET/strings/0x409/serialnumber
62+
63+
mkdir -p $GADGET/functions/ffs.iio_ffs
64+
mkdir -p $GADGET/functions/acm.usb0
65+
mkdir -p $GADGET/functions/rndis.0
66+
mkdir -p $GADGET/functions/mass_storage.0
67+
68+
# echo /opt/vfat.img > $GADGET/functions/mass_storage.0/lun.0/file
69+
echo Y > $GADGET/functions/mass_storage.0/lun.0/removable
70+
71+
host_addr=`echo -n 00:E0:22; echo $sha1 | dd bs=1 count=6 2>/dev/null | hexdump -v -e '/1 ":%01c""%c"'`
72+
dev_addr=`echo -n 00:05:F7; echo $sha1 | dd bs=1 count=6 skip=6 2>/dev/null | hexdump -v -e '/1 ":%01c""%c"'`
73+
74+
echo $host_addr > $GADGET/functions/rndis.0/host_addr
75+
echo $dev_addr > $GADGET/functions/rndis.0/dev_addr
76+
77+
mkdir -p $GADGET/configs/c.1
78+
mkdir -p $GADGET/configs/c.1/strings/0x409
79+
echo "RNDIS/MSD/ACM/IIOUSBD" > $GADGET/configs/c.1/strings/0x409/configuration
80+
echo 500 > $GADGET/configs/c.1/MaxPower
81+
82+
ln -s $GADGET/functions/rndis.0 $GADGET/configs/c.1
83+
ln -s $GADGET/functions/mass_storage.0 $GADGET/configs/c.1
84+
ln -s $GADGET/functions/acm.usb0 $GADGET/configs/c.1
85+
ln -s $GADGET/functions/ffs.iio_ffs $GADGET/configs/c.1/ffs.iio_ffs
86+
87+
mkdir -p /dev/iio_ffs
88+
mount iio_ffs -t functionfs /dev/iio_ffs 2> /dev/null
89+
90+
start-stop-daemon -S -b -q -m -p /var/run/iiod.pid -x /usr/sbin/iiod -- $IIOD_OPTS
91+
sleep 0.2
92+
93+
echo ci_hdrc.0 > $GADGET/UDC
94+
95+
[ $? = 0 ] && echo "OK" || echo "FAIL"
96+
97+
if [ "$UDC_HANDLE_SUSPEND" == "1" ]; then
98+
start-stop-daemon -S -b -q -m -p /var/run/udc_handle_suspend.pid -x /sbin/udc_handle_suspend.sh
99+
fi
100+
101+
;;
102+
stop)
103+
echo "Stopping UDC Gadgets"
104+
105+
if [ "$UDC_HANDLE_SUSPEND" == "1" ]; then
106+
start-stop-daemon -K -q -p /var/run/udc_handle_suspend.pid 2>/dev/null
107+
fi
108+
109+
echo "" > $GADGET/UDC
110+
start-stop-daemon -K -q -p /var/run/iiod.pid 2>/dev/null
111+
112+
rm $GADGET/configs/c.1/rndis.0
113+
rm $GADGET/configs/c.1/mass_storage.0
114+
rm $GADGET/configs/c.1/acm.usb0
115+
rm $GADGET/configs/c.1/ffs.iio_ffs
116+
117+
rmdir $GADGET/strings/0x409
118+
rmdir $GADGET/configs/c.1/strings/0x409
119+
rmdir $GADGET/configs/c.1
120+
121+
rmdir $GADGET/functions/ffs.iio_ffs
122+
#rmdir $GADGET/functions/acm.usb0
123+
rmdir $GADGET/functions/rndis.0
124+
rmdir $GADGET/functions/mass_storage.0
125+
126+
rmdir $GADGET 2> /dev/null
127+
128+
;;
129+
restart|reload)
130+
"$0" stop
131+
"$0" start
132+
;;
133+
*)
134+
echo "Usage: $0 {start|stop|restart}"
135+
exit 1
136+
esac
137+
138+
exit $?
139+
140+
141+
142+
143+
144+

0 commit comments

Comments
 (0)
0