From eea1ff0328f5f108555862348a88c0fd274c3f89 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Thu, 3 Feb 2011 22:18:34 +0800 Subject: [PATCH] add nanonote script files --- nanonote-example-files/Makefile | 14 ++- .../script-files/usr/bin/mtd.nn | 85 +++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) create mode 100755 nanonote-example-files/script-files/usr/bin/mtd.nn diff --git a/nanonote-example-files/Makefile b/nanonote-example-files/Makefile index 19033f1..43ff099 100644 --- a/nanonote-example-files/Makefile +++ b/nanonote-example-files/Makefile @@ -1,11 +1,11 @@ include $(TOPDIR)/rules.mk -PKG_NAME:=nanonote-example-files +PKG_NAME:=nanonote-files PKG_VERSION:=1.0 include $(INCLUDE_DIR)/package.mk -define Package/nanonote-example-files/Default +define Package/nanonote-files/Default MAINTAINER:="Xiangfu Liu" TITLE:=NanoNote Files SECTION:=utils @@ -17,6 +17,11 @@ define Package/nanonote-example-files TITLE+=(Example Files) endef +define Package/nanonote-script-files + $(call Package/nanonote-files/Default) + TITLE+=(Script Files) +endef + define Build/Compile endef @@ -24,4 +29,9 @@ define Package/nanonote-example-files/install $(CP) ./example-files/* $(1)/ endef +define Package/nanonote-script-files/install + $(CP) ./script-files/* $(1)/ +endef + $(eval $(call BuildPackage,nanonote-example-files)) +$(eval $(call BuildPackage,nanonote-script-files)) diff --git a/nanonote-example-files/script-files/usr/bin/mtd.nn b/nanonote-example-files/script-files/usr/bin/mtd.nn new file mode 100755 index 0000000..447879a --- /dev/null +++ b/nanonote-example-files/script-files/usr/bin/mtd.nn @@ -0,0 +1,85 @@ +#!/bin/bash + +if [ "$1" == "flash" ] && [ "$#" == "3" ]; then + case "$2" in + "bootloader") + echo "not implenment" + #flash_eraseall /dev/mtd0 + exit 0 + ;; + "kernel") + echo "flashing kernel ..." + flash_eraseall /dev/mtd1 + nandwrite -p /dev/mtd1 "$3" + exit 0 + ;; + "rootfs") + echo "flashing rootfs ..." + ubiformat /dev/mtd2 -f "$3" + exit 0 + ;; + "data") + echo "flashing data partition ..." + ubiformat /dev/mtd3 -f "$3" + exit 0 + ;; + esac +fi + +if [ "$1" == "mount" ] && [ "$#" == "3" ]; then + MOUNT_POINT="$3" + + if [ "$2" == "rootfs" ]; then + PARTITION="2" + elif [ "$2" == "data" ]; then + PARTITION="3" + fi + + ubiattach /dev/ubi_ctrl -m ${PARTITION} + DEV_UBI=`dmesg | grep "UBI: attached mtd${PARTITION} to" | cut -d ":" -f 2 | cut -d " " -f 5` + mkdir -p $MOUNT_POINT + if [ -d "$3" ]; then + echo "$3 not a folder" + exit 1 + fi + + mount -t ubifs ${DEV_UBI}_0 $MOUNT_POINT +fi + + +if [ "$1" == "format_data" ]; then + ubiformat /dev/mtd3 -y + ubiattach /dev/ubi_ctrl -m 3 + ubimkvol /dev/ubi1 -s 1730MiB -N data + exit 0 +fi + +if [ "$1" == "fw_setenv_default" ]; then + fw_setenv bootargs mem=32M console=tty0 console=ttyS0,57600n8 ubi.mtd=2 rootfstype=ubifs root=ubi0:rootfs rw rootwait + fw_setenv bootcmd nand read 0x80600000 0x400000 0x200000\;bootm + fw_setenv bootargsfromsd mem=32M console=tty0 console=ttyS0,57600n8 rootfstype=ext2 root=/dev/mmcblk0p1 rw rootwait + fw_setenv bootcmdfromsd mmc init\; ext2load mmc 0 0x80600000 /boot/uImage\; bootm + fw_setenv bootdelay 0 + fw_setenv baudrate 57600 + fw_setenv loads_echo 1 + fw_setenv stdin serial + fw_setenv stderr serial + fw_setenv stdout serial + exit 0 +fi + +echo "\ +Usage: $0 [-d ] [-l ] [-h] + -d <> I will download and flash a specific version of OpenWrt images + + -l <> I will flash images present in + (missing files will be skipped) + + -h you already found out + +OpenWrt reflash script for qi-hardware Ben NanoNote +written by: Xiangfu Liu (xiangfu@sharism.cc) + + version: ${__VERSION__} +Please report bugs to developer@lists.qi-hardware.com" +exit 1