recovery build
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
parent
5b164e465b
commit
4d8b81a40e
|
@ -1,7 +1,7 @@
|
|||
*/dl
|
||||
*/dl/*
|
||||
download
|
||||
*/output/*
|
||||
*~
|
||||
br.log
|
||||
id_rsa_funkey
|
||||
id_rsa_funkey.pub
|
||||
images
|
||||
|
|
|
@ -13,6 +13,3 @@ rm -f ${TARGET_DIR}/etc/init.d/S01syslogd ${TARGET_DIR}/etc/init.d/S02klogd
|
|||
|
||||
# Change dropbear init sequence
|
||||
mv ${TARGET_DIR}/etc/init.d/S50dropbear ${TARGET_DIR}/etc/init.d/S42dropbear
|
||||
|
||||
# Generate U-Boot environment
|
||||
${HOST_DIR}/bin/mkenvimage -p 0x0 -s 0x20000 -o ${BINARIES_DIR}/u-boot-env.img ${TARGET_DIR}/etc/u-boot.env
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
BR2_arm=y
|
||||
BR2_cortex_a7=y
|
||||
BR2_DL_DIR="$(BR2_EXTERNAL_FUNKEY_PATH)/dl"
|
||||
BR2_DL_DIR="../download"
|
||||
BR2_CCACHE=y
|
||||
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/patches"
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
|
@ -14,8 +14,6 @@ BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
|
|||
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/users_table.txt"
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/rootfs-overlay"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/post-build.sh"
|
||||
BR2_ROOTFS_POST_IMAGE_SCRIPT="support/scripts/genimage.sh"
|
||||
BR2_ROOTFS_POST_SCRIPT_ARGS="-c $(BR2_EXTERNAL_FUNKEY_PATH)/board/funkey/genimage.cfg"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_GIT=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/FunKey-Project/linux"
|
||||
|
@ -89,6 +87,5 @@ BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y
|
|||
BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
|
||||
BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-sunxi-with-spl.bin"
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_UBOOT_TOOLS=y
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
# Makefile for FunKey-OS
|
||||
#
|
||||
# Copyright (C) 2020 by Michel Stempin <michel.stempin@funkey-project.com>
|
||||
#
|
||||
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
BRMAKE = buildroot/utils/brmake -C buildroot
|
||||
BR = make -C buildroot
|
||||
|
||||
.PHONY: fun source image clean distclean
|
||||
|
||||
.IGNORE: Makefile
|
||||
|
||||
all: fun image
|
||||
|
||||
fun: download Recovery/output/.config FunKey/output/.config
|
||||
@echo "*** Making fun"
|
||||
$(BRMAKE) BR2_EXTERNAL=../Recovery O=../Recovery/output
|
||||
$(BRMAKE) BR2_EXTERNAL=../FunKey O=../FunKey/output
|
||||
|
||||
FunKey/%: download FunKey/output/.config
|
||||
@echo "*** Making $(notdir $@) in $(subst /,,$(dir $@))"
|
||||
$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output $(notdir $@)
|
||||
|
||||
Recovery/%: download Recovery/output/.config
|
||||
@echo "*** Making $(notdir $@) in $(subst /,,$(dir $@))"
|
||||
$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output $(notdir $@)
|
||||
|
||||
%: download FunKey/output/.config
|
||||
@echo "*** Making $* in FunKey"
|
||||
$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output $*
|
||||
|
||||
source:
|
||||
@echo "*** Getting sources"
|
||||
$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output source
|
||||
$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output source
|
||||
|
||||
image:
|
||||
mkdir -p root tmp
|
||||
./Recovery/output/host/bin/genimage --inputpath .
|
||||
rm -rf root tmp
|
||||
|
||||
clean:
|
||||
@echo "*** Clean everything"
|
||||
$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output distclean
|
||||
$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output distclean
|
||||
|
||||
distclean: clean
|
||||
@echo "*** Really clean everything"
|
||||
rm -rf download images
|
||||
|
||||
download:
|
||||
@echo "*** Making download directory"
|
||||
mkdir -rf download
|
||||
|
||||
FunKey/output/.config:
|
||||
@echo "*** Configure FunKey"
|
||||
$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output funkey_defconfig
|
||||
|
||||
Recovery/output/.config:
|
||||
@echo "*** Configure Recovery"
|
||||
$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output recovery_defconfig
|
|
@ -0,0 +1 @@
|
|||
source "$BR2_EXTERNAL_RECOVERY_PATH/package/FunKey-GPIO-Mapping/Config.in"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,173 @@
|
|||
CONFIG_LOCALVERSION="-funkey"
|
||||
CONFIG_KERNEL_LZO=y
|
||||
CONFIG_DEFAULT_HOSTNAME="funkey"
|
||||
CONFIG_NO_HZ=y
|
||||
CONFIG_HIGH_RES_TIMERS=y
|
||||
CONFIG_LOG_BUF_SHIFT=16
|
||||
CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT=12
|
||||
CONFIG_CGROUPS=y
|
||||
CONFIG_EMBEDDED=y
|
||||
CONFIG_PERF_EVENTS=y
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_MODULE_UNLOAD=y
|
||||
CONFIG_PARTITION_ADVANCED=y
|
||||
# CONFIG_MSDOS_PARTITION is not set
|
||||
CONFIG_ARCH_SUNXI=y
|
||||
# CONFIG_MACH_SUN4I is not set
|
||||
# CONFIG_MACH_SUN5I is not set
|
||||
# CONFIG_MACH_SUN6I is not set
|
||||
# CONFIG_MACH_SUN7I is not set
|
||||
# CONFIG_MACH_SUN9I is not set
|
||||
CONFIG_SMP=y
|
||||
CONFIG_HAVE_ARM_ARCH_TIMER=y
|
||||
CONFIG_ARM_PSCI=y
|
||||
CONFIG_HIGHMEM=y
|
||||
CONFIG_CPU_FREQ=y
|
||||
CONFIG_CPUFREQ_DT=y
|
||||
CONFIG_VFP=y
|
||||
CONFIG_NEON=y
|
||||
# CONFIG_COREDUMP is not set
|
||||
CONFIG_HIBERNATION=y
|
||||
CONFIG_PM_STD_PARTITION="/dev/mmcblk0p2"
|
||||
CONFIG_PM_DEBUG=y
|
||||
CONFIG_PM_ADVANCED_DEBUG=y
|
||||
CONFIG_NET=y
|
||||
CONFIG_PACKET=y
|
||||
CONFIG_UNIX=y
|
||||
CONFIG_INET=y
|
||||
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
|
||||
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
|
||||
# CONFIG_INET_XFRM_MODE_BEET is not set
|
||||
# CONFIG_INET_DIAG is not set
|
||||
CONFIG_DNS_RESOLVER=y
|
||||
# CONFIG_WIRELESS is not set
|
||||
CONFIG_DEVTMPFS=y
|
||||
CONFIG_DEVTMPFS_MOUNT=y
|
||||
# CONFIG_ALLOW_DEV_COREDUMP is not set
|
||||
# CONFIG_SUNXI_RSB is not set
|
||||
CONFIG_BLK_DEV_LOOP=y
|
||||
CONFIG_BLK_DEV_LOOP_MIN_COUNT=1
|
||||
CONFIG_SCSI=y
|
||||
CONFIG_BLK_DEV_SD=y
|
||||
CONFIG_NETDEVICES=y
|
||||
# CONFIG_ETHERNET is not set
|
||||
# CONFIG_WLAN is not set
|
||||
CONFIG_INPUT_POLLDEV=y
|
||||
CONFIG_INPUT_EVDEV=y
|
||||
# CONFIG_INPUT_KEYBOARD is not set
|
||||
# CONFIG_INPUT_MOUSE is not set
|
||||
CONFIG_INPUT_MISC=y
|
||||
CONFIG_INPUT_UINPUT=y
|
||||
CONFIG_LEGACY_PTY_COUNT=4
|
||||
CONFIG_SERIAL_8250=y
|
||||
CONFIG_SERIAL_8250_CONSOLE=y
|
||||
CONFIG_SERIAL_8250_NR_UARTS=8
|
||||
CONFIG_SERIAL_8250_RUNTIME_UARTS=8
|
||||
CONFIG_SERIAL_8250_DW=y
|
||||
CONFIG_SERIAL_OF_PLATFORM=y
|
||||
# CONFIG_HW_RANDOM is not set
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_CHARDEV=y
|
||||
CONFIG_I2C_MV64XXX=y
|
||||
CONFIG_SPI=y
|
||||
CONFIG_SPI_SUN6I=y
|
||||
CONFIG_GPIO_SYSFS=y
|
||||
CONFIG_GPIO_AXP209=y
|
||||
CONFIG_POWER_SUPPLY=y
|
||||
CONFIG_CHARGER_AXP20X=y
|
||||
CONFIG_BATTERY_AXP20X=y
|
||||
CONFIG_AXP20X_POWER=y
|
||||
# CONFIG_HWMON is not set
|
||||
CONFIG_THERMAL=y
|
||||
CONFIG_CPU_THERMAL=y
|
||||
CONFIG_WATCHDOG=y
|
||||
CONFIG_SUNXI_WATCHDOG=y
|
||||
CONFIG_MFD_AXP20X_I2C=y
|
||||
CONFIG_MFD_SYSCON=y
|
||||
CONFIG_REGULATOR=y
|
||||
CONFIG_REGULATOR_FIXED_VOLTAGE=y
|
||||
CONFIG_REGULATOR_AXP20X=y
|
||||
# CONFIG_RC_CORE is not set
|
||||
CONFIG_FB=y
|
||||
CONFIG_FB_SIMPLE=y
|
||||
CONFIG_FB_SSD1307=y
|
||||
CONFIG_BACKLIGHT_PWM=y
|
||||
CONFIG_FRAMEBUFFER_CONSOLE=y
|
||||
CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
|
||||
CONFIG_LOGO=y
|
||||
CONFIG_SOUND=y
|
||||
CONFIG_SND=y
|
||||
# CONFIG_SND_DRIVERS is not set
|
||||
# CONFIG_SND_SPI is not set
|
||||
# CONFIG_SND_USB is not set
|
||||
CONFIG_SND_SOC=y
|
||||
CONFIG_SND_SUN4I_CODEC=y
|
||||
CONFIG_SND_SUN8I_CODEC_ANALOG=y
|
||||
# CONFIG_HID is not set
|
||||
# CONFIG_USB_HID is not set
|
||||
CONFIG_USB=y
|
||||
CONFIG_USB_EHCI_HCD=y
|
||||
CONFIG_USB_EHCI_HCD_PLATFORM=y
|
||||
CONFIG_USB_OHCI_HCD=y
|
||||
CONFIG_USB_OHCI_HCD_PLATFORM=y
|
||||
CONFIG_USB_MUSB_HDRC=y
|
||||
CONFIG_USB_MUSB_GADGET=y
|
||||
CONFIG_USB_MUSB_SUNXI=y
|
||||
CONFIG_NOP_USB_XCEIV=y
|
||||
CONFIG_USB_GADGET=y
|
||||
CONFIG_USB_ZERO=m
|
||||
CONFIG_USB_ETH=m
|
||||
CONFIG_USB_ETH_EEM=y
|
||||
CONFIG_USB_G_NCM=m
|
||||
CONFIG_USB_MASS_STORAGE=m
|
||||
CONFIG_USB_G_SERIAL=m
|
||||
CONFIG_USB_G_ACM_MS=m
|
||||
CONFIG_MMC=y
|
||||
# CONFIG_PWRSEQ_EMMC is not set
|
||||
CONFIG_MMC_SUNXI=y
|
||||
CONFIG_RTC_CLASS=y
|
||||
# CONFIG_RTC_INTF_SYSFS is not set
|
||||
# CONFIG_RTC_INTF_PROC is not set
|
||||
CONFIG_DMADEVICES=y
|
||||
CONFIG_DMA_SUN6I=y
|
||||
CONFIG_SYNC_FILE=y
|
||||
CONFIG_STAGING=y
|
||||
CONFIG_FB_TFT=y
|
||||
CONFIG_FB_TFT_ST7789V=y
|
||||
CONFIG_FB_FLEX=y
|
||||
# CONFIG_SUN8I_A23_CCU is not set
|
||||
# CONFIG_SUN8I_A33_CCU is not set
|
||||
# CONFIG_SUN8I_H3_CCU is not set
|
||||
CONFIG_SUN8I_DE2_CCU=y
|
||||
# CONFIG_IOMMU_SUPPORT is not set
|
||||
CONFIG_IIO=y
|
||||
CONFIG_AXP20X_ADC=y
|
||||
CONFIG_PWM_SUN4I=y
|
||||
CONFIG_PHY_SUN4I_USB=y
|
||||
CONFIG_NVMEM_SUNXI_SID=y
|
||||
CONFIG_EXT4_FS=y
|
||||
# CONFIG_EXT4_USE_FOR_EXT2 is not set
|
||||
CONFIG_FANOTIFY=y
|
||||
CONFIG_AUTOFS4_FS=y
|
||||
CONFIG_VFAT_FS=y
|
||||
CONFIG_TMPFS=y
|
||||
CONFIG_CONFIGFS_FS=y
|
||||
# CONFIG_MISC_FILESYSTEMS is not set
|
||||
# CONFIG_NETWORK_FILESYSTEMS is not set
|
||||
CONFIG_NLS_CODEPAGE_437=y
|
||||
CONFIG_NLS_ISO8859_1=y
|
||||
CONFIG_PRINTK_TIME=y
|
||||
# CONFIG_SCHED_DEBUG is not set
|
||||
# CONFIG_DEBUG_BUGVERBOSE is not set
|
||||
# CONFIG_RCU_TRACE is not set
|
||||
# CONFIG_FTRACE is not set
|
||||
# CONFIG_ARM_UNWIND is not set
|
||||
CONFIG_KEYS=y
|
||||
CONFIG_CRYPTO_CCM=y
|
||||
CONFIG_CRYPTO_GCM=y
|
||||
CONFIG_CRYPTO_CMAC=y
|
||||
CONFIG_CRYPTO_ARC4=y
|
||||
CONFIG_CRYPTO_DEFLATE=y
|
||||
CONFIG_CRYPTO_LZO=y
|
||||
CONFIG_CRYPTO_DEV_SUN4I_SS=y
|
||||
CONFIG_XZ_DEC=y
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Add local path to init scripts
|
||||
sed -i '3iexport PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin' ${TARGET_DIR}/etc/init.d/rcK
|
||||
sed -i '3iexport PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin' ${TARGET_DIR}/etc/init.d/rcS
|
||||
|
||||
# Remove log daemon init scripts since they are loaded from inittab
|
||||
rm -f ${TARGET_DIR}/etc/init.d/S01syslogd ${TARGET_DIR}/etc/init.d/S02klogd
|
||||
|
||||
# Change dropbear init sequence
|
||||
mv ${TARGET_DIR}/etc/init.d/S50dropbear ${TARGET_DIR}/etc/init.d/S42dropbear
|
||||
|
||||
# Generate U-Boot environment
|
||||
${HOST_DIR}/bin/mkenvimage -p 0x0 -s 0x20000 -o ${BINARIES_DIR}/u-boot-env.img ${TARGET_DIR}/etc/u-boot.env
|
|
@ -0,0 +1,76 @@
|
|||
# FunKey
|
||||
|
||||
Intro
|
||||
=====
|
||||
|
||||
This directory contains a buildroot-based external configuration for
|
||||
building the FunKey.
|
||||
|
||||
How to get it
|
||||
===============
|
||||
|
||||
Clone the FunKey OS repository and the required submodules from
|
||||
BitBucket:
|
||||
|
||||
$ git clone --recurse-submodules git@bitbucket.org:keymu2/funkey-os.git <Funkey directory>
|
||||
|
||||
Then enter into the created directory:
|
||||
|
||||
$ cd <Funkey directory>
|
||||
|
||||
How to build it
|
||||
===============
|
||||
|
||||
Configure Buildroot
|
||||
-------------------
|
||||
|
||||
There is only one Funkey defconfig files in Buildroot:
|
||||
|
||||
$ ./fun funkey_defconfig
|
||||
|
||||
Build the rootfs
|
||||
----------------
|
||||
|
||||
Note: you will need to have access to the network, since Buildroot
|
||||
will download the packages' sources.
|
||||
|
||||
You may now build your FunKey with:
|
||||
|
||||
$ ./have fun
|
||||
|
||||
(This may take a while, consider getting yourself a coffee ;-) )
|
||||
|
||||
Result of the build
|
||||
-------------------
|
||||
|
||||
After building, you should obtain this tree:
|
||||
|
||||
FunKey/output/images/
|
||||
+-- boot.scr
|
||||
+-- boot.vfat
|
||||
+-- rootfs.ext2
|
||||
+-- rootfs.ext4 -> rootfs.ext2
|
||||
+-- sdcard.img
|
||||
+-- sun8i-v3s-funkey.dtb
|
||||
+-- u-boot.bin
|
||||
+-- u-boot-sunxi-with-spl.bin
|
||||
`-- uImage
|
||||
|
||||
How to write the SD card
|
||||
========================
|
||||
|
||||
Once the build process is finished you will have an image called
|
||||
"sdcard.img" in the FunKey/output/images/ directory.
|
||||
|
||||
Copy the bootable "sdcard.img" onto an SD card with "dd":
|
||||
|
||||
$ sudo dd if=<Funkey directory>/FunKey/output/images/sdcard.img of=/dev/sdX
|
||||
|
||||
Alternatively, you can use the Etcher graphical tool to burn the image
|
||||
to the SD card safely and on any platform:
|
||||
|
||||
https://etcher.io/
|
||||
|
||||
Once the SD card is burned, insert it into your FunKey board, and
|
||||
power it up. Your new system should come up now and start a console on
|
||||
the UART0 serial port.
|
|
@ -0,0 +1 @@
|
|||
100
|
|
@ -0,0 +1 @@
|
|||
100
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
#DROPBEAR_ARGS="-b /etc/issue.net"
|
|
@ -0,0 +1,10 @@
|
|||
# <file system> <mount pt> <type> <options> <dump> <pass>
|
||||
/dev/root / ext2 rw,noauto 0 1
|
||||
proc /proc proc defaults 0 0
|
||||
devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0
|
||||
tmpfs /dev/shm tmpfs mode=0777 0 0
|
||||
tmpfs /tmp tmpfs mode=1777 0 0
|
||||
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
||||
sysfs /sys sysfs defaults 0 0
|
||||
configfs /sys/kernel/config configfs rw,relatime 0 0
|
||||
/dev/mmcblk0p3 /mnt vfat rw,relatime,fmask=0022,dmask=0022,iocharset=iso8859-1,shortname=mixed,errors=remount-ro 0 0
|
|
@ -0,0 +1,40 @@
|
|||
# Configuration file for fw_(printenv/setenv) utility.
|
||||
# Up to two entries are valid, in this case the redundant
|
||||
# environment sector is assumed present.
|
||||
# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash.
|
||||
# Futhermore, if the Flash sector size is omitted, this value is assumed to
|
||||
# be the same as the Environment size, which is valid for NOR and SPI-dataflash
|
||||
# Device offset must be prefixed with 0x to be parsed as a hexadecimal value.
|
||||
|
||||
# NOR example
|
||||
# MTD device name Device offset Env. size Flash sector size Number of sectors
|
||||
#/dev/mtd1 0x0000 0x4000 0x4000
|
||||
#/dev/mtd2 0x0000 0x4000 0x4000
|
||||
|
||||
# MTD SPI-dataflash example
|
||||
# MTD device name Device offset Env. size Flash sector size Number of sectors
|
||||
#/dev/mtd5 0x4200 0x4200
|
||||
#/dev/mtd6 0x4200 0x4200
|
||||
|
||||
# NAND example
|
||||
#/dev/mtd0 0x4000 0x4000 0x20000 2
|
||||
|
||||
# On a block device a negative offset is treated as a backwards offset from the
|
||||
# end of the device/partition, rather than a forwards offset from the start.
|
||||
|
||||
# Block device example
|
||||
#/dev/mmcblk0 0xc0000 0x20000
|
||||
#/dev/mmcblk0 -0x20000 0x20000
|
||||
/dev/mmcblk0 0x88000 0x20000
|
||||
|
||||
# VFAT example
|
||||
#/boot/uboot.env 0x0000 0x4000
|
||||
|
||||
# UBI volume
|
||||
#/dev/ubi0_0 0x0 0x1f000 0x1f000
|
||||
#/dev/ubi0_1 0x0 0x1f000 0x1f000
|
||||
|
||||
# UBI volume by name
|
||||
#/dev/ubi0:env 0x0 0x1f000 0x1f000
|
||||
#/dev/ubi0:env-redund 0x0 0x1f000 0x1f000
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
THIS=$(basename $0)
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if /etc/rc.local; then
|
||||
echo "Starting rc.local: OK"
|
||||
exit 0
|
||||
else
|
||||
echo "Starting rc.local: ERROR"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop}" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
# Assure that the kernel has module support.
|
||||
[ -e /proc/ksyms -o -e /proc/modules ] || exit 0
|
||||
|
||||
THIS=$(basename $0)
|
||||
|
||||
case "${1}" in
|
||||
start)
|
||||
|
||||
# Exit if there's no modules file or there are no
|
||||
# valid entries
|
||||
if [ -r /etc/sysconfig/modules ]; then
|
||||
egrep -qv '^($|#)' /etc/sysconfig/modules
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Only try to load modules if the user has actually given us
|
||||
# some modules to load.
|
||||
while read MODULE ARGS; do
|
||||
|
||||
# Ignore comments and blank lines.
|
||||
case "$MODULE" in
|
||||
""|"#"*) continue ;;
|
||||
esac
|
||||
|
||||
# Attempt to load the module, making
|
||||
# sure to pass any arguments provided.
|
||||
modprobe ${MODULE} ${ARGS} >/dev/null
|
||||
|
||||
# Print the module name if successful,
|
||||
# otherwise take note.
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Loading module ${MODULE}: OK"
|
||||
else
|
||||
echo "Loading module ${MODULE}: ERROR"
|
||||
fi
|
||||
done < /etc/sysconfig/modules
|
||||
;;
|
||||
stop)
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ${0} {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
|
||||
THIS=$(basename $0)
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if share init; then
|
||||
echo "Starting share: OK"
|
||||
exit 0
|
||||
else
|
||||
echo "Starting share: ERROR"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
if share stop >/dev/null 2>&1; then
|
||||
echo "Stopping share: OK"
|
||||
exit 0
|
||||
else
|
||||
echo "Stopping share: ERROR"
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop}" >&2
|
||||
exit 3
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start/stop low_bat_check
|
||||
#
|
||||
|
||||
DAEMON=/usr/local/sbin/low_bat_check
|
||||
PIDFILE=/var/run/low_bat_check.pid
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting low_bat_check: "
|
||||
start-stop-daemon -S -x ${DAEMON} -p ${PIDFILE} -m -b -- > /dev/null 2>&1
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping low_bat_check: "
|
||||
start-stop-daemon -K -x ${DAEMON} -p ${PIDFILE} -o > /dev/null 2>&1
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
${0} stop
|
||||
sleep 1 # Prevent race condition: ensure low_bat_check stops before start.
|
||||
${0} start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ${0} {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start/stop system_stats
|
||||
#
|
||||
|
||||
DAEMON=/usr/local/sbin/system_stats
|
||||
PIDFILE=/var/run/system_stats.pid
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting system_stats: "
|
||||
start-stop-daemon -S -x ${DAEMON} -p ${PIDFILE} -m -b -- > /dev/null 2>&1
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping system_stats: "
|
||||
start-stop-daemon -K -x ${DAEMON} -p ${PIDFILE} -o > /dev/null 2>&1
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
${0} stop
|
||||
sleep 1 # Prevent race condition: ensure system_stats stops before start.
|
||||
${0} start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ${0} {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
|
@ -0,0 +1,51 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# urandom This script saves the random seed between reboots.
|
||||
# It is called from the boot, halt and reboot scripts.
|
||||
#
|
||||
# Version: @(#)urandom 1.33 22-Jun-1998 miquels@cistron.nl
|
||||
#
|
||||
|
||||
[ -c /dev/urandom ] || exit 0
|
||||
#. /etc/default/rcS
|
||||
|
||||
case "$1" in
|
||||
start|"")
|
||||
# check for read only file system
|
||||
if ! touch /etc/random-seed 2>/dev/null
|
||||
then
|
||||
# echo "read-only file system detected...done"
|
||||
exit
|
||||
fi
|
||||
if [ "$VERBOSE" != no ]
|
||||
then
|
||||
echo -n "Starting random number generator: "
|
||||
fi
|
||||
# Load and then save 512 bytes,
|
||||
# which is the size of the entropy pool
|
||||
cat /etc/random-seed >/dev/urandom
|
||||
rm -f /etc/random-seed
|
||||
umask 077
|
||||
dd if=/dev/urandom of=/etc/random-seed count=1 \
|
||||
>/dev/null 2>&1 || echo "ERROR"
|
||||
umask 022
|
||||
[ "$VERBOSE" != no ] && echo "OK"
|
||||
;;
|
||||
stop)
|
||||
if ! touch /etc/random-seed 2>/dev/null
|
||||
then
|
||||
exit
|
||||
fi
|
||||
# Carry a random seed from shut-down to start-up;
|
||||
# see documentation in linux/drivers/char/random.c
|
||||
[ "$VERBOSE" != no ] && echo -n "Stopping random number generator: "
|
||||
umask 077
|
||||
dd if=/dev/urandom of=/etc/random-seed count=1 \
|
||||
>/dev/null 2>&1 || echo "ERROR"
|
||||
[ "$VERBOSE" != no ] && echo "OK"
|
||||
;;
|
||||
*)
|
||||
echo "Usage: urandom {start|stop}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start the network....
|
||||
#
|
||||
|
||||
# Debian ifupdown needs the /run/network lock directory
|
||||
mkdir -p /run/network
|
||||
[ -f /mnt/usbnet ] || exit 0
|
||||
case "$1" in
|
||||
start)
|
||||
printf "Starting network: "
|
||||
/sbin/ifup -a
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
;;
|
||||
stop)
|
||||
printf "Stopping network: "
|
||||
/sbin/ifdown -a
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
;;
|
||||
restart|reload)
|
||||
"$0" stop
|
||||
"$0" start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start/stop dhcpcd
|
||||
#
|
||||
|
||||
DAEMON=/sbin/dhcpcd
|
||||
CONFIG=/etc/dhcpcd.conf
|
||||
PIDFILE=/var/run/dhcpcd.pid
|
||||
[ -f /mnt/usbnet ] || exit 0
|
||||
[ -f $CONFIG ] || exit 0
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting dhcpcd: "
|
||||
start-stop-daemon -S -x "$DAEMON" -p "$PIDFILE" -- -f "$CONFIG" > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping dhcpcd: "
|
||||
start-stop-daemon -K -x "$DAEMON" -p "$PIDFILE" -o > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
reload|force-reload)
|
||||
echo -n "Reloading dhcpcd configuration: "
|
||||
"$DAEMON" -s reload >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
"$0" stop
|
||||
sleep 1 # Prevent race condition: ensure dhcpcd stops before start.
|
||||
"$0" start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
|
||||
exit 1
|
||||
esac
|
|
@ -0,0 +1,62 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Starts dropbear sshd.
|
||||
#
|
||||
|
||||
[ -f /mnt/usbnet ] || exit 0
|
||||
# Allow a few customizations from a config file
|
||||
test -r /etc/default/dropbear && . /etc/default/dropbear
|
||||
|
||||
start() {
|
||||
DROPBEAR_ARGS="$DROPBEAR_ARGS -R"
|
||||
|
||||
# If /etc/dropbear is a symlink to /var/run/dropbear, and
|
||||
# - the filesystem is RO (i.e. we can not rm the symlink),
|
||||
# create the directory pointed to by the symlink.
|
||||
# - the filesystem is RW (i.e. we can rm the symlink),
|
||||
# replace the symlink with an actual directory
|
||||
if [ -L /etc/dropbear \
|
||||
-a "$(readlink /etc/dropbear)" = "/var/run/dropbear" ]
|
||||
then
|
||||
if rm -f /etc/dropbear >/dev/null 2>&1; then
|
||||
mkdir -p /etc/dropbear
|
||||
else
|
||||
echo "No persistent location to store SSH host keys. New keys will be"
|
||||
echo "generated at each boot. Are you sure this is what you want to do?"
|
||||
mkdir -p "$(readlink /etc/dropbear)"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf "Starting dropbear sshd: "
|
||||
umask 077
|
||||
|
||||
start-stop-daemon -S -q -p /var/run/dropbear.pid \
|
||||
--exec /usr/sbin/dropbear -- $DROPBEAR_ARGS
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
stop() {
|
||||
printf "Stopping dropbear sshd: "
|
||||
start-stop-daemon -K -q -p /var/run/dropbear.pid
|
||||
[ $? = 0 ] && echo "OK" || echo "FAIL"
|
||||
}
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload)
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $?
|
|
@ -0,0 +1,41 @@
|
|||
# /etc/inittab
|
||||
#
|
||||
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Note: BusyBox init doesn't support runlevels. The runlevels field is
|
||||
# completely ignored by BusyBox init. If you want runlevels, use
|
||||
# sysvinit.
|
||||
#
|
||||
# Format for each entry: <id>:<runlevels>:<action>:<process>
|
||||
#
|
||||
# id == tty to run on, or empty for /dev/console
|
||||
# runlevels == ignored
|
||||
# action == one of sysinit, respawn, askfirst, wait, and once
|
||||
# process == program to run
|
||||
|
||||
# Startup the system
|
||||
::sysinit:/bin/cat /etc/issue
|
||||
::sysinit:/bin/mount -t proc proc /proc
|
||||
::sysinit:/bin/mount -o remount,rw /
|
||||
::sysinit:/bin/mkdir -p /dev/pts /dev/shm
|
||||
::sysinit:/bin/mount -a
|
||||
null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
|
||||
null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
|
||||
null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
|
||||
null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
|
||||
::sysinit:/bin/hostname -F /etc/hostname
|
||||
::sysinit:/sbin/syslogd
|
||||
::sysinit:/sbin/klogd
|
||||
|
||||
# now run any rc scripts
|
||||
::sysinit:/etc/init.d/rcS
|
||||
|
||||
# Start an automatic root login on the console
|
||||
::respawn:-/bin/login -f root
|
||||
|
||||
# Stuff to do for the 3-finger salute
|
||||
#::ctrlaltdel:/sbin/reboot
|
||||
|
||||
# Stuff to do before rebooting
|
||||
::shutdown:/etc/init.d/rcK
|
||||
::shutdown:/bin/umount -a -r
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
_______ __ __
|
||||
| ___|.--.--.-----.| |/ |.-----.--.--.
|
||||
| ___|| | | || < | -__| | |
|
||||
|___| |_____|__|__||__|\__||_____|___ |
|
||||
FUN ON A KEYCHAIN |_____|
|
||||
-----------------------------------------------------
|
||||
Version 0.6 (Recovery)
|
||||
-----------------------------------------------------
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
NAME="FunKey-OS Recovery"
|
||||
VERSION="0.6 (Khaki Kitten)"
|
||||
ID=funkey-recovery
|
||||
ID_LIKE=buildroot
|
||||
PRETTY_NAME="FunKey-OS Recovery 0.6"
|
||||
VERSION_ID="0.6"
|
||||
HOME_URL="https://www.funkey-project.com/"
|
||||
SUPPORT_URL="https://www.funkey-project.com/"
|
||||
BUG_REPORT_URL="https://www.funkey-project.com/"
|
||||
PRIVACY_POLICY_URL="https://www.funkey-project.com"
|
||||
VERSION_CODENAME=khaki
|
||||
UBUNTU_CODENAME=khaki
|
|
@ -0,0 +1,21 @@
|
|||
export PATH="/usr/local/games:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
if [ "$PS1" ]; then
|
||||
if [ "`id -u`" -eq 0 ]; then
|
||||
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\# '
|
||||
else
|
||||
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
fi
|
||||
fi
|
||||
|
||||
export PAGER='/bin/more'
|
||||
export EDITOR='/usr/bin/nano'
|
||||
export SDL_NOMOUSE=1
|
||||
|
||||
# Source configuration files from /etc/profile.d
|
||||
for i in /etc/profile.d/*.sh ; do
|
||||
if [ -r "$i" ]; then
|
||||
. $i
|
||||
fi
|
||||
done
|
||||
unset i
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# rc.local
|
||||
#
|
||||
# This script is executed at the end of each multiuser runlevel.
|
||||
# Make sure that the script will "exit 0" on success or any other
|
||||
# value on error.
|
||||
#
|
||||
# In order to enable or disable this script just change the execution
|
||||
# bits.
|
||||
#
|
||||
# By default this script does nothing.
|
||||
|
||||
exit 0
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
args_mmc=setenv bootargs console=ttyS0,115200 panic=5 rootwait fbcon=map:10 fbcon=font:VGA8x8 vt.global_cursor_default=0 root=/dev/mmcblk0p${bootpart} rootfstype=ext4 rootflags=commit=120,data=writeback,barrier=0,journal_async_commit rw quiet
|
||||
baudrate=115200
|
||||
bootcmd=run getbootpart; run args_mmc; run loadfdt; run loadimage; bootz ${loadaddr} - ${fdtaddr}
|
||||
bootdelay=0
|
||||
console=ttyS0,115200
|
||||
fdt_high=0xffffffff
|
||||
fdtaddr=0x41800000
|
||||
getbootpart=part list mmc 0 -bootable bootpart
|
||||
loadaddr=0x41000000
|
||||
loadfdt=load mmc 0:${bootpart} ${fdtaddr} /boot/sun8i-v3s-funkey.dtb
|
||||
loadimage=load mmc 0:${bootpart} ${loadaddr} /boot/zImage
|
||||
stderr=serial@01c28000
|
||||
stdin=serial@01c28000
|
||||
stdout=serial@01c28000
|
||||
verify=n
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
|
||||
#set -xv
|
||||
|
||||
if [ x"$THIS" != x ]; then
|
||||
THIS="${THIS}: "
|
||||
fi
|
||||
log_action_msg () {
|
||||
echo "${THIS}${@}." | tee /dev/kmsg
|
||||
}
|
||||
|
||||
log_action_begin_msg () {
|
||||
echo -n "${THIS}${@}: " | tee /dev/kmsg
|
||||
}
|
||||
|
||||
log_action_cont_msg () {
|
||||
echo "${THIS}${@}..." | tee /dev/kmsg
|
||||
}
|
||||
|
||||
log_action_end_msg () {
|
||||
local end
|
||||
if [ -z "${2:-}" ]; then
|
||||
end=""
|
||||
else
|
||||
end=" ($2)"
|
||||
fi
|
||||
|
||||
if [ $1 -eq 0 ]; then
|
||||
echo "${THIS}OK${end}" | tee /dev/kmsg
|
||||
else
|
||||
echo "${THIS}ERROR${end}" | tee /dev/kmsg
|
||||
fi
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# ~/.bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
# Note: PS1 and umask are already set in /etc/profile. You should not
|
||||
# need this unless you want different defaults for root.
|
||||
# PS1='${debian_chroot:+($debian_chroot)}\h:\w\$ '
|
||||
# umask 022
|
||||
|
||||
# You may uncomment the following lines if you want `ls' to be colorized:
|
||||
export TERM=xterm
|
||||
export LS_OPTIONS='--color=auto'
|
||||
#eval "`dircolors`"
|
||||
alias ls='ls $LS_OPTIONS'
|
||||
alias ll='ls $LS_OPTIONS -l'
|
||||
alias l='ls $LS_OPTIONS -lA'
|
||||
#
|
||||
# Some more alias to avoid making mistakes:
|
||||
# alias rm='rm -i'
|
||||
# alias cp='cp -i'
|
||||
# alias mv='mv -i'
|
||||
|
||||
# Resize the console to the terminal dimensions
|
||||
resize() {
|
||||
if [[ -t 0 && $# -eq 0 ]]; then
|
||||
local IFS='[;' escape geometry x y
|
||||
echo -ne '\e7\e[r\e[999;999H\e[6n\e8'
|
||||
read -sd R escape geometry
|
||||
x=${geometry##*;} y=${geometry%%;*}
|
||||
if [[ ${COLUMNS} -eq ${x} && ${LINES} -eq ${y} ]]; then
|
||||
echo "${TERM} ${x}x${y}"
|
||||
else
|
||||
echo "${COLUMNS}x${LINES} -> ${x}x${y}"
|
||||
stty cols ${x} rows ${y}
|
||||
fi
|
||||
else
|
||||
print 'Usage: resize'
|
||||
fi
|
||||
}
|
||||
|
||||
# Reset saved brightness
|
||||
echo "Reset saved brightness"
|
||||
brightness_set $(brightness_get) >/dev/null 2>&1
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Define log functions if they do not exist yet
|
||||
type -t info >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
info () {
|
||||
echo "$SELF:" "$@" | tee /dev/kmsg
|
||||
}
|
||||
|
||||
warn () {
|
||||
echo "$SELF:" "$@" >&2 | tee /dev/kmsg
|
||||
}
|
||||
|
||||
die () {
|
||||
local return_code=$1
|
||||
shift
|
||||
warn "$@"
|
||||
exit $return_code
|
||||
}
|
||||
fi
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
BRIGHTNESS_FILE=/etc/current_brightness
|
||||
BRIGHTNESS_DEFAULT_VALUE=100
|
||||
|
||||
# Check args
|
||||
if [ ${#} -ne 0 ]; then
|
||||
echo "Usage: $(basename ${0})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Sanity check: File does not exist
|
||||
if [ ! -f ${BRIGHTNESS_FILE} ]; then
|
||||
echo ${BRIGHTNESS_DEFAULT_VALUE} > ${BRIGHTNESS_FILE}
|
||||
fi
|
||||
|
||||
# Sanity check: Check if integer
|
||||
brightness=$(cat ${BRIGHTNESS_FILE})
|
||||
if ! [ ! "${brightness}" -ne "${brightness}" ] 2> /dev/null; then
|
||||
echo ${BRIGHTNESS_DEFAULT_VALUE} > ${BRIGHTNESS_FILE}
|
||||
brightness=${BRIGHTNESS_DEFAULT_VALUE}
|
||||
fi
|
||||
echo ${brightness}
|
||||
exit 0
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness
|
||||
|
||||
# Check args
|
||||
if [ ${#} -ne 0 ]; then
|
||||
echo "Usage: $(basename ${0})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
let brightness=$(cat ${SYSTEM_BRIGHTNESS})*10-10
|
||||
echo ${brightness}
|
||||
exit 0
|
|
@ -0,0 +1,28 @@
|
|||
#!/bin/sh
|
||||
|
||||
BRIGHTNESS_FILE=/etc/current_brightness
|
||||
SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness
|
||||
|
||||
# Check args
|
||||
if [ ${#} -ne 1 ]; then
|
||||
echo "Usage: $(basename ${0}) new_brightness_percentage"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check value's range
|
||||
if [ ${1} -gt 100 ]; then
|
||||
echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100"
|
||||
exit 1
|
||||
fi
|
||||
brightness_percentage=${1}
|
||||
|
||||
# Set new brightness percentage
|
||||
let value=${1}+10
|
||||
let value/=10
|
||||
echo ${value} > ${SYSTEM_BRIGHTNESS}
|
||||
|
||||
# Set new brightness value in brightness file
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo ${brightness_percentage} > ${BRIGHTNESS_FILE}
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
SYSTEM_BRIGHTNESS=/sys/class/backlight/backlight/brightness
|
||||
|
||||
# Check args
|
||||
if [ ${#} -ne 1 ]; then
|
||||
echo "Usage: $(basename ${0}) new_brightness_percentage"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check value's range
|
||||
if [ ${1} -gt 100 ]; then
|
||||
echo "Usage: Wrong brightness percentage (${1}), must be between 0 and 100"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set new brightness percentage
|
||||
let value=${1}+10
|
||||
let value/=10
|
||||
echo ${value} > ${SYSTEM_BRIGHTNESS}
|
||||
exit 0
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
notif_set 0 "Getting system stats..."
|
||||
killall -s USR1 system_stats
|
||||
exit 0
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
echo $(for i in 0 4 8 c; do devmem 0x01c2380$i 32; done) | sed 's/ \?0x//g'
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Uncomment the following line to get debug info
|
||||
#set -x
|
||||
|
||||
# Get USB state
|
||||
usb_present=$(cat /sys/class/power_supply/axp20x-usb/present)
|
||||
|
||||
# Get udc state
|
||||
udc_state=$(cat /sys/class/udc/musb-hdrc.1.auto/state)
|
||||
|
||||
if [[ x"$udc_state" == "xconfigured" -a "$usb_present" == "1" ]]; then
|
||||
|
||||
# Connected succesfully to a host
|
||||
echo "yes"
|
||||
exit 0
|
||||
else
|
||||
echo "no"
|
||||
exit 1
|
||||
fi
|
|
@ -0,0 +1,124 @@
|
|||
#!/bin/sh
|
||||
|
||||
# General constants declaration
|
||||
THRESHOLD_PERCENT_LOW_BAT=5
|
||||
THRESHOLD_PERCENT_EXTREMELY_LOW_BAT=2
|
||||
MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN=5
|
||||
SLEEP_SECS=2
|
||||
RESCALE_MAX_PERCENTAGE=120
|
||||
|
||||
# Blink Low bat constants declaration
|
||||
BLINK_ICON=0
|
||||
LOW_BAT_SECS_DISPLAYED=5
|
||||
LOW_BAT_SECS_NOT_DISPLAYED=5
|
||||
|
||||
# Files and commands declaration
|
||||
USB_PRESENT_FILE=/sys/class/power_supply/axp20x-usb/present
|
||||
#USB_PRESENT_FILE=/sys/class/power_supply/axp20x-ac/present # Cheat for no USB present simulation when debugging
|
||||
BAT_PRESENT_FILE=/sys/class/power_supply/axp20x-battery/present
|
||||
BAT_PERCENT_FILE=/sys/class/power_supply/axp20x-battery/capacity
|
||||
BAT_PERCENT_RESCALED_FILE=/etc/current_battery_percentage
|
||||
LOW_BAT_ICON=/sys/class/graphics/fb0/low_battery
|
||||
SCHEDULE_SHUTDOWN_CMD=sched_shutdown
|
||||
SIGNAL_URS1_TO_EMULATORS_CMD=signal_usr1_to_emulators
|
||||
|
||||
# Variables declaration
|
||||
low_bat_status=0
|
||||
low_bat_displayed=0
|
||||
cur_secs_disp=0
|
||||
cur_nb_extremely_low_bat_before_shutdown=0
|
||||
|
||||
# Default: Hide Low Bat Icon
|
||||
echo 0 > ${LOW_BAT_ICON}
|
||||
|
||||
# Check low bat #
|
||||
while true; do
|
||||
#echo "Bat present: $(cat ${BAT_PRESENT_FILE})"
|
||||
#echo "USB present: $(cat ${USB_PRESENT_FILE})"
|
||||
#echo "Bat percentage: $(cat ${BAT_PERCENT_FILE})"
|
||||
|
||||
# Get current bat percentage here once
|
||||
cur_bat_percent=$(cat ${BAT_PERCENT_FILE})
|
||||
#echo "cur_bat_percent = ${cur_bat_percent}"
|
||||
|
||||
# Rescale bat percentage between 0 and RESCALE_MAX_PERCENTAGE
|
||||
bat_percent_rescaled=$(printf "%.f" $(echo $cur_bat_percent $RESCALE_MAX_PERCENTAGE | awk '{print $1*$2/100}'))
|
||||
#echo "bat_percent_rescaled = ${bat_percent_rescaled}"
|
||||
|
||||
# Re-maximize to 100%
|
||||
bat_percent_rescaled_maxed=$(( bat_percent_rescaled < 100 ? bat_percent_rescaled : 100 ))
|
||||
#echo "bat_percent_rescaled_maxed = ${bat_percent_rescaled_maxed}"
|
||||
|
||||
# Save in file
|
||||
echo ${bat_percent_rescaled_maxed} > ${BAT_PERCENT_RESCALED_FILE}
|
||||
|
||||
# Low bat status detection
|
||||
if [ "$(cat ${USB_PRESENT_FILE})" -eq "0" ]; then
|
||||
|
||||
# Value of 0 means wrong i2c reading
|
||||
if [ "${cur_bat_percent}" -ne "0" ]; then
|
||||
|
||||
# Check if we must change state
|
||||
if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 0 ]; then
|
||||
|
||||
# Set Low Bat status
|
||||
low_bat_status=1
|
||||
low_bat_displayed=1
|
||||
cur_secs_disp=0
|
||||
echo 1 > ${LOW_BAT_ICON}
|
||||
|
||||
elif [ ${cur_bat_percent} -gt ${THRESHOLD_PERCENT_LOW_BAT} -a ${low_bat_status} -eq 1 ]; then
|
||||
|
||||
# Reset status
|
||||
low_bat_status=0
|
||||
cur_nb_extremely_low_bat_before_shutdown=0
|
||||
echo 0 > ${LOW_BAT_ICON}
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if [ ${low_bat_status} -eq 1 ]; then
|
||||
|
||||
# Reset status
|
||||
low_bat_status=0
|
||||
cur_nb_extremely_low_bat_before_shutdown=0
|
||||
echo 0 > ${LOW_BAT_ICON}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Low bat processing
|
||||
if [ ${low_bat_status} -eq 1 ]; then
|
||||
|
||||
# Check extremely low bat for clean shutdown
|
||||
if [ ${cur_bat_percent} -le ${THRESHOLD_PERCENT_EXTREMELY_LOW_BAT} ]; then
|
||||
let cur_nb_extremely_low_bat_before_shutdown++
|
||||
echo "cur_nb_extremely_low_bat_before_shutdown = ${cur_nb_extremely_low_bat_before_shutdown}"
|
||||
|
||||
# Clean shutdown
|
||||
if [ ${cur_nb_extremely_low_bat_before_shutdown} -ge ${MAX_EXTREMELY_LOW_BAT_BEFORE_SHUTDOWN} ]; then
|
||||
echo "Battery extremely low, shutting down now..."
|
||||
sched_shutdown 1 & signal_usr1_to_emulators
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Blinking process
|
||||
if [ ${BLINK_ICON} -eq 1 ]; then
|
||||
if [ ${low_bat_displayed} -eq 1 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_DISPLAYED} ]; then
|
||||
low_bat_displayed=0
|
||||
cur_secs_disp=0
|
||||
echo 0 > ${LOW_BAT_ICON}
|
||||
elif [ ${low_bat_displayed} -eq 0 -a ${cur_secs_disp} -ge ${LOW_BAT_SECS_NOT_DISPLAYED} ]; then
|
||||
low_bat_displayed=1
|
||||
cur_secs_disp=0
|
||||
echo 1 > ${LOW_BAT_ICON}
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Sleep before next check
|
||||
sleep ${SLEEP_SECS}
|
||||
|
||||
# Increase vars
|
||||
let cur_secs_disp+=${SLEEP_SECS}
|
||||
done
|
||||
exit 0
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
# Clear all current notifications
|
||||
|
||||
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
|
||||
|
||||
printf "clear" > ${NOTIFICATION_DISPLAY}
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
# Display notification for a certain amount of time
|
||||
# Special char: ^ to add a new line
|
||||
# Set seconds to 0 to display indefinitely (until the next notif)
|
||||
|
||||
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
|
||||
|
||||
display_usage() {
|
||||
echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n"
|
||||
}
|
||||
|
||||
# If less than two arguments supplied, display usage
|
||||
if [ ${#} -le 1 ]; then
|
||||
echo "Display notification for a certain amount of time"
|
||||
display_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get number of seconds to display notif
|
||||
nb_secs=${1}
|
||||
if ! [ ! "${nb_secs}" -ne "${nb_secs}" ] 2> /dev/null; then
|
||||
echo "error: ${nb_secs} is not a number" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Print notif
|
||||
printf "${*:2}" > ${NOTIFICATION_DISPLAY}
|
||||
|
||||
# Clear notif if NB_SECS is not 0, otherwise never clear
|
||||
if [ ${nb_secs} -ne 0 ]; then
|
||||
|
||||
# Wait time before clearing notif
|
||||
sleep ${nb_secs}
|
||||
|
||||
# Clear notif
|
||||
printf "clear" > ${NOTIFICATION_DISPLAY}
|
||||
fi
|
||||
exit 0
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
# Erase previous notif and display new one in background process for a certain amount of seconds
|
||||
# Special char: ^ to add a new line
|
||||
# Set seconds to 0 to display indefinitely (until the next notif_set)
|
||||
|
||||
NOTIFICATION_DISPLAY=/sys/class/graphics/fb0/notification
|
||||
|
||||
display_usage() {
|
||||
echo -e "Usage:\n$(basename ${0}) nb_seconds_display message_to_display\n"
|
||||
}
|
||||
|
||||
# If less than two arguments supplied, display usage
|
||||
if [ ${#} -le 1 ]; then
|
||||
echo "Erase previous notif and display new one in background process for a certain amount of time"
|
||||
echo "Special char: ^ to add a new line"
|
||||
echo "Set seconds to 0 to display indefinitely (until the next $(basename ${0}))"
|
||||
display_usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get number of seconds to display notif
|
||||
nb_secs=${1}
|
||||
if ! [ ! "${nb_secs}" -ne "${nb_secs}" ]; then
|
||||
echo "error: ${nb_secs} is not a number" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Kill previous notif_disp process
|
||||
pkill notif_disp 2> /dev/null
|
||||
|
||||
## Clear previous notif
|
||||
#printf "clear" > ${NOTIFICATION_DISPLAY}
|
||||
|
||||
# Print new notif
|
||||
notif_disp "$@" &
|
||||
exit 0
|
|
@ -0,0 +1,137 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Uncomment the following line to get debug info
|
||||
#set -x
|
||||
|
||||
SELF=${SELF:-$(basename $0)}
|
||||
LOCK_FILE=/var/lock/share.lock
|
||||
|
||||
source /usr/local/lib/utils
|
||||
source usb_gadget
|
||||
|
||||
# The USB network interface file
|
||||
USB_IF=/etc/network/interfaces.d/usb0
|
||||
|
||||
# The USB mass storage backing store file or partition
|
||||
BACKING_STORE_FILE=/sys/kernel/config/usb_gadget/FunKey/functions/mass_storage.mmcblk0p3/lun.0/file
|
||||
|
||||
# Unmount a local share
|
||||
unmount_share () {
|
||||
|
||||
umount /mnt || die 1 "cannot unmount the backing store partition"
|
||||
return 0
|
||||
}
|
||||
|
||||
# Mount a share locally
|
||||
mount_share () {
|
||||
|
||||
mount | grep -q /dev/mmcblk0p3
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
# Check if the FAT32 partition has been unmounted cleanly
|
||||
fsck.fat -n /dev/mmcblk0p3 2>/dev/null | egrep -q "Dirty bit"
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
# The FAT32 partition was not cleanly unmounted, try to
|
||||
# clean it
|
||||
warn "the backing store partition was not properly unmounted"
|
||||
#warn "the backing store partition was not properly
|
||||
#unmounted, clean it"
|
||||
# fsck.fat -a -t -w /dev/loop0 >/dev/null 2>&1
|
||||
# if [ $? -gt 1 ]; then
|
||||
# die 3 "cannot clean backing store file"
|
||||
# fi
|
||||
fi
|
||||
|
||||
# Mount the backing store file locally
|
||||
mount /mnt/ || die 4 "cannot mount backing store partition"
|
||||
fi
|
||||
|
||||
# Create the directory structure if required
|
||||
(cd /mnt; mkdir -p "Atari lynx" "Game Boy" "Game Boy Color" "Game Boy Advance" "Game Gear" "Neo Geo Pocket" "NES" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan")
|
||||
return 0
|
||||
}
|
||||
|
||||
# Initialize the backing store if needed and mount it locally
|
||||
init_share () {
|
||||
if [ -f ${LOCK_FILE} ]; then
|
||||
return 0
|
||||
fi
|
||||
touch ${LOCK_FILE}
|
||||
|
||||
# Initialize the USB gadget
|
||||
init_usb_gadget
|
||||
|
||||
# Mount the backing store partition locally
|
||||
mount_share
|
||||
return 0
|
||||
}
|
||||
|
||||
# Stop sharing the backing store partition
|
||||
stop_share () {
|
||||
|
||||
# Stop sharing the backing store partition
|
||||
echo > $BACKING_STORE_FILE || die 11 "the backing store partition is still mounted on host"
|
||||
|
||||
# 3) Mount the backing store partition locally
|
||||
mount_share
|
||||
|
||||
info "stopped sharing the backing store partition"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# Start sharing the backing store partition
|
||||
start_share () {
|
||||
|
||||
# 1) Check if the backing store partition is already shared
|
||||
cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3 && die 12 "the backing store partition is already shared"
|
||||
|
||||
# 2) Check if USB data is connected
|
||||
is_usb_data_connected > /dev/null 2>&1 || die 13 "USB sharing impossible, not connected to a host"
|
||||
|
||||
# 3) Unmount the backing store partition if it is locally mounted
|
||||
unmount_share
|
||||
|
||||
# 4) Everything is now clear to start sharing the backing store partition
|
||||
info "start sharing the backing store partition"
|
||||
echo /dev/mmcblk0p3 > $BACKING_STORE_FILE || die 14 "cannot share the backing store partition"
|
||||
}
|
||||
|
||||
# Return if currently sharing
|
||||
is_share_started () {
|
||||
|
||||
cat $BACKING_STORE_FILE | egrep -q ^/dev/mmcblk0p3
|
||||
local res=$?
|
||||
if [ "$res" == "0" ]; then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
fi
|
||||
return $res
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
||||
init)
|
||||
init_share
|
||||
;;
|
||||
|
||||
start)
|
||||
start_share
|
||||
;;
|
||||
|
||||
stop)
|
||||
stop_share
|
||||
;;
|
||||
|
||||
is_sharing)
|
||||
is_share_started
|
||||
;;
|
||||
|
||||
|
||||
*)
|
||||
die 15 "Usage $0 {init|start|stop|is_sharing}"
|
||||
;;
|
||||
esac
|
||||
exit $?
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Notif fullscreen "Shutting down"
|
||||
notif_set 0 "^^^^^^^^ SHUTTING DOWN...^^^^^^^^"
|
||||
|
||||
# Kill Emulators
|
||||
#kill_emulators >/dev/null 2>&1
|
||||
|
||||
# Kill Retrofe
|
||||
#pkill retrofe
|
||||
|
||||
# Sync filesystems (useful in case poweroff could not finish)
|
||||
sync
|
||||
|
||||
# Unmount Roms partition
|
||||
umount /mnt
|
||||
|
||||
# Shutdown amp
|
||||
start_audio_amp 0 >/dev/null 2>&1
|
||||
|
||||
# Poweroff
|
||||
poweroff
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOCK_FILE=/var/lock/gpio_manager.lock
|
||||
|
||||
if [ -f ${LOCK_FILE} ]; then
|
||||
echo "${LOCK_FILE} already exists"
|
||||
exit 1
|
||||
fi
|
||||
touch ${LOCK_FILE}
|
||||
funkey_gpio_management
|
||||
rm "${LOCK_FILE}"
|
||||
exit 0
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
UPDATE_PERIOD=2 #seconds
|
||||
|
||||
notif_dirty=0
|
||||
perform=0
|
||||
|
||||
# USR1 callback
|
||||
function toggle_perform()
|
||||
{
|
||||
let perform=1-${perform}
|
||||
if [ ${perform} -eq 0 ]; then
|
||||
notif_clear
|
||||
notif_dirty=1
|
||||
fi
|
||||
}
|
||||
trap toggle_perform SIGUSR1
|
||||
|
||||
while true; do
|
||||
if [ ${perform} -eq 1 ]; then
|
||||
|
||||
# Compute stats
|
||||
cpu=$(printf "%.1f\n" $(mpstat -P ALL $UPDATE_PERIOD 1 | tail -1 | awk '{print 100-$12}'))
|
||||
ram_mem=$(printf "%.1f\n" $(free | grep Mem | awk '{print $3/$2 * 100.0}'))
|
||||
ram_swap=$(printf "%.1f\n" $(free | grep Swap | awk '{print $3/$2 * 100.0}'))
|
||||
|
||||
# Notif
|
||||
if [ ${notif_dirty} -eq 1 ]; then
|
||||
notif_clear
|
||||
notif_dirty=0
|
||||
else
|
||||
notif_set 0 "CPU:${cpu}%% RAM:${ram_mem}%% SWAP:${ram_swap}%%"
|
||||
fi
|
||||
else
|
||||
sleep ${UPDATE_PERIOD}
|
||||
fi
|
||||
done
|
||||
exit 0
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ $# -ne 1 ];then
|
||||
echo "ERROR LED ARGS"
|
||||
exit;
|
||||
fi
|
||||
case ${1} in
|
||||
0) value=0x0a;;
|
||||
1) value=0x3a;;
|
||||
*) echo "ERROR LED VALUE"; exit 1;;
|
||||
esac
|
||||
|
||||
# Turn on/off the LED
|
||||
i2cset -f -y 0 0x34 0x32 ${value}
|
||||
if [ $? -ne 0 ]; then
|
||||
#echo "ERROR LED I2C"
|
||||
exit 1
|
||||
else
|
||||
#echo "OK"
|
||||
exit 0
|
||||
fi
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Turn on Power Amplifier
|
||||
gpioset $(gpiofind "PA")=1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR SPEAKER ON"
|
||||
else
|
||||
|
||||
# Play 1kHz sine wave
|
||||
speaker-test -t sine -s 1 -f 1000 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR SPEAKER SINE"
|
||||
gpioset $(gpiofind "PA")=0
|
||||
else
|
||||
|
||||
# Turn off Power Amplifier
|
||||
gpioset $(gpiofind "PA")=0
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR SPEAKER OFF"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
sgdisk -A 1:toggle:2 -A 2:toggle:2 /dev/mmcblk0 >/dev/null 2>&1
|
||||
recovery=$(sgdisk -A 1:get:2 /dev/mmcblk0 | cut -d : -f3)
|
||||
if [ ${recovery} -eq 1 ]; then
|
||||
echo "Next boot will be in recovery mode"
|
||||
else
|
||||
echo "Next boot will be in normal mode"
|
||||
fi
|
|
@ -0,0 +1,169 @@
|
|||
#!/bin/sh
|
||||
|
||||
#set -xv
|
||||
|
||||
SELF=${SELF:-$(basename $0)}
|
||||
|
||||
source /usr/local/lib/utils
|
||||
|
||||
# The composite gadget directory
|
||||
GADGET=/sys/kernel/config/usb_gadget/FunKey
|
||||
|
||||
# Check if Ethernet over USB network is requested
|
||||
[ ! -f /mnt/usbnet ]
|
||||
USBNET=${?}
|
||||
|
||||
# USB VID for Linux Foundation
|
||||
ID_VENDOR="0x1d6b"
|
||||
|
||||
# USB PID for Multifunction Composite Gadget
|
||||
ID_PRODUCT="0x0104"
|
||||
|
||||
# Get the CPU serial number
|
||||
SERIAL="$(grep Serial /proc/cpuinfo | sed 's/Serial\s*: \(\w*\)/\1/')"
|
||||
|
||||
# Build a MAC address from it
|
||||
MAC="$(echo ${SERIAL} | sed 's/\(\w\w\)/:\1/g' | cut -b 2-)"
|
||||
|
||||
# Derive host and device MAC addresses
|
||||
MAC_HOST="12$(echo ${MAC} | cut -b 3-)"
|
||||
MAC_DEV="02$(echo ${MAC} | cut -b 3-)"
|
||||
|
||||
# Initialize the USB gadget
|
||||
init_usb_gadget() {
|
||||
|
||||
# Don't proceed if existing gadget is present
|
||||
if [ -e ${GADGET} ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get the legacy drivers out of the way
|
||||
modprobe -r g_ether
|
||||
modprobe -r g_mass_storage
|
||||
|
||||
# Load the libcomposite USB driver
|
||||
modprobe libcomposite
|
||||
|
||||
# USB Device Controller Driver
|
||||
local udc_driver=$(ls /sys/class/udc | cut -f1 | head -n 1)
|
||||
|
||||
# Create our gadget directory
|
||||
mkdir ${GADGET}
|
||||
mkdir ${GADGET}/strings/0x409
|
||||
mkdir ${GADGET}/configs/FunKey.1
|
||||
mkdir ${GADGET}/configs/FunKey.1/strings/0x409
|
||||
test ${USBNET} -eq 1 && mkdir ${GADGET}/functions/rndis.usb0
|
||||
mkdir ${GADGET}/functions/mass_storage.mmcblk0p3
|
||||
|
||||
# USB2
|
||||
echo "0x0200" > ${GADGET}/bcdUSB
|
||||
|
||||
# Communication Device Class
|
||||
if [ ${USBNET} -eq 1 ]; then
|
||||
echo "0x02" > ${GADGET}/bDeviceClass
|
||||
echo "0x00" > ${GADGET}/bDeviceSubClass
|
||||
fi
|
||||
|
||||
# USB VID and PID
|
||||
echo ${ID_VENDOR} > ${GADGET}/idVendor
|
||||
echo ${ID_PRODUCT} > ${GADGET}/idProduct
|
||||
|
||||
# Device Release Number
|
||||
echo "0x0100" > ${GADGET}/bcdDevice
|
||||
|
||||
# Device String Descriptiors
|
||||
echo "FunKey" > ${GADGET}/strings/0x409/manufacturer
|
||||
echo "FunKey S" > ${GADGET}/strings/0x409/product
|
||||
echo ${SERIAL} > ${GADGET}/strings/0x409/serialnumber
|
||||
|
||||
# Turn on "OS Descriptors" support for RNDIS
|
||||
if [ ${USBNET} -eq 1 ]; then
|
||||
echo 1 > ${GADGET}/os_desc/use
|
||||
echo "0xcd" > ${GADGET}/os_desc/b_vendor_code
|
||||
echo "MSFT100" > ${GADGET}/os_desc/qw_sign
|
||||
fi
|
||||
|
||||
# Configuration
|
||||
|
||||
# Maximum power is 500 mA
|
||||
echo 500 > ${GADGET}/configs/FunKey.1/MaxPower
|
||||
|
||||
# Configuration String Descriptors
|
||||
if [ ${USBNET} -eq 1 ]; then
|
||||
echo "Mass Storage + RNDIS" > ${GADGET}/configs/FunKey.1/strings/0x409/configuration
|
||||
else
|
||||
echo "Mass Storage" > ${GADGET}/configs/FunKey.1/strings/0x409/configuration
|
||||
fi
|
||||
|
||||
if [ ${USBNET} -eq 1 ]; then
|
||||
|
||||
# Make the FunKey.1 configuration the one associated with OS Descriptors
|
||||
ln -s ${GADGET}/configs/FunKey.1 ${GADGET}/os_desc
|
||||
|
||||
# RNDIS Function
|
||||
|
||||
# Host & Device MAC Addresses
|
||||
echo ${MAC_HOST} > ${GADGET}/functions/rndis.usb0/host_addr
|
||||
echo ${MAC_DEV} > ${GADGET}/functions/rndis.usb0/dev_addr
|
||||
|
||||
# Compatible ID & Sub-Compatible ID
|
||||
echo "RNDIS" > ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/compatible_id
|
||||
echo "5162001" > ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/sub_compatible_id
|
||||
|
||||
# Add the "Icons" Extended Property
|
||||
mkdir ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Icons
|
||||
echo 2 > ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Icons/type
|
||||
echo "%SystemRoot%\\system32\\shell32.dll,-233" > ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Icons/data
|
||||
|
||||
# Add the "Label" Extended Property
|
||||
mkdir ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Label
|
||||
echo 1 > ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Label/type
|
||||
echo "FunKey S Device" > ${GADGET}/functions/rndis.usb0/os_desc/interface.rndis/Label/data
|
||||
fi
|
||||
|
||||
# Mass Storage Function
|
||||
|
||||
# Backing Store file
|
||||
#echo "/dev/mmcblk0p3" > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/file
|
||||
|
||||
# Gadget is not allowed to halt bulk endpoints
|
||||
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p3/stall
|
||||
|
||||
# Do not simulate a CDROM
|
||||
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/cdrom
|
||||
|
||||
# No SCSI Force Unit Access (FUA) to work in synchronous mode ?!?
|
||||
echo 0 > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/nofua
|
||||
|
||||
# LUN is removable
|
||||
echo 1 > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/removable
|
||||
|
||||
# Inquiry String
|
||||
echo "FunKey S Shared Disk" > ${GADGET}/functions/mass_storage.mmcblk0p3/lun.0/inquiry_string
|
||||
|
||||
if [ ${USBNET} -eq 1 ]; then
|
||||
|
||||
# Add the RNDIS function to the FunKey.1 configuration
|
||||
ln -s ${GADGET}/functions/rndis.usb0 ${GADGET}/configs/FunKey.1
|
||||
|
||||
# Bind the USB Gadget as RNDIS device
|
||||
echo ${udc_driver} > ${GADGET}/UDC
|
||||
sleep 5
|
||||
|
||||
# Start network services
|
||||
systemctl start networking ntp dropbear > /dev/null 2>&1
|
||||
|
||||
# Unbind the device
|
||||
echo > ${GADGET}/UDC
|
||||
fi
|
||||
|
||||
# Add the Mass Storage function to the FunKey.1 configuration
|
||||
ln -s ${GADGET}/functions/mass_storage.mmcblk0p3 ${GADGET}/configs/FunKey.1
|
||||
|
||||
# Each interface specifies its own class code
|
||||
echo "0x00" > ${GADGET}/bDeviceClass
|
||||
|
||||
# Bind the USB Gadget as a Mass Storage device
|
||||
echo ${udc_driver} > ${GADGET}/UDC
|
||||
return 0
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
CONFIG_ARM=y
|
||||
CONFIG_ARCH_SUNXI=y
|
||||
CONFIG_SPL=y
|
||||
CONFIG_IDENT_STRING=" FunKey"
|
||||
CONFIG_MACH_SUN8I_V3S=y
|
||||
CONFIG_DRAM_CLK=360
|
||||
# CONFIG_ARMV7_NONSEC is not set
|
||||
CONFIG_DEFAULT_DEVICE_TREE="sun8i-v3s-funkey"
|
||||
CONFIG_LOCALVERSION="-funkey"
|
||||
# CONFIG_DISTRO_DEFAULTS is not set
|
||||
# CONFIG_FIT is not set
|
||||
CONFIG_BOOTDELAY=0
|
||||
# CONFIG_PRE_CONSOLE_BUFFER is not set
|
||||
CONFIG_SYS_CONSOLE_INFO_QUIET=y
|
||||
CONFIG_SYS_STDIO_DEREGISTER=y
|
||||
# CONFIG_DISPLAY_CPUINFO is not set
|
||||
# CONFIG_DISPLAY_BOARDINFO is not set
|
||||
CONFIG_HUSH_PARSER=y
|
||||
CONFIG_CMD_BOOTZ=y
|
||||
CONFIG_CMD_PART=y
|
||||
CONFIG_CMD_EXT2=y
|
||||
CONFIG_CMD_EXT4=y
|
||||
CONFIG_CMD_FAT=y
|
||||
CONFIG_CMD_FS_GENERIC=y
|
||||
# CONFIG_ENV_IS_IN_FAT is not set
|
||||
CONFIG_ENV_IS_IN_MMC=y
|
||||
CONFIG_USE_DEFAULT_ENV_FILE=y
|
||||
CONFIG_DEFAULT_ENV_FILE="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/rootfs-overlay/etc/u-boot.env"
|
||||
# CONFIG_NET is not set
|
|
@ -0,0 +1,67 @@
|
|||
BR2_arm=y
|
||||
BR2_cortex_a7=y
|
||||
BR2_DL_DIR="../download"
|
||||
BR2_CCACHE=y
|
||||
BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/patches"
|
||||
BR2_TOOLCHAIN_EXTERNAL=y
|
||||
BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY=y
|
||||
BR2_TARGET_GENERIC_HOSTNAME="FunKey"
|
||||
BR2_TARGET_GENERIC_ISSUE="Welcome to Recovery Buildroot for the FunKey"
|
||||
BR2_ROOTFS_DEVICE_TABLE="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/device_table.txt"
|
||||
BR2_TARGET_GENERIC_ROOT_PASSWD="funkey"
|
||||
BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"
|
||||
BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
|
||||
BR2_ROOTFS_USERS_TABLES="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/users_table.txt"
|
||||
BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/rootfs-overlay"
|
||||
BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/post-build.sh"
|
||||
BR2_LINUX_KERNEL=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_GIT=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/FunKey-Project/linux"
|
||||
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="932bc41a1a2ce477855240d39edbf7a9af5b7490"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/linux.config"
|
||||
BR2_LINUX_KERNEL_LZO=y
|
||||
BR2_LINUX_KERNEL_DTS_SUPPORT=y
|
||||
BR2_LINUX_KERNEL_INTREE_DTS_NAME="sun8i-v3s-funkey"
|
||||
BR2_LINUX_KERNEL_INSTALL_TARGET=y
|
||||
BR2_PACKAGE_BUSYBOX_CONFIG="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/busybox.config"
|
||||
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
|
||||
BR2_PACKAGE_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_DOSFSTOOLS_FATLABEL=y
|
||||
BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y
|
||||
BR2_PACKAGE_DOSFSTOOLS_MKFS_FAT=y
|
||||
BR2_PACKAGE_E2FSPROGS=y
|
||||
# BR2_PACKAGE_E2FSPROGS_FSCK is not set
|
||||
BR2_PACKAGE_E2FSPROGS_RESIZE2FS=y
|
||||
BR2_PACKAGE_GPTFDISK=y
|
||||
BR2_PACKAGE_GPTFDISK_GDISK=y
|
||||
BR2_PACKAGE_GPTFDISK_SGDISK=y
|
||||
BR2_PACKAGE_PARTED=y
|
||||
BR2_PACKAGE_SYSSTAT=y
|
||||
BR2_PACKAGE_UBOOT_TOOLS=y
|
||||
BR2_PACKAGE_UBOOT_TOOLS_MKENVIMAGE=y
|
||||
BR2_PACKAGE_LIBNL=y
|
||||
BR2_PACKAGE_DHCPCD=y
|
||||
BR2_PACKAGE_DROPBEAR=y
|
||||
BR2_PACKAGE_PROCPS_NG=y
|
||||
BR2_PACKAGE_UTIL_LINUX_BINARIES=y
|
||||
BR2_PACKAGE_NANO=y
|
||||
BR2_TARGET_ROOTFS_EXT2=y
|
||||
BR2_TARGET_ROOTFS_EXT2_4=y
|
||||
BR2_TARGET_ROOTFS_EXT2_SIZE="100M"
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
BR2_TARGET_UBOOT=y
|
||||
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_GIT=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_REPO_URL="https://github.com/FunKey-Project/u-boot"
|
||||
BR2_TARGET_UBOOT_CUSTOM_REPO_VERSION="02e613eaddaacaf0ac0f0b941b90d9645be29f56"
|
||||
BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG=y
|
||||
BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_RECOVERY_PATH)/board/funkey/uboot.config"
|
||||
BR2_TARGET_UBOOT_NEEDS_DTC=y
|
||||
BR2_TARGET_UBOOT_NEEDS_PYLIBFDT=y
|
||||
BR2_TARGET_UBOOT_FORMAT_CUSTOM=y
|
||||
BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-sunxi-with-spl.bin"
|
||||
BR2_PACKAGE_HOST_DOSFSTOOLS=y
|
||||
BR2_PACKAGE_HOST_GENIMAGE=y
|
||||
BR2_PACKAGE_HOST_MTOOLS=y
|
||||
BR2_PACKAGE_HOST_UBOOT_TOOLS=y
|
|
@ -0,0 +1,2 @@
|
|||
name: RECOVERY
|
||||
desc: FunKey Recovery packages
|
|
@ -0,0 +1 @@
|
|||
include $(sort $(wildcard $(BR2_EXTERNAL_RECOVERY_PATH)/package/*/*.mk))
|
|
@ -0,0 +1,5 @@
|
|||
config BR2_PACKAGE_FUNKEY_GPIO_MAPPING
|
||||
bool "FunKey GPIO Mapping"
|
||||
default y
|
||||
help
|
||||
The FunKey GPIO mapping utility.
|
|
@ -0,0 +1,31 @@
|
|||
################################################################################
|
||||
#
|
||||
# FunKey-GPIO-mapping
|
||||
#
|
||||
################################################################################
|
||||
|
||||
FUNKEY_GPIO_MAPPING_VERSION = cd412528079a59eab66e7d426e28d9966c2d731c
|
||||
FUNKEY_GPIO_MAPPING_SITE_METHOD = git
|
||||
#FUNKEY_GPIO_MAPPING_SITE = ssh://git@github.com/FunKey-Project/FunKey-GPIO-Mapping.git
|
||||
FUNKEY_GPIO_MAPPING_SITE = ssh://git@fk/FunKey-Project/FunKey-GPIO-Mapping.git
|
||||
FUNKEY_GPIO_MAPPING_SITE_LICENSE = GPL-2.1+
|
||||
FUNKEY_GPIO_MAPPING_SITE_LICENSE_FILES = COPYING
|
||||
|
||||
define FUNKEY_GPIO_MAPPING_BUILD_CMDS
|
||||
$(TARGET_MAKE_ENV) CROSS_COMPILE=$(TARGET_CROSS) \
|
||||
CC="$(TARGET_CC)" \
|
||||
$(MAKE) -C $(@D) \
|
||||
CFLAGS="$(TARGET_CFLAGS)" $(FUNKEY_GPIO_MAPPING_BUILD_TARGET)
|
||||
endef
|
||||
|
||||
define FUNKEY_GPIO_MAPPING_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -d -m 0755 $(TARGET_DIR)/usr/local/sbin
|
||||
$(INSTALL) -m 0755 $(@D)/funkey_gpio_management $(TARGET_DIR)/usr/local/sbin/funkey_gpio_management
|
||||
$(INSTALL) -m 0755 $(@D)/termfix $(TARGET_DIR)/usr/local/sbin/termfix
|
||||
$(INSTALL) -d -m 0755 $(TARGET_DIR)/etc
|
||||
$(INSTALL) -m 0644 $(@D)/funkey_gpio_mapping.conf $(TARGET_DIR)/etc/funkey_gpio_mapping.conf
|
||||
$(INSTALL) -d -m 0755 $(TARGET_DIR)/etc/init.d
|
||||
$(INSTALL) -m 0755 $(FUNKEY_GPIO_MAPPING_PKGDIR)etc/init.d/S11funkey-gpio-management $(TARGET_DIR)/etc/init.d/S11funkey-gpio-management
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start/stop funkey_gpio_management
|
||||
#
|
||||
|
||||
DAEMON=/usr/local/sbin/funkey_gpio_management
|
||||
PIDFILE=/var/run/funkey_gpio_management.pid
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting funkey_gpio_management: "
|
||||
start-stop-daemon -S -x ${DAEMON} -p ${PIDFILE} -m -b -- > /dev/null 2>&1
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping funkey_gpio_management: "
|
||||
start-stop-daemon -K -x ${DAEMON} -p ${PIDFILE} -o > /dev/null 2>&1
|
||||
if [ ${?} -eq 0 ]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "ERROR"
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
${0} stop
|
||||
sleep 1 # Prevent race condition: ensure funkey_gpio_management stops before start.
|
||||
${0} start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ${0} {start|stop|restart}"
|
||||
exit 1
|
||||
esac
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
cd PCBA/output/images
|
||||
sudo ~/sunxi-tools/sunxi-fel -v -p uboot u-boot-sunxi-with-spl.bin \
|
||||
multi 3 \
|
||||
0x41000000 zImage \
|
||||
0x41800000 sun8i-v3s-funkey.dtb \
|
||||
0x41900000 boot.scr
|
||||
cd -
|
|
@ -12,7 +12,7 @@ image sdcard.img {
|
|||
|
||||
partition u-boot {
|
||||
in-partition-table = "no"
|
||||
image = "u-boot-sunxi-with-spl.bin"
|
||||
image = "Recovery/output/images/u-boot-sunxi-with-spl.bin"
|
||||
offset = 8K
|
||||
size = 536K # 544KB - 8KB
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ image sdcard.img {
|
|||
in-partition-table = "no"
|
||||
offset = 544K
|
||||
size = 128K
|
||||
image = "u-boot-env.img"
|
||||
image = "FunKey/output/images/u-boot-env.img"
|
||||
}
|
||||
|
||||
# partition gpt-table {
|
||||
|
@ -30,18 +30,18 @@ image sdcard.img {
|
|||
# size = 16K
|
||||
# }
|
||||
|
||||
partition rootfs_alt {
|
||||
partition Recovery {
|
||||
offset = 1M
|
||||
partition-type = 0x83
|
||||
image = "rootfs.ext4"
|
||||
image = "Recovery/output/images/rootfs.ext4"
|
||||
size = 100M
|
||||
}
|
||||
|
||||
partition rootfs {
|
||||
partition FunKey {
|
||||
offset = 101M
|
||||
partition-type = 0x83
|
||||
bootable = "yes"
|
||||
image = "rootfs.ext4"
|
||||
image = "FunKey/output/images/rootfs.ext4"
|
||||
size = 100M
|
||||
}
|
||||
|
Loading…
Reference in New Issue