Skip to content

Commit

Permalink
Merge pull request motioneye-project#55 from ccrisan/nanopir1
Browse files Browse the repository at this point in the history
Add Nano Pi R1 support
  • Loading branch information
ccrisan authored Aug 28, 2020
2 parents 73beeb3 + a688500 commit d0f50f9
Show file tree
Hide file tree
Showing 43 changed files with 1,822 additions and 42 deletions.
36 changes: 28 additions & 8 deletions board/common/busybox.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.29.3
# Tue Jan 14 23:44:35 2020
# Busybox version: 1.31.1
# Fri Aug 28 11:34:30 2020
#
CONFIG_HAVE_DOT_CONFIG=y

Expand All @@ -24,6 +24,7 @@ CONFIG_FEATURE_WTMP=y
# CONFIG_FEATURE_PIDFILE is not set
CONFIG_PID_FILE_PATH=""
CONFIG_BUSYBOX=y
CONFIG_FEATURE_SHOW_SCRIPT=y
CONFIG_FEATURE_INSTALLER=y
# CONFIG_INSTALL_NO_USR is not set
CONFIG_FEATURE_SUID=y
Expand All @@ -33,6 +34,7 @@ CONFIG_FEATURE_SUID=y
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
# CONFIG_SELINUX is not set
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_SYSLOG_INFO=y
CONFIG_FEATURE_SYSLOG=y
CONFIG_PLATFORM_LINUX=y

Expand Down Expand Up @@ -82,7 +84,9 @@ CONFIG_NO_DEBUG_LIB=y
# Library Tuning
#
# CONFIG_FEATURE_USE_BSS_TAIL is not set
CONFIG_FLOAT_DURATION=y
CONFIG_FEATURE_RTMINMAX=y
CONFIG_FEATURE_RTMINMAX_USE_LIBC_DEFINITIONS=y
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
Expand Down Expand Up @@ -205,6 +209,7 @@ CONFIG_CKSUM=y
# CONFIG_COMM is not set
CONFIG_CP=y
# CONFIG_FEATURE_CP_LONG_OPTIONS is not set
# CONFIG_FEATURE_CP_REFLINK is not set
CONFIG_CUT=y
CONFIG_DATE=y
CONFIG_FEATURE_DATE_ISOFMT=y
Expand Down Expand Up @@ -232,7 +237,6 @@ CONFIG_EXPR_MATH_SUPPORT_64=y
CONFIG_FACTOR=y
CONFIG_FALSE=y
CONFIG_FOLD=y
# CONFIG_FSYNC is not set
CONFIG_HEAD=y
CONFIG_FEATURE_FANCY_HEAD=y
CONFIG_HOSTID=y
Expand Down Expand Up @@ -287,7 +291,6 @@ CONFIG_SHRED=y
# CONFIG_SHUF is not set
CONFIG_SLEEP=y
# CONFIG_FEATURE_FANCY_SLEEP is not set
# CONFIG_FEATURE_FLOAT_SLEEP is not set
CONFIG_SORT=y
CONFIG_FEATURE_SORT_BIG=y
# CONFIG_FEATURE_SORT_OPTIMIZE_MEMORY is not set
Expand All @@ -300,6 +303,7 @@ CONFIG_STTY=y
# CONFIG_SUM is not set
CONFIG_SYNC=y
CONFIG_FEATURE_SYNC_FANCY=y
# CONFIG_FSYNC is not set
# CONFIG_TAC is not set
CONFIG_TAIL=y
CONFIG_FEATURE_FANCY_TAIL=y
Expand Down Expand Up @@ -438,6 +442,7 @@ CONFIG_FEATURE_FIND_MTIME=y
CONFIG_FEATURE_FIND_MMIN=y
CONFIG_FEATURE_FIND_PERM=y
CONFIG_FEATURE_FIND_TYPE=y
CONFIG_FEATURE_FIND_EXECUTABLE=y
CONFIG_FEATURE_FIND_XDEV=y
CONFIG_FEATURE_FIND_MAXDEPTH=y
CONFIG_FEATURE_FIND_NEWER=y
Expand All @@ -451,6 +456,7 @@ CONFIG_FEATURE_FIND_DEPTH=y
CONFIG_FEATURE_FIND_PAREN=y
CONFIG_FEATURE_FIND_SIZE=y
CONFIG_FEATURE_FIND_PRUNE=y
CONFIG_FEATURE_FIND_QUIT=y
# CONFIG_FEATURE_FIND_DELETE is not set
CONFIG_FEATURE_FIND_PATH=y
CONFIG_FEATURE_FIND_REGEX=y
Expand Down Expand Up @@ -630,6 +636,7 @@ CONFIG_LSUSB=y
# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set
# CONFIG_FEATURE_MDEV_EXEC is not set
# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set
# CONFIG_FEATURE_MDEV_DAEMON is not set
CONFIG_MESG=y
CONFIG_FEATURE_MESG_ENABLE_ONLY_GROUP=y
CONFIG_MKE2FS=y
Expand All @@ -653,6 +660,8 @@ CONFIG_FEATURE_MOUNT_FLAGS=y
CONFIG_FEATURE_MOUNT_FSTAB=y
CONFIG_FEATURE_MOUNT_OTHERTAB=y
# CONFIG_MOUNTPOINT is not set
CONFIG_NOLOGIN=y
CONFIG_NOLOGIN_DEPENDENCIES=y
CONFIG_NSENTER=y
# CONFIG_PIVOT_ROOT is not set
# CONFIG_RDATE is not set
Expand Down Expand Up @@ -728,6 +737,12 @@ CONFIG_FEATURE_VOLUMEID_MINIX=y
# CONFIG_ADJTIMEX is not set
# CONFIG_BBCONFIG is not set
# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set
CONFIG_BC=y
# CONFIG_DC is not set
CONFIG_FEATURE_DC_BIG=y
# CONFIG_FEATURE_DC_LIBM is not set
CONFIG_FEATURE_BC_INTERACTIVE=y
CONFIG_FEATURE_BC_LONG_OPTIONS=y
# CONFIG_BEEP is not set
CONFIG_FEATURE_BEEP_FREQ=0
CONFIG_FEATURE_BEEP_LENGTH_MS=0
Expand All @@ -746,14 +761,12 @@ CONFIG_FEATURE_CROND_D=y
CONFIG_FEATURE_CROND_SPECIAL_TIMES=y
CONFIG_FEATURE_CROND_DIR="/data/etc"
CONFIG_CRONTAB=y
# CONFIG_DC is not set
# CONFIG_FEATURE_DC_LIBM is not set
# CONFIG_DEVFSD is not set
# CONFIG_DEVFSD_MODLOAD is not set
# CONFIG_DEVFSD_FG_NP is not set
# CONFIG_DEVFSD_VERBOSE is not set
# CONFIG_FEATURE_DEVFS is not set
# CONFIG_DEVMEM is not set
CONFIG_DEVMEM=y
# CONFIG_FBSPLASH is not set
# CONFIG_FLASHCP is not set
# CONFIG_FLASH_ERASEALL is not set
Expand All @@ -771,6 +784,7 @@ CONFIG_I2CGET=y
CONFIG_I2CSET=y
CONFIG_I2CDUMP=y
CONFIG_I2CDETECT=y
CONFIG_I2CTRANSFER=y
# CONFIG_INOTIFYD is not set
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
Expand All @@ -797,13 +811,14 @@ CONFIG_FEATURE_MAKEDEVS_TABLE=y
CONFIG_PARTPROBE=y
# CONFIG_RAIDAUTORUN is not set
# CONFIG_READAHEAD is not set
# CONFIG_RFKILL is not set
CONFIG_RFKILL=y
# CONFIG_RUNLEVEL is not set
# CONFIG_RX is not set
CONFIG_SETFATTR=y
# CONFIG_SETSERIAL is not set
# CONFIG_STRINGS is not set
CONFIG_TIME=y
CONFIG_TS=y
# CONFIG_TTYSIZE is not set
CONFIG_UBIRENAME=y
# CONFIG_UBIATTACH is not set
Expand All @@ -822,6 +837,7 @@ CONFIG_FEATURE_IPV6=y
# CONFIG_FEATURE_UNIX_LOCAL is not set
# CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
# CONFIG_FEATURE_TLS_SHA1 is not set
# CONFIG_ARP is not set
CONFIG_ARPING=y
# CONFIG_BRCTL is not set
Expand Down Expand Up @@ -909,6 +925,7 @@ CONFIG_FEATURE_NSLOOKUP_LONG_OPTIONS=y
# CONFIG_NTPD is not set
# CONFIG_FEATURE_NTPD_SERVER is not set
# CONFIG_FEATURE_NTPD_CONF is not set
# CONFIG_FEATURE_NTP_AUTH is not set
CONFIG_PING=y
# CONFIG_PING6 is not set
CONFIG_FEATURE_FANCY_PING=y
Expand All @@ -929,6 +946,7 @@ CONFIG_FEATURE_TC_INGRESS=y
# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
# CONFIG_TFTP is not set
# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set
# CONFIG_FEATURE_TFTP_HPA_COMPAT is not set
# CONFIG_TFTPD is not set
# CONFIG_FEATURE_TFTP_GET is not set
# CONFIG_FEATURE_TFTP_PUT is not set
Expand Down Expand Up @@ -1134,11 +1152,13 @@ CONFIG_ASH_TEST=y
#
CONFIG_FEATURE_SH_MATH=y
CONFIG_FEATURE_SH_MATH_64=y
CONFIG_FEATURE_SH_MATH_BASE=y
# CONFIG_FEATURE_SH_EXTRA_QUIET is not set
# CONFIG_FEATURE_SH_STANDALONE is not set
# CONFIG_FEATURE_SH_NOFORK is not set
CONFIG_FEATURE_SH_READ_FRAC=y
# CONFIG_FEATURE_SH_HISTFILESIZE is not set
CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS=y

#
# System Logging Utilities
Expand Down
6 changes: 3 additions & 3 deletions board/common/overlay/etc/fstab.disk
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# <file system> <mount pt> <type> <options> <dump> <pass>
/dev/mmcblk0p1 /boot vfat ro,defaults 0 0
/dev/mmcblk0p3 /data ext4 defaults,noatime 0 0
# <file system> <mount pt> <type> <options> <dump> <pass>
${disk_dev_prefix}1 /boot vfat ro,defaults 0 0
${disk_dev_prefix}3 /data ext4 defaults,noatime 0 0
21 changes: 19 additions & 2 deletions board/common/overlay/etc/init.d/S00datapart
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,34 @@ case "$1" in
root_dev=$(cat /proc/cmdline | grep -oE 'root=[/a-z0-9]+' | cut -d '=' -f 2)
if [[ "${root_dev}" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
disk_dev=${BASH_REMATCH[1]}
disk_dev_prefix=${disk_dev}p
boot_dev=${disk_dev}p1
root_dev=${disk_dev}p2
data_dev=${disk_dev}p3
elif [[ "${root_dev}" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
disk_dev=${BASH_REMATCH[1]}
disk_dev_prefix=${disk_dev}
boot_dev=${disk_dev}1
root_dev=${disk_dev}2
data_dev=${disk_dev}3
else
msg_fail "unknown (${root_dev})"
exit 1
fi

for ext in disk extra overlay; do
sed "s,"'${disk_dev_prefix}'",${disk_dev_prefix},g" /etc/fstab.${ext} > /tmp/fstab.${ext}
done

# Output disk info to /tmp/disk_info
{
echo "DISK_DEV=${disk_dev}"
echo "DISK_DEV_PREFIX=${disk_dev_prefix}"
echo "BOOT_DEV=${boot_dev}"
echo "ROOT_DEV=${root_dev}"
echo "DATA_DEV=${data_dev}"
} > /tmp/disk_info

msg_done "${disk_dev}"

test -b ${data_dev} && exit 0
Expand All @@ -41,7 +59,7 @@ case "$1" in
test $? == 0 && msg_done || msg_fail

msg_begin "Mounting data partition"
mount -T /etc/fstab.disk /data && msg_done || msg_fail
mount -T /tmp/fstab.disk /data && msg_done || msg_fail

msg_begin "Copying data skeleton"
cp -pur /usr/share/dataskel/* /data
Expand All @@ -57,4 +75,3 @@ case "$1" in
echo "Usage: $0 {start}"
exit 1
esac

13 changes: 6 additions & 7 deletions board/common/overlay/etc/init.d/S01mountall
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ test -n "${OS_VERSION}" || source /etc/init.d/base

mount_fs() {
msg_begin "Mounting filesystems"
/bin/mount -T /etc/fstab.disk -a &&
/bin/mount -T /etc/fstab.extra -a &&
/bin/mount -T /tmp/fstab.disk -a &&
/bin/mount -T /tmp/fstab.extra -a &&
if [[ -r /data/etc/fstab.user ]]; then /bin/mount -T /data/etc/fstab.user -a; fi

test $? == 0 && msg_done || msg_fail
Expand All @@ -16,10 +16,10 @@ mount_overlay() {
grep -qw overlay /proc/filesystems || return

msg_begin "Mounting overlay filesystems"
grep -oE 'lowerdir=[^,]+' /etc/fstab.overlay | cut -d '=' -f 2 | xargs -r mkdir -p
grep -oE 'upperdir=[^,]+' /etc/fstab.overlay | cut -d '=' -f 2 | xargs -r mkdir -p
grep -oE 'workdir=[^ ]+' /etc/fstab.overlay | cut -d '=' -f 2 | xargs -r mkdir -p
/bin/mount -T /etc/fstab.overlay -a
grep -oE 'lowerdir=[^,]+' /tmp/fstab.overlay | cut -d '=' -f 2 | xargs -r mkdir -p
grep -oE 'upperdir=[^,]+' /tmp/fstab.overlay | cut -d '=' -f 2 | xargs -r mkdir -p
grep -oE 'workdir=[^ ]+' /tmp/fstab.overlay | cut -d '=' -f 2 | xargs -r mkdir -p
/bin/mount -T /tmp/fstab.overlay -a
test $? == 0 && msg_done || msg_fail
}

Expand Down Expand Up @@ -59,4 +59,3 @@ case "$1" in
esac

exit $?

24 changes: 3 additions & 21 deletions board/common/overlay/sbin/fwupdate
Original file line number Diff line number Diff line change
Expand Up @@ -99,31 +99,13 @@ function cleanup_on_exit() {
losetup -d ${BOOT_LOOP} 2>/dev/null
losetup -d ${ROOT_LOOP} 2>/dev/null

mount -T /etc/fstab.disk -o ro /boot 2>/dev/null
mount -T /tmp/fstab.disk -o ro /boot 2>/dev/null
}


#### disk & partition devices ####

BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
if [[ -n "${BOOT_DEV}" ]]; then
ROOT_DEV=${BOOT_DEV:0:-1}2
DATA_DEV=${BOOT_DEV:0:-1}3
else # boot partition not mounted, trying with data partition
DATA_DEV=$(mount | grep /data | cut -d ' ' -f 1)
BOOT_DEV=${DATA_DEV:0:-1}1
ROOT_DEV=${BOOT_DEV:0:-1}2
fi

DISK_DEV=${BOOT_DEV}
if [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
DISK_DEV=${BASH_REMATCH[1]}
elif [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
DISK_DEV=${BASH_REMATCH[1]}
else
echo "cannot identify disk device from ${ROOT_DEV}" 1>&2
exit 1
fi
source /tmp/disk_info

function reallocate_boot_part() {
current_boot_info=$(fdisk --bytes -l -o device,start,end,size ${DISK_DEV} | grep "${BOOT_DEV}")
Expand Down Expand Up @@ -480,7 +462,7 @@ function do_flash_boot() {
echo ${pid} > ${DD_PID_FILE}
wait ${pid}

mount -T /etc/fstab.disk -o rw /boot
mount -T /tmp/fstab.disk -o rw /boot

# the /usr/libexec/fw-restore-boot-cfg script, if present, takes the old (backup) boot dir as argument
# and should restore any /boot configuration that needs to be preserved across updates
Expand Down
56 changes: 56 additions & 0 deletions board/common/overlay/sbin/toemmc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

if [[ -z "$1" ]]; then
echo "Usage: $0 <emmc_dev>"
exit 1
fi

shopt -s extglob # For extended globbing of /boot/*.{txt,ini,...}

emmc_dev=$1

function msg() {
echo " * $1"
}

source /tmp/disk_info

msg "SD card device is ${DISK_DEV}"

root_info=$(fdisk -l -o device,start,end,size ${DISK_DEV} | grep "${ROOT_DEV}")
root_info=(${root_info})

root_end_sector=${root_info[2]}
total_size=$(((root_end_sector + 1) * 512 / 10485760)) # x 10MB

msg "Unmounting all EMMC partitions"
umount ${emmc_dev}* &>/dev/null
partx -d ${emmc_dev} &>/dev/null

msg "Copying ${total_size}0MB from ${DISK_DEV} to ${emmc_dev}"
dd if=${DISK_DEV} of=${emmc_dev} bs=10M count=${total_size} status=none
sync
partx -a ${emmc_dev} &>/dev/null

msg "Removing data partition from EMMC"
fdisk >/dev/null ${emmc_dev} <<END
d
3
w
END
sync

msg "Mounting ${emmc_dev}p1 boot partition"
mkdir -p /data/.emmc_boot
mount ${emmc_dev}p1 /data/.emmc_boot
cd /data/.emmc_boot

msg "Ajusting EMMC root device"
sed -i "s,${DISK_DEV},${emmc_dev},g" *.@(txt|ini|conf)

msg "Cleaning up"
cd - >/dev/null
umount /data/.emmc_boot
rmdir /data/.emmc_boot

msg "Done!"
1 change: 0 additions & 1 deletion board/nanopineo/os.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
OS_TTY_LOGIN="ttyS0"

Loading

0 comments on commit d0f50f9

Please sign in to comment.