#!/bin/sh

export LD_LIBRARY_PATH=/tmp/lib:$LD_LIBRARY_PATH:

cd /tmp/

chmod 777 web/images/*
chmod 777 web/css/*
chmod 777 web/js/*
chmod 777 web/*
chmod 777 ko/extdrv/*
chmod 777 ko/*
chmod 777 lib/*
chmod 777 *
chmod 777 nginx/sbin/*
chmod 777 samba/bin/*

edid_config=$(cat /box/box.ini | grep 'edid_index:')
edid=${edid_config:11:1}
edid_size=`echo "$edid" | wc -c`
if [ "$edid_size" = "2" ]
then
	cp /tmp/edid/$edid.* /tmp/edid.bin
	echo edid is index $edid
fi

cd /tmp/ko
./load3519v101 -i -offline

cd /tmp/
./reset &
#./remserial -p 5150 -s "9600 raw" /dev/ttyAMA1 &


himm 0x12040058 0 # GPIO1_5 RESET MUX SEL
himm 0x12040028 0 # GPIO3_0 RECORD BUTTON MUX SEL
himm 0x12040064 0 # GPIO3_1 RECORD LED MUX SEL
himm 0x12040068 0 # GPIO3_2 GREEN MUX SEL
himm 0x1204006C 0 # GPIO3_3 BLUE MUX SEL
himm 0x12040070 0 # GPIO3_4 RED MUX SEL

himm 0x12141400 0 # GPIO1 DIR

himm 0x12143400 0x1E # GPIO3 DIR

himm 0x12143008 0x2 # GPIO3_1 RECORD LED OFF
himm 0x12143010 0x4 # GPIO3_2 GREEN OFF
himm 0x12143020 0x8 # GPIO3_3 BLUE OFF
himm 0x12143040 0x0 # GPIO3_4 RED ON

himm 0x12040010 0 # GPIO0_2 MUX SEL
himm 0x12040014 0 # GPIO0_3 MUX SEL

himm 0x12140400 0xE # GPIO0 DIR

himm 0x12140010 0 # GPIO0_2 LOW

echo 20480000 > /proc/sys/net/core/wmem_default
echo 40960000 > /proc/sys/net/core/wmem_max

ifconfig lo up

/tmp/nginx/sbin/nginx -p /tmp/nginx/
/tmp/samba/bin/smbd -D

#RJ45
himm 0x100503c4 0xd04
himm 0x100503c0 0x11011f
himm 0x100503c4 0x17b
himm 0x100503c0 0x110110

./box.x9
