diff options
Diffstat (limited to 'meta-facebook/meta-wedge')
52 files changed, 2183 insertions, 3432 deletions
diff --git a/meta-facebook/meta-wedge/conf/bblayers.conf.sample b/meta-facebook/meta-wedge/conf/bblayers.conf.sample index e8b572a..90d4956 100644 --- a/meta-facebook/meta-wedge/conf/bblayers.conf.sample +++ b/meta-facebook/meta-wedge/conf/bblayers.conf.sample @@ -11,6 +11,7 @@ BBLAYERS ?= " \ ##OEROOT##/meta-yocto-bsp \ ##OEROOT##/meta-openembedded/meta-oe \ ##OEROOT##/meta-openembedded/meta-networking \ + ##OEROOT##/meta-openembedded/meta-python \ ##OEROOT##/meta-openbmc \ ##OEROOT##/meta-openbmc/meta-aspeed \ ##OEROOT##/meta-openbmc/meta-facebook/meta-wedge \ diff --git a/meta-facebook/meta-wedge/conf/local.conf.sample b/meta-facebook/meta-wedge/conf/local.conf.sample index 078ba23..7ddcaa6 100644 --- a/meta-facebook/meta-wedge/conf/local.conf.sample +++ b/meta-facebook/meta-wedge/conf/local.conf.sample @@ -138,3 +138,8 @@ EXTRA_USERS_PARAMS = " \ usermod -s /bin/bash root; \ usermod -p '\$1\$UGMqyqdG\$FZiylVFmRRfl9Z0Ue8G7e/' root; \ " + +OLDEST_KERNEL = "2.6.28" + +INHERIT += "blacklist" +PNBLACKLIST[glibc] = "glibc 2.21 does not work with our kernel 2.6.28"
\ No newline at end of file diff --git a/meta-facebook/meta-wedge/conf/machine/wedge.conf b/meta-facebook/meta-wedge/conf/machine/wedge.conf index 3ed8ec1..49241aa 100644 --- a/meta-facebook/meta-wedge/conf/machine/wedge.conf +++ b/meta-facebook/meta-wedge/conf/machine/wedge.conf @@ -6,7 +6,9 @@ UBOOT_MACHINE_wedge = "wedge_config" require conf/machine/include/ast1250.inc -# configuration for preferred version of packages +# configuration for preferred version of packages PREFERRED_VERSION_libipmi = "0.1" PREFERRED_VERSION_ipmid = "0.1" PREFERRED_VERSION_rest-api = "0.1" + +TCLIBC = 'eglibc' diff --git a/meta-facebook/meta-wedge/recipes-core/busybox/busybox/syslog.conf b/meta-facebook/meta-wedge/recipes-core/busybox/busybox/syslog.conf new file mode 100644 index 0000000..817a9a9 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-core/busybox/busybox/syslog.conf @@ -0,0 +1,5 @@ +# /etc/syslog.conf Configuration file for busybox's syslogd utility +# Send emergency messages to the console +*.emerg /dev/console +# Store everything else +*.* /var/log/messages diff --git a/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend b/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend index b8641ee..0047f92 100644 --- a/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend +++ b/meta-facebook/meta-wedge/recipes-core/busybox/busybox_%.bbappend @@ -2,4 +2,5 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += " \ file://busybox.cfg \ - "
\ No newline at end of file + file://syslog.conf \ + " diff --git a/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc b/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc index 7cd89de..a31655e 100644 --- a/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc +++ b/meta-facebook/meta-wedge/recipes-core/images/wedge-image.inc @@ -39,6 +39,7 @@ NTP_PKGS = " \ # Include modules in rootfs IMAGE_INSTALL += " \ kernel-modules \ + u-boot \ u-boot-fw-utils \ openbmc-utils \ fan-ctrl \ @@ -54,6 +55,7 @@ IMAGE_INSTALL += " \ wedge-eeprom \ sms-kcsd \ rest-api \ + cherryPy \ bottle \ ipmid \ po-eeprom \ diff --git a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_down b/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_down deleted file mode 100644 index a44deb4..0000000 --- a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_down +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash -# -# Copyright 2015-present Facebook. All Rights Reserved. -# -# This program file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -# - -pid="/var/run/dhclient6.${IFACE}.pid" - -if [ -f "${pid}" ]; then - kill -9 `cat ${pid}` 2>/dev/null -fi - -exit 0 diff --git a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_up b/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_up deleted file mode 100644 index 6469b9f..0000000 --- a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/files/dhcpv6_up +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Copyright 2015-present Facebook. All Rights Reserved. -# -# This program file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -# - -# only care about 'eth0' and 'oob' intf -[ "$IFACE" != "eth0" ] && [ "$IFACE" != "oob" ] && exit 0 - -pid="/var/run/dhclient6.${IFACE}.pid" - -dhclient -6 -nw -pf ${pid} ${IFACE} - -exit 0 diff --git a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend b/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend index e715c27..7d74521 100644 --- a/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend +++ b/meta-facebook/meta-wedge/recipes-core/init-ifupdown/init-ifupdown_%.bbappend @@ -1,18 +1,2 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/files:" - -SRC_URI += "file://dhcpv6_up \ - file://dhcpv6_down \ - " - -do_install_append() { - # rules to request dhcpv6 - install -d ${D}/${sysconfdir}/network/if-up.d - install -m 755 ${WORKDIR}/dhcpv6_up ${D}${sysconfdir}/network/if-up.d/dhcpv6_up - install -d ${D}/${sysconfdir}/network/if-down.d - install -m 755 ${WORKDIR}/dhcpv6_down ${D}${sysconfdir}/network/if-down.d/dhcpv6_down -} - -FILES_${PN} += "${sysconfdir}/network/if-up.d/dhcpv6_up \ - ${sysconfdir}/network/if-down.d/dhcpv6_down \ - " diff --git a/meta-facebook/meta-wedge/recipes-kernel/linux/files/defconfig b/meta-facebook/meta-wedge/recipes-kernel/linux/files/defconfig new file mode 100644 index 0000000..41fe288 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-kernel/linux/files/defconfig @@ -0,0 +1,1480 @@ +# +# Automatically generated make config: don't edit +# Linux kernel version: 2.6.28.9 +# Tue Feb 3 16:41:40 2015 +# +CONFIG_ARM=y +CONFIG_SYS_SUPPORTS_APM_EMULATION=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_TIME=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_MMU=y +# CONFIG_NO_IOPORT is not set +CONFIG_GENERIC_HARDIRQS=y +CONFIG_STACKTRACE_SUPPORT=y +CONFIG_HAVE_LATENCYTOP_SUPPORT=y +CONFIG_LOCKDEP_SUPPORT=y +CONFIG_TRACE_IRQFLAGS_SUPPORT=y +CONFIG_HARDIRQS_SW_RESEND=y +CONFIG_GENERIC_IRQ_PROBE=y +CONFIG_RWSEM_GENERIC_SPINLOCK=y +# CONFIG_ARCH_HAS_ILOG2_U32 is not set +# CONFIG_ARCH_HAS_ILOG2_U64 is not set +CONFIG_GENERIC_HWEIGHT=y +CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y +CONFIG_VECTORS_BASE=0xffff0000 +CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" + +# +# General setup +# +CONFIG_EXPERIMENTAL=y +CONFIG_BROKEN_ON_SMP=y +CONFIG_INIT_ENV_ARG_LIMIT=32 +CONFIG_LOCALVERSION="" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_KERNEL_GZIP=y +# CONFIG_KERNEL_BZIP2 is not set +# CONFIG_KERNEL_LZMA is not set +CONFIG_SWAP=y +CONFIG_SYSVIPC=y +CONFIG_SYSVIPC_SYSCTL=y +# CONFIG_POSIX_MQUEUE is not set +# CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set +# CONFIG_AUDIT is not set +CONFIG_IKCONFIG=m +CONFIG_IKCONFIG_PROC=y +CONFIG_LOG_BUF_SHIFT=16 +# CONFIG_CGROUPS is not set +# CONFIG_GROUP_SCHED is not set +CONFIG_SYSFS_DEPRECATED=y +CONFIG_SYSFS_DEPRECATED_V2=y +# CONFIG_RELAY is not set +CONFIG_NAMESPACES=y +# CONFIG_UTS_NS is not set +# CONFIG_IPC_NS is not set +# CONFIG_USER_NS is not set +# CONFIG_PID_NS is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL=y +CONFIG_ANON_INODES=y +# CONFIG_EMBEDDED is not set +CONFIG_UID16=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_KALLSYMS=y +CONFIG_KALLSYMS_EXTRA_PASS=y +CONFIG_HOTPLUG=y +CONFIG_PRINTK=y +CONFIG_BUG=y +CONFIG_ELF_CORE=y +CONFIG_BASE_FULL=y +CONFIG_FUTEX=y +CONFIG_EPOLL=y +CONFIG_SIGNALFD=y +CONFIG_TIMERFD=y +CONFIG_EVENTFD=y +CONFIG_SHMEM=y +CONFIG_AIO=y +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_SLUB_DEBUG=y +CONFIG_COMPAT_BRK=y +# CONFIG_SLAB is not set +CONFIG_SLUB=y +# CONFIG_SLOB is not set +# CONFIG_PROFILING is not set +# CONFIG_MARKERS is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_SLABINFO=y +CONFIG_RT_MUTEXES=y +# CONFIG_TINY_SHMEM is not set +CONFIG_BASE_SMALL=0 +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +CONFIG_MODULE_UNLOAD=y +# CONFIG_MODULE_FORCE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +CONFIG_KMOD=y +CONFIG_BLOCK=y +# CONFIG_LBD is not set +# CONFIG_BLK_DEV_IO_TRACE is not set +# CONFIG_LSF is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_BLK_DEV_INTEGRITY is not set + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +# CONFIG_DEFAULT_AS is not set +# CONFIG_DEFAULT_DEADLINE is not set +CONFIG_DEFAULT_CFQ=y +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="cfq" +CONFIG_CLASSIC_RCU=y +CONFIG_FREEZER=y + +# +# System Type +# +CONFIG_ARCH_ASPEED=y +# CONFIG_ARCH_AAEC2000 is not set +# CONFIG_ARCH_INTEGRATOR is not set +# CONFIG_ARCH_REALVIEW is not set +# CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_AT91 is not set +# CONFIG_ARCH_CLPS7500 is not set +# CONFIG_ARCH_CLPS711X is not set +# CONFIG_ARCH_EBSA110 is not set +# CONFIG_ARCH_EP93XX is not set +# CONFIG_ARCH_FOOTBRIDGE is not set +# CONFIG_ARCH_NETX is not set +# CONFIG_ARCH_H720X is not set +# CONFIG_ARCH_IMX is not set +# CONFIG_ARCH_IOP13XX is not set +# CONFIG_ARCH_IOP32X is not set +# CONFIG_ARCH_IOP33X is not set +# CONFIG_ARCH_IXP23XX is not set +# CONFIG_ARCH_IXP2000 is not set +# CONFIG_ARCH_IXP4XX is not set +# CONFIG_ARCH_L7200 is not set +# CONFIG_ARCH_KIRKWOOD is not set +# CONFIG_ARCH_KS8695 is not set +# CONFIG_ARCH_NS9XXX is not set +# CONFIG_ARCH_LOKI is not set +# CONFIG_ARCH_MV78XX0 is not set +# CONFIG_ARCH_MXC is not set +# CONFIG_ARCH_ORION5X is not set +# CONFIG_ARCH_PNX4008 is not set +# CONFIG_ARCH_PXA is not set +# CONFIG_ARCH_RPC is not set +# CONFIG_ARCH_SA1100 is not set +# CONFIG_ARCH_S3C2410 is not set +# CONFIG_ARCH_SHARK is not set +# CONFIG_ARCH_LH7A40X is not set +# CONFIG_ARCH_DAVINCI is not set +# CONFIG_ARCH_OMAP is not set +# CONFIG_ARCH_MSM is not set +CONFIG_IRMP=y +# CONFIG_PCEXT is not set +# CONFIG_REMOTEFX is not set +# CONFIG_ARCH_AST1100 is not set +# CONFIG_ARCH_AST2100 is not set +# CONFIG_ARCH_AST2200 is not set +# CONFIG_ARCH_AST2300 is not set +CONFIG_ARCH_AST2400=y +CONFIG_WEDGE=y +# CONFIG_ARCH_AST2500 is not set + +# +# FLASH Chip Select +# +# CONFIG_AST_CS0_NOR is not set +# CONFIG_AST_CS0_NAND is not set +CONFIG_AST_CS0_SPI=y +# CONFIG_AST_CS0_NONE is not set +# CONFIG_AST_CS1_NOR is not set +# CONFIG_AST_CS1_NAND is not set +# CONFIG_AST_CS1_SPI is not set +CONFIG_AST_CS1_NONE=y +# CONFIG_AST_CS2_NOR is not set +# CONFIG_AST_CS2_NAND is not set +# CONFIG_AST_CS2_SPI is not set +CONFIG_AST_CS2_NONE=y +# CONFIG_AST_CS3_NOR is not set +# CONFIG_AST_CS3_NAND is not set +# CONFIG_AST_CS3_SPI is not set +CONFIG_AST_CS3_NONE=y +# CONFIG_AST_CS4_NOR is not set +# CONFIG_AST_CS4_NAND is not set +# CONFIG_AST_CS4_SPI is not set +CONFIG_AST_CS4_NONE=y +# CONFIG_ARCH_AST1070 is not set +# CONFIG_AST_SCU_LOCK is not set + +# +# Boot options +# + +# +# Power management +# +CONFIG_PLAT_ASPEED=y + +# +# Processor Type +# +CONFIG_CPU_32=y +CONFIG_CPU_ARM926T=y +CONFIG_CPU_32v5=y +CONFIG_CPU_ABRT_EV5TJ=y +CONFIG_CPU_PABRT_NOIFAR=y +CONFIG_CPU_CACHE_VIVT=y +CONFIG_CPU_COPY_V4WB=y +CONFIG_CPU_TLB_V4WBI=y +CONFIG_CPU_CP15=y +CONFIG_CPU_CP15_MMU=y + +# +# Processor Features +# +CONFIG_ARM_THUMB=y +# CONFIG_CPU_ICACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_DISABLE is not set +# CONFIG_CPU_DCACHE_WRITETHROUGH is not set +# CONFIG_CPU_CACHE_ROUND_ROBIN is not set +# CONFIG_OUTER_CACHE is not set + +# +# Bus support +# +CONFIG_ARM_AMBA=y +# CONFIG_PCI_SYSCALL is not set +# CONFIG_ARCH_SUPPORTS_MSI is not set +# CONFIG_PCCARD is not set + +# +# Kernel Features +# +CONFIG_TICK_ONESHOT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_VMSPLIT_3G=y +# CONFIG_VMSPLIT_2G is not set +# CONFIG_VMSPLIT_1G is not set +CONFIG_PAGE_OFFSET=0xC0000000 +# CONFIG_PREEMPT is not set +CONFIG_HZ=100 +CONFIG_AEABI=y +CONFIG_OABI_COMPAT=y +CONFIG_ARCH_FLATMEM_HAS_HOLES=y +# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set +# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set +CONFIG_SELECT_MEMORY_MODEL=y +CONFIG_FLATMEM_MANUAL=y +# CONFIG_DISCONTIGMEM_MANUAL is not set +# CONFIG_SPARSEMEM_MANUAL is not set +CONFIG_FLATMEM=y +CONFIG_FLAT_NODE_MEM_MAP=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_SPLIT_PTLOCK_CPUS=4096 +# CONFIG_RESOURCES_64BIT is not set +# CONFIG_PHYS_ADDR_T_64BIT is not set +CONFIG_ZONE_DMA_FLAG=0 +CONFIG_VIRT_TO_BUS=y +CONFIG_UNEVICTABLE_LRU=y +CONFIG_ALIGNMENT_TRAP=y + +# +# Boot options +# +CONFIG_ZBOOT_ROM_TEXT=0 +CONFIG_ZBOOT_ROM_BSS=0 +CONFIG_CMDLINE="" +# CONFIG_XIP_KERNEL is not set +# CONFIG_KEXEC is not set + +# +# CPU Power Management +# +# CONFIG_CPU_IDLE is not set + +# +# Floating point emulation +# + +# +# At least one emulation must be selected +# +CONFIG_FPE_NWFPE=y +CONFIG_FPE_NWFPE_XP=y +# CONFIG_FPE_FASTFPE is not set +CONFIG_VFP=y + +# +# Userspace binary formats +# +CONFIG_BINFMT_ELF=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_HAVE_AOUT=y +CONFIG_BINFMT_AOUT=y +# CONFIG_BINFMT_MISC is not set + +# +# Power management options +# +CONFIG_PM=y +# CONFIG_PM_DEBUG is not set +CONFIG_PM_SLEEP=y +CONFIG_SUSPEND=y +CONFIG_SUSPEND_FREEZER=y +# CONFIG_APM_EMULATION is not set +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_MMAP is not set +CONFIG_UNIX=y +CONFIG_XFRM=y +# CONFIG_XFRM_USER is not set +# CONFIG_XFRM_SUB_POLICY is not set +# CONFIG_XFRM_MIGRATE is not set +# CONFIG_XFRM_STATISTICS is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +# CONFIG_IP_ADVANCED_ROUTER is not set +CONFIG_IP_FIB_HASH=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +# CONFIG_IP_PNP_RARP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE is not set +# CONFIG_IP_MROUTE is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +CONFIG_INET_TUNNEL=m +CONFIG_INET_XFRM_MODE_TRANSPORT=y +CONFIG_INET_XFRM_MODE_TUNNEL=y +CONFIG_INET_XFRM_MODE_BEET=y +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_TCP_MD5SIG is not set +CONFIG_IPV6=m +# CONFIG_IPV6_PRIVACY is not set +# CONFIG_IPV6_ROUTER_PREF is not set +# CONFIG_IPV6_OPTIMISTIC_DAD is not set +# CONFIG_INET6_AH is not set +# CONFIG_INET6_ESP is not set +# CONFIG_INET6_IPCOMP is not set +# CONFIG_IPV6_MIP6 is not set +# CONFIG_INET6_XFRM_TUNNEL is not set +# CONFIG_INET6_TUNNEL is not set +CONFIG_INET6_XFRM_MODE_TRANSPORT=m +CONFIG_INET6_XFRM_MODE_TUNNEL=m +CONFIG_INET6_XFRM_MODE_BEET=m +# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set +CONFIG_IPV6_SIT=m +CONFIG_IPV6_NDISC_NODETYPE=y +# CONFIG_IPV6_TUNNEL is not set +# CONFIG_IPV6_MULTIPLE_TABLES is not set +# CONFIG_IPV6_MROUTE is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_IP_DCCP is not set +# CONFIG_IP_SCTP is not set +# CONFIG_TIPC is not set +# CONFIG_ATM is not set +# CONFIG_BRIDGE is not set +# CONFIG_NET_DSA is not set +CONFIG_VLAN_8021Q=m +# CONFIG_VLAN_8021Q_GVRP is not set +# CONFIG_DECNET is not set +# CONFIG_LLC2 is not set +# CONFIG_IPX is not set +# CONFIG_ATALK is not set +# CONFIG_X25 is not set +# CONFIG_LAPB is not set +# CONFIG_ECONET is not set +CONFIG_WAN_ROUTER=y +# CONFIG_NET_SCHED is not set + +# +# Network testing +# +# CONFIG_NET_PKTGEN is not set +# CONFIG_HAMRADIO is not set +# CONFIG_CAN is not set +# CONFIG_IRDA is not set +# CONFIG_BT is not set +# CONFIG_AF_RXRPC is not set +# CONFIG_PHONET is not set +# CONFIG_WIRELESS is not set +# CONFIG_RFKILL is not set +# CONFIG_NET_9P is not set + +# +# Device Drivers +# + +# +# Generic Driver Options +# +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_STANDALONE=y +CONFIG_PREVENT_FIRMWARE_BUILD=y +CONFIG_FW_LOADER=y +CONFIG_FIRMWARE_IN_KERNEL=y +CONFIG_EXTRA_FIRMWARE="" +# CONFIG_SYS_HYPERVISOR is not set +CONFIG_CONNECTOR=y +CONFIG_PROC_EVENTS=y +CONFIG_MTD=y +# CONFIG_MTD_DEBUG is not set +CONFIG_MTD_CONCAT=y +CONFIG_MTD_PARTITIONS=y +# CONFIG_MTD_REDBOOT_PARTS is not set +CONFIG_MTD_CMDLINE_PARTS=y +# CONFIG_MTD_AFS_PARTS is not set +# CONFIG_MTD_AR7_PARTS is not set + +# +# User Modules And Translation Layers +# +CONFIG_MTD_CHAR=y +CONFIG_MTD_BLKDEVS=y +CONFIG_MTD_BLOCK=y +# CONFIG_FTL is not set +# CONFIG_NFTL is not set +# CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set +# CONFIG_SSFDC is not set +# CONFIG_MTD_OOPS is not set + +# +# RAM/ROM/Flash chip drivers +# +# CONFIG_MTD_CFI is not set +# CONFIG_MTD_JEDECPROBE is not set +CONFIG_MTD_MAP_BANK_WIDTH_1=y +CONFIG_MTD_MAP_BANK_WIDTH_2=y +CONFIG_MTD_MAP_BANK_WIDTH_4=y +# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set +# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set +CONFIG_MTD_CFI_I1=y +CONFIG_MTD_CFI_I2=y +# CONFIG_MTD_CFI_I4 is not set +# CONFIG_MTD_CFI_I8 is not set +# CONFIG_MTD_RAM is not set +# CONFIG_MTD_ROM is not set +# CONFIG_MTD_ABSENT is not set + +# +# Mapping drivers for chip access +# +# CONFIG_MTD_COMPLEX_MAPPINGS is not set +# CONFIG_MTD_PLATRAM is not set + +# +# Self-contained MTD device drivers +# +CONFIG_MTD_DATAFLASH=m +CONFIG_MTD_DATAFLASH_WRITE_VERIFY=y +# CONFIG_MTD_DATAFLASH_OTP is not set +CONFIG_MTD_M25P80=y +CONFIG_M25PXX_USE_FAST_READ=y +# CONFIG_MTD_SLRAM is not set +# CONFIG_MTD_PHRAM is not set +# CONFIG_MTD_MTDRAM is not set +# CONFIG_MTD_BLOCK2MTD is not set + +# +# Disk-On-Chip Device Drivers +# +# CONFIG_MTD_DOC2000 is not set +# CONFIG_MTD_DOC2001 is not set +# CONFIG_MTD_DOC2001PLUS is not set +# CONFIG_MTD_NAND is not set +# CONFIG_MTD_ONENAND is not set + +# +# UBI - Unsorted block images +# +# CONFIG_MTD_UBI is not set +# CONFIG_PARPORT is not set +CONFIG_BLK_DEV=y +# CONFIG_BLK_DEV_COW_COMMON is not set +CONFIG_BLK_DEV_LOOP=y +# CONFIG_BLK_DEV_CRYPTOLOOP is not set +CONFIG_BLK_DEV_NBD=y +# CONFIG_BLK_DEV_UB is not set +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_COUNT=16 +CONFIG_BLK_DEV_RAM_SIZE=16384 +# CONFIG_BLK_DEV_XIP is not set +# CONFIG_RD_BZIP2 is not set +CONFIG_RD_LZMA=y +CONFIG_RD_GZIP=y +# CONFIG_CDROM_PKTCDVD is not set +# CONFIG_ATA_OVER_ETH is not set +CONFIG_MISC_DEVICES=y +# CONFIG_EEPROM_93CX6 is not set +# CONFIG_ICS932S401 is not set +# CONFIG_ENCLOSURE_SERVICES is not set +# CONFIG_C2PORT is not set +CONFIG_HAVE_IDE=y +# CONFIG_IDE is not set + +# +# SCSI device support +# +# CONFIG_RAID_ATTRS is not set +CONFIG_SCSI=y +CONFIG_SCSI_DMA=y +CONFIG_SCSI_TGT=y +# CONFIG_SCSI_NETLINK is not set +CONFIG_SCSI_PROC_FS=y + +# +# SCSI support type (disk, tape, CD-ROM) +# +CONFIG_BLK_DEV_SD=y +# CONFIG_CHR_DEV_ST is not set +# CONFIG_CHR_DEV_OSST is not set +# CONFIG_BLK_DEV_SR is not set +CONFIG_CHR_DEV_SG=y +# CONFIG_CHR_DEV_SCH is not set + +# +# Some SCSI devices (e.g. CD jukebox) support multiple LUNs +# +# CONFIG_SCSI_MULTI_LUN is not set +# CONFIG_SCSI_CONSTANTS is not set +# CONFIG_SCSI_LOGGING is not set +CONFIG_SCSI_SCAN_ASYNC=y +CONFIG_SCSI_WAIT_SCAN=m + +# +# SCSI Transports +# +# CONFIG_SCSI_SPI_ATTRS is not set +# CONFIG_SCSI_FC_ATTRS is not set +CONFIG_SCSI_ISCSI_ATTRS=m +# CONFIG_SCSI_SAS_LIBSAS is not set +# CONFIG_SCSI_SRP_ATTRS is not set +# CONFIG_SCSI_LOWLEVEL is not set +# CONFIG_SCSI_DH is not set +# CONFIG_ATA is not set +# CONFIG_MD is not set +CONFIG_NETDEVICES=y +# CONFIG_DUMMY is not set +CONFIG_BONDING=m +# CONFIG_MACVLAN is not set +# CONFIG_EQUALIZER is not set +CONFIG_TUN=m +# CONFIG_VETH is not set +# CONFIG_NET_ETHERNET is not set +CONFIG_NETDEV_1000=y +CONFIG_ASPEEDMAC=y +# CONFIG_NETDEV_10000 is not set + +# +# Wireless LAN +# +# CONFIG_WLAN_PRE80211 is not set +# CONFIG_WLAN_80211 is not set +# CONFIG_IWLWIFI_LEDS is not set + +# +# USB Network Adapters +# +# CONFIG_USB_CATC is not set +# CONFIG_USB_KAWETH is not set +# CONFIG_USB_PEGASUS is not set +# CONFIG_USB_RTL8150 is not set +# CONFIG_USB_USBNET is not set +# CONFIG_WAN is not set +# CONFIG_PPP is not set +# CONFIG_SLIP is not set +# CONFIG_NETCONSOLE is not set +# CONFIG_NETPOLL is not set +# CONFIG_NET_POLL_CONTROLLER is not set +# CONFIG_ISDN is not set + +# +# Input device support +# +CONFIG_INPUT=y +# CONFIG_INPUT_FF_MEMLESS is not set +# CONFIG_INPUT_POLLDEV is not set + +# +# Userland interfaces +# +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_MOUSEDEV_PSAUX=y +CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024 +CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768 +# CONFIG_INPUT_JOYDEV is not set +CONFIG_INPUT_EVDEV=y +# CONFIG_INPUT_EVBUG is not set + +# +# Input Device Drivers +# +CONFIG_INPUT_KEYBOARD=y +CONFIG_KEYBOARD_ATKBD=y +# CONFIG_KEYBOARD_SUNKBD is not set +# CONFIG_KEYBOARD_LKKBD is not set +# CONFIG_KEYBOARD_XTKBD is not set +# CONFIG_KEYBOARD_NEWTON is not set +# CONFIG_KEYBOARD_STOWAWAY is not set +# CONFIG_KEYBOARD_GPIO is not set +CONFIG_INPUT_MOUSE=y +CONFIG_MOUSE_PS2=y +CONFIG_MOUSE_PS2_ALPS=y +CONFIG_MOUSE_PS2_LOGIPS2PP=y +CONFIG_MOUSE_PS2_SYNAPTICS=y +CONFIG_MOUSE_PS2_LIFEBOOK=y +CONFIG_MOUSE_PS2_TRACKPOINT=y +# CONFIG_MOUSE_PS2_ELANTECH is not set +# CONFIG_MOUSE_PS2_TOUCHKIT is not set +CONFIG_MOUSE_SERIAL=y +# CONFIG_MOUSE_APPLETOUCH is not set +# CONFIG_MOUSE_BCM5974 is not set +# CONFIG_MOUSE_VSXXXAA is not set +# CONFIG_MOUSE_GPIO is not set +# CONFIG_INPUT_JOYSTICK is not set +# CONFIG_INPUT_TABLET is not set +# CONFIG_INPUT_TOUCHSCREEN is not set +# CONFIG_INPUT_MISC is not set + +# +# Hardware I/O ports +# +CONFIG_SERIO=y +CONFIG_SERIO_SERPORT=y +# CONFIG_SERIO_AMBAKMI is not set +CONFIG_SERIO_LIBPS2=y +# CONFIG_SERIO_RAW is not set +# CONFIG_GAMEPORT is not set + +# +# Character devices +# +CONFIG_VT=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_VT_CONSOLE=y +CONFIG_HW_CONSOLE=y +# CONFIG_VT_HW_CONSOLE_BINDING is not set +CONFIG_DEVKMEM=y +CONFIG_SERIAL_NONSTANDARD=y +# CONFIG_N_HDLC is not set +# CONFIG_RISCOM8 is not set +# CONFIG_SPECIALIX is not set +# CONFIG_RIO is not set +# CONFIG_STALDRV is not set + +# +# Serial drivers +# +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=4 +CONFIG_SERIAL_8250_RUNTIME_UARTS=4 +# CONFIG_SERIAL_AST_DMA_UART is not set +# CONFIG_SERIAL_8250_EXTENDED is not set + +# +# Non-8250 serial port support +# +# CONFIG_SERIAL_AMBA_PL010 is not set +# CONFIG_SERIAL_AMBA_PL011 is not set +# CONFIG_SERIAL_AST is not set +CONFIG_SERIAL_CORE=y +CONFIG_SERIAL_CORE_CONSOLE=y +CONFIG_UNIX98_PTYS=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +# CONFIG_IPMI_HANDLER is not set +CONFIG_AST_MISC=y +# CONFIG_AST_VIDEO is not set +# CONFIG_ADC_CAT9883 is not set +# CONFIG_AST_SPI_BIOS is not set +CONFIG_AST_PECI=y +# CONFIG_AST_KCS is not set +# CONFIG_AST_GPIO is not set +# CONFIG_HW_RANDOM is not set +CONFIG_NVRAM=y +# CONFIG_R3964 is not set +# CONFIG_RAW_DRIVER is not set +# CONFIG_TCG_TPM is not set +CONFIG_I2C=y +CONFIG_I2C_BOARDINFO=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_HELPER_AUTO=y + +# +# I2C Hardware Bus support +# + +# +# I2C system bus drivers (mostly embedded / system-on-chip) +# +# CONFIG_I2C_GPIO is not set +# CONFIG_I2C_OCORES is not set +CONFIG_I2C_AST=y +CONFIG_AST_I2C_SLAVE_MODE=y +CONFIG_AST_I2C_SLAVE_EEPROM=y +# CONFIG_AST_I2C_SLAVE_RDWR is not set +# CONFIG_I2C_SIMTEC is not set + +# +# External I2C/SMBus adapter drivers +# +# CONFIG_I2C_PARPORT_LIGHT is not set +# CONFIG_I2C_TAOS_EVM is not set +# CONFIG_I2C_TINY_USB is not set + +# +# Other I2C/SMBus bus drivers +# +# CONFIG_I2C_PCA_PLATFORM is not set +# CONFIG_I2C_STUB is not set + +# +# Miscellaneous I2C Chip support +# +# CONFIG_DS1682 is not set +CONFIG_AT24=m +# CONFIG_SENSORS_EEPROM is not set +CONFIG_SENSORS_PCF8574=m +# CONFIG_PCF8575 is not set +# CONFIG_SENSORS_PCA9539 is not set +# CONFIG_SENSORS_PCF8591 is not set +# CONFIG_TPS65010 is not set +# CONFIG_SENSORS_MAX6875 is not set +# CONFIG_SENSORS_TSL2550 is not set +# CONFIG_I2C_DEBUG_CORE is not set +# CONFIG_I2C_DEBUG_ALGO is not set +# CONFIG_I2C_DEBUG_BUS is not set +# CONFIG_I2C_DEBUG_CHIP is not set +CONFIG_SPI=y +CONFIG_SPI_MASTER=y + +# +# SPI Master Controller Drivers +# +CONFIG_SPI_AST=y +CONFIG_SPI_FMC=y +CONFIG_SPI_BITBANG=y + +# +# SPI Protocol Masters +# +CONFIG_SPI_AT25=m +# CONFIG_SPI_SPIDEV is not set +# CONFIG_SPI_TLE62X0 is not set +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y + +# +# Memory mapped GPIO expanders: +# + +# +# I2C GPIO expanders: +# +# CONFIG_GPIO_MAX732X is not set +# CONFIG_GPIO_PCA953X is not set +# CONFIG_GPIO_PCF857X is not set + +# +# PCI GPIO expanders: +# + +# +# SPI GPIO expanders: +# +# CONFIG_GPIO_MAX7301 is not set +# CONFIG_GPIO_MCP23S08 is not set +# CONFIG_W1 is not set +# CONFIG_POWER_SUPPLY is not set +CONFIG_HWMON=y +# CONFIG_HWMON_VID is not set +# CONFIG_SENSORS_AD7414 is not set +# CONFIG_SENSORS_AD7418 is not set +# CONFIG_SENSORS_ADCXX is not set +# CONFIG_SENSORS_ADM1021 is not set +# CONFIG_SENSORS_ADM1025 is not set +# CONFIG_SENSORS_ADM1026 is not set +# CONFIG_SENSORS_ADM1029 is not set +# CONFIG_SENSORS_ADM1031 is not set +# CONFIG_SENSORS_ADM9240 is not set +# CONFIG_SENSORS_ADT7462 is not set +# CONFIG_SENSORS_ADT7470 is not set +# CONFIG_SENSORS_ADT7473 is not set +# CONFIG_SENSORS_ATXP1 is not set +# CONFIG_SENSORS_DS1621 is not set +# CONFIG_SENSORS_F71805F is not set +# CONFIG_SENSORS_F71882FG is not set +# CONFIG_SENSORS_F75375S is not set +# CONFIG_SENSORS_GL518SM is not set +# CONFIG_SENSORS_GL520SM is not set +# CONFIG_SENSORS_IT87 is not set +# CONFIG_SENSORS_LM63 is not set +# CONFIG_SENSORS_LM70 is not set +CONFIG_SENSORS_LM75=m +# CONFIG_SENSORS_LM77 is not set +# CONFIG_SENSORS_LM78 is not set +# CONFIG_SENSORS_LM80 is not set +# CONFIG_SENSORS_LM83 is not set +# CONFIG_SENSORS_LM85 is not set +# CONFIG_SENSORS_LM87 is not set +# CONFIG_SENSORS_LM90 is not set +# CONFIG_SENSORS_LM92 is not set +# CONFIG_SENSORS_LM93 is not set +CONFIG_SENSORS_MAX127=m +# CONFIG_SENSORS_MAX1111 is not set +# CONFIG_SENSORS_MAX1619 is not set +# CONFIG_SENSORS_MAX6650 is not set +# CONFIG_SENSORS_PC87360 is not set +# CONFIG_SENSORS_PC87427 is not set +# CONFIG_SENSORS_DME1737 is not set +# CONFIG_SENSORS_SMSC47M1 is not set +# CONFIG_SENSORS_SMSC47M192 is not set +# CONFIG_SENSORS_SMSC47B397 is not set +CONFIG_SENSORS_ADS7828=m +# CONFIG_SENSORS_THMC50 is not set +# CONFIG_SENSORS_VT1211 is not set +# CONFIG_SENSORS_W83781D is not set +# CONFIG_SENSORS_W83791D is not set +# CONFIG_SENSORS_W83792D is not set +# CONFIG_SENSORS_W83793 is not set +# CONFIG_SENSORS_W83L785TS is not set +# CONFIG_SENSORS_W83L786NG is not set +# CONFIG_SENSORS_W83627HF is not set +# CONFIG_SENSORS_W83627EHF is not set +CONFIG_SENSORS_AST_ADC=y +CONFIG_SENSORS_AST_PWM_FAN=y +CONFIG_SENSORS_FB_PANTHER_PLUS=m +CONFIG_PMBUS=m +CONFIG_SENSORS_PMBUS=m +CONFIG_SENSORS_ADM1275=m +# CONFIG_SENSORS_LM25066 is not set +# CONFIG_SENSORS_LTC2978 is not set +# CONFIG_SENSORS_MAX16064 is not set +# CONFIG_SENSORS_MAX34440 is not set +# CONFIG_SENSORS_MAX8688 is not set +CONFIG_SENSORS_PFE1100=m +CONFIG_SENSORS_PFE3000=m +# CONFIG_SENSORS_UCD9000 is not set +# CONFIG_SENSORS_UCD9200 is not set +# CONFIG_SENSORS_ZL6100 is not set +# CONFIG_HWMON_DEBUG_CHIP is not set +CONFIG_THERMAL=y +CONFIG_THERMAL_HWMON=y +CONFIG_WATCHDOG=y +# CONFIG_WATCHDOG_NOWAYOUT is not set + +# +# Watchdog Device Drivers +# +# CONFIG_SOFT_WATCHDOG is not set +CONFIG_AST_WATCHDOG=y + +# +# USB-based Watchdog Cards +# +# CONFIG_USBPCWATCHDOG is not set +CONFIG_SSB_POSSIBLE=y + +# +# Sonics Silicon Backplane +# +# CONFIG_SSB is not set + +# +# Multifunction device drivers +# +# CONFIG_MFD_CORE is not set +# CONFIG_MFD_SM501 is not set +# CONFIG_MFD_ASIC3 is not set +# CONFIG_HTC_EGPIO is not set +# CONFIG_HTC_PASIC3 is not set +# CONFIG_MFD_TMIO is not set +# CONFIG_MFD_TC6393XB is not set +# CONFIG_PMIC_DA903X is not set +# CONFIG_MFD_WM8400 is not set +# CONFIG_MFD_WM8350_I2C is not set + +# +# Multimedia devices +# + +# +# Multimedia core support +# +# CONFIG_VIDEO_DEV is not set +# CONFIG_DVB_CORE is not set +# CONFIG_VIDEO_MEDIA is not set + +# +# Multimedia drivers +# +# CONFIG_DAB is not set + +# +# Graphics support +# +# CONFIG_VGASTATE is not set +# CONFIG_VIDEO_OUTPUT_CONTROL is not set +# CONFIG_FB is not set +# CONFIG_BACKLIGHT_LCD_SUPPORT is not set + +# +# Display device support +# +# CONFIG_DISPLAY_SUPPORT is not set + +# +# Console display driver support +# +# CONFIG_VGA_CONSOLE is not set +CONFIG_DUMMY_CONSOLE=y +# CONFIG_SOUND is not set +# CONFIG_HID_SUPPORT is not set +CONFIG_USB_SUPPORT=y +CONFIG_USB_ARCH_HAS_HCD=y +# CONFIG_USB_ARCH_HAS_OHCI is not set +CONFIG_USB_ARCH_HAS_EHCI=y +CONFIG_USB=m +# CONFIG_USB_DEBUG is not set +# CONFIG_USB_ANNOUNCE_NEW_DEVICES is not set + +# +# Miscellaneous USB options +# +CONFIG_USB_DEVICEFS=y +CONFIG_USB_DEVICE_CLASS=y +# CONFIG_USB_DYNAMIC_MINORS is not set +# CONFIG_USB_SUSPEND is not set +# CONFIG_USB_OTG is not set +# CONFIG_USB_MON is not set +# CONFIG_USB_WUSB is not set +# CONFIG_USB_WUSB_CBAF is not set + +# +# USB Host Controller Drivers +# +# CONFIG_USB_C67X00_HCD is not set +# CONFIG_USB_EHCI_HCD is not set +# CONFIG_USB_ISP116X_HCD is not set +# CONFIG_USB_SL811_HCD is not set +# CONFIG_USB_R8A66597_HCD is not set +# CONFIG_USB_HWA_HCD is not set + +# +# AST USB Drivers +# +CONFIG_AST_USB_UHCI_HCD=y +# CONFIG_AST_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_AST_USB_UHCI_MULTIPORT_2 is not set +CONFIG_AST_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_EHCI_SPLIT_ISO is not set + +# +# USB Device Class drivers +# +# CONFIG_USB_ACM is not set +# CONFIG_USB_PRINTER is not set +# CONFIG_USB_WDM is not set +# CONFIG_USB_TMC is not set + +# +# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may also be needed; +# + +# +# see USB_STORAGE Help for more information +# +CONFIG_USB_STORAGE=m +# CONFIG_USB_STORAGE_DEBUG is not set +# CONFIG_USB_STORAGE_DATAFAB is not set +# CONFIG_USB_STORAGE_FREECOM is not set +# CONFIG_USB_STORAGE_ISD200 is not set +# CONFIG_USB_STORAGE_DPCM is not set +# CONFIG_USB_STORAGE_USBAT is not set +# CONFIG_USB_STORAGE_SDDR09 is not set +# CONFIG_USB_STORAGE_SDDR55 is not set +# CONFIG_USB_STORAGE_JUMPSHOT is not set +# CONFIG_USB_STORAGE_ALAUDA is not set +# CONFIG_USB_STORAGE_ONETOUCH is not set +# CONFIG_USB_STORAGE_KARMA is not set +# CONFIG_USB_STORAGE_CYPRESS_ATACB is not set +# CONFIG_USB_LIBUSUAL is not set + +# +# USB Imaging devices +# +# CONFIG_USB_MDC800 is not set +# CONFIG_USB_MICROTEK is not set + +# +# USB port drivers +# +# CONFIG_USB_SERIAL is not set + +# +# USB Miscellaneous drivers +# +# CONFIG_USB_EMI62 is not set +# CONFIG_USB_EMI26 is not set +# CONFIG_USB_ADUTUX is not set +# CONFIG_USB_SEVSEG is not set +# CONFIG_USB_RIO500 is not set +# CONFIG_USB_LEGOTOWER is not set +# CONFIG_USB_LCD is not set +# CONFIG_USB_BERRY_CHARGE is not set +# CONFIG_USB_LED is not set +# CONFIG_USB_CYPRESS_CY7C63 is not set +# CONFIG_USB_CYTHERM is not set +# CONFIG_USB_PHIDGET is not set +# CONFIG_USB_IDMOUSE is not set +# CONFIG_USB_FTDI_ELAN is not set +# CONFIG_USB_APPLEDISPLAY is not set +# CONFIG_USB_LD is not set +# CONFIG_USB_TRANCEVIBRATOR is not set +# CONFIG_USB_IOWARRIOR is not set +# CONFIG_USB_TEST is not set +# CONFIG_USB_ISIGHTFW is not set +# CONFIG_USB_VST is not set +CONFIG_USB_GADGET=y +# CONFIG_USB_GADGET_DEBUG_FILES is not set +CONFIG_USB_GADGET_VBUS_DRAW=2 +CONFIG_USB_GADGET_SELECTED=y +# CONFIG_USB_GADGET_AT91 is not set +# CONFIG_USB_GADGET_ATMEL_USBA is not set +# CONFIG_USB_GADGET_FSL_USB2 is not set +# CONFIG_USB_GADGET_LH7A40X is not set +# CONFIG_USB_GADGET_OMAP is not set +# CONFIG_USB_GADGET_PXA25X is not set +# CONFIG_USB_GADGET_PXA27X is not set +# CONFIG_USB_GADGET_S3C2410 is not set +# CONFIG_USB_GADGET_M66592 is not set +# CONFIG_USB_GADGET_AMD5536UDC is not set +# CONFIG_USB_GADGET_FSL_QE is not set +# CONFIG_USB_GADGET_NET2280 is not set +# CONFIG_USB_GADGET_GOKU is not set +CONFIG_USB_GADGET_ASPEED_AST=y +CONFIG_USB_ASPEED_AST=y +# CONFIG_USB_GADGET_DUMMY_HCD is not set +CONFIG_USB_GADGET_DUALSPEED=y +CONFIG_USB_ZERO=m +CONFIG_USB_ETH=m +CONFIG_USB_ETH_RNDIS=y +CONFIG_USB_GADGETFS=m +CONFIG_USB_FILE_STORAGE=m +# CONFIG_USB_FILE_STORAGE_TEST is not set +CONFIG_USB_G_SERIAL=m +# CONFIG_USB_MIDI_GADGET is not set +# CONFIG_USB_G_PRINTER is not set +CONFIG_USB_CDC_COMPOSITE=m +# CONFIG_MMC is not set +# CONFIG_MEMSTICK is not set +# CONFIG_ACCESSIBILITY is not set +# CONFIG_NEW_LEDS is not set +CONFIG_RTC_LIB=y +CONFIG_RTC_CLASS=y +# CONFIG_RTC_HCTOSYS is not set +# CONFIG_RTC_DEBUG is not set + +# +# RTC interfaces +# +CONFIG_RTC_INTF_SYSFS=y +CONFIG_RTC_INTF_PROC=y +CONFIG_RTC_INTF_DEV=y +# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set +# CONFIG_RTC_DRV_TEST is not set + +# +# I2C RTC drivers +# +# CONFIG_RTC_DRV_DS1307 is not set +# CONFIG_RTC_DRV_DS1374 is not set +# CONFIG_RTC_DRV_DS1672 is not set +# CONFIG_RTC_DRV_MAX6900 is not set +# CONFIG_RTC_DRV_RS5C372 is not set +# CONFIG_RTC_DRV_ISL1208 is not set +# CONFIG_RTC_DRV_X1205 is not set +# CONFIG_RTC_DRV_PCF8563 is not set +# CONFIG_RTC_DRV_PCF8583 is not set +# CONFIG_RTC_DRV_M41T80 is not set +# CONFIG_RTC_DRV_S35390A is not set +# CONFIG_RTC_DRV_FM3130 is not set +# CONFIG_RTC_DRV_RX8581 is not set + +# +# SPI RTC drivers +# +# CONFIG_RTC_DRV_M41T94 is not set +# CONFIG_RTC_DRV_DS1305 is not set +# CONFIG_RTC_DRV_DS1390 is not set +# CONFIG_RTC_DRV_MAX6902 is not set +# CONFIG_RTC_DRV_R9701 is not set +# CONFIG_RTC_DRV_RS5C348 is not set +# CONFIG_RTC_DRV_DS3234 is not set + +# +# Platform RTC drivers +# +# CONFIG_RTC_DRV_CMOS is not set +# CONFIG_RTC_DRV_DS1286 is not set +# CONFIG_RTC_DRV_DS1511 is not set +# CONFIG_RTC_DRV_DS1553 is not set +# CONFIG_RTC_DRV_DS1742 is not set +# CONFIG_RTC_DRV_STK17TA8 is not set +# CONFIG_RTC_DRV_M48T86 is not set +# CONFIG_RTC_DRV_M48T35 is not set +# CONFIG_RTC_DRV_M48T59 is not set +# CONFIG_RTC_DRV_BQ4802 is not set +# CONFIG_RTC_DRV_V3020 is not set + +# +# on-CPU RTC drivers +# +# CONFIG_RTC_DRV_PL030 is not set +# CONFIG_RTC_DRV_PL031 is not set +CONFIG_RTC_DRV_ASPEED=y +# CONFIG_DMADEVICES is not set +# CONFIG_REGULATOR is not set +# CONFIG_UIO is not set + +# +# File systems +# +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +# CONFIG_EXT2_FS_XIP is not set +# CONFIG_EXT3_FS is not set +# CONFIG_EXT4_FS is not set +CONFIG_FS_MBCACHE=y +# CONFIG_REISERFS_FS is not set +# CONFIG_JFS_FS is not set +CONFIG_FS_POSIX_ACL=y +CONFIG_FILE_LOCKING=y +# CONFIG_XFS_FS is not set +# CONFIG_OCFS2_FS is not set +CONFIG_DNOTIFY=y +CONFIG_INOTIFY=y +CONFIG_INOTIFY_USER=y +# CONFIG_QUOTA is not set +# CONFIG_AUTOFS_FS is not set +# CONFIG_AUTOFS4_FS is not set +# CONFIG_FUSE_FS is not set +CONFIG_GENERIC_ACL=y + +# +# CD-ROM/DVD Filesystems +# +# CONFIG_ISO9660_FS is not set +# CONFIG_UDF_FS is not set + +# +# DOS/FAT/NT Filesystems +# +CONFIG_FAT_FS=y +CONFIG_MSDOS_FS=y +CONFIG_VFAT_FS=y +CONFIG_FAT_DEFAULT_CODEPAGE=437 +CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" +CONFIG_NTFS_FS=y +# CONFIG_NTFS_DEBUG is not set +CONFIG_NTFS_RW=y + +# +# Pseudo filesystems +# +CONFIG_PROC_FS=y +CONFIG_PROC_SYSCTL=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_SYSFS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +# CONFIG_HUGETLB_PAGE is not set +CONFIG_CONFIGFS_FS=m + +# +# Miscellaneous filesystems +# +# CONFIG_ADFS_FS is not set +# CONFIG_AFFS_FS is not set +# CONFIG_HFS_FS is not set +# CONFIG_HFSPLUS_FS is not set +# CONFIG_BEFS_FS is not set +# CONFIG_BFS_FS is not set +# CONFIG_EFS_FS is not set +CONFIG_YAFFS_FS=y +CONFIG_YAFFS_YAFFS1=y +# CONFIG_YAFFS_9BYTE_TAGS is not set +# CONFIG_YAFFS_DOES_ECC is not set +CONFIG_YAFFS_YAFFS2=y +CONFIG_YAFFS_AUTO_YAFFS2=y +# CONFIG_YAFFS_DISABLE_TAGS_ECC is not set +# CONFIG_YAFFS_DISABLE_LAZY_LOAD is not set +# CONFIG_YAFFS_DISABLE_WIDE_TNODES is not set +# CONFIG_YAFFS_ALWAYS_CHECK_CHUNK_ERASED is not set +CONFIG_YAFFS_SHORT_NAMES_IN_RAM=y +# CONFIG_YAFFS_EMPTY_LOST_AND_FOUND is not set +CONFIG_JFFS2_FS=y +CONFIG_JFFS2_FS_DEBUG=0 +CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_FS_WBUF_VERIFY is not set +# CONFIG_JFFS2_SUMMARY is not set +# CONFIG_JFFS2_FS_XATTR is not set +# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set +CONFIG_JFFS2_ZLIB=y +# CONFIG_JFFS2_LZO is not set +CONFIG_JFFS2_RTIME=y +# CONFIG_JFFS2_RUBIN is not set +# CONFIG_CRAMFS is not set +# CONFIG_VXFS_FS is not set +# CONFIG_MINIX_FS is not set +# CONFIG_OMFS_FS is not set +# CONFIG_HPFS_FS is not set +# CONFIG_QNX4FS_FS is not set +# CONFIG_ROMFS_FS is not set +# CONFIG_SYSV_FS is not set +# CONFIG_UFS_FS is not set +CONFIG_NETWORK_FILESYSTEMS=y +CONFIG_NFS_FS=y +# CONFIG_NFS_V3 is not set +# CONFIG_NFS_V4 is not set +CONFIG_ROOT_NFS=y +# CONFIG_NFSD is not set +CONFIG_LOCKD=y +CONFIG_NFS_COMMON=y +CONFIG_SUNRPC=y +# CONFIG_SUNRPC_REGISTER_V4 is not set +# CONFIG_RPCSEC_GSS_KRB5 is not set +# CONFIG_RPCSEC_GSS_SPKM3 is not set +# CONFIG_SMB_FS is not set +# CONFIG_CIFS is not set +# CONFIG_NCP_FS is not set +# CONFIG_CODA_FS is not set +# CONFIG_AFS_FS is not set + +# +# Partition Types +# +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_MSDOS_PARTITION=y +CONFIG_NLS=y +CONFIG_NLS_DEFAULT="utf8" +CONFIG_NLS_CODEPAGE_437=y +# CONFIG_NLS_CODEPAGE_737 is not set +# CONFIG_NLS_CODEPAGE_775 is not set +# CONFIG_NLS_CODEPAGE_850 is not set +# CONFIG_NLS_CODEPAGE_852 is not set +# CONFIG_NLS_CODEPAGE_855 is not set +# CONFIG_NLS_CODEPAGE_857 is not set +# CONFIG_NLS_CODEPAGE_860 is not set +# CONFIG_NLS_CODEPAGE_861 is not set +# CONFIG_NLS_CODEPAGE_862 is not set +# CONFIG_NLS_CODEPAGE_863 is not set +# CONFIG_NLS_CODEPAGE_864 is not set +# CONFIG_NLS_CODEPAGE_865 is not set +# CONFIG_NLS_CODEPAGE_866 is not set +# CONFIG_NLS_CODEPAGE_869 is not set +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_CODEPAGE_950=y +CONFIG_NLS_CODEPAGE_932=y +# CONFIG_NLS_CODEPAGE_949 is not set +# CONFIG_NLS_CODEPAGE_874 is not set +# CONFIG_NLS_ISO8859_8 is not set +# CONFIG_NLS_CODEPAGE_1250 is not set +# CONFIG_NLS_CODEPAGE_1251 is not set +CONFIG_NLS_ASCII=y +CONFIG_NLS_ISO8859_1=y +# CONFIG_NLS_ISO8859_2 is not set +# CONFIG_NLS_ISO8859_3 is not set +# CONFIG_NLS_ISO8859_4 is not set +# CONFIG_NLS_ISO8859_5 is not set +# CONFIG_NLS_ISO8859_6 is not set +# CONFIG_NLS_ISO8859_7 is not set +# CONFIG_NLS_ISO8859_9 is not set +# CONFIG_NLS_ISO8859_13 is not set +# CONFIG_NLS_ISO8859_14 is not set +# CONFIG_NLS_ISO8859_15 is not set +# CONFIG_NLS_KOI8_R is not set +# CONFIG_NLS_KOI8_U is not set +CONFIG_NLS_UTF8=y +# CONFIG_DLM is not set + +# +# Kernel hacking +# +# CONFIG_PRINTK_TIME is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +CONFIG_ENABLE_MUST_CHECK=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +# CONFIG_UNUSED_SYMBOLS is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_HEADERS_CHECK is not set +# CONFIG_DEBUG_KERNEL is not set +# CONFIG_SLUB_DEBUG_ON is not set +# CONFIG_SLUB_STATS is not set +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_MEMORY_INIT=y +CONFIG_FRAME_POINTER=y +# CONFIG_RCU_CPU_STALL_DETECTOR is not set +# CONFIG_LATENCYTOP is not set +# CONFIG_SYSCTL_SYSCALL_CHECK is not set +CONFIG_HAVE_FUNCTION_TRACER=y + +# +# Tracers +# +# CONFIG_DYNAMIC_PRINTK_DEBUG is not set +# CONFIG_SAMPLES is not set +CONFIG_HAVE_ARCH_KGDB=y +# CONFIG_DEBUG_USER is not set + +# +# Security options +# +# CONFIG_KEYS is not set +# CONFIG_SECURITY is not set +# CONFIG_SECURITYFS is not set +# CONFIG_SECURITY_FILE_CAPABILITIES is not set +CONFIG_CRYPTO=y + +# +# Crypto core or helper +# +# CONFIG_CRYPTO_FIPS is not set +CONFIG_CRYPTO_ALGAPI=y +CONFIG_CRYPTO_ALGAPI2=y +CONFIG_CRYPTO_AEAD=m +CONFIG_CRYPTO_AEAD2=y +CONFIG_CRYPTO_BLKCIPHER=y +CONFIG_CRYPTO_BLKCIPHER2=y +CONFIG_CRYPTO_HASH=y +CONFIG_CRYPTO_HASH2=y +CONFIG_CRYPTO_RNG2=y +CONFIG_CRYPTO_MANAGER=y +CONFIG_CRYPTO_MANAGER2=y +# CONFIG_CRYPTO_GF128MUL is not set +CONFIG_CRYPTO_NULL=y +# CONFIG_CRYPTO_CRYPTD is not set +CONFIG_CRYPTO_AUTHENC=m +# CONFIG_CRYPTO_TEST is not set + +# +# Authenticated Encryption with Associated Data +# +# CONFIG_CRYPTO_CCM is not set +# CONFIG_CRYPTO_GCM is not set +# CONFIG_CRYPTO_SEQIV is not set + +# +# Block modes +# +CONFIG_CRYPTO_CBC=y +# CONFIG_CRYPTO_CTR is not set +# CONFIG_CRYPTO_CTS is not set +# CONFIG_CRYPTO_ECB is not set +# CONFIG_CRYPTO_LRW is not set +# CONFIG_CRYPTO_PCBC is not set +# CONFIG_CRYPTO_XTS is not set + +# +# Hash modes +# +CONFIG_CRYPTO_HMAC=y +# CONFIG_CRYPTO_XCBC is not set + +# +# Digest +# +# CONFIG_CRYPTO_CRC32C is not set +# CONFIG_CRYPTO_MD4 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_MICHAEL_MIC is not set +# CONFIG_CRYPTO_RMD128 is not set +# CONFIG_CRYPTO_RMD160 is not set +# CONFIG_CRYPTO_RMD256 is not set +# CONFIG_CRYPTO_RMD320 is not set +CONFIG_CRYPTO_SHA1=y +# CONFIG_CRYPTO_SHA256 is not set +# CONFIG_CRYPTO_SHA512 is not set +# CONFIG_CRYPTO_TGR192 is not set +# CONFIG_CRYPTO_WP512 is not set + +# +# Ciphers +# +# CONFIG_CRYPTO_AES is not set +# CONFIG_CRYPTO_ANUBIS is not set +# CONFIG_CRYPTO_ARC4 is not set +# CONFIG_CRYPTO_BLOWFISH is not set +# CONFIG_CRYPTO_CAMELLIA is not set +# CONFIG_CRYPTO_CAST5 is not set +# CONFIG_CRYPTO_CAST6 is not set +CONFIG_CRYPTO_DES=y +# CONFIG_CRYPTO_FCRYPT is not set +# CONFIG_CRYPTO_KHAZAD is not set +# CONFIG_CRYPTO_SALSA20 is not set +# CONFIG_CRYPTO_SEED is not set +# CONFIG_CRYPTO_SERPENT is not set +# CONFIG_CRYPTO_TEA is not set +# CONFIG_CRYPTO_TWOFISH is not set + +# +# Compression +# +CONFIG_CRYPTO_DEFLATE=m +# CONFIG_CRYPTO_LZO is not set + +# +# Random Number Generation +# +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set + +# +# Library routines +# +CONFIG_BITREVERSE=y +# CONFIG_CRC_CCITT is not set +# CONFIG_CRC16 is not set +# CONFIG_CRC_T10DIF is not set +CONFIG_CRC_ITU_T=m +CONFIG_CRC32=y +# CONFIG_CRC7 is not set +# CONFIG_LIBCRC32C is not set +CONFIG_ZLIB_INFLATE=y +CONFIG_ZLIB_DEFLATE=y +CONFIG_PLIST=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAS_DMA=y + + +# GUC USB Drivers +# +CONFIG_GUC_USB_UHCI_HCD=m +# CONFIG_GUC_USB_UHCI_MULTIPORT_1 is not set +# CONFIG_GUC_USB_UHCI_MULTIPORT_2 is not set +CONFIG_GUC_USB_UHCI_MULTIPORT_4=y +# CONFIG_USB_GADGET_MUSB_HDRC is not set diff --git a/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend b/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend index 3c5b71c..4ff7eac 100644 --- a/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend +++ b/meta-facebook/meta-wedge/recipes-kernel/linux/linux-aspeed_2.6%.bbappend @@ -2,4 +2,7 @@ LINUX_VERSION_EXTENSION = "-wedge" COMPATIBLE_MACHINE = "wedge" -KERNEL_CONFIG_COMMAND = "oe_runmake wedge_defconfig && oe_runmake oldconfig" +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI += "file://defconfig \ + " diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/bitbang_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/bitbang/bitbang_0.1.bb deleted file mode 100644 index 443d81d..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/bitbang_0.1.bb +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -SUMMARY = "Device driver using GPIO bitbang" -DESCRIPTION = "Various device driver using GPIO bitbang" -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://bitbang.c;beginline=4;endline=16;md5=da35978751a9d71b73679307c4d296ec" - -SRC_URI = "file://src \ - " - -DEPENDS += "fbutils" - -S = "${WORKDIR}/src" - -do_install() { - install -d ${D}${bindir} - install -m 755 spi-bb ${D}${bindir}/spi-bb - install -m 755 mdio-bb ${D}${bindir}/mdio-bb -} - -FILES_${PN} = "${bindir}" diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/Makefile b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/Makefile deleted file mode 100644 index 102ac4e..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -all: spi-bb mdio-bb - -spi-bb: spi_bb.o bitbang.o gpio.o - $(CC) -o $@ $^ $(LDFLAGS) - -mdio-bb: mdio_bb.o bitbang.o gpio.o - $(CC) -o $@ $^ $(LDFLAGS) - -.PHONY: clean - -clean: - rm -rf *.o spi-bb mdio-bb diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.c deleted file mode 100644 index cf7dcd3..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "bitbang.h" - -#include <errno.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/types.h> - -#include "facebook/log.h" - -#define NANOSEC_IN_SEC (1000 * 1000 * 1000) - -#define BITBANG_FREQ_MAX (500 * 1000 * 1000) /* 500M Hz */ -#define BITBANG_FREQ_DEFAULT (1 * 1000 * 1000) /* 1M Hz */ - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) - -struct bitbang_handle { - bitbang_init_st bbh_init; - uint32_t bbh_half_clk; /* ns per clock cycle */ -}; - -void bitbang_init_default(bitbang_init_st *init) -{ - memset(init, sizeof(*init), 0); - init->bbi_clk_start = BITBANG_PIN_HIGH; - init->bbi_data_out = BITBANG_CLK_EDGE_FALLING; - init->bbi_data_in = BITBANG_CLK_EDGE_RISING; - init->bbi_freq = BITBANG_FREQ_DEFAULT; -} - -bitbang_handle_st* bitbang_open(const bitbang_init_st *init) -{ - bitbang_handle_st *hdl; - - if (!init || !init->bbi_pin_f - || !init->bbi_freq || init->bbi_freq > BITBANG_FREQ_MAX) { - LOG_ERR(EINVAL, "Invalid init structure"); - return NULL; - } - - hdl = calloc(1, sizeof(*hdl)); - if (!hdl) { - return NULL; - } - - hdl->bbh_init = *init; - hdl->bbh_half_clk = NANOSEC_IN_SEC / init->bbi_freq / 2; - - LOG_DBG("Bitbang open with initial %s, data out at %s, data in at %s, " - "freq at %uHz, half clk %uns", - (init->bbi_clk_start == BITBANG_PIN_LOW) ? "LOW" : "HIGH", - (init->bbi_data_out == BITBANG_CLK_EDGE_RISING) - ? "RISING" : "FALLING", - (init->bbi_data_in == BITBANG_CLK_EDGE_RISING) - ? "RISING" : "FALLING", - init->bbi_freq, hdl->bbh_half_clk); - - return hdl; -} - -void bitbang_close(bitbang_handle_st *hdl) -{ - free(hdl); -} - -/* - * The threshold (ns) to use spin instead of nanosleep(). - * Before adding the high resolution timer support, either spin or nanosleep() - * will not bring the process wakeup within 10ms. It turns out the system time - * update is also controlled by HZ (100). - * After I added the high resolution timer support, the spin works as the - * system time is updated more frequently. However, nanosleep() solution is - * still noticable slower comparing with spin. There could be some kernel - * scheduling tweak missing. Did not get time on that yet. - * For now, use 10ms as the threshold to determine if spin or nanosleep() - * is used. - */ -#define BITBANG_SPIN_THRESHOLD (10 * 1000 * 1000) - -static int sleep_ns(uint32_t clk) -{ - struct timespec req, rem; - int rc = 0; - if (clk <= BITBANG_SPIN_THRESHOLD) { - struct timespec orig; - rc = clock_gettime(CLOCK_MONOTONIC, &req); - orig = req; - while (!rc && clk) { - uint32_t tmp; - rc = clock_gettime(CLOCK_MONOTONIC, &rem); - tmp = (rem.tv_sec - req.tv_sec) * NANOSEC_IN_SEC; - if (rem.tv_nsec >= req.tv_nsec) { - tmp += rem.tv_nsec - req.tv_nsec; - } else { - tmp -= req.tv_nsec - rem.tv_nsec; - } - if (tmp >= clk) { - break; - } - clk -= tmp; - req = rem; - } - } else { - req.tv_sec = 0; - req.tv_nsec = clk; - while ((rc = nanosleep(&req, &rem)) == -1 && errno == EINTR) { - req = rem; - } - } - if (rc == -1) { - rc = errno; - LOG_ERR(rc, "Failed to sleep %u nanoseconds", clk); - } - return rc; -} - -int bitbang_io(const bitbang_handle_st *hdl, bitbang_io_st *io) -{ - int rc = 0; - uint32_t clk = hdl->bbh_half_clk; - const struct { - bitbang_pin_value_en value; - bitbang_clk_edge_en edge; - } clks[] = { - {BITBANG_PIN_HIGH, BITBANG_CLK_EDGE_FALLING}, - {BITBANG_PIN_LOW, BITBANG_CLK_EDGE_RISING}, - }; - int clk_idx; - int n_clk = 0; - int n_bits = 0; - const uint8_t *dout = io->bbio_dout; - uint8_t *din = io->bbio_din; - int bit_pos = 7; - bitbang_pin_func pin_f = hdl->bbh_init.bbi_pin_f; - void *context = hdl->bbh_init.bbi_context; - - if ((io->bbio_in_bits == 0 && io->bbio_din) - || (io->bbio_in_bits > 0 && !io->bbio_din)) { - rc = EINVAL; - LOG_ERR(rc, "Incorrect in bits and in buffer"); - goto out; - } - - if ((io->bbio_out_bits == 0 && io->bbio_dout) - || (io->bbio_out_bits > 0 && !io->bbio_dout)) { - rc = EINVAL; - LOG_ERR(rc, "Incorrect out bits and out buffer"); - goto out; - } - - if (io->bbio_in_bits == 0 && io->bbio_out_bits == 0) { - rc = EINVAL; - LOG_ERR(rc, "Both in and out bits are 0"); - goto out; - } - - if (hdl->bbh_init.bbi_clk_start == BITBANG_PIN_HIGH) { - clk_idx = 0; - } else { - clk_idx = 1; - } - - /* set the CLK pin start position */ - pin_f(BITBANG_CLK_PIN, clks[clk_idx].value, context); - - /* clear the first byte of din */ - if (din && io->bbio_in_bits) { - memset(din, 0, (io->bbio_in_bits + 7) / 8); - } - - do { - if ((rc = sleep_ns(clk))) { - goto out; - } - - /* output first */ - if (hdl->bbh_init.bbi_data_out == clks[clk_idx].edge) { - if (dout && n_bits < io->bbio_out_bits) { - pin_f(BITBANG_DATA_OUT, (*dout >> bit_pos) & 0x1, context); - } - } - - /* then, input */ - if (hdl->bbh_init.bbi_data_in == clks[clk_idx].edge) { - if (din && n_bits < io->bbio_in_bits) { - *din |= (pin_f(BITBANG_DATA_IN, 0, context) & 0x1) << bit_pos; - } - } - - if (++n_clk % 2 == 0) { - /* one bit for every 2 half clks */ - n_bits ++; - if (bit_pos == 0) { - if (dout) { - dout++; - } - if (din) { - din++; - } - bit_pos = 7; - } else { - bit_pos --; - } - } - clk_idx = 1 - clk_idx; - pin_f(BITBANG_CLK_PIN, clks[clk_idx].value, context); - } while (n_bits < MAX(io->bbio_in_bits, io->bbio_out_bits)); - - out: - - return -rc; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.h b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.h deleted file mode 100644 index 0f21a49..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/bitbang.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef BITBANG_H -#define BITBANG_H - -#include <stdint.h> - -typedef enum { - BITBANG_CLK_PIN, - BITBANG_DATA_IN, - BITBANG_DATA_OUT, -} bitbang_pin_type_en; - -typedef enum { - BITBANG_PIN_LOW = 0, - BITBANG_PIN_HIGH = 1, -} bitbang_pin_value_en; - -typedef enum { - BITBANG_CLK_EDGE_RISING, - BITBANG_CLK_EDGE_FALLING, -} bitbang_clk_edge_en; - -typedef bitbang_pin_value_en (* bitbang_pin_func)( - bitbang_pin_type_en pin, bitbang_pin_value_en value, void *context); - -typedef struct { - bitbang_pin_value_en bbi_clk_start; - bitbang_clk_edge_en bbi_data_out; - bitbang_clk_edge_en bbi_data_in; - uint32_t bbi_freq; - bitbang_pin_func bbi_pin_f; - void *bbi_context; -} bitbang_init_st; - -typedef struct bitbang_handle bitbang_handle_st; - -void bitbang_init_default(bitbang_init_st *init); -bitbang_handle_st* bitbang_open(const bitbang_init_st *init); -void bitbang_close(bitbang_handle_st *hdl); - -typedef struct { - uint32_t bbio_in_bits; - uint32_t bbio_out_bits; - uint8_t *bbio_dout; - uint8_t *bbio_din; -} bitbang_io_st; - -int bitbang_io(const bitbang_handle_st *hdl, bitbang_io_st *io); - -#endif diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.c deleted file mode 100644 index 026aebc..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "gpio.h" - -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <sys/errno.h> - -#include "facebook/log.h" - -void gpio_init_default(gpio_st *g) { - g->gs_gpio = -1; - g->gs_fd = -1; -} - -int gpio_open(gpio_st *g, int gpio) -{ - char buf[128]; - int rc; - - snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/value", gpio); - rc = open(buf, O_RDWR); - if (rc == -1) { - rc = errno; - LOG_ERR(rc, "Failed to open %s", buf); - return -rc; - } - g->gs_fd = rc; - g->gs_gpio = gpio; - return 0; -} - -void gpio_close(gpio_st *g) -{ - if (g && g->gs_fd != -1) { - close(g->gs_fd); - } - gpio_init_default(g); -} - -gpio_value_en gpio_read(gpio_st *g) -{ - char buf[32] = {0}; - gpio_value_en v; - lseek(g->gs_fd, 0, SEEK_SET); - read(g->gs_fd, buf, sizeof(buf)); - v = atoi(buf) ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW; - LOG_VER("read gpio=%d value=%d %d", g->gs_gpio, atoi(buf), v); - return v; -} - -void gpio_write(gpio_st *g, gpio_value_en v) -{ - lseek(g->gs_fd, 0, SEEK_SET); - write(g->gs_fd, (v == GPIO_VALUE_HIGH) ? "1" : "0", 1); - LOG_VER("write gpio=%d value=%d", g->gs_gpio, v); -} - -int gpio_change_direction(gpio_st *g, gpio_direction_en dir) -{ - char buf[128]; - char *val; - int fd = -1; - int rc = 0; - - snprintf(buf, sizeof(buf), "/sys/class/gpio/gpio%u/direction", g->gs_gpio); - fd = open(buf, O_WRONLY); - if (fd == -1) { - rc = errno; - LOG_ERR(rc, "Failed to open %s", buf); - return -rc; - } - - val = (dir == GPIO_DIRECTION_IN) ? "in" : "out"; - write(fd, val, strlen(val)); - - LOG_VER("change gpio=%d direction=%s", g->gs_gpio, val); - - out: - if (fd != -1) { - close(fd); - } - return -rc; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.h b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.h deleted file mode 100644 index 3303986..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/gpio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef GPIO_H -#define GPIO_H - -typedef struct { - int gs_gpio; - int gs_fd; -} gpio_st; - -typedef enum { - GPIO_DIRECTION_IN, - GPIO_DIRECTION_OUT, -} gpio_direction_en; - -typedef enum { - GPIO_VALUE_LOW = 0, - GPIO_VALUE_HIGH = 1, -} gpio_value_en; - -int gpio_open(gpio_st* g, int gpio); -void gpio_close(gpio_st *g); -gpio_value_en gpio_read(gpio_st *g); -void gpio_write(gpio_st *g, gpio_value_en v); -int gpio_change_direction(gpio_st *g, gpio_direction_en dir); - -#endif diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/mdio_bb.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/mdio_bb.c deleted file mode 100644 index ef0c567..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/mdio_bb.c +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "bitbang.h" -#include "gpio.h" - -#include <stdlib.h> -#include <unistd.h> - -#include "facebook/log.h" - - -typedef struct { - gpio_st m_mdc; - gpio_st m_mdio; -} mdio_context_st; - -/* - * 32b preamble, 2b start of frame, 2b operation code, - * 5b phy addr, 5b register addr, 2b turnaround, 16b data - */ -#define N_BITS (32 + 2 + 2 + 5 + 5 + 2 + 16) -#define N_BYTES (N_BITS + 7 / 8) - -#define START_OF_FRAME 0x1 -#define OP_READ 0x2 -#define OP_WRITE 0x1 -#define TURNAROUND 0x2 /* TA for write, for read, phy sends out TA */ - -void usage() -{ - fprintf(stderr, - "Usage:\n" - "mdio-bb: -c <GPIO for MDC> [-C <HIGH|low>]\n" - " -d <GPIO for MDIO> [-O <rising|FALLING>]\n" - " [-I <RISING|falling>] [-p] [-b]\n" - " <read|write> <phy address> <register address>\n" - " [value to write]\n"); -} - -bitbang_pin_value_en mdio_pin_f( - bitbang_pin_type_en pin, bitbang_pin_value_en value, void *context) -{ - mdio_context_st *ctx = (mdio_context_st *)context; - gpio_st *gpio; - bitbang_pin_value_en res; - - switch (pin) { - case BITBANG_CLK_PIN: - gpio = &ctx->m_mdc; - break; - case BITBANG_DATA_IN: - case BITBANG_DATA_OUT: - gpio = &ctx->m_mdio; - break; - } - if (pin == BITBANG_DATA_IN) { - res = gpio_read(gpio) ? BITBANG_PIN_HIGH : BITBANG_PIN_LOW; - } else { - res = value; - gpio_write(gpio, ((res == BITBANG_PIN_HIGH) - ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW)); - } - return res; -} - -int main(int argc, char* const argv[]) -{ - int opt; - int mdc = -1, mdio = -1; - bitbang_pin_value_en mdc_start = BITBANG_PIN_HIGH; - bitbang_clk_edge_en out_edge = BITBANG_CLK_EDGE_FALLING; - bitbang_clk_edge_en in_edge = BITBANG_CLK_EDGE_RISING; - int is_write; - uint32_t phy_addr; - uint32_t reg_addr; - uint32_t data; /* data to write/read*/ - uint8_t buf[N_BYTES]; - uint8_t *buf_p; - mdio_context_st ctx; - bitbang_init_st init; - bitbang_handle_st *hdl = NULL; - bitbang_io_st io; - int n_bits; - int i; - int rc = 0; - int preamble = 0; - int binary = 0; - - while ((opt = getopt(argc, argv, "bc:C:d:D:p")) != -1) { - switch (opt) { - case 'b': - binary = 1; - break; - case 'c': - mdc = atoi(optarg); - break; - case 'C': - if (!strcasecmp(optarg, "high")) { - mdc_start = BITBANG_PIN_HIGH; - } else if (!strcasecmp(optarg, "low")) { - mdc_start = BITBANG_PIN_LOW; - } else { - usage(); - exit(-1); - } - break; - case 'd': - mdio = atoi(optarg); - break; - case 'I': - if (!strcasecmp(optarg, "rising")) { - in_edge = BITBANG_CLK_EDGE_RISING; - } if (!strcasecmp(optarg, "falling")) { - in_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'O': - if (!strcasecmp(optarg, "rising")) { - out_edge = BITBANG_CLK_EDGE_RISING; - } if (!strcasecmp(optarg, "falling")) { - out_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'p': - preamble = 1; - break; - default: - usage(); - exit(-1); - } - } - - if (mdc < 0 || mdio < 0) { - usage(); - exit(-1); - } - - if (optind + 2 >= argc) { - usage(); - exit(-1); - } - - /* read or write */ - if (!strcasecmp(argv[optind], "read")) { - is_write = 0; - } else if (!strcasecmp(argv[optind], "write")) { - is_write = 1; - } else { - usage(); - exit(-1); - } - - /* phy address, 5 bits only, so must be <= 0x1f */ - phy_addr = strtoul(argv[optind + 1], NULL, 0); - if (phy_addr > 0x1f) { - usage(); - exit(-1); - } - - /* register address, 5 bits only, so must be <= 0x1f */ - reg_addr = strtoul(argv[optind + 2], NULL, 0); - if (reg_addr > 0x1f) { - usage(); - exit(-1); - } - - /* data */ - if (is_write) { - if ((!binary && (optind + 4 != argc)) || - (binary && (optind + 3 != argc))) { - usage(); - exit(-1); - } - if (binary) { - uint16_t temp = 0; - if (fread(&temp, sizeof(temp), 1, stdin) != 1) { - usage(); - exit(-1); - } - data = htons(temp); - } else { - data = strtoul(argv[optind + 3], NULL, 0); - } - if (data > 0xFFFF) { - usage(); - exit(-1); - } - } else { - if ((!binary && (optind + 3 != argc)) || - (binary && (optind + 2 != argc))) { - usage(); - exit(-1); - } - } - - /* open all gpio */ - memset(&ctx, sizeof(ctx), 0); - gpio_init_default(&ctx.m_mdc); - gpio_init_default(&ctx.m_mdio); - if (gpio_open(&ctx.m_mdc, mdc) || gpio_open(&ctx.m_mdio, mdio)) { - goto out; - } - - if (gpio_change_direction(&ctx.m_mdc, GPIO_DIRECTION_OUT) - || gpio_change_direction(&ctx.m_mdio, GPIO_DIRECTION_OUT)) { - goto out; - } - - bitbang_init_default(&init); - init.bbi_clk_start = mdc_start; - init.bbi_data_out = out_edge; - init.bbi_data_in = in_edge; - init.bbi_freq = 1000 * 1000; /* 1M Hz */ - init.bbi_pin_f = mdio_pin_f; - init.bbi_context = &ctx; - hdl = bitbang_open(&init); - if (!hdl) { - goto out; - } - - if (is_write) { - buf[0] = (data >> 8) & 0xFF; - buf[1] = data & 0xFF; - io.bbio_out_bits = 16; - io.bbio_dout = buf; - io.bbio_in_bits = 0; - io.bbio_din = NULL; - } else { - io.bbio_in_bits = 16; - io.bbio_din = buf; - io.bbio_out_bits = 0; - io.bbio_dout = NULL; - } - - /* preamble, 32b */ - buf_p = buf; - n_bits = 0; - if (preamble) { - /* 32 bit of 1 for preamble */ - for (i = 0; i < 4; i++) { - *buf_p++ = 0xFF; - } - n_bits += 32; - } - - /* - * MDIO transaction header is: - * 2b START, 2b OPER CODE, 5b PHY ADDR, 5b register addr, 2b TURNROUND - */ - *buf_p++ = (START_OF_FRAME << 6) | (((is_write) ? OP_WRITE : OP_READ) << 4) - | ((phy_addr >> 1) & 0xF); - *buf_p++ = ((phy_addr & 0x1) << 7) | ((reg_addr & 0x1F) << 2) | TURNAROUND; - if (is_write) { - *buf_p++ = (data >> 8) & 0xFF; - *buf_p++ = data & 0xFF; - /* total # of bits is transaction header + 2 bytes to write */ - n_bits += 2 + 2 + 5 + 5 + 2 + 16; - } else { - /* for read, master does not send TR, so, n_bits should not include TR */ - n_bits += 2 + 2 + 5 + 5; - } - - memset(&io, sizeof(io), 0); - io.bbio_out_bits = n_bits; - io.bbio_dout = buf; - io.bbio_in_bits = 0; - io.bbio_din = NULL; - - rc = bitbang_io(hdl, &io); - if (rc != 0) { - goto out; - } - - /* for read, need to do another io for (2b TR + 16b data) reading */ - if (!is_write) { - /* first, change the MDIO to input */ - gpio_change_direction(&ctx.m_mdio, GPIO_DIRECTION_IN); - /* then, run the clock for read */ - memset(&io, sizeof(io), 0); - io.bbio_out_bits = 0; - io.bbio_dout = NULL;; - io.bbio_in_bits = 18; - io.bbio_din = buf; - - rc = bitbang_io(hdl, &io); - if (rc != 0) { - goto out; - } - - data = ((buf[0] << 2) | (buf[1] >> 6)) & 0xFF; - data <<= 8; - data |= ((buf[1] << 2) | (buf[2] >> 6)) & 0xFF; - } - - if (binary) { - if (!is_write) { - uint16_t temp = ntohs(data); - fwrite(&temp, sizeof(temp), 1, stdout); - } - } else { - printf("%s: 0x%02x\n", (is_write) ? "Wrote" : "Read", data); - } - - out: - if (hdl) { - bitbang_close(hdl); - } - gpio_close(&ctx.m_mdc); - gpio_close(&ctx.m_mdio); - - return 0; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/spi_bb.c b/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/spi_bb.c deleted file mode 100644 index ce366a5..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/bitbang/files/src/spi_bb.c +++ /dev/null @@ -1,317 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -//#define DEBUG -//#define VERBOSE - -#include "bitbang.h" -#include "gpio.h" - -#include <stdlib.h> -#include <unistd.h> - -#include "facebook/log.h" - -void usage() -{ - fprintf(stderr, - "Usage:\n" - "spi-bb: -s <GPIO for CS> [-S <HIGH|low>]\n" - " -c <GPIO for CLK> [-C <HIGH|low>]\n" - " -o <GPIO for MOSI> [-O <rising|FALLING>]\n" - " -i <GPIO for MISO> [-I <RISING|falling>]\n" - " [-b]\n" - " < [-r <number of bits to read>]\n" - " [-w <number of bits to write> <byte 1> [... byte N]>\n\n" - "Note: If both '-r' and '-w' are provided, 'write' will be performed\n" - " before 'read'.\n"); -} - -typedef struct { - gpio_st sc_clk; - gpio_st sc_mosi; - gpio_st sc_miso; -} spi_context_st; - -bitbang_pin_value_en spi_pin_f( - bitbang_pin_type_en pin, bitbang_pin_value_en value, void *context) -{ - spi_context_st *ctx = (spi_context_st *)context; - gpio_st *gpio; - bitbang_pin_value_en res; - - switch (pin) { - case BITBANG_CLK_PIN: - gpio = &ctx->sc_clk; - break; - case BITBANG_DATA_IN: - gpio = &ctx->sc_miso; - break; - case BITBANG_DATA_OUT: - gpio = &ctx->sc_mosi; - break; - } - if (pin == BITBANG_DATA_IN) { - res = gpio_read(gpio) ? BITBANG_PIN_HIGH : BITBANG_PIN_LOW; - } else { - res = value; - gpio_write(gpio, ((res == BITBANG_PIN_HIGH) - ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW)); - } - return res; -} - -int main(int argc, char * const argv[]) -{ - bitbang_init_st init; - bitbang_handle_st *hdl = NULL; - int cs = -1, clk = -1, in = -1, out = -1; - gpio_st cs_gpio; - int opt; - int is_write = 0; - int is_read = 0; - int read_bits = 0; - int write_bits = 0; - int read_bytes = 0; - int write_bytes = 0; - int i; - uint8_t *read_buf = NULL;; - uint8_t *write_buf = NULL;; - bitbang_clk_edge_en dout_edge = BITBANG_CLK_EDGE_FALLING; - bitbang_clk_edge_en din_edge = BITBANG_CLK_EDGE_RISING; - bitbang_pin_value_en clk_start = BITBANG_PIN_HIGH; - bitbang_pin_value_en cs_value = BITBANG_PIN_HIGH; - spi_context_st ctx; - bitbang_io_st io; - int rc = 0; - int binary = 0; - - memset(&ctx, sizeof(ctx), 0); - gpio_init_default(&ctx.sc_clk); - gpio_init_default(&ctx.sc_mosi); - gpio_init_default(&ctx.sc_miso); - gpio_init_default(&cs_gpio); - - while ((opt = getopt(argc, argv, "bs:S:c:C:o:O:i:I:w:r:")) != -1) { - switch (opt) { - case 'b': - binary = 1; - break; - case 's': - cs = atoi(optarg); - break; - case 'S': - if (!strcmp(optarg, "high")) { - cs_value = BITBANG_PIN_HIGH; - } else if (!strcmp(optarg, "low")) { - cs_value = BITBANG_PIN_LOW; - } else { - usage(); - exit(-1); - } - break; - case 'c': - clk = atoi(optarg); - break; - case 'C': - if (!strcasecmp(optarg, "high")) { - clk_start = BITBANG_PIN_HIGH; - } else if (!strcasecmp(optarg, "low")) { - clk_start = BITBANG_PIN_LOW; - } else { - usage(); - exit(-1); - } - break; - case 'o': - out = atoi(optarg); - break; - case 'O': - if (!strcasecmp(optarg, "rising")) { - dout_edge = BITBANG_CLK_EDGE_RISING; - } else if (!strcasecmp(optarg, "falling")) { - dout_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'i': - in = atoi(optarg); - break; - case 'I': - if (!strcasecmp(optarg, "rising")) { - din_edge = BITBANG_CLK_EDGE_RISING; - } else if (!strcasecmp(optarg, "falling")) { - din_edge = BITBANG_CLK_EDGE_FALLING; - } else { - usage(); - exit(-1); - } - break; - case 'w': - is_write = 1; - write_bits = atoi(optarg); - if (write_bits <= 0) { - usage(); - exit(-1); - } - break; - case 'r': - is_read = 1; - read_bits = atoi(optarg); - if (read_bits <= 0) { - usage(); - exit(-1); - } - break; - default: - usage(); - exit(-1); - } - } - - if (clk < 0 || in < 0 || out < 0) { - usage(); - exit(-1); - } - - if ((!is_read && !is_write)) { - usage(); - exit(-1); - } - - write_bytes = ((write_bits + 7) / 8); - if (write_bytes) { - write_buf = calloc(write_bytes, sizeof(uint8_t)); - if (!write_buf) { - goto out; - } - if (binary) { - size_t written_bytes; - written_bytes = fread(write_buf, sizeof(*write_buf), write_bytes, stdin); - if( written_bytes != write_bytes ) { - goto out; - } - } else { - for (i = 0; i < write_bytes && i + optind < argc; i++) { - write_buf[i] = strtoul(argv[i + optind], NULL, 0); - } - } - } - - read_bytes = ((read_bits + 7) / 8); - if (read_bytes) { - read_buf = calloc(read_bytes, sizeof(uint8_t)); - if (!read_buf) { - goto out; - } - } - - if (gpio_open(&ctx.sc_clk, clk) || gpio_open(&ctx.sc_miso, in) - || gpio_open(&ctx.sc_mosi, out)) { - goto out; - } - - /* change GPIO directions, only MISO is input, all others are output */ - if (gpio_change_direction(&ctx.sc_clk, GPIO_DIRECTION_OUT) - || gpio_change_direction(&ctx.sc_miso, GPIO_DIRECTION_IN) - || gpio_change_direction(&ctx.sc_mosi, GPIO_DIRECTION_OUT)) { - goto out; - } - - if (cs != -1) { - if (gpio_open(&cs_gpio, cs)) { - goto out; - } - if (gpio_change_direction(&cs_gpio, GPIO_DIRECTION_OUT)) { - goto out; - } - } - - bitbang_init_default(&init); - init.bbi_clk_start = clk_start; - init.bbi_data_out = dout_edge; - init.bbi_data_in = din_edge; - init.bbi_freq = 1000 * 1000; /* 1M Hz */ - init.bbi_pin_f = spi_pin_f; - init.bbi_context = &ctx; - - hdl = bitbang_open(&init); - if (!hdl) { - goto out; - } - - if (cs != -1) { - /* have chip select */ - gpio_write(&cs_gpio, ((cs_value == BITBANG_PIN_HIGH) - ? GPIO_VALUE_HIGH : GPIO_VALUE_LOW)); - } - - memset(&io, sizeof(io), 0); - io.bbio_in_bits = read_bits; - io.bbio_din = read_buf; - io.bbio_out_bits = write_bits; - io.bbio_dout = write_buf; - - rc = bitbang_io(hdl, &io); - if (rc != 0) { - goto out; - } - - if (binary) { - fwrite(read_buf, sizeof(*read_buf), read_bytes, stdout); - } else { - if (write_bits) { - printf("Wrote %u bits:", write_bits); - for (i = 0; i < write_bytes; i++) { - printf(" %02x", write_buf[i]); - } - printf("\n"); - } - - if (read_bits) { - printf("Read %u bits:", read_bits); - for (i = 0; i < read_bytes; i++) { - printf(" %02x", read_buf[i]); - } - printf("\n"); - } - } - - out: - if (hdl) { - bitbang_close(hdl); - } - gpio_close(&ctx.sc_clk); - gpio_close(&ctx.sc_miso); - gpio_close(&ctx.sc_mosi); - if (cs != -1) { - /* reset have chip select */ - gpio_write(&cs_gpio, ((cs_value == BITBANG_PIN_HIGH) - ? GPIO_VALUE_LOW : GPIO_VALUE_HIGH)); - gpio_close(&cs_gpio); - } - - if (read_buf) { - free(read_buf); - } - if (write_buf) { - free(write_buf); - } - return rc; -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/Makefile b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/Makefile deleted file mode 100644 index fa9a8f4..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -all: fand - -fand: fand.cpp watchdog.cpp - $(CXX) -pthread -o $@ $^ $(LDFLAGS) -lwedge_eeprom - -.PHONY: clean - -clean: - rm -rf *.o fand diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/README b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/README deleted file mode 100644 index 2a92b9d..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/README +++ /dev/null @@ -1,5 +0,0 @@ -The AST PWM/Tach driver is in the kernel sources at drivers/hwmon/ast_pwm_fan.c - -There are 7 PWM output pins. Each PWM can be configured in one of 3 types (M, -N, or O). The clock settings for each type are configurable. See init_pwm.sh -for more comments about how we configure the settings. diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/fand.cpp b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/fand.cpp deleted file mode 100644 index 24e107c..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/fand.cpp +++ /dev/null @@ -1,851 +0,0 @@ -/* - * fand - * - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Daemon to manage the fan speed to ensure that we stay within a reasonable - * temperature range. We're using a simplistic algorithm to get started: - * - * If the fan is already on high, we'll move it to medium if we fall below - * a top temperature. If we're on medium, we'll move it to high - * if the temperature goes over the top value, and to low if the - * temperature falls to a bottom level. If the fan is on low, - * we'll increase the speed if the temperature rises to the top level. - * - * To ensure that we're not just turning the fans up, then back down again, - * we'll require an extra few degrees of temperature drop before we lower - * the fan speed. - * - * We check the RPM of the fans against the requested RPMs to determine - * whether the fans are failing, in which case we'll turn up all of - * the other fans and report the problem.. - * - * TODO: Implement a PID algorithm to closely track the ideal temperature. - * TODO: Determine if the daemon is already started. - */ - -/* Yeah, the file ends in .cpp, but it's a C program. Deal. */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <errno.h> -#include <signal.h> -#include <syslog.h> -#include "watchdog.h" - -#include "facebook/wedge_eeprom.h" - -/* Sensor definitions */ - -#define INTERNAL_TEMPS(x) ((x) * 1000) // stored a C * 1000 -#define EXTERNAL_TEMPS(x) ((x) / 1000) - -#define I2C_BUS_3_DIR "/sys/class/i2c-adapter/i2c-3/" -#define I2C_BUS_4_DIR "/sys/class/i2c-adapter/i2c-4/" - -#define INTAKE_TEMP_DEVICE I2C_BUS_3_DIR "3-0048" -#define T2_TEMP_DEVICE I2C_BUS_3_DIR "3-0049" -#define EXHAUST_TEMP_DEVICE I2C_BUS_3_DIR "3-004a" -#define USERVER_TEMP_DEVICE I2C_BUS_4_DIR "4-0040" - -/* - * The sensor for the uServer CPU is not on the CPU itself, so it reads - * a little low. We are special casing this, but we should obviously - * be thinking about a way to generalize these tweaks, and perhaps - * the entire configuration. JSON file? - */ - -#define USERVER_TEMP_FUDGE INTERNAL_TEMPS(10) - -#define BAD_TEMP INTERNAL_TEMPS(-60) - -#define BAD_READ_THRESHOLD 4 /* How many times can reads fail */ -#define FAN_FAILURE_THRESHOLD 4 /* How many times can a fan fail */ - -#define PWM_DIR "/sys/devices/platform/ast_pwm_tacho.0" - -#define PWM_UNIT_MAX 96 - -#define LARGEST_DEVICE_NAME 120 - -#define GPIO_USERVER_POWER_DIRECTION "/sys/class/gpio/gpio25/direction" -#define GPIO_USERVER_POWER "/sys/class/gpio/gpio25/value" -#define GPIO_T2_POWER_DIRECTION "/sys/class/gpio/gpio41/direction" -#define GPIO_T2_POWER "/sys/class/gpio/gpio41/value" - -#define GPIO_FAN0_LED "/sys/class/gpio/gpio53/value" -#define GPIO_FAN1_LED "/sys/class/gpio/gpio54/value" -#define GPIO_FAN2_LED "/sys/class/gpio/gpio55/value" -#define GPIO_FAN3_LED "/sys/class/gpio/gpio72/value" - -const char *fan_led[] = {GPIO_FAN0_LED, GPIO_FAN1_LED, - GPIO_FAN2_LED, GPIO_FAN3_LED}; - -#define FAN_LED_RED "0" -#define FAN_LED_BLUE "1" - -#define GPIO_PIN_ID "/sys/class/gpio/gpio%d/value" -#define REV_IDS 3 -#define GPIO_REV_ID_START 192 - -#define BOARD_IDS 4 -#define GPIO_BOARD_ID_START 160 - -/* - * With hardware revisions after 3, we use a different set of pins for - * the BOARD_ID. - */ - -#define REV_ID_NEW_BOARD_ID 3 -#define GPIO_BOARD_ID_START_NEW 166 - -#define REPORT_TEMP 720 /* Report temp every so many cycles */ - -/* Sensor limits and tuning parameters */ - -#define INTAKE_LIMIT INTERNAL_TEMPS(60) -#define T2_LIMIT INTERNAL_TEMPS(95) -#define USERVER_LIMIT INTERNAL_TEMPS(75) - -#define TEMP_TOP INTERNAL_TEMPS(70) -#define TEMP_BOTTOM INTERNAL_TEMPS(40) - -/* - * Toggling the fan constantly will wear it out (and annoy anyone who - * can hear it), so we'll only turn down the fan after the temperature - * has dipped a bit below the point at which we'd otherwise switch - * things up. - */ - -#define COOLDOWN_SLOP INTERNAL_TEMPS(6) - -#define FAN_LOW 35 -#define FAN_MEDIUM 50 -#define FAN_HIGH 70 -#define FAN_MAX 99 - -/* - * Mapping physical to hardware addresses for fans; it's different for - * RPM measuring and PWM setting, naturally. Doh. - */ - -int fan_to_rpm_map[] = {3, 2, 0, 1}; -int fan_to_pwm_map[] = {7, 6, 0, 1}; - -#define FANS 4 - -/* - * The measured RPM of the fans doesn't match linearly to the requested - * rate. In addition, there are coaxially mounted fans, so the rear fans - * feed into the front fans. The rear fans will run slower since they're - * grabbing still air, and the front fants are getting an extra boost. - * - * We'd like to measure the fan RPM and compare it to the expected RPM - * so that we can detect failed fans, so we have a table (derived from - * hardware testing): - */ - -struct rpm_to_pct_map { - ushort pct; - ushort rpm; -}; - -struct rpm_to_pct_map rpm_front_map[] = {{30, 6150}, - {35, 7208}, - {40, 8195}, - {45, 9133}, - {50, 10017}, - {55, 10847}, - {60, 11612}, - {65, 12342}, - {70, 13057}, - {75, 13717}, - {80, 14305}, - {85, 14869}, - {90, 15384}, - {95, 15871}, - {100, 16095}}; - -struct rpm_to_pct_map rpm_rear_map[] = {{30, 3911}, - {35, 4760}, - {40, 5587}, - {45, 6434}, - {50, 7295}, - {55, 8187}, - {60, 9093}, - {65, 10008}, - {70, 10949}, - {75, 11883}, - {80, 12822}, - {85, 13726}, - {90, 14690}, - {95, 15516}, - {100, 15897}}; - -#define FAN_FAILURE_OFFSET 30 - -int fan_low = FAN_LOW; -int fan_medium = FAN_MEDIUM; -int fan_high = FAN_HIGH; -int fan_max = FAN_MAX; -int total_fans = FANS; -int fan_offset = 0; - -int temp_bottom = TEMP_BOTTOM; -int temp_top = TEMP_TOP; - -int report_temp = REPORT_TEMP; -bool verbose = false; - -void usage() { - fprintf(stderr, - "fand [-v] [-l <low-pct>] [-m <medium-pct>] " - "[-h <high-pct>]\n" - "\t[-b <temp-bottom>] [-t <temp-top>] [-r <report-temp>]\n\n" - "\tlow-pct defaults to %d%% fan\n" - "\tmedium-pct defaults to %d%% fan\n" - "\thigh-pct defaults to %d%% fan\n" - "\ttemp-bottom defaults to %dC\n" - "\ttemp-top defaults to %dC\n" - "\treport-temp defaults to every %d measurements\n\n" - "fand compensates for uServer temperature reading %d degrees low\n" - "kill with SIGUSR1 to stop watchdog\n", - fan_low, - fan_medium, - fan_high, - EXTERNAL_TEMPS(temp_bottom), - EXTERNAL_TEMPS(temp_top), - report_temp, - EXTERNAL_TEMPS(USERVER_TEMP_FUDGE)); - exit(1); -} - -/* We need to open the device each time to read a value */ - -int read_device(const char *device, int *value) { - FILE *fp; - int rc; - - fp = fopen(device, "r"); - if (!fp) { - int err = errno; - - syslog(LOG_INFO, "failed to open device %s", device); - return err; - } - - rc = fscanf(fp, "%d", value); - fclose(fp); - - if (rc != 1) { - syslog(LOG_INFO, "failed to read device %s", device); - return ENOENT; - } else { - return 0; - } -} - -/* We need to open the device again each time to write a value */ - -int write_device(const char *device, const char *value) { - FILE *fp; - int rc; - - fp = fopen(device, "w"); - if (!fp) { - int err = errno; - - syslog(LOG_INFO, "failed to open device for write %s", device); - return err; - } - - rc = fputs(value, fp); - fclose(fp); - - if (rc < 0) { - syslog(LOG_INFO, "failed to write device %s", device); - return ENOENT; - } else { - return 0; - } -} - -int read_temp(const char *device, int *value) { - char full_name[LARGEST_DEVICE_NAME + 1]; - - /* We set an impossible value to check for errors */ - *value = BAD_TEMP; - snprintf( - full_name, LARGEST_DEVICE_NAME, "%s/temp1_input", device); - return read_device(full_name, value); -} - -int read_gpio_value(const int id, const char *device, int *value) { - char full_name[LARGEST_DEVICE_NAME]; - - snprintf(full_name, LARGEST_DEVICE_NAME, device, id); - return read_device(full_name, value); -} - -int read_gpio_values(const int start, const int count, - const char *device, int *result) { - int status = 0; - int value; - - *result = 0; - for (int i = 0; i < count; i++) { - status |= read_gpio_value(start + i, GPIO_PIN_ID, &value); - *result |= value << i; - } - return status; -} - -int read_ids(int *rev_id, int *board_id) { - int status = 0; - int value; - - status = read_gpio_values(GPIO_REV_ID_START, REV_IDS, GPIO_PIN_ID, rev_id); - if (status != 0) { - syslog(LOG_INFO, "failed to read rev_id"); - return status; - } - - int board_id_start; - if (*rev_id >= REV_ID_NEW_BOARD_ID) { - board_id_start = GPIO_BOARD_ID_START_NEW; - } else { - board_id_start = GPIO_BOARD_ID_START; - } - - status = read_gpio_values(board_id_start, BOARD_IDS, GPIO_PIN_ID, board_id); - if (status != 0) { - syslog(LOG_INFO, "failed to read board_id"); - } - return status; -} - -bool is_two_fan_board(bool verbose) { - struct wedge_eeprom_st eeprom; - /* Retrieve the board type from EEPROM */ - if (wedge_eeprom_parse(NULL, &eeprom) == 0) { - /* able to parse EEPROM */ - if (verbose) { - syslog(LOG_INFO, "board type is %s", eeprom.fbw_location); - } - /* only WEDGE is NOT two-fan board */ - return strncasecmp(eeprom.fbw_location, "wedge", - sizeof(eeprom.fbw_location)); - } else { - int status; - int board_id = 0; - int rev_id = 0; - /* - * Could not parse EEPROM. Most likely, it is an old HW without EEPROM. - * In this case, use board ID to distinguish if it is wedge or 6-pack. - */ - status = read_ids(&rev_id, &board_id); - if (verbose) { - syslog(LOG_INFO, "rev ID %d, board id %d", rev_id, board_id); - } - if (status == 0 && board_id != 0xf) { - return true; - } else { - return false; - } - } -} - -int read_fan_value(const int fan, const char *device, int *value) { - char device_name[LARGEST_DEVICE_NAME]; - char output_value[LARGEST_DEVICE_NAME]; - char full_name[LARGEST_DEVICE_NAME]; - - snprintf(device_name, LARGEST_DEVICE_NAME, device, fan); - snprintf(full_name, LARGEST_DEVICE_NAME, "%s/%s", PWM_DIR, device_name); - return read_device(full_name, value); -} - -int write_fan_value(const int fan, const char *device, const int value) { - char full_name[LARGEST_DEVICE_NAME]; - char device_name[LARGEST_DEVICE_NAME]; - char output_value[LARGEST_DEVICE_NAME]; - - snprintf(device_name, LARGEST_DEVICE_NAME, device, fan); - snprintf(full_name, LARGEST_DEVICE_NAME, "%s/%s", PWM_DIR, device_name); - snprintf(output_value, LARGEST_DEVICE_NAME, "%d", value); - return write_device(full_name, output_value); -} - -/* Return fan speed as a percentage of maximum -- not necessarily linear. */ - -int fan_rpm_to_pct(const struct rpm_to_pct_map *table, - const int table_len, - int rpm) { - int i; - - for (i = 0; i < table_len; i++) { - if (table[i].rpm > rpm) { - break; - } - } - - /* - * If the fan RPM is lower than the lowest value in the table, - * we may have a problem -- fans can only go so slow, and it might - * have stopped. In this case, we'll return an interpolated - * percentage, as just returning zero is even more problematic. - */ - - if (i == 0) { - return (rpm * table[i].pct) / table[i].rpm; - } else if (i == table_len) { // Fell off the top? - return table[i - 1].pct; - } - - // Interpolate the right percentage value: - - int percent_diff = table[i].pct - table[i - 1].pct; - int rpm_diff = table[i].rpm - table[i - 1].rpm; - int fan_diff = table[i].rpm - rpm; - - return table[i].pct - (fan_diff * percent_diff / rpm_diff); -} - -int fan_speed_okay(const int fan, const int speed, const int slop) { - int front_fan, rear_fan; - int front_pct, rear_pct; - int real_fan; - int okay; - - /* - * The hardware fan numbers are different from the physical order - * in the box, so we have to map them: - */ - - real_fan = fan_to_rpm_map[fan]; - - front_fan = 0; - rear_fan = 0; - read_fan_value(real_fan, "tacho%d_rpm", &front_fan); - read_fan_value(real_fan + 4, "tacho%d_rpm", &rear_fan); - - front_pct = - fan_rpm_to_pct(rpm_front_map, - sizeof(rpm_front_map) / sizeof(struct rpm_to_pct_map), - front_fan); - rear_pct = - fan_rpm_to_pct(rpm_rear_map, - sizeof(rpm_rear_map) / sizeof(struct rpm_to_pct_map), - rear_fan); - - /* - * If the fans are broken, the measured rate will be rather - * different from the requested rate, and we can turn up the - * rest of the fans to compensate. The slop is the percentage - * of error that we'll tolerate. - * - * XXX: I suppose that we should only measure negative values; - * running too fast isn't really a problem. - */ - - okay = (abs(front_pct - speed) * 100 / speed < slop && - abs(rear_pct - speed) * 100 / speed < slop); - - if (!okay || verbose) { - syslog(!okay ? LOG_ALERT : LOG_INFO, - "fan %d rear %d (%d%%), front %d (%d%%), expected %d", - fan, - rear_fan, - rear_pct, - front_fan, - front_pct, - speed); - } - - return okay; -} - -/* Set fan speed as a percentage */ - -int write_fan_speed(const int fan, const int value) { - /* - * The hardware fan numbers for pwm control are different from - * both the physical order in the box, and the mapping for reading - * the RPMs per fan, above. - */ - - int real_fan = fan_to_pwm_map[fan]; - - if (value == 0) { - return write_fan_value(real_fan, "pwm%d_en", 0); - } else { - int unit = value * PWM_UNIT_MAX / 100; - int status; - - if (unit == PWM_UNIT_MAX) - unit = 0; - - if ((status = write_fan_value(real_fan, "pwm%d_type", 0)) != 0 || - (status = write_fan_value(real_fan, "pwm%d_rising", 0)) != 0 || - (status = write_fan_value(real_fan, "pwm%d_falling", unit)) != 0 || - (status = write_fan_value(real_fan, "pwm%d_en", 1)) != 0) { - return status; - } - } -} - -/* Set up fan LEDs */ - -int write_fan_led(const int fan, const char *color) -{ - return write_device(fan_led[fan], color); -} - -int server_shutdown(const char *why) { - int fan; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_max); - } - - syslog(LOG_EMERG, "Shutting down: %s", why); - write_device(GPIO_USERVER_POWER_DIRECTION, "out"); - write_device(GPIO_USERVER_POWER, "0"); - /* - * Putting T2 in reset generating a non-maskable interrupt to uS, - * the kernel running on uS might panic depending on its version. - * sleep 5s here to make sure uS is completely down. - */ - sleep(5); - write_device(GPIO_T2_POWER_DIRECTION, "out"); - write_device(GPIO_T2_POWER, "0"); - - /* - * We have to stop the watchdog, or the system will be automatically - * rebooted some seconds after fand exits (and stops kicking the - * watchdog). - */ - - stop_watchdog(); - - sleep(2); - exit(2); -} - -/* Gracefully shut down on receipt of a signal */ - -void fand_interrupt(int sig) -{ - int fan; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_max); - } - - syslog(LOG_ALERT, "Shutting down fand on signal %s", strsignal(sig)); - if (sig == SIGUSR1) { - stop_watchdog(); - } - exit(3); -} - -int main(int argc, char **argv) { - /* Sensor values */ - - int intake_temp; - int exhaust_temp; - int t2_temp; - int userver_temp; - - int fan_speed = FAN_HIGH; - int bad_reads = 0; - int fan_failure = 0; - int fan_speed_changes = 0; - int old_speed; - - int fan_bad[FANS]; - int fan; - - unsigned log_count = 0; // How many times have we logged our temps? - int opt; - int prev_fans_bad = 0; - - struct sigaction sa; - - sa.sa_handler = fand_interrupt; - sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); - - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - sigaction(SIGUSR1, &sa, NULL); - - while ((opt = getopt(argc, argv, "l:m:h:b:t:r:v")) != -1) { - switch (opt) { - case 'l': - fan_low = atoi(optarg); - break; - case 'm': - fan_medium = atoi(optarg); - break; - case 'h': - fan_high = atoi(optarg); - break; - case 'b': - temp_bottom = INTERNAL_TEMPS(atoi(optarg)); - break; - case 't': - temp_top = INTERNAL_TEMPS(atoi(optarg)); - break; - case 'r': - report_temp = atoi(optarg); - break; - case 'v': - verbose = true; - break; - default: - usage(); - break; - } - } - - if (optind > argc) { - usage(); - } - - if (temp_bottom > temp_top) { - fprintf(stderr, - "Should temp-bottom (%d) be higher than " - "temp-top (%d)? Starting anyway.\n", - EXTERNAL_TEMPS(temp_bottom), - EXTERNAL_TEMPS(temp_top)); - } - - if (fan_low > fan_medium || fan_low > fan_high || fan_medium > fan_high) { - fprintf(stderr, - "fan RPMs not strictly increasing " - "-- %d, %d, %d, starting anyway\n", - fan_low, - fan_medium, - fan_high); - } - - daemon(1, 0); - openlog("fand", LOG_CONS, LOG_DAEMON); - - /* Start watchdog in manual mode */ - start_watchdog(0); - - /* Set watchdog to persistent mode so timer expiry will happen independent - * of this process's liveliness. */ - set_persistent_watchdog(WATCHDOG_SET_PERSISTENT); - - if (is_two_fan_board(verbose)) { - /* Alternate, two fan configuration */ - total_fans = 2; - fan_offset = 2; /* fan 3 is the first */ - } - - for (fan = 0; fan < total_fans; fan++) { - fan_bad[fan] = 0; - write_fan_speed(fan + fan_offset, fan_speed); - write_fan_led(fan + fan_offset, FAN_LED_BLUE); - } - - sleep(5); /* Give the fans time to come up to speed */ - - while (1) { - int max_temp; - old_speed = fan_speed; - - /* Read sensors */ - - read_temp(INTAKE_TEMP_DEVICE, &intake_temp); - read_temp(EXHAUST_TEMP_DEVICE, &exhaust_temp); - read_temp(T2_TEMP_DEVICE, &t2_temp); - read_temp(USERVER_TEMP_DEVICE, &userver_temp); - - /* - * uServer can be powered down, but all of the rest of the sensors - * should be readable at any time. - */ - - if ((intake_temp == BAD_TEMP || exhaust_temp == BAD_TEMP || - t2_temp == BAD_TEMP)) { - bad_reads++; - } - - if (bad_reads > BAD_READ_THRESHOLD) { - server_shutdown("Some sensors couldn't be read"); - } - - if (log_count++ % report_temp == 0) { - syslog(LOG_DEBUG, - "Temp intake %d, t2 %d, userver %d, exhaust %d, " - "fan speed %d, speed changes %d", - intake_temp, - t2_temp, - userver_temp, - exhaust_temp, - fan_speed, - fan_speed_changes); - } - - /* Protection heuristics */ - - if (intake_temp > INTAKE_LIMIT) { - server_shutdown("Intake temp limit reached"); - } - - if (t2_temp > T2_LIMIT) { - server_shutdown("T2 temp limit reached"); - } - - if (userver_temp + USERVER_TEMP_FUDGE > USERVER_LIMIT) { - server_shutdown("uServer temp limit reached"); - } - - /* - * Calculate change needed -- we should eventually - * do something more sophisticated, like PID. - * - * We should use the intake temperature to adjust this - * as well. - */ - - if (t2_temp > userver_temp + USERVER_TEMP_FUDGE) { - max_temp = t2_temp; - } else { - max_temp = userver_temp + USERVER_TEMP_FUDGE; - } - - /* - * If recovering from a fan problem, spin down fans gradually in case - * temperatures are still high. Gradual spin down also reduces wear on - * the fans. - */ - if (fan_speed == fan_max) { - if (fan_failure == 0) { - fan_speed = fan_high; - } - } else if (fan_speed == fan_high) { - if (max_temp + COOLDOWN_SLOP < temp_top) { - fan_speed = fan_medium; - } - } else if (fan_speed == fan_medium) { - if (max_temp > temp_top) { - fan_speed = fan_high; - } else if (max_temp + COOLDOWN_SLOP < temp_bottom) { - fan_speed = fan_low; - } - } else {/* low */ - if (max_temp > temp_bottom) { - fan_speed = fan_medium; - } - } - - /* - * Update fans only if there are no failed ones. If any fans failed - * earlier, all remaining fans should continue to run at max speed. - */ - - if (fan_failure == 0 && fan_speed != old_speed) { - syslog(LOG_NOTICE, - "Fan speed changing from %d to %d", - old_speed, - fan_speed); - fan_speed_changes++; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_speed); - } - } - - /* - * Wait for some change. Typical I2C temperature sensors - * only provide a new value every second and a half, so - * checking again more quickly than that is a waste. - * - * We also have to wait for the fan changes to take effect - * before measuring them. - */ - - sleep(5); - - /* Check fan RPMs */ - - for (fan = 0; fan < total_fans; fan++) { - /* - * Make sure that we're within some percentage - * of the requested speed. - */ - if (fan_speed_okay(fan + fan_offset, fan_speed, FAN_FAILURE_OFFSET)) { - if (fan_bad[fan] > FAN_FAILURE_THRESHOLD) { - write_fan_led(fan + fan_offset, FAN_LED_BLUE); - syslog(LOG_NOTICE, - "Fan %d has recovered", - fan); - } - fan_bad[fan] = 0; - } else { - fan_bad[fan]++; - } - } - - fan_failure = 0; - for (fan = 0; fan < total_fans; fan++) { - if (fan_bad[fan] > FAN_FAILURE_THRESHOLD) { - fan_failure++; - write_fan_led(fan + fan_offset, FAN_LED_RED); - } - } - - if (fan_failure > 0) { - if (prev_fans_bad != fan_failure) { - syslog(LOG_ALERT, "%d fans failed", fan_failure); - } - - /* - * If fans are bad, we need to blast all of the - * fans at 100%; we don't bother to turn off - * the bad fans, in case they are all that is left. - * - * Note that we have a temporary bug with setting fans to - * 100% so we only do fan_max = 99%. - */ - - fan_speed = fan_max; - for (fan = 0; fan < total_fans; fan++) { - write_fan_speed(fan + fan_offset, fan_speed); - } - - /* - * Fans can be hot swapped and replaced; in which case the fan daemon - * will automatically detect the new fan and (assuming the new fan isn't - * itself faulty), automatically readjust the speeds for all fans down - * to a more suitable rpm. The fan daemon does not need to be restarted. - */ - } - - /* Suppress multiple warnings for similar number of fan failures. */ - prev_fans_bad = fan_failure; - - /* if everything is fine, restart the watchdog countdown. If this process - * is terminated, the persistent watchdog setting will cause the system - * to reboot after the watchdog timeout. */ - kick_watchdog(); - } -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.cpp b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.cpp deleted file mode 100644 index ebb390a..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * watchdog - * - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include "watchdog.h" - -#include <errno.h> -#include <fcntl.h> -#include <pthread.h> -#include <syslog.h> -#include <unistd.h> - -#define WATCHDOG_START_KEY "x" -#define WATCHDOG_STOP_KEY "X" -/* The "magic close" character (as defined in Linux watchdog specs). */ -#define WATCHDOG_PERSISTENT_KEY "V" -#define WATCHDOG_NON_PERSISTENT_KEY "a" - -static int watchdog_dev = -1; - -/* This is needed to prevent rapid consecutive stop/start watchdog calls from - * generating multiple threads. */ -static int watchdog_started = 0; - -static const char* watchdog_kick_key = WATCHDOG_PERSISTENT_KEY; -static pthread_t watchdog_tid; -static pthread_mutex_t watchdog_lock = PTHREAD_MUTEX_INITIALIZER; - -/* Forward declarations. */ -static void* watchdog_thread(void* args); -static int kick_watchdog_unsafe(); - -/* - * When started, this background thread will constantly reset the watchdog - * at every 5 second interval. - */ - -static void* watchdog_thread(void* args) { - - pthread_detach(pthread_self()); - - /* Make sure another instance of the thread hasn't already been started. */ - pthread_mutex_lock(&watchdog_lock); - if (watchdog_started) { - goto done; - } else { - watchdog_started = 1; - } - pthread_mutex_unlock(&watchdog_lock); - - /* Actual loop for refreshing the watchdog timer. */ - while (1) { - pthread_mutex_lock(&watchdog_lock); - if (watchdog_dev != -1) { - kick_watchdog_unsafe(); - } else { - break; - } - pthread_mutex_unlock(&watchdog_lock); - sleep(5); - } - - /* Broke out of loop because watchdog was stopped. */ - watchdog_started = 0; -done: - pthread_mutex_unlock(&watchdog_lock); - return NULL; -} - -/* - * Starts the watchdog timer. timer counts down and restarts the ARM chip - * upon timeout. use kick_watchdog() to restart the timer. - * - * Returns: 1 on success; 0 otherwise. - */ - -int start_watchdog(const int auto_mode) { - int status; - - pthread_mutex_lock(&watchdog_lock); - - /* Don't start the watchdog again if it has already been started. */ - if (watchdog_dev != -1) { - while ((status = write(watchdog_dev, WATCHDOG_START_KEY, 1)) == 0 - && errno == EINTR); - pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_ALERT, "system watchdog already started.\n"); - return 0; - } - - while (((watchdog_dev = open("/dev/watchdog", O_WRONLY)) == -1) && - errno == EINTR); - - /* Fail if watchdog device is invalid or if the user asked for auto - * mode and the thread failed to spawn. */ - if ((watchdog_dev == -1) || - (auto_mode == 1 && watchdog_started == 0 && - pthread_create(&watchdog_tid, NULL, watchdog_thread, NULL) != 0)) { - goto fail; - } - - while ((status = write(watchdog_dev, WATCHDOG_START_KEY, 1)) == 0 - && errno == EINTR); - pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_INFO, "system watchdog started.\n"); - return 1; - -fail: - if (watchdog_dev != -1) { - close(watchdog_dev); - watchdog_dev = -1; - } - - pthread_mutex_unlock(&watchdog_lock); - syslog(LOG_ALERT, "system watchdog failed to start!\n"); - return 0; -} - -/* - * Toggles between watchdog persistent modes. In persistent mode, the watchdog - * timer will continue to tick even after process shutdown. Under non- - * persistent mode, the watchdog timer will automatically be disabled when the - * process shuts down. - */ -void set_persistent_watchdog(enum watchdog_persistent_en persistent) { - switch (persistent) { - case WATCHDOG_SET_PERSISTENT: - watchdog_kick_key = WATCHDOG_PERSISTENT_KEY; - break; - default: - watchdog_kick_key = WATCHDOG_NON_PERSISTENT_KEY; - break; - } - kick_watchdog(); -} - -/* - * Restarts the countdown timer on the watchdog, delaying restart by another - * timeout period (default: 11 seconds as configured in the device driver). - * - * This function assumes the watchdog lock has already been acquired and is - * only used internally within the watchdog code. - * - * Returns 1 on success; 0 or -1 indicates failure (check errno). - */ - -static int kick_watchdog_unsafe() { - int status = 0; - if (watchdog_dev != -1) { - while ((status = write(watchdog_dev, watchdog_kick_key, 1)) == 0 - && errno == EINTR); - } - return status; -} - -/* - * Acquires the watchdog lock and resets the watchdog atomically. For use by - * library users. - */ - -int kick_watchdog() { - int result; - pthread_mutex_lock(&watchdog_lock); - result = kick_watchdog_unsafe(); - pthread_mutex_unlock(&watchdog_lock); - - return result; -} - -/* Shuts down the watchdog gracefully and disables the watchdog timer so that - * restarts no longer happen. - */ - -void stop_watchdog() { - int status; - pthread_mutex_lock(&watchdog_lock); - if (watchdog_dev != -1) { - while ((status = write(watchdog_dev, WATCHDOG_STOP_KEY, 1)) == 0 - && errno == EINTR); - close(watchdog_dev); - watchdog_dev = -1; - syslog(LOG_INFO, "system watchdog stopped.\n"); - } - pthread_mutex_unlock(&watchdog_lock); -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.h b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.h deleted file mode 100644 index 19b9944..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl/watchdog.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * watchdog - * - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Utility library to handle the aspeed watchdog. Only one watchdog - * should be in use at any time throughout the entire system (multiple users - * will not cause adverse effects but the behavior of the watchdog becomes - * undefined). - * - * The watchdog can be started in either manual or automatic mode. In manual - * mode, the watchdog has to be constantly reset by the user via the - * kick_watchdog() function. Under automatic mode, the watchdog will - * run in a separate thread and reset the timer on its own so no intervention - * is required from the user. - * - * In both modes, the watchdog timer will not stop when the process is - * terminated, unless a call to stop_watchdog() has been made beforehand, or - * if the user runs in manual mode and uses a non persistent watchdog kick. - * - * The default timeout for the watchdog is 11 seconds. When this time period - * elapses, the ARM chip is restarted and the kernel is rebooted. Other - * hardware state is not reset, so this may introduce strange behavior on - * reboot (example: an I2C bus may be left in the open state, triggering - * constant interrupts). In rare cases, this could result in the kernel - * failing to fully restart itself and thus preclude the possibility of - * reinitializing the watchdog timer. Someone will then have to go over and - * physically restart the machine. - * - * The alternative to the soft reset is to request the watchdog device driver - * for a hard reset on timeout. However this will stop the fans. If the - * kernel fails to fully boot and restart the fan daemon, the system could - * overheat. For this reason, we've chosen to take the risk of a stuck soft - * reset instead. - * - */ - -/* Forward declarations. */ -int start_watchdog(const int auto_mode); -enum watchdog_persistent_en { - WATCHDOG_SET_PERSISTENT, - WATCHDOG_SET_NONPERSISTENT, -}; -void set_persistent_watchdog(enum watchdog_persistent_en persistent); -int kick_watchdog(); -void stop_watchdog(); diff --git a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl_0.1.bb deleted file mode 100644 index 6e0c980..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fan-ctrl/fan-ctrl_0.1.bb +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -SUMMARY = "Fan controller" -DESCRIPTION = "The utilities to control fan." -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://fand.cpp;beginline=6;endline=18;md5=da35978751a9d71b73679307c4d296ec" - -DEPENDS_append = "libwedge-eeprom update-rc.d-native" - -SRC_URI = "file://get_fan_speed.sh \ - file://init_pwm.sh \ - file://set_fan_speed.sh \ - file://README \ - file://setup-fan.sh \ - file://Makefile \ - file://fand.cpp \ - file://watchdog.h \ - file://watchdog.cpp \ - " - -S = "${WORKDIR}" - -binfiles = "get_fan_speed.sh \ - init_pwm.sh \ - set_fan_speed.sh \ - fand \ - " - -otherfiles = "README" - -pkgdir = "fan_ctrl" - -do_install() { - dst="${D}/usr/local/fbpackages/${pkgdir}" - bin="${D}/usr/local/bin" - install -d $dst - install -d $bin - for f in ${binfiles}; do - install -m 755 $f ${dst}/$f - ln -snf ../fbpackages/${pkgdir}/$f ${bin}/$f - done - for f in ${otherfiles}; do - install -m 644 $f ${dst}/$f - done - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/rcS.d - install -m 755 setup-fan.sh ${D}${sysconfdir}/init.d/setup-fan.sh - update-rc.d -r ${D} setup-fan.sh start 91 S . -} - -FBPACKAGEDIR = "${prefix}/local/fbpackages" - -FILES_${PN} = "${FBPACKAGEDIR}/fan_ctrl ${prefix}/local/bin ${sysconfdir} " - -# Inhibit complaints about .debug directories for the fand binary: - -INHIBIT_PACKAGE_DEBUG_SPLIT = "1" -INHIBIT_PACKAGE_STRIP = "1" diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/fbutils_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/fbutils/fbutils_0.1.bb deleted file mode 100644 index 753adbe..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/fbutils_0.1.bb +++ /dev/null @@ -1,86 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -SUMMARY = "Utilities" -DESCRIPTION = "Various utilities" -SECTION = "base" -PR = "r1" -LICENSE = "GPLv2" -LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a" - -SRC_URI = "file://ast-functions \ - file://us_console.sh \ - file://sol.sh \ - file://power_led.sh \ - file://post_led.sh \ - file://reset_usb.sh \ - file://setup-gpio.sh \ - file://setup_rov.sh \ - file://mdio.py \ - file://bcm5396.py \ - file://bcm5396_util.py \ - file://mount_data0.sh \ - file://eth0_mac_fixup.sh \ - file://wedge_power.sh \ - file://power-on.sh \ - file://wedge_us_mac.sh \ - file://setup_switch.py \ - file://create_vlan_intf \ - file://watch-fc.sh \ - file://fcswitcher.sh \ - file://rc.early \ - file://rc.local \ - file://src \ - file://COPYING \ - " - -pkgdir = "utils" - -S = "${WORKDIR}" - -binfiles = "us_console.sh sol.sh power_led.sh post_led.sh \ - reset_usb.sh mdio.py setup_rov.sh wedge_power.sh wedge_us_mac.sh \ - bcm5396.py bcm5396_util.py setup_switch.py watch-fc.sh" - -DEPENDS_append = "update-rc.d-native" - -do_install() { - dst="${D}/usr/local/fbpackages/${pkgdir}" - install -d $dst - install -m 644 ast-functions ${dst}/ast-functions - localbindir="${D}/usr/local/bin" - install -d ${localbindir} - for f in ${binfiles}; do - install -m 755 $f ${dst}/${f} - ln -s ../fbpackages/${pkgdir}/${f} ${localbindir}/${f} - done - - # common lib and include files - install -d ${D}${includedir}/facebook - install -m 0644 src/include/log.h ${D}${includedir}/facebook/log.h - install -m 0644 src/include/i2c-dev.h ${D}${includedir}/facebook/i2c-dev.h - - # init - install -d ${D}${sysconfdir}/init.d - install -d ${D}${sysconfdir}/rcS.d - # the script to mount /mnt/data - install -m 0755 ${WORKDIR}/mount_data0.sh ${D}${sysconfdir}/init.d/mount_data0.sh - update-rc.d -r ${D} mount_data0.sh start 03 S . - install -m 0755 ${WORKDIR}/rc.early ${D}${sysconfdir}/init.d/rc.early - update-rc.d -r ${D} rc.early start 04 S . - install -m 755 setup-gpio.sh ${D}${sysconfdir}/init.d/setup-gpio.sh - update-rc.d -r ${D} setup-gpio.sh start 59 S . - # create VLAN intf automatically - install -d ${D}/${sysconfdir}/network/if-up.d - install -m 755 create_vlan_intf ${D}${sysconfdir}/network/if-up.d/create_vlan_intf - # networking is done after rcS, any start level within rcS - # for mac fixup should work - install -m 755 eth0_mac_fixup.sh ${D}${sysconfdir}/init.d/eth0_mac_fixup.sh - update-rc.d -r ${D} eth0_mac_fixup.sh start 70 S . - install -m 755 power-on.sh ${D}${sysconfdir}/init.d/power-on.sh - update-rc.d -r ${D} power-on.sh start 85 S . - install -m 755 fcswitcher.sh ${D}${sysconfdir}/init.d/fcswitcher.sh - update-rc.d -r ${D} fcswitcher.sh start 90 S . - install -m 0755 ${WORKDIR}/rc.local ${D}${sysconfdir}/init.d/rc.local - update-rc.d -r ${D} rc.local start 99 2 3 4 5 . -} - -FILES_${PN} += "/usr/local ${sysconfdir}" diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions deleted file mode 100644 index dd53ad1..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/ast-functions +++ /dev/null @@ -1,222 +0,0 @@ -# Copyright 2014-present Facebook. All Rights Reserved. -DEVMEM=/sbin/devmem - -devmem_set_bit() { - local addr - local val - addr=$1 - val=$($DEVMEM $addr) - val=$((val | (0x1 << $2))) - $DEVMEM $addr 32 $val -} - -devmem_clear_bit() { - local addr - local val - addr=$1 - val=$($DEVMEM $addr) - val=$((val & ~(0x1 << $2))) - $DEVMEM $addr 32 $val -} - -scu_addr() { - echo $((0x1E6E2000 + 0x$1)) -} - -GPIODIR="/sys/class/gpio" -GPIOEXPORT="$GPIODIR/export" - -gpio_dir() { - echo "$GPIODIR/gpio$1" -} - -gpio_name2value() { - local first remaining base val - remaining=$1 - val=0 - while [ -n "$remaining" ]; do - first=${remaining:0:1} - case "$first" in - [[:lower:]]) - base=$(printf "%d" "'$first'") - base=$((base - 96)) - val=$((val * 26 + base)) - ;; - [[:upper:]]) - base=$(printf "%d" "'$first'") - base=$((base - 64)) - val=$((val * 26 + base)) - ;; - *) - if [ $val -gt 0 ]; then - val=$((val-1)) - fi - val=$((val * 8 + $remaining)) - break - ;; - esac - remaining=${remaining:1} - done - echo "$val" -} - -gpio_export() { - local gpio - gpio=$(gpio_name2value $1) - dir=$(gpio_dir $gpio) - if [ ! -d ${dir} ]; then - echo $gpio > $GPIOEXPORT - fi -} - -gpio_set() { - local gpio - local val - gpio=$(gpio_name2value $1) - val=$2 - dir=$(gpio_dir $gpio) - if [ ! -d ${dir} ]; then - echo $gpio > $GPIOEXPORT - fi - echo out > ${dir}/direction - echo $val > ${dir}/value -} - -gpio_get() { - local gpio - local val - gpio=$(gpio_name2value $1) - dir=$(gpio_dir $gpio) - if [ ! -d ${dir} ]; then - echo $gpio > $GPIOEXPORT - fi - echo in > ${dir}/direction - cat ${dir}/value -} - -wedge_iso_buf_enable() { - # GPIOC2 (18) to low, SCU90[0] and SCU90[24] must be 0 - devmem_clear_bit $(scu_addr 90) 0 - devmem_clear_bit $(scu_addr 90) 24 - gpio_set 18 0 -} - -wedge_iso_buf_disable() { - # GPIOC2 (18) to low, SCU90[0] and SCU90[24] must be 0 - devmem_clear_bit $(scu_addr 90) 0 - devmem_clear_bit $(scu_addr 90) 24 - gpio_set 18 1 -} - -wedge_is_us_on() { - local val n retries prog - if [ $# -gt 0 ]; then - retries="$1" - else - retries=1 - fi - if [ $# -gt 1 ]; then - prog="$2" - else - prog="" - fi - n=1 - while true; do - val=$(cat /sys/class/i2c-adapter/i2c-4/4-0040/gpio_inputs 2>/dev/null) - if [ -n "$val" ]; then - break - fi - n=$((n+1)) - if [ $n -gt $retries ]; then - echo -n " failed to read GPIO. " - val=0 - break - fi - echo -n "$prog" - sleep 1 - done - if [ "$((val & (0x1 << 14)))" != "0" ]; then - # powered on already - return 0 - else - return 1 - fi -} - - -# Return the board type, 'LC', 'FC-LEFT', 'FC-RIGHT', or, 'WEDGE' -wedge_board_type() { - local pn - pn=$(/usr/bin/weutil 2> /dev/null | grep -i '^Location on Fabric:') - case "$pn" in - *LEFT*) - echo 'FC-LEFT' - ;; - *RIGHT*) - echo 'FC-RIGHT' - ;; - *LC*) - echo 'LC' - ;; - *) - echo 'WEDGE' - ;; - esac -} - -# On FC, FAB_SLOT_ID (GPIOU0), low == FC0; high == FC1 -# On LC, Wedge, -# board rev < 3: -# GPIOU0(ID0), GPIOU1(ID1), GPIOU2(ID2), GPIOU3(ID3) -# else: -# GPIOU6(ID0), GPIOU7(ID1), GPIOV0(ID2), GPIOV1(ID3) -# -# ID[2:0] ID3 Slot# -# 000 0 1 -# 000 1 2 -# 001 0 3 -# 001 1 4 -# 010 0 5 -# 010 1 6 -# 011 0 7 -# 011 1 8 - -wedge_slot_id() { - local type slot id3 id2 id1 id0 FC_CARD_BASE board_rev - FC_CARD_BASE=65 - if [ "$1" = "FC-LEFT" ]; then - # fabric card left - slot=$(gpio_get U0) - slot=$((FC_CARD_BASE + slot * 2)) - elif [ "$1" = "FC-RIGHT" ]; then - # fabric card right - slot=$(gpio_get U0) - slot=$((FC_CARD_BASE + slot * 2 + 1)) - else - # either edge or LC - # need to check the board rev - board_rev=$(wedge_board_rev) - if [ $board_rev -lt 3 ]; then - id0=$(gpio_get U0) - id1=$(gpio_get U1) - id2=$(gpio_get U2) - id3=$(gpio_get U3) - else - id0=$(gpio_get U6) - id1=$(gpio_get U7) - id2=$(gpio_get V0) - id3=$(gpio_get V1) - fi - slot=$(((id2 * 4 + id1 * 2 + id0) * 2 + id3 + 1)) - fi - echo "$slot" -} - -# wedge_board_rev() is only valid after GPIO Y0, Y1, and Y2 are enabled -wedge_board_rev() { - local val0 val1 val2 - val0=$(cat /sys/class/gpio/gpio192/value 2>/dev/null) - val1=$(cat /sys/class/gpio/gpio193/value 2>/dev/null) - val2=$(cat /sys/class/gpio/gpio194/value 2>/dev/null) - echo $((val0 | (val1 << 1) | (val2 << 2))) -} diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46.py b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46.py deleted file mode 100644 index 368b807..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46.py +++ /dev/null @@ -1,260 +0,0 @@ -# Copyright 2004-present Facebook. All rights reserved. - -import subprocess -import struct -import sys - -class VerboseLogger: - def __init__(self, verbose=False): - self.verbose = verbose - - def _verbose_print(self, caption, bytestream=None): - ''' - Print a bytestream to stdout if verbose is enabled. - ''' - if self.verbose: - if bytestream is not None: - sys.stderr.write("{}: {}\n".format(caption, " ".join(['{:02X}'.format(ord(x)) for x in bytestream]))) - else: - sys.stderr.write("{}\n".format(caption)) - -class AT93C46SPI(VerboseLogger): - '''The class to access AT93C46 through SPI intf''' - SPI_CMD = 'spi-bb' - - def __init__(self, bus_width, gpio_cs, gpio_ck, gpio_do, gpio_di, - verbose=False): - if bus_width != 8 and bus_width != 16: - raise Exception("Invalid bus width for AT93C46!") - - self.bus_width = bus_width - self.gpio_cs = gpio_cs - self.gpio_ck = gpio_ck - self.gpio_do = gpio_do - self.gpio_di = gpio_di - self.verbose = verbose - - self.addr_bits = 6 if self.bus_width == 16 else 7 - self.addr_mask = 0x3F if self.bus_width == 16 else 0x7F - - def __shift(self, bytestream, value): - ''' - Shift an entire byte stream by value bits. - ''' - binary = "".join(['{:08b}'.format(ord(x)) for x in bytestream]) - if value > 0: - binary = binary[value:] + '0' * value - else: - binary = '0' * (-value) + binary[:value] - return "".join([chr(int(binary[x:x+8],2)) for x in range(0, len(binary), 8)]) - - def __io(self, op, addr, data=None): - ''' - Perform an IO operation against the EEPROM - ''' - write_bits = self.addr_bits + 3 - if data is not None: - # If giving data, we are doing a write command so - # no need to read any data. - write_bits = write_bits + self.bus_width - read_bits = 0 - else: - # If not giving data, we are doing either a read - # command or a set command, so read the result. - # We pad with an extra bit due to a dummy bit introduced - # by a delay for address decoding on chip. - read_bits = self.addr_bits + 4 + self.bus_width - - # Format the command itself - cmd_loc = 6 if self.bus_width == 16 else 7 - instruction = addr & self.addr_mask - instruction = instruction | ((0x4 | (op & 0x3)) << cmd_loc) - if data is not None: - if self.bus_width == 16: - write_data = struct.pack(">HH", instruction, data & 0xFFFF) - else: - write_data = struct.pack(">HB", instruction, data & 0xFF) - else: - write_data = struct.pack(">H", instruction) - write_data = self.__shift(write_data, 16 - (cmd_loc + 3)) - - self._verbose_print("Write data", write_data) - - # Run the command with the bitbang driver - if read_bits > 0: - data_portion = "-r {} -w {}".format(read_bits, write_bits) - else: - data_portion = "-w {}".format(write_bits) - - cmd = "{} -s {} -c {} -o {} -i {} -b {}".format( - self.SPI_CMD, self.gpio_cs, self.gpio_ck, self.gpio_do, - self.gpio_di, data_portion - ) - - self._verbose_print("Command: {}".format(cmd)) - - out = subprocess.Popen(cmd.split(), - stdout=subprocess.PIPE, - stdin = subprocess.PIPE)\ - .communicate(input=write_data) - - # Format the response - read_data = self.__shift(out[0], cmd_loc + 4) - if self.bus_width == 16: - read_data = read_data[:2] - self._verbose_print("Read data", read_data) - return struct.unpack(">H", read_data)[0] - else: - read_data = read_data[:1] - self._verbose_print("Read data", read_data) - return struct.unpack(">B", read_data)[0] - - def read(self, addr): - return self.__io(0x2, addr) - - def ewen(self): - self.__io(0x0, 0x3 << (self.addr_bits - 2)) - - def erase(self, addr): - self.__io(0x3, addr) - - def write(self, addr, data): - self.__io(0x1, addr, data) - - def eral(self): - self.__io(0x0, 0x2 << (self.addr_bits - 2)) - - def wral(self, data): - self.__io(0x0, 0x1 << (self.addr_bits - 2), data) - - def ewds(self): - self.__io(0x0, 0x0) - -class AT93C46(VerboseLogger): - ''' - The class which handles accessing memory on the AT93C46 chip. - ''' - AT93C46_MEMORY_SIZE = 128 - - def __init__(self, bus_width, gpio_cs, gpio_ck, gpio_do, gpio_di, - byte_swap, verbose=False): - self.bus_width = bus_width - self.verbose = verbose - self.byte_swap = byte_swap - - self.spi = AT93C46SPI(bus_width=bus_width, gpio_cs=gpio_cs, - gpio_ck=gpio_ck, gpio_do=gpio_do, - gpio_di=gpio_di, verbose=verbose) - - def __swap(self, value): - ''' - Swap bytes for a 16-bit integer if instructed to do so. - ''' - if self.bus_width == 16: - if self.byte_swap: - return ((value >> 8) & 0xFF) | ((value << 8) & 0xFF00) - else: - return value - else: - return value - - def erase(self, offset=None, limit=None): - ''' - Erase the chip. - ''' - if offset is None: - offset = 0 - if limit is None: - limit = self.AT93C46_MEMORY_SIZE - - if offset < 0 or offset + limit > self.AT93C46_MEMORY_SIZE: - raise Exception("Erase would be out of bounds!") - if self.bus_width == 16 and \ - ((offset & 1) != 0 or ((offset + limit) & 1) != 0): - raise Exception("Erase can't start or end on odd boundary in 16-bit mode!") - - if offset == 0 and limit == self.AT93C46_MEMORY_SIZE: - # Special case when we are erasing the entire chip - self.spi.ewen() - self.spi.eral() - self.spi.ewds() - - self._verbose_print("Erased entire chip") - else: - # Regular case - if self.bus_width == 16: - real_offset = offset / 2 - real_limit = limit / 2 - else: - real_offset = offset - real_limit = limit - - self.spi.ewen() - for addr in range(real_offset, real_offset + real_limit): - self.spi.erase(addr) - self.spi.ewds() - - self._verbose_print("Erased {} bytes from offset {}".format(limit, offset)) - - def read(self, offset=None, limit=None): - ''' - Read the chip into a memory buffer. - ''' - if offset is None: - offset = 0 - if limit is None: - limit = self.AT93C46_MEMORY_SIZE - - if offset < 0 or offset + limit > self.AT93C46_MEMORY_SIZE: - raise Exception("Read would be out of bounds!") - if self.bus_width == 16 and \ - ((offset & 1) != 0 or ((offset + limit) & 1) != 0): - raise Exception("Read can't start or end on odd boundary in 16-bit mode!") - - output = "" - if self.bus_width == 16: - real_offset = offset / 2 - real_limit = limit / 2 - pack_instruction = "=H" - else: - real_offset = offset - real_offset - pack_instruction = "=B" - - for addr in range(real_offset, real_offset + real_limit): - output = output + struct.pack(pack_instruction, self.__swap(self.spi.read(addr))) - - self._verbose_print("Read {} bytes from offset {}".format(limit, offset), output) - - return output - - def write(self, data, offset=None): - ''' - Write a memory buffer to the chip. - ''' - if offset is None: - offset = 0 - - if offset < 0 or offset + len(data) > self.AT93C46_MEMORY_SIZE: - raise Exception("Write would be out of bounds!") - if self.bus_width == 16 and \ - ((offset & 1) != 0 or ((offset + len(data)) & 1) != 0): - raise Exception("Write can't start or end on odd boundary in 16-bit mode!") - - if self.bus_width == 16: - offset_divisor = 2 - pack_instruction = "=H" - else: - offset_divisor = 1 - pack_instruction = "=B" - - self.spi.ewen() - for addr in range(offset, offset + len(data), offset_divisor): - actual_addr = addr / offset_divisor - value = self.__swap(struct.unpack(pack_instruction, data[(addr - offset):(addr - offset) + offset_divisor])[0]) - - self.spi.erase(actual_addr) - self.spi.write(actual_addr, value) - self.spi.ewds() - - self._verbose_print("Wrote {} bytes from offset {}".format(len(data), offset), data) diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46_util.py b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46_util.py deleted file mode 100755 index 8910002..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/at93c46_util.py +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/python -S -# Copyright 2004-present Facebook. All rights reserved. - -from argparse import ArgumentParser -from at93c46 import AT93C46, AT93C46SPI -import sys - -def get_raw(args): - return AT93C46SPI(args.bus_width, args.cs, args.clk, args.mosi, args.miso, - args.verbose) - -def get_chip(args): - return AT93C46(args.bus_width, args.cs, args.clk, args.mosi, args.miso, - args.byte_swap, args.verbose) - -def access_parser(ap): - # Default, based on currenct HW configuration - SPI_CS_DEFAULT = 68 - SPI_CLK_DEFAULT = 69 - SPI_MOSI_DEFAULT = 70 - SPI_MISO_DEFAULT = 71 - - spi_group = ap.add_argument_group('SPI Access') - spi_group.add_argument('--cs', type=int, default=SPI_CS_DEFAULT, - help='The GPIO number for SPI CS pin (default: %s)' - % SPI_CS_DEFAULT) - spi_group.add_argument('--clk', type=int, default=SPI_CLK_DEFAULT, - help='The GPIO number for SPI CLK pin (default: %s)' - % SPI_CLK_DEFAULT) - spi_group.add_argument('--mosi', type=int, default=SPI_MOSI_DEFAULT, - help='The GPIO number for SPI MOSI pin (default: %s)' - % SPI_MOSI_DEFAULT) - spi_group.add_argument('--miso', type=int, default=SPI_MISO_DEFAULT, - help='The GPIO number for SPI MISO pin (default: %s)' - % SPI_MISO_DEFAULT) - -def bus_width_parser(ap): - # Default, based on currenct HW configuration - AT83C46_BUS_WIDTH = 16 - - bus_group = ap.add_argument_group('Bus Width') - bus_group.add_argument('--bus-width', type=int, default=AT83C46_BUS_WIDTH, - help='The configured bus width (default: %s)' - % AT83C46_BUS_WIDTH) - -def read_raw(args): - raw = get_raw(args) - val = raw.read(args.address) - - if args.int: - print "{}".format(val) - else: - if args.bus_width == 16: - print "0x{:04X}".format(val) - else: - print "0x{:02X}".format(val) - -def write_raw(args): - if args.value[:2] == "0x": - value = int(args.value, 16) - else: - value = int(args.value) - - raw = get_raw(args) - raw.ewen() - raw.erase(args.address) - raw.write(args.address, value) - raw.ewds() - -def erase_raw(args): - raw = get_raw(args) - raw.ewen() - raw.erase(args.address) - raw.ewds() - -def raw_subparser(subparsers): - raw_parser = subparsers.add_parser('raw', help='Raw memory access') - raw_sub = raw_parser.add_subparsers() - - read_parser = raw_sub.add_parser('read', help='Read a single memory address') - read_parser.add_argument('address', type=int, help='The memory address') - read_parser.add_argument('--int', action='store_true', - help='Display output as an integer') - read_parser.set_defaults(func=read_raw) - - write_parser = raw_sub.add_parser('write', help='Write a single memory address') - write_parser.add_argument('address', type=int, help='The memory address') - write_parser.add_argument('value', type=str, help='The value to write, either integer or hex') - write_parser.set_defaults(func=write_raw) - - erase_parser = raw_sub.add_parser('erase', help='Erase a single memory address') - erase_parser.add_argument('address', type=int, help='The memory address') - erase_parser.set_defaults(func=erase_raw) - -def read_chip(args): - chip = get_chip(args) - data = chip.read(args.start, args.length) - - if args.file is None: - sys.stdout.write(data) - else: - fp = open(args.file, "wb") - fp.write(data) - -def write_chip(args): - chip = get_chip(args) - - # Either way, limit reads to the size of the chip - if args.file is None: - data = sys.stdin.read(AT93C46.AT93C46_MEMORY_SIZE) - else: - fp = open(args.file, "rb") - data = fp.read(AT93C46.AT93C46_MEMORY_SIZE) - - if args.length is not None: - # Make sure length is correct - if len(data) < args.length: - data = data + '\x00' * (args.length - len(data)) - if len(data) > args.length: - data = data[:args.length] - - chip.write(data, args.start) - -def erase_chip(args): - chip = get_chip(args) - chip.erase(args.start, args.length) - -def chip_subparser(subparsers): - chip_parser = subparsers.add_parser('chip', help='Chip-level access') - chip_sub = chip_parser.add_subparsers() - - read_parser = chip_sub.add_parser('read', help='Read from the chip') - read_parser.add_argument('--start', type=int, - help='The memory address to start at (default: 0)') - read_parser.add_argument('--length', type=int, - help='The number of bytes to read (default: whole chip)') - read_parser.add_argument('--file', type=str, - help='File to operate on (default: stdout)') - read_parser.add_argument('--byte-swap', action='store_true', - help='Byte swap values for 16-bit reads/writes') - read_parser.set_defaults(func=read_chip) - - write_parser = chip_sub.add_parser('write', help='Write to the chip') - write_parser.add_argument('--start', type=int, - help='The memory address to start at (default: 0)') - write_parser.add_argument('--length', type=int, - help='The number of bytes to write (default: file length)') - write_parser.add_argument('--file', type=str, - help='File to operate on (default: stdin)') - write_parser.add_argument('--byte-swap', action='store_true', - help='Byte swap values for 16-bit reads/writes') - write_parser.set_defaults(func=write_chip) - - erase_parser = chip_sub.add_parser('erase', help='Erase the chip') - erase_parser.add_argument('--start', type=int, - help='The memory address to start at (default: 0)') - erase_parser.add_argument('--length', type=int, - help='The number of bytes to erase (default: whole chip)') - erase_parser.set_defaults(func=erase_chip) - -if __name__ == "__main__": - # General arguments - ap = ArgumentParser() - ap.add_argument('--verbose', action='store_true', - help='Print verbose debugging information') - - # SPI and bus width arguments - access_parser(ap) - bus_width_parser(ap) - - # Functionality - subparsers = ap.add_subparsers() - raw_subparser(subparsers) - chip_subparser(subparsers) - - # Command runner - args = ap.parse_args() - args.func(args) diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/fcswitcher.sh b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/fcswitcher.sh deleted file mode 100755 index 53e24f3..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/fcswitcher.sh +++ /dev/null @@ -1,83 +0,0 @@ -#! /bin/sh -# -# Copyright 2014-present Facebook. All Rights Reserved. -# -# This program file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -# - -### BEGIN INIT INFO -# Provides: usbcons -# Required-Start: -# Required-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Creates a virtual USB serial device and starts a console -# on it. -# -### END INIT INFO - -PATH=/sbin:/bin:/usr/sbin:/usr/bin -NAME="FC Switcher" -DESC="FC Failover Daemon" - -# source function library -. /etc/init.d/functions - -. /usr/local/fbpackages/utils/ast-functions - -STOPPER= -ACTION="$1" - -case "$ACTION" in - start) - if [ "$(wedge_board_type)" = "LC" ]; then - # Ability to prevent this from starting by editing cmdline in u-boot. - # Keeping this here until I get gadget switching working properly. (t4906522) - /usr/local/bin/watch-fc.sh > /dev/null 2>&1 & - echo "$NAME." - else - echo 'skipping watch-fc.sh: only necessary on six-pack line cards.' - fi - ;; - stop) - echo -n "Stopping $DESC: " - killall watch-fc.sh - echo "$NAME." - ;; - restart|force-reload) - echo -n "Restarting $DESC: " - killall watch-fc.sh - if [ "$(wedge_board_type)" = "LC" ]; then - sleep 1 - /usr/local/bin/watch-fc.sh > /dev/null 2>&1 & - echo "$NAME." - else - echo 'skipping watch-fc.sh: only necessary on six-pack line cards.' - fi - ;; - status) - status watch-fc.sh - exit $? - ;; - *) - N=${0##*/} - N=${N#[SK]??} - echo "Usage: $N {start|stop|status|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh index 1400464..4ff6f24 100755 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/setup_rov.sh @@ -56,12 +56,19 @@ target_volts=$(( $target_volts * 1 )) # normalize to decimal rmmod pmbus reload=$? -# Get current voltage value +# Get current voltage value. +# The device here is NCP4200. It turns out the first i2c transaction to this +# device always fails. The spec does not mention anything about NCP4200 i2c +# engine start delay. However, each time, when the isolation buffer between the +# BMC i2c controller and NCP4200 is disabled and re-enabled, the first i2c +# transaction to NCP4200 always fails. +# To workaround this issue, we are doing the first read twice. +cur_volts=$(i2cget -y 1 0x60 0x8b w 2> /dev/null) cur_volts=$(i2cget -y 1 0x60 0x8b w) cur_volts=$(( $cur_volts * 1 )) # normalize to decimal # Only bounce the T2 if we actually need to modify the voltage -if [ $cur_volts -ne $target_volts ]; then +if [ $cur_volts -ne $target_volts ]; then # Set values before turning out output; we're using "PCIE, then MCS" echo 1 > /sys/class/gpio/gpio42/value echo 1 > /sys/class/gpio/gpio43/value @@ -71,7 +78,7 @@ if [ $cur_volts -ne $target_volts ]; then echo out > /sys/class/gpio/gpio16/direction # T2 is in reset; note that this may cause NMI messages on the uServer, # which shouldn't be up anyway when this is first run. - + # Set the requested value to the current value to avoid rapid shifts i2cset -y 1 0x60 0x21 $cur_volts w # Enable the requested voltage @@ -81,7 +88,7 @@ if [ $cur_volts -ne $target_volts ]; then # Set the target voltage i2cset -y 1 0x60 0x21 $target_volts w - + sleep 1 # Let T2 come out of reset diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/src/include/log.h b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/src/include/log.h deleted file mode 100644 index a69d69e..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/src/include/log.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2014-present Facebook. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#ifndef LOG_H -#define LOG_H - -#include <stdio.h> -#include <string.h> - -//#define DEBUG -//#define VERBOSE - -#define _LOG(dst, fmt, ...) do { \ - fprintf(dst, "%s:%d " fmt "\n", \ - __FUNCTION__, __LINE__, ##__VA_ARGS__); \ - fflush(dst); \ -} while(0) - -#define LOG_ERR(err, fmt, ...) do { \ - char buf[128]; \ - strerror_r(err, buf, sizeof(buf)); \ - _LOG(stderr, "ERROR " fmt ": %s", ##__VA_ARGS__, buf); \ -} while(0) - -#define LOG_INFO(fmt, ...) do { \ - _LOG(stdout, fmt, ##__VA_ARGS__); \ -} while(0) - -#ifdef DEBUG -#define LOG_DBG(fmt, ...) do { \ - _LOG(stdout, fmt, ##__VA_ARGS__); \ -} while(0) -#else -#define LOG_DBG(fmt, ...) -#endif - -#ifdef VERBOSE -#define LOG_VER(fmt, ...) do { \ - _LOG(stdout, fmt, ##__VA_ARGS__); \ -} while(0) -#else -#define LOG_VER(fmt, ...) -#endif - -#endif diff --git a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/watch-fc.sh b/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/watch-fc.sh deleted file mode 100755 index d04b7cd..0000000 --- a/meta-facebook/meta-wedge/recipes-wedge/fbutils/files/watch-fc.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# -# Copyright 2014-present Facebook. All Rights Reserved. -# -# This program file is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; version 2 of the License. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program in a file named COPYING; if not, write to the -# Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, -# Boston, MA 02110-1301 USA -# - -. /usr/local/fbpackages/utils/ast-functions - -MAC1LINK=0 # GPIOA0 -FAB0_PRES=20 # GPIOC4 -FAB1_PRES=21 # GPIOC5 -while true; do - # fabN_pres: active low. - if [ $(gpio_get $FAB0_PRES) = 0 ]; then - gpio_set $MAC1LINK 0 - elif [ $(gpio_get $FAB1_PRES) = 0 ]; then - gpio_set $MAC1LINK 1 - fi - sleep 1 -done diff --git a/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf b/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf index 44b6595..266a695 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf +++ b/meta-facebook/meta-wedge/recipes-wedge/lm_sensors/files/wedge.conf @@ -7,12 +7,18 @@ bus "i2c-6" "ast_i2c.6" chip "tmp75-i2c-3-48" label temp1 "Inlet Temp" + set temp1_max 70 + set temp1_max_hyst 60 chip "tmp75-i2c-3-49" label temp1 "Switch Temp" + set temp1_max 70 + set temp1_max_hyst 60 chip "tmp75-i2c-3-4a" label temp1 "Outlet Temp" + set temp1_max 70 + set temp1_max_hyst 60 chip "tmp75-i2c-4-4c" label temp1 "Microserver Ambient Temp" diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile index 926bf52..fa1e932 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/Makefile @@ -15,7 +15,7 @@ # 51 Franklin Street, Fifth Floor, # Boston, MA 02110-1301 USA -override CFLAGS+=-D_GNU_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309 -Wall -Werror -std=c99 +override CFLAGS+=-D_GNU_SOURCE -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=199309 -Wall -Werror -std=c99 override LDFLAGS+=-pthread all: modbuscmd gpiowatch modbussim rackmond rackmondata diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py index a92cf8e..34a64f8 100755 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/psu-update-delta.py @@ -2,11 +2,15 @@ from __future__ import print_function import os.path +import os +import fcntl import socket import struct import sys import argparse import traceback +import json +from tempfile import mkstemp import hexfile @@ -18,8 +22,32 @@ def auto_int(x): parser = argparse.ArgumentParser() parser.add_argument('--addr', type=auto_int, required=True, help="PSU Modbus Address") +parser.add_argument('--statusfile', default=None, + help="Write status to JSON file during process") +parser.add_argument('--rmfwfile', action='store_true', + help="Delete FW file after update completes") parser.add_argument('file', help="firmware file") +status = { + 'pid': os.getpid(), + 'state': 'started' +} + +statuspath = None + +def write_status(): + global status + if statuspath is None: + return + tmppath = statuspath + '~' + with open(tmppath, 'wb') as tfh: + tfh.write(json.dumps(status)) + os.rename(tmppath, statuspath) + +def status_state(state): + global status + status['state'] = state + write_status() class ModbusTimeout(Exception): pass @@ -193,6 +221,7 @@ def write_data(addr, data): def send_image(addr, fwimg): + global statuspath total_chunks = sum([len(s) for s in fwimg.segments]) / 8 sent_chunks = 0 for s in fwimg.segments: @@ -205,11 +234,15 @@ def send_image(addr, fwimg): if len(chunk) < 8: chunk = chunk + ("\xFF" * (8 - len(chunk))) sent_chunks += 1 - print("\r[%.2f%%] Sending chunk %d of %d..." % - (sent_chunks * 100.0 / total_chunks, - sent_chunks, total_chunks), end="") + # dont fill the restapi log with junk + if statuspath is None: + print("\r[%.2f%%] Sending chunk %d of %d..." % + (sent_chunks * 100.0 / total_chunks, + sent_chunks, total_chunks), end="") sys.stdout.flush() write_data(addr, str(bytearray(chunk))) + status['flash_progress_percent'] = sent_chunks * 100.0 / total_chunks + write_status() print("") @@ -241,28 +274,45 @@ def erase_flash(addr): def update_psu(addr, filename): + status_state('pausing_monitoring') pause_monitoring() + status_state('parsing_fw_file') fwimg = hexfile.load(filename) + status_state('bootloader_handshake') enter_bootloader(addr) start_programming(addr) challenge = get_challenge(addr) send_key(addr, delta_seccalckey(challenge)) + status_state('erase_flash') erase_flash(addr) + status_state('flashing') send_image(addr, fwimg) + status_state('verifying') verify_flash(addr) + status_state('resetting') reset_psu(addr) + status_state('done') def main(): args = parser.parse_args() + global statuspath + statuspath = args.statusfile + print("statusfile %s" % statuspath) try: update_psu(args.addr, args.file) - except: - traceback.print_exc() + except Exception, e: print("Firmware update failed") + global status + status['exception'] = traceback.format_exc() + status_state('failed') resume_monitoring() + if args.rmfwfile: + os.remove(args.file) sys.exit(1) resume_monitoring() + if args.rmfwfile: + os.remove(args.file) sys.exit(0) if __name__ == "__main__": diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py index e93dfae..130f26f 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmon-config.py @@ -1,7 +1,4 @@ -from __future__ import print_function -import struct -import socket -import os, os.path +from rackmond import configure_rackmond reglist = [ {"begin": 0x0, #MFR_MODEL @@ -26,68 +23,198 @@ reglist = [ "length": 1, "keep": 10, # 10-sample ring buffer "flags": 1}, + {"begin": 0x6B, #BBU Battery Mode + "length": 1, + "keep": 10, # 10-sample ring buffer + "flags": 1}, + {"begin": 0x6C, #BBU Battery Status + "length": 1, + "keep": 10, # 10-sample ring buffer + "flags": 1}, + {"begin": 0x6D, #BBU Cell Voltage 1 + "length": 1, + "keep": 10}, + {"begin": 0x6E, #BBU Cell Voltage 2 + "length": 1, + "keep": 10}, + {"begin": 0x6F, #BBU Cell Voltage 3 + "length": 1, + "keep": 10}, + {"begin": 0x70, #BBU Cell Voltage 4 + "length": 1, + "keep": 10}, + {"begin": 0x71, #BBU Cell Voltage 5 + "length": 1, + "keep": 10}, + {"begin": 0x72, #BBU Cell Voltage 6 + "length": 1, + "keep": 10}, + {"begin": 0x73, #BBU Cell Voltage 7 + "length": 1, + "keep": 10}, + {"begin": 0x74, #BBU Cell Voltage 8 + "length": 1, + "keep": 10}, + {"begin": 0x75, #BBU Cell Voltage 9 + "length": 1, + "keep": 10}, + {"begin": 0x76, #BBU Cell Voltage 10 + "length": 1, + "keep": 10}, + {"begin": 0x77, #BBU Cell Voltage 11 + "length": 1, + "keep": 10}, + {"begin": 0x78, #BBU Cell Voltage 12 + "length": 1, + "keep": 10}, + {"begin": 0x79, #BBU Cell Voltage 13 + "length": 1, + "keep": 10}, + {"begin": 0x7A, #BBU Temp 1 + "length": 1, + "keep": 10}, + {"begin": 0x7B, #BBU Temp 2 + "length": 1, + "keep": 10}, + {"begin": 0x7C, #BBU Temp 3 + "length": 1, + "keep": 10}, + {"begin": 0x7D, #BBU Temp 4 + "length": 1, + "keep": 10}, + {"begin": 0x7E, #BBU Relative State of Charge + "length": 1, + "keep": 10}, + {"begin": 0x7F, #BBU Absolute State of Charge + "length": 1, + "keep": 10}, {"begin": 0x80, #Input VAC "length": 1, "keep": 10}, + {"begin": 0x81, #BBU Battery Voltage + "length": 1, + "keep": 10}, {"begin": 0x82, #Input Current AC "length": 1, "keep": 10}, + {"begin": 0x83, #BBU Battery Current + "length": 1, + "keep": 10}, {"begin": 0x84, #Battery Voltage "length": 1, "keep": 10}, + {"begin": 0x85, #BBU Average Current + "length": 1, + "keep": 10}, {"begin": 0x86, #Battery Current Output "length": 1}, + {"begin": 0x87, #BBU Remaining Capacity + "length": 1, + "keep": 10}, {"begin": 0x88, #Battery Current Input "length": 1}, + {"begin": 0x89, #BBU Full Charge Capacity + "length": 1, + "keep": 10}, {"begin": 0x8A, #Output Voltage (main converter) "length": 1, "keep": 10}, + {"begin": 0x8B, #BBU Run Time to Empty + "length": 1, + "keep": 10}, {"begin": 0x8C, #Output Current (main converter) "length": 1, "keep": 10}, + {"begin": 0x8D, #BBU Average Time to Empty + "length": 1, + "keep": 10}, {"begin": 0x8E, #IT Load Voltage Output "length": 1}, + {"begin": 0x8F, #BBU Charging Current + "length": 1}, {"begin": 0x90, #IT Load Current Output "length": 1}, + {"begin": 0x91, #BBU Charging Voltage + "length": 1, + "keep": 10}, {"begin": 0x92, #Bulk Cap Voltage "length": 1}, + {"begin": 0x93, #BBU Cycle Count + "length": 1, + "keep": 10}, {"begin": 0x94, #Input Power "length": 1, "keep": 10}, + {"begin": 0x95, #BBU Design Capacity + "length": 1}, {"begin": 0x96, #Output Power "length": 1, "keep": 10}, + {"begin": 0x97, #BBU Design Voltage + "length": 1}, {"begin": 0x98, #RPM Fan 0 "length": 1}, + {"begin": 0x99, #BBU At Rate + "length": 1}, {"begin": 0x9A, #RPM Fan 1 "length": 1}, + {"begin": 0x9B, #BBU At Rate Time to Full + "length": 1, + "keep": 10}, + {"begin": 0x9C, #BBU At Rate Time to Empty + "length": 1, + "keep": 10}, + {"begin": 0x9D, #BBU At Rate OK + "length": 1, + "keep": 10}, {"begin": 0x9E, #Temp 0 "length": 1}, + {"begin": 0x9F, #BBU Temp + "length": 1}, {"begin": 0xA0, #Temp 1 "length": 1}, + {"begin": 0xA1, #BBU Max Error + "length": 1}, + {"begin": 0xD0, #General Alarm Status Register + "length": 1}, + {"begin": 0xD1, #PFC Alarm Status Register + "length": 1}, + {"begin": 0xD2, #LLC Alarm Status Register + "length": 1}, + {"begin": 0xD3, #Current Feed Alarm Status Register + "length": 1}, + {"begin": 0xD4, #Auxiliary Alarm Status Register + "length": 1}, + {"begin": 0xD5, #Battery Charger Alarm Status Register + "length": 1}, + {"begin": 0xD7, #Temperature Alarm Status Register + "length": 1}, + {"begin": 0xD8, #Fan Alarm Status Register + "length": 1}, + {"begin": 0xD9, #Communication Alarm Status Register + "length": 1}, + {"begin": 0x106, #BBU Specification Info + "length": 1}, + {"begin": 0x107, #BBU Manufacturer Date + "length": 1}, + {"begin": 0x108, #BBU Serial Number + "length": 1}, + {"begin": 0x109, #BBU Device Chemistry + "length": 2}, + {"begin": 0x10B, #BBU Manufacturer Data + "length": 2}, + {"begin": 0x10D, #BBU Manufacturer Name + "length": 8}, + {"begin": 0x115, #BBU Device Name + "length": 8}, + {"begin": 0x11D, #FB Battery Status + "length": 4}, + {"begin": 0x121, #SoH results + "length": 1}, ] def main(): - COMMAND_TYPE_SET_CONFIG = 2 - config_command = struct.pack("@HxxH", - COMMAND_TYPE_SET_CONFIG, - len(reglist)) - for r in reglist: - keep = 1 - if "keep" in r: - keep = r["keep"] - flags = 0 - if "flags" in r: - flags = r["flags"] - monitor_interval = struct.pack("@HHHH", r["begin"], r["length"], keep, flags) - config_command += monitor_interval - - config_packet = struct.pack("H", len(config_command)) + config_command - srvpath = "/var/run/rackmond.sock" - if os.path.exists(srvpath): - client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - client.connect(srvpath) - client.send(config_packet) + configure_rackmond(reglist) if __name__ == "__main__": main() diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmond.py b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmond.py new file mode 100644 index 0000000..35dbaa5 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/rackmond.py @@ -0,0 +1,26 @@ +import struct +import socket +import os, os.path + +def configure_rackmond(reglist): + COMMAND_TYPE_SET_CONFIG = 2 + config_command = struct.pack("@HxxH", + COMMAND_TYPE_SET_CONFIG, + len(reglist)) + for r in reglist: + keep = 1 + if "keep" in r: + keep = r["keep"] + flags = 0 + if "flags" in r: + flags = r["flags"] + monitor_interval = struct.pack("@HHHH", r["begin"], r["length"], keep, flags) + config_command += monitor_interval + + config_packet = struct.pack("H", len(config_command)) + config_command + srvpath = "/var/run/rackmond.sock" + if os.path.exists(srvpath): + client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + client.connect(srvpath) + client.send(config_packet) + diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh index 85a1e22..b592a35 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon/setup-rackmond.sh @@ -16,5 +16,5 @@ echo -n "Starting rackmon background service..." echo "done." echo -n "Configuring rackmon service..." -python /etc/rackmon-config.py +PYTHONPATH=/etc python /etc/rackmon-config.py echo "done." diff --git a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb index 399f7c0..c7e78c9 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb +++ b/meta-facebook/meta-wedge/recipes-wedge/rackmon/rackmon_0.1.bb @@ -34,6 +34,7 @@ SRC_URI = "file://Makefile \ file://rackmondata.c \ file://setup-rackmond.sh \ file://rackmon-config.py \ + file://rackmond.py \ file://psu-update-delta.py \ file://hexfile.py \ " @@ -66,6 +67,7 @@ do_install() { install -d ${D}${sysconfdir}/rcS.d install -m 755 setup-rackmond.sh ${D}${sysconfdir}/init.d/setup-rackmond.sh install -m 755 rackmon-config.py ${D}${sysconfdir}/rackmon-config.py + install -m 755 rackmond.py ${D}${sysconfdir}/rackmond.py update-rc.d -r ${D} setup-rackmond.sh start 95 2 3 4 5 . } diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/bmc_command.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/bmc_command.py new file mode 100644 index 0000000..d4dc877 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/bmc_command.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python +# +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import os +import subprocess +import select +import sys +import time + +DEFAULT_TIMEOUT = 10 #sec + +# Note: Python 3.0 supports communicate() with a timeout option. +# If we upgrade to this version we will no longer need timed_communicate + +class TimeoutError(Exception): + def __init__(self, output, error): + super(TimeoutError, self).__init__('process timed out') + self.output = output + self.error = error + +class WaitTimeoutError(Exception): + pass + +def kill_process(proc): + proc.terminate() + try: + timed_wait(proc, 0.1) + except WaitTimeoutError: + proc.kill() + try: + timed_wait(proc, 0.1) + except WaitTimeoutError: + # This can happen if the process is stuck waiting inside a system + # call for a long time. There isn't much we can do unless we want + # to keep waiting forever. Just give up. The child process will + # remain around as a zombie until we exit. + pass + +def timed_wait(proc, timeout): + # There unfortunately isn't a great way to wait for a process with a + # timeout, other than polling. (Registering for SIGCHLD and sleeping might + # be one option, but that's fragile and not thread-safe.) + poll_interval = 0.1 + end_time = time.time() + timeout + while True: + if proc.poll() is not None: + return + time_left = max(end_time - time.time(), 0) + if time_left <= 0: + raise WaitTimeoutError() + time.sleep(min(time_left, poll_interval)) + +def timed_communicate(proc, timeout=DEFAULT_TIMEOUT): + end_time = time.time() + timeout + + p = select.poll() + outfd = proc.stdout.fileno() + errfd = proc.stderr.fileno() + p.register(outfd, select.POLLIN) + p.register(errfd, select.POLLIN) + results = {outfd: [], errfd: []} + remaining_fds = set([outfd, errfd]) + + bufsize = 4096 + while remaining_fds: + time_left = max(end_time - time.time(), 0) + r = p.poll(time_left * 1000) # poll() takes timeout in milliseconds + if not r: + kill_process(proc) + raise TimeoutError(b''.join(results[outfd]), + b''.join(results[errfd])) + for fd, flags in r: + # We didn't put the fds in non-blocking mode, but we know the fd + # has data to read, so os.read() will return immediately. + d = os.read(fd, bufsize) + if d: + results[fd].append(d) + else: + # EOF on this fd, stop listening on it + p.unregister(fd) + remaining_fds.remove(fd) + + try: + timed_wait(proc, max(end_time - time.time(), 0)) + except WaitTimeoutError: + kill_process(proc) + raise TimeoutError(b''.join(results[outfd]), + b''.join(results[errfd])) + + return b''.join(results[outfd]), b''.join(results[errfd]) diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py index 52c98d9..af3e75d 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest.py @@ -18,11 +18,13 @@ # Boston, MA 02110-1301 USA # - from ctypes import * -from bottle import route, run, template, request, response, ServerAdapter -from bottle import abort -from wsgiref.simple_server import make_server, WSGIRequestHandler, WSGIServer +import bottle +from cherrypy.wsgiserver import CherryPyWSGIServer +from cherrypy.wsgiserver.ssl_pyopenssl import pyOpenSSLAdapter +import datetime +import logging +import logging.config import json import ssl import socket @@ -34,13 +36,43 @@ import rest_bmc import rest_gpios import rest_modbus import rest_slotid +import rest_psu_update CONSTANTS = { 'certificate': '/usr/lib/ssl/certs/rest_server.pem', + 'key': '/usr/lib/ssl/private/rest_server_key.pem', +} + +LOGGER_CONF = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'default': { + 'format': '%(message)s' + }, + }, + 'handlers': { + 'file_handler': { + 'level': 'INFO', + 'formatter':'default', + 'class': 'logging.handlers.RotatingFileHandler', + 'filename':'/tmp/rest.log', + 'maxBytes': 1048576, + 'backupCount': 3, + 'encoding': 'utf8' + }, + }, + 'loggers': { + '': { + 'handlers': ['file_handler'], + 'level': 'DEBUG', + 'propagate': True, + }, + } } # Handler for root resource endpoint -@route('/api') +@bottle.route('/api') def rest_api(): result = { "Information": { @@ -53,7 +85,7 @@ def rest_api(): return result # Handler for sys resource endpoint -@route('/api/sys') +@bottle.route('/api/sys') def rest_sys(): result = { "Information": { @@ -67,7 +99,7 @@ def rest_sys(): return result # Handler for sys/mb resource endpoint -@route('/api/sys/mb') +@bottle.route('/api/sys/mb') def rest_sys(): result = { "Information": { @@ -80,73 +112,110 @@ def rest_sys(): return result # Handler for sys/mb/fruid resource endpoint -@route('/api/sys/mb/fruid') +@bottle.route('/api/sys/mb/fruid') def rest_fruid_hdl(): return rest_fruid.get_fruid() # Handler for sys/bmc resource endpoint -@route('/api/sys/bmc') +@bottle.route('/api/sys/bmc') def rest_bmc_hdl(): return rest_bmc.get_bmc() # Handler for sys/server resource endpoint -@route('/api/sys/server') +@bottle.route('/api/sys/server') def rest_server_hdl(): return rest_server.get_server() # Handler for uServer resource endpoint -@route('/api/sys/server', method='POST') +@bottle.route('/api/sys/server', method='POST') def rest_server_act_hdl(): data = json.load(request.body) return rest_server.server_action(data) # Handler for sensors resource endpoint -@route('/api/sys/sensors') +@bottle.route('/api/sys/sensors') def rest_sensors_hdl(): return rest_sensors.get_sensors() # Handler for sensors resource endpoint -@route('/api/sys/gpios') +@bottle.route('/api/sys/gpios') def rest_gpios_hdl(): return rest_gpios.get_gpios() -@route('/api/sys/modbus_registers') +@bottle.route('/api/sys/modbus_registers') def modbus_registers_hdl(): return rest_modbus.get_modbus_registers() +@bottle.route('/api/sys/psu_update') +def psu_update_hdl(): + return rest_psu_update.get_jobs() + +@bottle.route('/api/sys/psu_update', method='POST') +def psu_update_hdl(): + data = json.load(request.body) + return rest_psu_update.begin_job(data) + # Handler for sensors resource endpoint -@route('/api/sys/slotid') +@bottle.route('/api/sys/slotid') def rest_slotid_hdl(): return rest_slotid.get_slotid() -run(host = "::", port = 8080) - # SSL Wrapper for Rest API -class SSLWSGIRefServer(ServerAdapter): +class SSLCherryPyServer(bottle.ServerAdapter): def run(self, handler): - if self.quiet: - class QuietHandler(WSGIRequestHandler): - def log_request(*args, **kw): pass - self.options['handler_class'] = QuietHandler - - # IPv6 Support - server_cls = self.options.get('server_class', WSGIServer) - - if ':' in self.host: - if getattr(server_cls, 'address_family') == socket.AF_INET: - class server_cls(server_cls): - address_family = socket.AF_INET6 - - srv = make_server(self.host, self.port, handler, - server_class=server_cls, **self.options) - srv.socket = ssl.wrap_socket ( - srv.socket, - certfile=CONSTANTS['certificate'], - server_side=True) - srv.serve_forever() - -# Use SSL if the certificate exists. Otherwise, run without SSL. -if os.access(CONSTANTS['certificate'], os.R_OK): - run(server=SSLWSGIRefServer(host="::", port=8443)) + server = CherryPyWSGIServer((self.host, self.port), handler) + server.ssl_adapter = pyOpenSSLAdapter(CONSTANTS['certificate'], CONSTANTS['key']) + try: + server.start() + finally: + server.stop() + + +def log_after_request(): + try: + length = bottle.response.content_length + except: + try: + length = len(bottle.response.body) + except: + length = 0 + + logging.info('{} - - [{}] "{} {} {}" {} {}'.format( + bottle.request.environ.get('REMOTE_ADDR'), + datetime.datetime.now().strftime('%d/%b/%Y %H:%M:%S'), + bottle.request.environ.get('REQUEST_METHOD'), + bottle.request.environ.get('REQUEST_URI'), + bottle.request.environ.get('SERVER_PROTOCOL'), + bottle.response.status_code, + length)) + + +# Error logging to log file +class ErrorLogging(object): + def write(self, err): + logging.error(err) + + +# Middleware to log the requests +class LogMiddleware(object): + def __init__(self, app): + self.app = app + + def __call__(self, e, h): + e['wsgi.errors'] = ErrorLogging() + ret_val = self.app(e, h) + log_after_request() + return ret_val + +# overwrite the stderr and stdout to log to the file +bottle._stderr = logging.error +bottle._stdout = logging.info +logging.config.dictConfig(LOGGER_CONF) + +bottle_app = LogMiddleware(bottle.app()) +# Use SSL if the certificate and key exists. Otherwise, run without SSL. +if (os.access(CONSTANTS['key'], os.R_OK) and + os.access(CONSTANTS['certificate'], os.R_OK)): + bottle.run(host = "::", port= 8443, server=SSLCherryPyServer, app=bottle_app) else: - run(host = "::", port = 8080) + bottle.run(host = "::", port = 8080, server='cherrypy', app=bottle_app) diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py index 167e1fa..3248e92 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_fruid.py @@ -29,9 +29,10 @@ class FRU(Structure): ("fbw_product_name", c_char * 13), ("fbw_product_number", c_char * 10), ("fbw_assembly_number", c_char * 15), + ("fbw_facebook_pcba_number", c_char * 15), ("fbw_facebook_pcb_number", c_char * 15), - ("fbw_odm_pcb_number", c_char * 14), - ("fbw_odm_pcb_serial", c_char * 13), + ("fbw_odm_pcba_number", c_char * 14), + ("fbw_odm_pcba_serial", c_char * 13), ("fbw_production_state", c_ubyte), ("fbw_product_version", c_ubyte), ("fbw_product_subversion", c_ubyte), @@ -59,9 +60,10 @@ def get_fruid(): "Product Name": myfru.fbw_product_name, "Product Part Number": myfru.fbw_product_number, "System Assembly Part Number": myfru.fbw_assembly_number, + "Facebook PCBA Part Number": myfru.fbw_facebook_pcba_number, "Facebook PCB Part Number": myfru.fbw_facebook_pcb_number, - "ODM PCB Part Number": myfru.fbw_odm_pcb_number, - "ODM PCB Serial Number": myfru.fbw_odm_pcb_serial, + "ODM PCBA Part Number": myfru.fbw_odm_pcba_number, + "ODM PCBA Serial Number": myfru.fbw_odm_pcba_serial, "Product Production State": myfru.fbw_production_state, "Product Version": myfru.fbw_product_version, "Product Sub-Version": myfru.fbw_product_subversion, diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_psu_update.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_psu_update.py new file mode 100644 index 0000000..d0e57c7 --- /dev/null +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_psu_update.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# +# Copyright 2014-present Facebook. All Rights Reserved. +# +# This program file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program in a file named COPYING; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# + +import subprocess +from subprocess import Popen +import os +import os.path +import json +import uuid +import urllib2 +from tempfile import mkstemp +from bottle import HTTPError + +UPDATE_JOB_DIR = '/var/rackmond/update_jobs' +UPDATERS = {'delta': '/usr/local/bin/psu-update-delta.py'} + +def get_jobs(): + jobs = [] + if not os.path.exists(UPDATE_JOB_DIR): + os.makedirs(UPDATE_JOB_DIR) + for f in os.listdir(UPDATE_JOB_DIR): + fullpath = os.path.join(UPDATE_JOB_DIR, f) + if f.endswith('.json') and os.path.isfile(fullpath): + with open(fullpath, 'r') as fh: + jdata = json.load(fh) + jdata['job_id'] = os.path.splitext(f)[0] + jobs.append(jdata) + return {'jobs': jobs} + +updater_process = None +def begin_job(jobdesc): + global updater_process + if updater_process is not None: + if updater_process.poll() is not None: + # Update complete + updater_process = None + else: + body = {'error': 'update_already_running', + 'pid': updater_process.pid } + raise HTTPError(409, body) + job_id = str(uuid.uuid1()) + (fwfd, fwfilepath) = mkstemp() + if not os.path.exists(UPDATE_JOB_DIR): + os.makedirs(UPDATE_JOB_DIR) + statusfilepath = os.path.join(UPDATE_JOB_DIR, str(job_id) + '.json') + status = {'pid': 0, + 'state': 'fetching' } + with open(statusfilepath, 'wb') as sfh: + sfh.write(json.dumps(status)) + fwdata = urllib2.urlopen(jobdesc['fw_url']) + with os.fdopen(fwfd, 'wb') as fwfile: + fwfile.write(fwdata.read()) + fwfile.flush() + updater = UPDATERS[jobdesc.get('updater', 'delta')] + updater_process = Popen([updater, + '--addr', str(jobdesc['address']), + '--statusfile', statusfilepath, + '--rmfwfile', + fwfilepath]) + status = {'pid': updater_process.pid, + 'state': 'starting' } + with open(statusfilepath, 'wb') as sfh: + sfh.write(json.dumps(status)) + return {'job_id': job_id, 'pid': updater_process.pid} diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py index fa65372..382513b 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/rest_sensors.py @@ -18,15 +18,23 @@ # Boston, MA 02110-1301 USA # - import json -import os import re +import subprocess +import bmc_command # Handler for sensors resource endpoint def get_sensors(): result = [] - data = os.popen('sensors').read() + proc = subprocess.Popen(['sensors'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + try: + data, err = bmc_command.timed_communicate(proc) + except bmc_command.TimeoutError as ex: + data = ex.output + err = ex.error + data = re.sub(r'\(.+?\)', '', data) for edata in data.split('\n\n'): adata = edata.split('\n', 1) @@ -40,6 +48,7 @@ def get_sensors(): continue sresult[tdata[0].strip()] = tdata[1].strip() result.append(sresult) + fresult = { "Information": result, "Actions": [], diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh index bdd79b6..2b274dc 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/files/setup-rest-api.sh @@ -27,6 +27,53 @@ # Short-Description: Set REST API handler ### END INIT INFO -echo -n "Setup REST API handler... " -/usr/local/bin/rest.py > /tmp/rest.log 2>&1 & -echo "done." +# source function library +. /etc/init.d/functions + +ACTION="$1" +CMD="/usr/local/bin/rest.py" +case "$ACTION" in + start) + echo -n "Setting up REST API handler: " + pid=$(ps | grep -v grep | grep $CMD | awk '{print $1}') + if [ $pid ]; then + echo "already running" + else + $CMD > /tmp/rest_start.log 2>&1 & + echo "done." + fi + ;; + stop) + echo -n "Stopping REST API handler: " + pid=$(ps | grep -v grep | grep $CMD | awk '{print $1}') + if [ $pid ]; then + kill $pid + fi + echo "done." + ;; + restart) + echo -n "Restarting REST API handler: " + pid=$(ps | grep -v grep | grep $CMD | awk '{print $1}') + if [ $pid ]; then + kill $pid + fi + sleep 1 + $CMD > /tmp/rest_start.log 2>&1 & + echo "done." + ;; + status) + if [[ -n $(ps | grep -v grep | grep $CMD | awk '{print $1}') ]]; then + echo "REST API handler is running" + else + echo "REST API is stopped" + fi + ;; + *) + N=${0##*/} + N=${N#[SK]??} + echo "Usage: $N {start|stop|status|restart}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb index 5dec4bf..2ed3f7f 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb +++ b/meta-facebook/meta-wedge/recipes-wedge/rest-api/rest-api_0.1.bb @@ -33,11 +33,13 @@ SRC_URI = "file://setup-rest-api.sh \ file://rest_sensors.py \ file://rest_modbus.py \ file://rest_slotid.py \ + file://rest_psu_update.py \ + file://bmc_command.py \ " S = "${WORKDIR}" -binfiles = "rest.py rest_bmc.py rest_fruid.py rest_gpios.py rest_server.py rest_sensors.py rest_modbus.py rest_slotid.py setup-rest-api.sh" +binfiles = "rest.py rest_bmc.py rest_fruid.py rest_gpios.py rest_server.py rest_sensors.py bmc_command.py rest_modbus.py rest_slotid.py rest_psu_update.py setup-rest-api.sh" pkgdir = "rest-api" diff --git a/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh b/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh index 0030775..2e1ee67 100755 --- a/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh +++ b/meta-facebook/meta-wedge/recipes-wedge/usb-console/files/usbmon.sh @@ -19,6 +19,15 @@ # modprobe g_cdc host_addr=02:00:00:00:00:02 dev_addr=02:00:00:00:00:01 +# For g-ether interface, if the remote side brings down the interface, BMC side +# still treats it as up. In this case, all packets through usb0 (i.e. NDP) will +# be queued in the kernel for this interface. Ether interface has the default +# TX queue length as 1000, which means there could be up to 1000 package queued +# in kernel for that. In our case, kmalloc-192 is exhausted when 298 packets +# are queued. +# To solve this issue, we change the TX queue length for usb0 to 64 to avoid +# memory exhaust. +ifconfig usb0 txqueuelen 64 while true; do getty /dev/ttyGS0 57600 sleep 1 diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c index e66941e..7e9b50d 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.c @@ -29,8 +29,10 @@ #define FBW_EEPROM_FILE "/sys/class/i2c-adapter/i2c-6/6-0050/eeprom" #endif -#define FBW_EEPROM_VERSION 0 +#define FBW_EEPROM_VERSION0 0 #define FBW_EEPROM_V0_SIZE 162 +#define FBW_EEPROM_VERSION1 1 +#define FBW_EEPROM_V1_SIZE 174 /* * The eeprom size is 8K, we only use 157 bytes for v1 format. @@ -225,12 +227,17 @@ static int fbw_parse_buffer( /* confirm the version number, only version is supported */ fbw_copy_uint8(&eeprom->fbw_version, &cur, FBW_EEPROM_F_VERSION); - if (eeprom->fbw_version != FBW_EEPROM_VERSION) { + if ((eeprom->fbw_version != FBW_EEPROM_VERSION0) && + (eeprom->fbw_version != FBW_EEPROM_VERSION1)) { rc = EFAULT; LOG_ERR(rc, "Unsupported version number %u", eeprom->fbw_version); goto out; } else { - crc_len = FBW_EEPROM_V0_SIZE; + if (eeprom->fbw_version == FBW_EEPROM_VERSION0) { + crc_len = FBW_EEPROM_V0_SIZE; + } else if (eeprom->fbw_version == FBW_EEPROM_VERSION1) { + crc_len = FBW_EEPROM_V1_SIZE; + } assert(crc_len <= len); } @@ -257,20 +264,27 @@ static int fbw_parse_buffer( sizeof(eeprom->fbw_assembly_number), &cur, FBW_EEPROM_F_ASSEMBLY_NUMBER); - /* Facebook PCB Part Number: XXX-XXXXXXX-XX */ - fbw_copy_facebook_pcb_part(eeprom->fbw_facebook_pcb_number, - sizeof(eeprom->fbw_facebook_pcb_number), - &cur, FBW_EEPROM_F_FACEBOOK_PCB_NUMBER); + /* Facebook PCBA Part Number: XXX-XXXXXXX-XX */ + fbw_copy_facebook_pcb_part(eeprom->fbw_facebook_pcba_number, + sizeof(eeprom->fbw_facebook_pcba_number), + &cur, FBW_EEPROM_F_FACEBOOK_PCBA_NUMBER); + + /* Facebook PCBA Part Number: XXX-XXXXXXX-XX */ + if (eeprom->fbw_version >= FBW_EEPROM_VERSION1) { + fbw_copy_facebook_pcb_part(eeprom->fbw_facebook_pcb_number, + sizeof(eeprom->fbw_facebook_pcb_number), + &cur, FBW_EEPROM_F_FACEBOOK_PCB_NUMBER); + } /* ODM PCB Part Number: XXXXXXXXXXXX */ - fbw_strcpy(eeprom->fbw_odm_pcb_number, - sizeof(eeprom->fbw_odm_pcb_number), - &cur, FBW_EEPROM_F_ODM_PCB_NUMBER); + fbw_strcpy(eeprom->fbw_odm_pcba_number, + sizeof(eeprom->fbw_odm_pcba_number), + &cur, FBW_EEPROM_F_ODM_PCBA_NUMBER); /* ODM PCB Serial Number: XXXXXXXXXXXX */ - fbw_strcpy(eeprom->fbw_odm_pcb_serial, - sizeof(eeprom->fbw_odm_pcb_serial), - &cur, FBW_EEPROM_F_ODM_PCB_SERIAL); + fbw_strcpy(eeprom->fbw_odm_pcba_serial, + sizeof(eeprom->fbw_odm_pcba_serial), + &cur, FBW_EEPROM_F_ODM_PCBA_SERIAL); /* Product Production State */ fbw_copy_uint8(&eeprom->fbw_production_state, diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h index 2c4f39e..8aa012f 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/lib/wedge_eeprom.h @@ -29,9 +29,10 @@ extern "C" { #define FBW_EEPROM_F_PRODUCT_NAME 12 #define FBW_EEPROM_F_PRODUCT_NUMBER 8 #define FBW_EEPROM_F_ASSEMBLY_NUMBER 12 +#define FBW_EEPROM_F_FACEBOOK_PCBA_NUMBER 12 #define FBW_EEPROM_F_FACEBOOK_PCB_NUMBER 12 -#define FBW_EEPROM_F_ODM_PCB_NUMBER 13 -#define FBW_EEPROM_F_ODM_PCB_SERIAL 12 +#define FBW_EEPROM_F_ODM_PCBA_NUMBER 13 +#define FBW_EEPROM_F_ODM_PCBA_SERIAL 12 #define FBW_EEPROM_F_PRODUCT_STATE 1 #define FBW_EEPROM_F_PRODUCT_VERSION 1 #define FBW_EEPROM_F_PRODUCT_SUBVERSION 1 @@ -60,14 +61,17 @@ struct wedge_eeprom_st { /* System Assembly Part Number XXX-XXXXXX-XX */ char fbw_assembly_number[FBW_EEPROM_F_ASSEMBLY_NUMBER + 3]; + /* Facebook PCBA Part Number: XXX-XXXXXXX-XX */ + char fbw_facebook_pcba_number[FBW_EEPROM_F_FACEBOOK_PCBA_NUMBER + 3]; + /* Facebook PCB Part Number: XXX-XXXXXXX-XX */ char fbw_facebook_pcb_number[FBW_EEPROM_F_FACEBOOK_PCB_NUMBER + 3]; /* ODM PCB Part Number: XXXXXXXXXXXX */ - char fbw_odm_pcb_number[FBW_EEPROM_F_ODM_PCB_NUMBER + 1]; + char fbw_odm_pcba_number[FBW_EEPROM_F_ODM_PCBA_NUMBER + 1]; /* ODM PCB Serial Number: XXXXXXXXXXXX */ - char fbw_odm_pcb_serial[FBW_EEPROM_F_ODM_PCB_SERIAL + 1]; + char fbw_odm_pcba_serial[FBW_EEPROM_F_ODM_PCBA_SERIAL + 1]; /* Product Production State */ uint8_t fbw_production_state; @@ -88,7 +92,7 @@ struct wedge_eeprom_st { char fbw_system_manufacturer[FBW_EEPROM_F_SYSTEM_MANUFACTURER + 1]; /* System Manufacturing Date: mm-dd-yy */ - char fbw_system_manufacturing_date[10]; + uint8_t fbw_system_manufacturing_date[10]; /* PCB Manufacturer: XXXXXXXXX */ char fbw_pcb_manufacturer[FBW_EEPROM_F_PCB_MANUFACTURER + 1]; diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c index 90aca10..49d7174 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/files/utils/weutil.c @@ -45,9 +45,10 @@ int main(int argc, const char *argv[]) printf("Product Name: %s\n", eeprom.fbw_product_name); printf("Product Part Number: %s\n", eeprom.fbw_product_number); printf("System Assembly Part Number: %s\n", eeprom.fbw_assembly_number); + printf("Facebook PCBA Part Number: %s\n", eeprom.fbw_facebook_pcba_number); printf("Facebook PCB Part Number: %s\n", eeprom.fbw_facebook_pcb_number); - printf("ODM PCB Part Number: %s\n", eeprom.fbw_odm_pcb_number); - printf("ODM PCB Serial Number: %s\n", eeprom.fbw_odm_pcb_serial); + printf("ODM PCBA Part Number: %s\n", eeprom.fbw_odm_pcba_number); + printf("ODM PCBA Serial Number: %s\n", eeprom.fbw_odm_pcba_serial); printf("Product Production State: %d\n", eeprom.fbw_production_state); printf("Product Version: %d\n", eeprom.fbw_product_version); printf("Product Sub-Version: %d\n", eeprom.fbw_product_subversion); @@ -58,11 +59,11 @@ int main(int argc, const char *argv[]) eeprom.fbw_system_manufacturing_date); printf("PCB Manufacturer: %s\n", eeprom.fbw_pcb_manufacturer); printf("Assembled At: %s\n", eeprom.fbw_assembled); - printf("Local MAC: %X:%X:%X:%X:%X:%X\n", + printf("Local MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", eeprom.fbw_local_mac[0], eeprom.fbw_local_mac[1], eeprom.fbw_local_mac[2], eeprom.fbw_local_mac[3], eeprom.fbw_local_mac[4], eeprom.fbw_local_mac[5]); - printf("Extended MAC Base: %X:%X:%X:%X:%X:%X\n", + printf("Extended MAC Base: %02X:%02X:%02X:%02X:%02X:%02X\n", eeprom.fbw_mac_base[0], eeprom.fbw_mac_base[1], eeprom.fbw_mac_base[2], eeprom.fbw_mac_base[3], eeprom.fbw_mac_base[4], eeprom.fbw_mac_base[5]); diff --git a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb index 3afbed1..ea41a98 100644 --- a/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb +++ b/meta-facebook/meta-wedge/recipes-wedge/wedge-eeprom/wedge-eeprom_0.1.bb @@ -31,6 +31,8 @@ do_install() { install -m 0755 weutil ${D}${bindir}/weutil } +RDEPENDS_${PN} = "libwedge-eeprom" + DEPENDS += "libwedge-eeprom" FILES_${PN} = "${bindir}" |