Commit 50351adc authored by carbon's avatar carbon

use buildroot to create rootfs

parent 713cbc4b
......@@ -37,4 +37,5 @@ CONFIG_ENABLE_RTOS_DUMP_PRINT=y
CONFIG_DUMP_PRINT_SZ_IDX=17
CONFIG_USE_4K_ERASE_SIZE_FOR_JFFS2=y
CONFIG_USB_OSDRV_CVITEK_GADGET=n
CONFIG_BUILDROOT_FS=y
CONFIG_BUILD_FOR_DEBUG=y
This diff is collapsed.
mnt/system/
\ No newline at end of file
#!/bin/sh
${CVI_SHOPTS}
#
# Start firmware
#
export USERDATAPATH=/mnt/data/
export SYSTEMPATH=/mnt/system/
case "$1" in
start)
echo "init mpp system..."
if [ -d $SYSTEMPATH/ko ]; then
sh $SYSTEMPATH/ko/loadsystemko.sh
fi
echo "Starting app..."
if [ -f $USERDATAPATH/auto.sh ]; then
usleep 30000
. $USERDATAPATH/auto.sh &
exit 1
fi
if [ -f $SYSTEMPATH/auto.sh ]; then
usleep 30000
. $SYSTEMPATH/auto.sh &
fi
;;
stop)
;;
restart|reload)
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id == tty to run on, or empty for /dev/console
# runlevels == ignored
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mount -o remount,rw /
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
::sysinit:/bin/mount -a
::sysinit:/sbin/swapon -a
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
::sysinit:/bin/hostname -F /etc/hostname
# now run any rc scripts
::sysinit:/etc/init.d/rcS
# Put a getty on the serial port
# console::respawn:/sbin/getty -L console 0 vt100 # GENERIC_SERIAL
console::respawn:/sbin/getty -L console 115200 vt100 -n -l /usr/local/bin/autologin
# Stuff to do for the 3-finger salute
#::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/mnt/system/usr/bin:/mnt/system/usr/sbin:/mnt/data/bin:/mnt/data/sbin"
if [ "$PS1" ]; then
if [ "`id -u`" -eq 0 ]; then
export PS1='# '
else
export PS1='$ '
fi
fi
export PAGER='/bin/more '
export EDITOR='/bin/vi'
# Source configuration files from /etc/profile.d
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
unset i
done
export HOSTNAME="$(hostname)"
export OLDPWD=/root
if [ '$USER' == 'root' ]; then
export PS1='[\u@\h]\w\# '
else
export PS1='[\u@\h]\w\$ '
fi
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
export TERM=vt100
export TERMINFO=/usr/share/terminfo
CLASS=acm
VID=0x3346
PID=0x1003
MSC_PID=0x1008
RNDIS_PID=0x1009
UVC_PID=0x100A
UAC_PID=0x100B
ADB_VID=0x18D1
ADB_PID=0x4EE0
ADB_PID_M1=0x4EE2
ADB_PID_M2=0x4EE4
MANUFACTURER="Cvitek"
PRODUCT="USB Com Port"
PRODUCT_RNDIS="RNDIS"
PRODUCT_UVC="UVC"
PRODUCT_UAC="UAC"
PRODUCT_ADB="ADB"
ADBD_PATH=/usr/bin/
SERIAL="0123456789"
MSC_FILE=$3
CVI_DIR=/tmp/usb
CVI_GADGET=$CVI_DIR/usb_gadget/cvitek
CVI_FUNC=$CVI_GADGET/functions
FUNC_NUM=0
MAX_EP_NUM=4
TMP_NUM=0
INTF_NUM=0
EP_IN=0
EP_OUT=0
case "$2" in
acm)
CLASS=acm
;;
msc)
CLASS=mass_storage
PID=$MSC_PID
;;
cvg)
CLASS=cvg
;;
rndis)
CLASS=rndis
PID=$RNDIS_PID
PRODUCT=$PRODUCT_RNDIS
;;
uvc)
CLASS=uvc
PID=$UVC_PID
PRODUCT=$PRODUCT_UVC
;;
uac1)
CLASS=uac1
PID=$UAC_PID
PRODUCT=$PRODUCT_UAC
;;
adb)
CLASS=ffs.adb
VID=$ADB_VID
PID=$ADB_PID
PRODUCT=$PRODUCT_ADB
;;
*)
if [ "$1" = "probe" ] ; then
echo "Usage: $0 probe {acm|msc|cvg|rndis|uvc|uac1|adb}"
exit 1
fi
esac
calc_func() {
FUNC_NUM=$(ls $CVI_GADGET/functions -l | grep ^d | wc -l)
echo "$FUNC_NUM file(s)"
}
res_check() {
TMP_NUM=$(find $CVI_GADGET/functions/ -name "acm*" | wc -l)
EP_OUT=$(($EP_OUT+$TMP_NUM))
TMP_NUM=$(($TMP_NUM * 2))
EP_IN=$(($EP_IN+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "mass_storage*" | wc -l)
EP_IN=$(($EP_IN+$TMP_NUM))
EP_OUT=$(($EP_OUT+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "cvg*" | wc -l)
EP_IN=$(($EP_IN+$TMP_NUM))
EP_OUT=$(($EP_OUT+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "rndis*" | wc -l)
EP_OUT=$(($EP_OUT+$TMP_NUM))
TMP_NUM=$(($TMP_NUM * 2))
EP_IN=$(($EP_IN+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "uvc*" | wc -l)
TMP_NUM=$(($TMP_NUM * 2))
EP_IN=$(($EP_IN+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name "uac1*" | wc -l)
TMP_NUM=$(($TMP_NUM * 2))
EP_IN=$(($EP_IN+$TMP_NUM))
EP_OUT=$(($EP_OUT+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
TMP_NUM=$(find $CVI_GADGET/functions/ -name ffs.adb | wc -l)
EP_IN=$(($EP_IN+$TMP_NUM))
EP_OUT=$(($EP_OUT+$TMP_NUM))
INTF_NUM=$(($INTF_NUM+$TMP_NUM))
if [ "$CLASS" = "acm" ] ; then
EP_IN=$(($EP_IN+2))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "mass_storage" ] ; then
EP_IN=$(($EP_IN+1))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "cvg" ] ; then
EP_IN=$(($EP_IN+1))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "rndis" ] ; then
EP_IN=$(($EP_IN+2))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "uvc" ] ; then
EP_IN=$(($EP_IN+2))
fi
if [ "$CLASS" = "uac1" ] ; then
EP_IN=$(($EP_IN+1))
EP_OUT=$(($EP_OUT+1))
fi
if [ "$CLASS" = "ffs.adb" ] ; then
EP_IN=$(($EP_IN+1))
EP_OUT=$(($EP_OUT+1))
fi
echo "$EP_IN in ep"
echo "$EP_OUT out ep"
if [ $EP_IN -gt $MAX_EP_NUM ]; then
echo "reach maximum resource"
exit 1
fi
if [ $EP_OUT -gt $MAX_EP_NUM ]; then
echo "reach maximum resource"
exit 1
fi
}
probe() {
if [ ! -d $CVI_DIR ]; then
mkdir $CVI_DIR
fi
if [ ! -d $CVI_DIR/usb_gadget ]; then
# Enale USB ConfigFS
mount none $CVI_DIR -t configfs
# Create gadget dev
mkdir $CVI_GADGET
# Set the VID and PID
echo $VID >$CVI_GADGET/idVendor
echo $PID >$CVI_GADGET/idProduct
# Set the product information string
mkdir $CVI_GADGET/strings/0x409
echo $MANUFACTURER>$CVI_GADGET/strings/0x409/manufacturer
echo $PRODUCT>$CVI_GADGET/strings/0x409/product
echo $SERIAL>$CVI_GADGET/strings/0x409/serialnumber
# Set the USB configuration
mkdir $CVI_GADGET/configs/c.1
mkdir $CVI_GADGET/configs/c.1/strings/0x409
echo "config1">$CVI_GADGET/configs/c.1/strings/0x409/configuration
# Set the MaxPower of USB descriptor
echo 120 >$CVI_GADGET/configs/c.1/MaxPower
fi
# get current functions number
calc_func
# assign the class code for composite device
if [ ! $FUNC_NUM -eq 0 ]; then
echo 0xEF >$CVI_GADGET/bDeviceClass
echo 0x02 >$CVI_GADGET/bDeviceSubClass
echo 0x01 >$CVI_GADGET/bDeviceProtocol
fi
# resource check
res_check
# create the desired function
if [ "$CLASS" = "ffs.adb" ] ; then
# adb shall be the last function to probe. Override the pid/vid
echo $VID >$CVI_GADGET/idVendor
echo $PID >$CVI_GADGET/idProduct
# choose pid for different function number
if [ $INTF_NUM -eq 1 ]; then
echo $ADB_PID_M1 >$CVI_GADGET/idProduct
fi
if [ $INTF_NUM -eq 2 ]; then
echo $ADB_PID_M2 >$CVI_GADGET/idProduct
fi
mkdir $CVI_GADGET/functions/$CLASS
else
mkdir $CVI_GADGET/functions/$CLASS.usb$FUNC_NUM
fi
if [ "$CLASS" = "mass_storage" ] ; then
echo $MSC_FILE >$CVI_GADGET/functions/$CLASS.usb$FUNC_NUM/lun.0/file
fi
if [ "$CLASS" = "rndis" ] ; then
#OS STRING
echo 1 >$CVI_GADGET/os_desc/use
echo 0xcd >$CVI_GADGET/os_desc/b_vendor_code
echo MSFT100 >$CVI_GADGET/os_desc/qw_sign
#COMPATIBLE ID
echo RNDIS >$CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/compatible_id
#MAKE c.1 THE ONE ASSOCIATED WITH OS DESCRIPTORS
ln -s $CVI_GADGET/configs/c.1 $CVI_GADGET/os_desc
#MAKE "Icons" EXTENDED PROPERTY
mkdir $CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/Icons
echo 2 >$CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/Icons/type
echo "%SystemRoot%\\system32\\shell32.dll,-233" >$CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/Icons/data
#MAKE "Label" EXTENDED PROPERTY
mkdir $CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/Label
echo 1 >$CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/Label/type
echo "XYZ Device" >$CVI_FUNC/rndis.usb$FUNC_NUM/os_desc/interface.rndis/Label/data
fi
}
start() {
# link this function to the configuration
calc_func
if [ $FUNC_NUM -eq 0 ]; then
echo "Functions Empty!"
exit 1
fi
if [ -d $CVI_GADGET/functions/ffs.adb ]; then
FUNC_NUM=$(($FUNC_NUM-1))
fi
for i in `seq 0 $(($FUNC_NUM-1))`;
do
find $CVI_GADGET/functions/ -name "*.usb$i" | xargs -I % ln -s % $CVI_GADGET/configs/c.1
done
if [ -d $CVI_GADGET/functions/ffs.adb ]; then
ln -s $CVI_GADGET/functions/ffs.adb $CVI_GADGET/configs/c.1
mkdir /dev/usb-ffs/adb -p
mount -t functionfs adb /dev/usb-ffs/adb
if [ -f $ADBD_PATH/adbd ]; then
$ADBD_PATH/adbd &
fi
else
# Start the gadget driver
UDC=`ls /sys/class/udc/ | awk '{print $1}'`
echo ${UDC} >$CVI_GADGET/UDC
fi
}
stop() {
if [ -d $CVI_GADGET/configs/c.1/ffs.adb ]; then
pkill adbd
rm $CVI_GADGET/configs/c.1/ffs.adb
else
echo "" >$CVI_GADGET/UDC
fi
find $CVI_GADGET/configs/ -name "*.usb*" | xargs rm -f
rmdir $CVI_GADGET/configs/c.*/strings/0x409/
tmp_dirs=$(find $CVI_GADGET/os_desc/c.* -type d)
if [ -n tmp_dirs ]; then
echo "remove os_desc!"
rm -rf $CVI_GADGET/os_desc/c.*/
find $CVI_GADGET/functions/ -name Icons | xargs rmdir
find $CVI_GADGET/functions/ -name Label | xargs rmdir
fi
rmdir $CVI_GADGET/configs/c.*/
rmdir $CVI_GADGET/functions/*
rmdir $CVI_GADGET/strings/0x409/
rmdir $CVI_GADGET
umount $CVI_DIR
rmdir $CVI_DIR
}
case "$1" in
start)
start
;;
stop)
stop
;;
probe)
probe
;;
UDC)
ls /sys/class/udc/ >$CVI_GADGET/UDC
;;
*)
echo "Usage: $0 probe {acm|msc|cvg|uvc|uac1} {file (msc)}"
echo "Usage: $0 start"
echo "Usage: $0 stop"
exit 1
esac
exit $?
GPIO_HUBPORT_EN=449
GPIO_ROLESEL=450
GPIO_HUBRST=451
SYS_GPIO=/sys/class/gpio
hub_on() {
echo "turn on usb hub"
if [ ! -d $SYS_GPIO/gpio$GPIO_HUBPORT_EN ]; then
echo $GPIO_HUBPORT_EN >/sys/class/gpio/export
fi
if [ ! -d $SYS_GPIO/gpio$GPIO_ROLESEL ]; then
echo $GPIO_ROLESEL >/sys/class/gpio/export
fi
if [ ! -d $SYS_GPIO/gpio$GPIO_HUBRST ]; then
echo $GPIO_HUBRST >/sys/class/gpio/export
fi
echo "out" >/sys/class/gpio/gpio$GPIO_HUBPORT_EN/direction
echo "out" >/sys/class/gpio/gpio$GPIO_ROLESEL/direction
echo "out" >/sys/class/gpio/gpio$GPIO_HUBRST/direction
echo 1 >/sys/class/gpio/gpio$GPIO_HUBPORT_EN/value
echo 0 >/sys/class/gpio/gpio$GPIO_ROLESEL/value
echo 0 >/sys/class/gpio/gpio$GPIO_HUBRST/value
}
hub_off() {
echo "turn off usb hub"
if [ ! -d $SYS_GPIO/gpio$GPIO_HUBPORT_EN ]; then
echo $GPIO_HUBPORT_EN >/sys/class/gpio/export
fi
if [ ! -d $SYS_GPIO/gpio$GPIO_ROLESEL ]; then
echo $GPIO_ROLESEL >/sys/class/gpio/export
fi
if [ ! -d $SYS_GPIO/gpio$GPIO_HUBRST ]; then
echo $GPIO_HUBRST >/sys/class/gpio/export
fi
echo "out" >/sys/class/gpio/gpio$GPIO_HUBPORT_EN/direction
echo "out" >/sys/class/gpio/gpio$GPIO_ROLESEL/direction
echo "out" >/sys/class/gpio/gpio$GPIO_HUBRST/direction
echo 0 >/sys/class/gpio/gpio$GPIO_HUBPORT_EN/value
echo 1 >/sys/class/gpio/gpio$GPIO_ROLESEL/value
echo 1 >/sys/class/gpio/gpio$GPIO_HUBRST/value
}
inst_mod() {
insmod /mnt/system/ko/configfs.ko
insmod /mnt/system/ko/libcomposite.ko
insmod /mnt/system/ko/u_serial.ko
insmod /mnt/system/ko/usb_f_acm.ko
insmod /mnt/system/ko/cvi_usb_f_cvg.ko
insmod /mnt/system/ko/usb_f_uvc.ko
insmod /mnt/system/ko/usb_f_fs.ko
insmod /mnt/system/ko/u_audio.ko
insmod /mnt/system/ko/usb_f_uac1.ko
insmod /mnt/system/ko/usb_f_serial.ko
insmod /mnt/system/ko/usb_f_mass_storage.ko
insmod /mnt/system/ko/u_ether.ko
insmod /mnt/system/ko/usb_f_ecm.ko
insmod /mnt/system/ko/usb_f_eem.ko
insmod /mnt/system/ko/usb_f_rndis.ko
}
case "$1" in
host)
insmod /mnt/system/ko/dwc2.ko
echo host > /proc/cviusb/otg_role
;;
device)
echo device > /proc/cviusb/otg_role
;;
*)
echo "Usage: $0 host"
echo "Usage: $0 device"
exit 1
esac
exit $?
../usr/lib64v0p7_xthead/lp64d/libc.so
\ No newline at end of file
This diff is collapsed.
#!/bin/bash
export MV_BOARD_CPU=cv1800b
export MV_BUILD_ENV=cvisetup.sh
export MV_BUILD_ENV=milkvsetup.sh
export MV_BOARD_LINK=cv1800b_milkv_duo_sd
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment