[VOL-1685][BAL3.0 Bridade] generate OpenOLT debian package file

Change-Id: Ib0332d948602bf7892b6aae91a4147356237f7e2
diff --git a/agent/Makefile.in b/agent/Makefile.in
index f30f94f..920a381 100644
--- a/agent/Makefile.in
+++ b/agent/Makefile.in
@@ -250,14 +250,17 @@
 	ln -sf $(LIBGRPC_PATH)/libgrpc.so.6 $(BUILD_DIR)/libgrpc.so.6
 	ln -sf $(LIBGRPC_PATH)/libgrpc++.so.1 $(BUILD_DIR)/libgrpc++.so.1
 	ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 $(BUILD_DIR)/libstdc++.so.6
+	strip $(BUILD_DIR)/openolt
 src/%.o: src/%.cc
 	$(CXX) $(CXXFLAGS) $(CXXFLAGSDEVICE) -I./common -c $< -o $@
 
 deb:
-	cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(DEV_VER).tar.gz mkdebian/debian
+	cp $(BUILD_DIR)/release_$(OPENOLTDEVICE)_V$(BAL_MAJOR_VER).$(BAL_MINOR_VER).$(BAL_REV_A_VER).$(DEV_VER).tar.gz mkdebian/debian
 	cp $(BUILD_DIR)/openolt mkdebian/debian
 	cp $(BUILD_DIR)/libgrpc.so.6 mkdebian/debian
 	cp $(BUILD_DIR)/libgrpc++.so.1 mkdebian/debian
+	cp $(BUILD_DIR)/libstdc++.so.6 mkdebian/debian
+	cp $(BUILD_DIR)/libbal_host_api.so mkdebian/debian
 	cp -a scripts/init.d mkdebian/debian
 	cd mkdebian && ./build_$(OPENOLTDEVICE)_deb.sh
 	mv *.deb $(BUILD_DIR)/openolt.deb
diff --git a/agent/mkdebian/debian/asfvolt16.postinst b/agent/mkdebian/debian/asfvolt16.postinst
index 66bb97d..c271f29 100644
--- a/agent/mkdebian/debian/asfvolt16.postinst
+++ b/agent/mkdebian/debian/asfvolt16.postinst
@@ -17,19 +17,20 @@
 
 rm -rf /opt/bcm68620
 rm -rf /broadcom
-tar zxf /tmp/release_asfvolt16_V02.06.201804301043.tar.gz -C / 2>&1 > /dev/null
+tar zxf /tmp/release_asfvolt16_V3.0.3.201904171432.tar.gz -C / 2>&1 > /dev/null
 grep -q '\/opt\/bcm68620\/svk_init.sh' /etc/rc.local || sed -i -e '$i \/opt\/bcm68620\/svk_init.sh' /etc/rc.local
 rm -f /run/bcm68620
-cp /tmp/init.d/bal_core_dist /etc/init.d
+cp /tmp/init.d/dev_mgmt_daemon /etc/init.d
 cp /tmp/init.d/openolt /etc/init.d
 cp /tmp/logrotate.d/openolt /etc/logrotate.d
-chmod +x /etc/init.d/bal_core_dist
+chmod +x /etc/init.d/dev_mgmt_daemon
 chmod +x /etc/init.d/openolt
-update-rc.d bal_core_dist defaults
+update-rc.d dev_mgmt_daemon defaults
 update-rc.d openolt defaults
 mv /tmp/openolt /broadcom
 mv /tmp/libgrpc++.so.1 /usr/local/lib
 mv /tmp/libgrpc.so.6 /usr/local/lib
-mv /broadcom/libbal_api_dist.so /usr/local/lib
+mv /tmp/libstdc++.so.6 /usr/local/lib
+mv /tmp/libbal_host_api.so /usr/local/lib
 /opt/bcm68620/svk_init.sh
 ldconfig
diff --git a/agent/mkdebian/debian/asfvolt16.postrm b/agent/mkdebian/debian/asfvolt16.postrm
index e99a65a..3f45572 100644
--- a/agent/mkdebian/debian/asfvolt16.postrm
+++ b/agent/mkdebian/debian/asfvolt16.postrm
@@ -21,4 +21,5 @@
 rm -rf /run/bcm68620
 rm -rf /usr/local/lib/libgrpc++.so.1
 rm -rf /usr/local/lib/libgrpc.so.6
-rm -rf /usr/local/lib/libbal_api_dist.so
+rm -rf /usr/local/lib/libbal_host_api.so
+rm -rf /usr/local/lib/libstdc++.so.6
diff --git a/agent/mkdebian/debian/asfvolt16.preinst b/agent/mkdebian/debian/asfvolt16.preinst
index 1237c87..cf43cc1 100644
--- a/agent/mkdebian/debian/asfvolt16.preinst
+++ b/agent/mkdebian/debian/asfvolt16.preinst
@@ -15,35 +15,41 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+DEVMEM_MAJOR=`cat /sys/module/devmem/parameters/bcmolt_devmem_chrdev_major`
 # kill CLI applications
 echo "kill running time application"
-[ -n "`pidof bcm_user_appl`" ] && killall bcm_user_appl
+[ -n "`pidof dev_mgmt_daemon`" ] && killall dev_mgmt_daemon
 [ -n "`pidof bcm.user`" ] && killall bcm.user
-[ -n "`pidof voltha_bal_driver`" ] && killall voltha_bal_driver
-# service bal_core_dist stop
-# service openolt stop
-[ -n "`pidof bal_core_dist`" ] && killall bal_core_dist
-rm -f /var/run/bal_core_dist.pid
+[ -n "`pidof dev_mgmt_attach`" ] && killall dev_mgmt_attach
+[ -n "`pidof embedded_console`" ] && killall embedded_console 
+[ -n "`pidof example_user_appl`" ] && killall example_user_appl 
 [ -n "`pidof openolt`" ] && killall openolt
-rm -f /var/run/openolt.pid
+rm -f /tmp/root_dev_mgmt_pid /tmp/root_dev_mgmt_init_done
 
 # unload drivers
 echo "unload kernel drivers"
-[ -n "`lsmod | grep bcm_coop_dba_linux`" ] && rmmod bcm_coop_dba_linux && sleep 1
-[ -n "`lsmod | grep bcm_dev_ctrl_linux`" ] &&  rmmod bcm_dev_ctrl_linux && sleep 1
 [ -n "`lsmod | grep i2c_devs`" ] && rmmod i2c_devs && sleep 1
-[ -n "`lsmod | grep trmux`" ] && rmmod trmux && sleep 1
-[ -n "`lsmod | grep fld`" ] && rmmod fld && sleep 1
+[ -n "`lsmod | grep nltr`" ] &&  rmmod nltr && sleep 1
+[ -n "`lsmod | grep pcie_proxy`" ] && rmmod pcie_proxy && sleep 1
+[ -n "`lsmod | grep devmem`" ] && rmmod devmem && sleep 1
+[ -n "`lsmod | grep fld_linux`" ] && rmmod fld_linux && sleep 1
 [ -n "`lsmod | grep os_linux`" ] && rmmod os_linux && sleep 1
 [ -n "`lsmod | grep ll_pcie`" ] && rmmod ll_pcie && sleep 1
 [ -n "`lsmod | grep linux_user_bde`" ] && rmmod linux-user-bde && sleep 1
 [ -n "`lsmod | grep linux_kernel_bde`" ] && rmmod linux-kernel-bde && sleep 1
 rm -rf /dev/maple_i2c
-rm -rf /dev/bcm_log
-rm -rf /dev/maple_dev_ctrl
+rm -rf /dev/bcmolt_pcie_proxy
+rm -rf /dev/linux-uk-proxy
 rm -rf /dev/linux-user-bde
 rm -rf /dev/linux-kernel-bde
+rm -rf /dev/coop_dba_example
 rm -rf /dev/coop_dba
+for i in {0..7}; do
+    MAJOR=$(($DEVMEM_MAJOR + $i))
+    [ ! -f /dev/bcmolt_devmem_sram$i ] && rm -f /dev/bcmolt_devmem_sram$i
+    [ ! -f /dev/bcmolt_devmem_ddr$i ] && rm -f /dev/bcmolt_devmem_ddr$i
+    [ ! -f /dev/bcmolt_devmem_regs$i ] && rm -f /dev/bcmolt_devmem_regs$i
+done
 
 rm -rf /opt/bcm68620
 rm -rf /run/bcm68620
@@ -51,6 +57,7 @@
 rm -rf  /broadcom
 
 rm -rf /usr/local/lib/libgrpc++.so.1
-rm -rf /usr/local/lib/libgrpc.so.5
-rm -rf /usr/local/lib/libbal_api_dist.so
+rm -rf /usr/local/lib/libgrpc.so.6
+rm -rf /usr/local/lib/libbal_host_api.so
+rm -rf /usr/local/lib/libstdc++.so.6
 
diff --git a/agent/mkdebian/debian/changelog b/agent/mkdebian/debian/changelog
index 3969177..938b033 100644
--- a/agent/mkdebian/debian/changelog
+++ b/agent/mkdebian/debian/changelog
@@ -1,10 +1,6 @@
-asfvolt16 (2.6.0.1+edgecore-V201804301043) stable; urgency=high
+asfvolt16 (3.0.3.3+edgecore-V201904171432) stable; urgency=high
 
-    * Based on code from SW-BCM68620_2_6_0_1.zip.
-    * Merged the Accton's fixed done in ACCTON_BAL_2.4.7.12-V201712061142.patch.
-    * To increase the stack size to 2M to avoid segment fault while init bcm.user code.
-    * To modify the BALAPI_OPER_TIMEOUT from 5 to 10 seconds to avoid timeout warning message.
-    * Patch file name: ACCTON_BAL_2.6.0.1-V201804301043.patch
+    * Based on code from SW-BCM68620_3_0_3_3.tgz.
+    * Merged the Accton's fixed to ACCTON_BAL_3.0.3.3-V201904171432.patch.
 
- -- Jason Huang <jasonsc_huang@edge-core.com>  Thu, 31 May 2018 10:36:32 +0800
-
+ -- Jason Huang <jasonsc_huang@edge-core.com>  Wed, 17 APR 2019 08:12:24 +0800
diff --git a/agent/mkdebian/debian/control b/agent/mkdebian/debian/control
index c68f14e..55e7db8 100644
--- a/agent/mkdebian/debian/control
+++ b/agent/mkdebian/debian/control
@@ -9,5 +9,5 @@
 Architecture: amd64
 Depends: ${shlibs:Depends}
 Description: Broadcom OLT drivers,CLI
-  ported from Broadcom SDK-2.6.0.1 package
+  ported from Broadcom SDK-3.0.3.3 package
 
diff --git a/agent/mkdebian/debian/files b/agent/mkdebian/debian/files
index 4061fba..e8fd78d 100644
--- a/agent/mkdebian/debian/files
+++ b/agent/mkdebian/debian/files
@@ -1 +1 @@
-asfvolt16_2.6.0.1+edgecore-V201804301043_amd64.deb misc optional
+asfvolt16_3.0.3.3+edgecore-V201904171432_amd64.deb misc optional
diff --git a/agent/mkdebian/debian/rules b/agent/mkdebian/debian/rules
index 61e1bb7..d5b0e46 100755
--- a/agent/mkdebian/debian/rules
+++ b/agent/mkdebian/debian/rules
@@ -26,11 +26,12 @@
 
 override_dh_auto_install: 
 	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/release_asfvolt16_V02.06.201804301043.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/release_asfvolt16_V3.0.3.201904171432.tar.gz $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc++.so.1 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/libgrpc.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/libstdc++.so.6 $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+	cp -a $(CURDIR)/debian/libbal_host_api.so $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/openolt $(DEB_DH_INSTALL_SOURCEDIR)/tmp
-	cp -a $(CURDIR)/debian/init.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 	cp -a $(CURDIR)/debian/logrotate.d $(DEB_DH_INSTALL_SOURCEDIR)/tmp
 
 #override_dh_shlibdeps:
diff --git a/agent/scripts/init.d/bal_core_dist b/agent/scripts/init.d/dev_mgmt_daemon
similarity index 94%
rename from agent/scripts/init.d/bal_core_dist
rename to agent/scripts/init.d/dev_mgmt_daemon
index 3fc9d78..0fd80d8 100755
--- a/agent/scripts/init.d/bal_core_dist
+++ b/agent/scripts/init.d/dev_mgmt_daemon
@@ -10,12 +10,12 @@
 # Description:       Broadcom BAL core daemon
 ### END INIT INFO
 
-NAME="bal_core_dist"
+NAME="dev_mgmt_daemon"
 PATH="/broadcom:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
 APPDIR="/broadcom"
-#APPBIN="/broadcom/bal_core_dist"
-APPBIN="bal_core_dist"
-APPARGS="-C :55001"
+APPBIN="dev_mgmt_daemon"
+APPARGS="-d -pcie"
+PID_FILE="root_dev_mgmt_pid"
 USER="root"
 GROUP="root"
 
diff --git a/agent/scripts/init.d/openolt b/agent/scripts/init.d/openolt
index bd414c9..3c13436 100755
--- a/agent/scripts/init.d/openolt
+++ b/agent/scripts/init.d/openolt
@@ -15,7 +15,7 @@
 APPDIR="/broadcom"
 #APPBIN="/broadcom/openolt"
 APPBIN="openolt"
-APPARGS="-C 127.0.0.1:55001"
+APPARGS=""
 USER="root"
 GROUP="root"
 
@@ -26,7 +26,7 @@
 start() {
   touch /var/log/$NAME.log
   printf "Starting '$NAME'... "
-  sleep 20
+  sleep 60
   start-stop-daemon --verbose --start --chuid "$USER:$GROUP" --background --no-close --make-pidfile --pidfile /var/run/$NAME.pid --chdir "$APPDIR" --exec "$APPBIN" -- $APPARGS < /dev/tty1 >> /var/log/$NAME.log 2>&1 || true
   printf "done\n"
 }