From c19b7a2b7e455922ecab1aa37c708f67a7f82db3 Mon Sep 17 00:00:00 2001 From: Pankaj Bansal Date: Fri, 23 Dec 2016 20:11:50 +0530 Subject: [PATCH 1/2] armv8a : Fix Compilation errors in compiling armv8a machines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit problem : copliation errors like "ERROR: Missing SYSROOT_LIB: ld-2.24.so” when sysroot is prepared. cause : New crosstool-ng, keeps the c libs fo 64 bit architectures (such as armv8a and x86_64) in lib64 folders of cross toolchain installation directory. fix : for 64 bit architectures first lokkup the c Libraries in lib64 and then in lib folder of cross toolchain installation directory. Signed-off-by: Pankaj Bansal --- build-config/make/images.make | 16 +++++++++++----- build-config/make/sysroot.make | 6 ++++++ build-config/scripts/onie-mk-iso.sh | 10 ++++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/build-config/make/images.make b/build-config/make/images.make index 15b207088..648ed3696 100644 --- a/build-config/make/images.make +++ b/build-config/make/images.make @@ -196,11 +196,17 @@ endif sysroot-check: $(SYSROOT_CHECK_STAMP) $(SYSROOT_CHECK_STAMP): $(PACKAGES_INSTALL_STAMPS) $(Q) for file in $(SYSROOT_LIBS) ; do \ - [ -r "$(DEV_SYSROOT)/lib/$$file" ] || { \ - echo "ERROR: Missing SYSROOT_LIB: $$file" ; \ - exit 1; } ; \ - find $(DEV_SYSROOT)/lib -name $$file | xargs -i \ - cp -av {} $(SYSROOTDIR)/lib/ || exit 1 ; \ + if [ "$(ARCH)" == "arm64" ] || [ "$(ARCH)" == "x86_64" ] ; then \ + [ -r "$(DEV_SYSROOT)/lib64/$$file" ] || [ -r "$(DEV_SYSROOT)/lib/$$file" ] || { \ + echo "ERROR: Missing SYSROOT_LIB: $$file" ; \ + exit 1; } ; \ + find $(DEV_SYSROOT)/lib64 $(DEV_SYSROOT)/lib -name $$file | xargs -i cp -av {} $(SYSROOTDIR)/lib/ || exit 1 ; \ + else \ + [ -r "$(DEV_SYSROOT)/lib/$$file" ] || { \ + echo "ERROR: Missing SYSROOT_LIB: $$file" ; \ + exit 1; } ; \ + find $(DEV_SYSROOT)/lib -name $$file | xargs -i cp -av {} $(SYSROOTDIR)/lib/ || exit 1 ; \ + fi; \ done $(Q) for file in $(DEBUG_UTILS) ; do \ cp -av $$file $(SYSROOTDIR)/usr/bin || exit 1 ; \ diff --git a/build-config/make/sysroot.make b/build-config/make/sysroot.make index f5d0291a4..26ca62281 100644 --- a/build-config/make/sysroot.make +++ b/build-config/make/sysroot.make @@ -43,6 +43,8 @@ $(SYSROOT_INIT_STAMP): $(TREE_STAMP) $(Q) mkdir -p -v -m 0755 $(SYSROOTDIR)/dev $(Q) mkdir -p -v $(SYSROOTDIR)/{sys,proc,tmp,etc,lib,mnt} $(Q) mkdir -p -v $(SYSROOTDIR)/{var/log,usr/lib,usr/bin,usr/sbin,usr/share/locale,lib,mnt} + $(Q) cd $(SYSROOTDIR) && ln -s lib lib32 && ln -s lib lib64 + $(Q) cd $(SYSROOTDIR)/usr && ln -s lib lib32 && ln -s lib lib64 $(Q) touch $@ # Development sysroot, used for compiling and linking user space @@ -53,6 +55,10 @@ $(DEV_SYSROOT_INIT_STAMP): $(TREE_STAMP) | $(XTOOLS_BUILD_STAMP) $(Q) echo "==== Preparing a new development sysroot ====" $(Q) rm -rf $(DEV_SYSROOT) $(Q) cp -a $$($(CROSSBIN)/$(CROSSPREFIX)gcc -print-sysroot) $(DEV_SYSROOT) + $(Q) rsync -rl $(XTOOLS_INSTALL_DIR)/$(TARGET)/$(TARGET)/lib $(DEV_SYSROOT) + ifeq ($(ARCH),$(filter $(ARCH),arm64 x86_64)) + $(Q) rsync -rl $(XTOOLS_INSTALL_DIR)/$(TARGET)/$(TARGET)/lib64 $(DEV_SYSROOT) + endif $(Q) chmod +w -R $(DEV_SYSROOT) $(Q) touch $@ diff --git a/build-config/scripts/onie-mk-iso.sh b/build-config/scripts/onie-mk-iso.sh index 0dabf2714..ad8a26b22 100755 --- a/build-config/scripts/onie-mk-iso.sh +++ b/build-config/scripts/onie-mk-iso.sh @@ -64,10 +64,12 @@ RECOVERY_ISO_IMAGE=${12} echo "ERROR: Unable to read recovery config directory: $RECOVERY_CONF_DIR" exit 1 } -[ -r "${GRUB_TARGET_LIB_I386_DIR}/biosdisk.mod" ] || { - echo "ERROR: Does not look like valid GRUB i386-pc library directory: $GRUB_TARGET_LIB_I386_DIR" - exit 1 -} +if [ "$FIRMWARE_TYPE" = "auto" ] || [ "$FIRMWARE_TYPE" = "bios" ] ; then + [ -r "${GRUB_TARGET_LIB_I386_DIR}/biosdisk.mod" ] || { + echo "ERROR: Does not look like valid GRUB i386-pc library directory: $GRUB_TARGET_LIB_I386_DIR" + exit 1 + } +fi [ -x "${GRUB_HOST_BIN_I386_DIR}/grub-mkimage" ] || { echo "ERROR: Does not look like valid GRUB i386-pc bin directory: $GRUB_HOST_BIN_I386_DIR" exit 1 From eb48f011c7cce53bbb8f89feeee000bd34c1c5d0 Mon Sep 17 00:00:00 2001 From: Pankaj Bansal Date: Fri, 23 Dec 2016 20:19:15 +0530 Subject: [PATCH 2/2] Fixed issue with onie image discovery with multiple network interfaces Problem : Onie installation doesnt complete if multiple ethernet interfaces are there and tftpserver connected to 1st valid interface(that is eth0) doesnt have valid Onie installer. Cause : The installer only searches eth0 for NOS images Fix : The installer should search all ethernet interfaces for NOS image Signed-off-by: Pankaj Bansal --- rootconf/default/bin/discover | 73 +++++++++++------------ rootconf/default/etc/init.d/networking.sh | 55 ++++++++--------- 2 files changed, 61 insertions(+), 67 deletions(-) diff --git a/rootconf/default/bin/discover b/rootconf/default/bin/discover index f2cb12b2f..82811d7b7 100755 --- a/rootconf/default/bin/discover +++ b/rootconf/default/bin/discover @@ -1,6 +1,7 @@ #!/bin/sh # Copyright (C) 2013-2014 Curt Brune +# Copyright (C) 2016 Pankaj Bansal # # SPDX-License-Identifier: GPL-2.0 @@ -33,21 +34,19 @@ onie_parms_file="${ONIE_RUN_DIR}/onie_parms_file.txt" neigh_discovery() { - intf_list=$(net_intf) + intf=$1 ping_cnt=3 - for i in $intf_list ; do - # Wait for interface link-local addr to leave tentative state - cnt=300 - while [ $cnt -gt 0 ] ; do - foo=$(ip addr show dev $i | grep tentative) - [ "$?" -ne 0 ] && break - cnt=$(( $cnt - 1 )) - sleep 0.1 - done - ping6 -I $i -c $ping_cnt ff02::1 > /dev/null 2>&1 - ping -I $i -w 2 -c $ping_cnt -q 255.255.255.255 > /dev/null 2>&1 + # Wait for interface link-local addr to leave tentative state + cnt=300 + while [ $cnt -gt 0 ] ; do + foo=$(ip addr show dev $intf | grep tentative) + [ "$?" -ne 0 ] && break + cnt=$(( $cnt - 1 )) + sleep 0.1 done + ping6 -I $intf -c $ping_cnt ff02::1 > /dev/null 2>&1 + ping -I $intf -w 2 -c $ping_cnt -q 255.255.255.255 > /dev/null 2>&1 # Allow neighbor table to populate -- better way? sleep 4 @@ -115,22 +114,19 @@ sd_dhcp6() # DHCPv4 service discovery sd_dhcp4() { - intf_list=$(net_intf) + intf=$1 udhcp_args="$(udhcpc_args) -t 2 -T 2 -n" + tmp= udhcp_request_opts= for o in 7 43 54 66 67 72 114 125 ; do udhcp_request_opts="$udhcp_request_opts -O $o" done - # Initate DHCP request on every interface in the list. Stop after - # one works. + # Initate DHCP request on specified interface. - for i in $intf_list ; do - log_debug_msg "Trying DHCPv4 on interface: $i" - tmp=$(udhcpc $udhcp_args $udhcp_request_opts -i $i -s /lib/onie/udhcp4_sd) && break - tmp= - done + log_debug_msg "Trying DHCPv4 on interface: $intf" + tmp=$(udhcpc $udhcp_args $udhcp_request_opts -i $intf -s /lib/onie/udhcp4_sd) onie_disco="${onie_disco}${tmp##*ONIE_PARMS:}" if [ -n "$onie_disco" ] ; then @@ -162,30 +158,33 @@ service_discovery() # add/update $onie_disco log_console_msg "Starting ONIE Service Discovery" onie_disco= - sd_static && return - sd_localfs - sd_dhcp6 - sd_dhcp4 - sd_mdns - sd_fallback + sd_static $* && return + sd_localfs $* + sd_dhcp6 $* + sd_dhcp4 $* + sd_mdns $* + sd_fallback $* } delay=20 # Download and run installer entry point while true ; do - /etc/init.d/networking.sh discover - /etc/init.d/syslogd.sh discover - service_discovery - log_debug_msg "onie_disco: $onie_disco" - neigh_discovery + intf_list=$(net_intf) + for i in $intf_list ; do + /etc/init.d/networking.sh "$i" discover + /etc/init.d/syslogd.sh discover + service_discovery "$i" + log_debug_msg "onie_disco: $onie_disco" + neigh_discovery - rm -f /var/run/install.rc - cat $onie_neigh_file > $onie_parms_file - echo "$onie_disco" >> $onie_parms_file - sed -e 's/@@/ = /g' -e 's/##/\n/g' $onie_parms_file | logger -t discover -p ${syslog_onie}.info - exec_installer $onie_parms_file 2>&1 | tee $tee_log_file | logger -t onie-exec -p ${syslog_onie}.info - [ -r /var/run/install.rc ] && [ "$(cat /var/run/install.rc)" = "0" ] && exit 0 + rm -f /var/run/install.rc + cat $onie_neigh_file > $onie_parms_file + echo "$onie_disco" >> $onie_parms_file + sed -e 's/@@/ = /g' -e 's/##/\n/g' $onie_parms_file | logger -t discover -p ${syslog_onie}.info + exec_installer $onie_parms_file 2>&1 | tee $tee_log_file | logger -t onie-exec -p ${syslog_onie}.info + [ -r /var/run/install.rc ] && [ "$(cat /var/run/install.rc)" = "0" ] && exit 0 + done # pause to avoid DoSing someone log_info_msg "Sleeping for $delay seconds " cnt=0 diff --git a/rootconf/default/etc/init.d/networking.sh b/rootconf/default/etc/init.d/networking.sh index 551195b04..bb3ba93b4 100755 --- a/rootconf/default/etc/init.d/networking.sh +++ b/rootconf/default/etc/init.d/networking.sh @@ -3,6 +3,7 @@ # Copyright (C) 2013,2014,2016 Curt Brune # Copyright (C) 2014 david_yang # Copyright (C) 2013 Doron Tsur +# Copyright (C) 2016 Pankaj Bansal # # SPDX-License-Identifier: GPL-2.0 @@ -78,8 +79,6 @@ config_ethmgmt_fallback() local prefix=16 local default_hn="onie-host" - local intf_counter=$1 - shift local intf=$1 shift @@ -155,34 +154,29 @@ check_link_up() # 4. Fall back to well known IP address config_ethmgmt() { - intf_list=$(net_intf) - intf_counter=0 + intf=$1 + shift return_value=0 - # Bring up all the interfaces for the subsequent methods. - for intf in $intf_list ; do - cmd_run ifconfig $intf up - params="$intf $*" - eval "result_${intf}=0" - check_link_up $intf || { - log_console_msg "${intf}: link down. Skipping configuration." - eval "result_${intf}=1" - continue - } - config_ethmgmt_static $params || \ - config_ethmgmt_dhcp6 $params || \ - config_ethmgmt_dhcp4 $params || \ - config_ethmgmt_fallback $intf_counter $params || \ - eval "result_${intf}=1" - intf_counter=$(( $intf_counter + 1)) - done - for intf in $intf_list ; do - eval "curr_intf_result=\${result_${intf}}" - if [ "x$curr_intf_result" != "x0" ] ; then - log_console_msg "Failed to configure ${intf} interface" - return_value=1 - fi - done + # Bring up the interface for the subsequent methods. + cmd_run ifconfig $intf up + params="$intf $*" + eval "result_${intf}=0" + check_link_up $intf || { + log_console_msg "${intf}: link down. Skipping configuration." + eval "result_${intf}=1" + return $return_value + } + config_ethmgmt_static $params || \ + config_ethmgmt_dhcp6 $params || \ + config_ethmgmt_dhcp4 $params || \ + config_ethmgmt_fallback $params || \ + eval "result_${intf}=1" + eval "curr_intf_result=\${result_${intf}}" + if [ "x$curr_intf_result" != "x0" ] ; then + log_console_msg "Failed to configure ${intf} interface" + return_value=1 + fi return $return_value } @@ -209,7 +203,8 @@ if [ "$1" = "start" ] ; then fi log_info_msg "Using $intf MAC address: $mac" intf_counter=$(( $intf_counter + 1)) + config_ethmgmt "$intf" $* done +else + config_ethmgmt $* fi - -config_ethmgmt "$*"