support for sda3016ss

Change-Id: Id86e26e2389455e04173a1568b503d3bd77dac6d
diff --git a/agent/device/sda3016ss/mkdebian/debian/changelog b/agent/device/sda3016ss/mkdebian/debian/changelog
new file mode 100644
index 0000000..b7b0586
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/changelog
@@ -0,0 +1,5 @@
+sda3016ss (3.10.0.0-ABXZ-a12) stable; urgency=high
+
+    * Based on code from SW-BCM686OLT_3_10_0_0.tgz.
+
+ -- Wilson Lee <Wilson.Lee@zyxel.com.tw>  Tue, 12 OCT 2021 01:01:03 +0800
diff --git a/agent/device/sda3016ss/mkdebian/debian/compat b/agent/device/sda3016ss/mkdebian/debian/compat
new file mode 100644
index 0000000..ec63514
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/agent/device/sda3016ss/mkdebian/debian/control b/agent/device/sda3016ss/mkdebian/debian/control
new file mode 100644
index 0000000..c775d71
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/control
@@ -0,0 +1,13 @@
+Source: sda3016ss
+Section: misc
+Priority: optional
+Maintainer: Wilson Lee <Wilson.Lee@zyxel.com.tw>
+Build-Depends: debhelper (>= 4.0.0)
+Standards-Version: 3.6.2
+
+Package: sda3016ss
+Architecture: amd64
+Depends: ${shlibs:Depends}
+Description: Broadcom OLT drivers,CLI
+  ported from Broadcom SDK-3.10.0.0 package
+
diff --git a/agent/device/sda3016ss/mkdebian/debian/copyright b/agent/device/sda3016ss/mkdebian/debian/copyright
new file mode 100644
index 0000000..db307cb
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/copyright
@@ -0,0 +1 @@
+(C) Copyright Broadcom Corporation 2016-2020
diff --git a/agent/device/sda3016ss/mkdebian/debian/files b/agent/device/sda3016ss/mkdebian/debian/files
new file mode 100644
index 0000000..9251daf
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/files
@@ -0,0 +1,2 @@
+sda3016ss_3.10.0.0-ABXZ-a12_amd64.buildinfo misc optional
+sda3016ss_3.10.0.0-ABXZ-a12_amd64.deb misc optional
diff --git a/agent/device/sda3016ss/mkdebian/debian/rules b/agent/device/sda3016ss/mkdebian/debian/rules
new file mode 100755
index 0000000..80bb7ba
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/rules
@@ -0,0 +1,74 @@
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+# output every command that modifies files on the build system.
+#DH_VERBOSE = 1
+
+# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/default.mk
+
+# see FEATURE AREAS in dpkg-buildflags(1)
+#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+
+# see ENVIRONMENT in dpkg-buildflags(1)
+# package maintainers to append CFLAGS
+#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
+# package maintainers to append LDFLAGS
+#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
+
+# main packaging script based on dh7 syntax
+%:
+	dh $@
+
+DOCS=LEGAL_TERMS README LICENSE_APACHE20
+
+#DEB_DH_INSTALL_SOURCEDIR = $(CURDIR)/tmp
+#
+#override_dh_auto_install: 
+#	mkdir -p $(DEB_DH_INSTALL_SOURCEDIR)/tmp
+#	cp -a $(CURDIR)/debian/release_asfvolt16_V3.4.3.3.202002100101.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:
+#	dh_shlibdeps -- --ignore-missing-info -l$(ONLP_LIB_PATH):$(OFDPA_LIB_PATH)
+
+# avoid auto strip for debug ofagentapp.dbg
+#
+#override_dh_strip:
+#	echo "No auto strip!"
+
+#override_dh_installdeb:
+#	dh_installdeb
+#	for pkg in $$(dh_listpackages); do \
+#		sed -i -e 's!#DEB_SOURCE#!$(DEB_SOURCE)!' debian/$$pkg/DEBIAN/*; \
+#		sed -i -e 's!#OPDPA_VER_SUFFIX#!-$(OPDPA_VER)!g' debian/$$pkg/DEBIAN/*; \
+#	done
+
+test:
+	@echo DEB_SOURCE=$(DEB_SOURCE)
+	@echo DEB_VERSION=$(DEB_VERSION)
+	@echo DEB_VERSION_EPOCH_UPSTREAM=$(DEB_VERSION_EPOCH_UPSTREAM)
+	@echo DEB_VERSION_UPSTREAM_REVISION=$(DEB_VERSION_UPSTREAM_REVISION)
+	@echo DEB_VERSION_UPSTREAM=$(DEB_VERSION_UPSTREAM)
+	@echo DEB_DISTRIBUTION=$(DEB_DISTRIBUTION)
+	@echo DEB_HOST_ARCH=$(DEB_HOST_ARCH)
+	@echo DEB_HOST_ARCH_CPU=$(DEB_HOST_ARCH_CPU)
+	@echo DEB_HOST_ARCH_OS=$(DEB_HOST_ARCH_OS)
+	@echo DEB_HOST_GNU_TYPE=$(DEB_HOST_GNU_TYPE)
+	@echo DEB_HOST_GNU_CPU=$(DEB_HOST_GNU_CPU)
+	@echo DEB_HOST_GNU_SYSTEM=$(DEB_HOST_GNU_SYSTEM)
+	@echo DEB_BUILD_ARCH=$(DEB_BUILD_ARCH)
+	@echo DEB_BUILD_ARCH_CPU=$(DEB_BUILD_ARCH_CPU)
+	@echo DEB_BUILD_ARCH_OS=$(DEB_BUILD_ARCH_OS)
+	@echo DEB_BUILD_GNU_TYPE=$(DEB_BUILD_GNU_TYPE)
+	@echo DEB_BUILD_GNU_CPU=$(DEB_BUILD_GNU_CPU)
+	@echo DEB_BUILD_GNU_SYSTEM=$(DEB_BUILD_GNU_SYSTEM)
+	@echo ONLP_LIB_PATH=$(ONLP_LIB_PATH)
+#	@echo OFDPA_LIB_PATH=$(OFDPA_LIB_PATH)
+#	@echo OFDPA_BIN_PATH=$(OFDPA_BIN_PATH)
diff --git a/agent/device/sda3016ss/mkdebian/debian/sda3016ss.install b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.install
new file mode 100644
index 0000000..ceeb05b
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.install
@@ -0,0 +1 @@
+/tmp
diff --git a/agent/device/sda3016ss/mkdebian/debian/sda3016ss.postinst b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.postinst
new file mode 100644
index 0000000..5df67ab
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.postinst
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+#Copyright 2018-present Open Networking Foundation
+#
+#Licensed under the Apache License, Version 2.0 (the "License");
+#you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing, software
+#distributed under the License is distributed on an "AS IS" BASIS,
+#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#See the License for the specific language governing permissions and
+#limitations under the License.
+
+
+rm -rf /opt/bcm68620
+tar zxf /tmp/release_sda3016ss_custom_V2.0.0.1-20220425.tar.gz --strip-components=1 -C / 2>&1 > /dev/null
+tar zxf /tmp/release_sda3016ss_V3.10.0.0-20220425.tar.gz --strip-components=1 -C / 2>&1 > /dev/null
+rm -f /tmp/release_sda3016ss_custom_V2.0.0.1-20220425.tar.gz
+rm -f /tmp/release_sda3016ss_V3.10.0.0-20220425.tar.gz
+ln -sf /lib/platform-config/x86-64-zyxel-sda3016ss-r0/onl/lib/libonlp-x86-64-zyxel-sda3016ss.so /lib/platform-config/x86-64-zyxel-sda3016ss-r0/onl/lib/libonlp-x86-64-zyxel-sda3016ss.so.1
+chmod +x /opt/bcm68620/sda3016ss/htp/htpNniLb
+chmod +x /opt/bcm68620/sda3016ss/htp/htpPonLb
+chmod +x /etc/init.d/dev_mgmt_svc
+chmod +x /etc/init.d/openolt
+chmod +x /etc/init.d/hwmon_svc
+chmod +x /etc/init.d/htp_svc
+update-rc.d dev_mgmt_svc defaults
+update-rc.d openolt defaults
+update-rc.d hwmon_svc defaults
+update-rc.d htp_svc defaults
+mkdir -p /tmp/bcmpon
+echo "0:0,1:0" > /tmp/bcmpon/bcm68650_chip_reset
+
+tar zxf /tmp/release_sda3016ss_openolt_V3.10.0.0-20220425.tar.gz -C / --strip-components=1
+rm -f /tmp/release_sda3016ss_openolt_V3.10.0.0-20220425.tar.gz
+
diff --git a/agent/device/sda3016ss/mkdebian/debian/sda3016ss.postrm b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.postrm
new file mode 100644
index 0000000..a1c3c88
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.postrm
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+#Copyright 2018-present Open Networking Foundation
+#
+#Licensed under the Apache License, Version 2.0 (the "License");
+#you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing, software
+#distributed under the License is distributed on an "AS IS" BASIS,
+#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#See the License for the specific language governing permissions and
+#limitations under the License.
+
+
+rm -rf /opt/bcm68620
+update-rc.d dev_mgmt_svc remove
+update-rc.d openolt remove
+update-rc.d hwmon_svc remove
+update-rc.d htp_svc remove
+rm -f /etc/init.d/dev_mgmt_svc
+rm -f /etc/init.d/openolt
+rm -f /etc/init.d/hwmon_svc
+rm -f /etc/init.d/htp_svc
+
+rm -rf /opt/openolt
+#rm -rf /usr/local/lib/libgrpc.so
diff --git a/agent/device/sda3016ss/mkdebian/debian/sda3016ss.preinst b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.preinst
new file mode 100644
index 0000000..c80ba72
--- /dev/null
+++ b/agent/device/sda3016ss/mkdebian/debian/sda3016ss.preinst
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+#Copyright 2018-present Open Networking Foundation
+#
+#Licensed under the Apache License, Version 2.0 (the "License");
+#you may not use this file except in compliance with the License.
+#You may obtain a copy of the License at
+#
+#http://www.apache.org/licenses/LICENSE-2.0
+#
+#Unless required by applicable law or agreed to in writing, software
+#distributed under the License is distributed on an "AS IS" BASIS,
+#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#See the License for the specific language governing permissions and
+#limitations under the License.
+
+
+# kill CLI applications
+echo "kill running time application"
+[ -n "`pidof openolt`" ] && killall openolt
+[ -n "`pidof dev_mgmt_daemon`" ] && killall dev_mgmt_daemon
+[ -n "`pidof bcm.user`" ] && killall bcm.user
+[ -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 
+rm -f /tmp/root_dev_mgmt_pid /tmp/root_dev_mgmt_init_done
+sleep 3
+# unload drivers
+echo "unload kernel drivers"
+[ -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/bcmolt_pcie_proxy
+rm -rf /dev/linux-uk-proxy
+rm -rf /dev/linux-user-bde
+rm -rf /dev/linux-kernel-bde
+for i in {0..1}; do
+    [ ! -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
+