aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2016-06-17 03:46:25 +0200
committerJohn Crispin <john@phrozen.org>2016-06-17 04:13:08 +0200
commite81020c3173a108fb9045af3989a74f51997b44e (patch)
tree0a32d824e7cbeca650bf590c9e71288caa681691
parent16e04fd1b4572ad9f6cf006ff6dc895711d5d6cd (diff)
downloadupstream-e81020c3173a108fb9045af3989a74f51997b44e.tar.gz
upstream-e81020c3173a108fb9045af3989a74f51997b44e.tar.bz2
upstream-e81020c3173a108fb9045af3989a74f51997b44e.zip
medaitek: convert the NAND target to UBI
Signed-off-by: John Crispin <john@phrozen.org>
-rw-r--r--target/linux/mediatek/Makefile2
-rwxr-xr-xtarget/linux/mediatek/base-files/lib/upgrade/platform.sh14
-rw-r--r--target/linux/mediatek/config-4.425
-rw-r--r--target/linux/mediatek/files/arch/arm/boot/dts/mt7623-NAND.dts3
-rw-r--r--target/linux/mediatek/image/Makefile11
-rw-r--r--target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch177
-rw-r--r--target/linux/mediatek/patches-4.4/0103-nand_fixes.patch22
7 files changed, 62 insertions, 192 deletions
diff --git a/target/linux/mediatek/Makefile b/target/linux/mediatek/Makefile
index 8a7f0af4f6..689ba31b02 100644
--- a/target/linux/mediatek/Makefile
+++ b/target/linux/mediatek/Makefile
@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
ARCH:=arm
BOARD:=mediatek
BOARDNAME:=MediaTek Ralink ARM
-FEATURES:=squashfs jffs2
+FEATURES:=squashfs nand ubifs
CPU_TYPE:=cortex-a7
MAINTAINER:=John Crispin <john@phrozen.org>
diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
index be72114adb..f2dd453a11 100755
--- a/target/linux/mediatek/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
@@ -20,7 +20,10 @@ platform_check_image() {
local board=$(cat /tmp/sysinfo/board_name)
case "$board" in
- NAND | \
+ NAND)
+ nand_do_platform_check $board $1
+ return $?
+ ;;
eMMC)
local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
@@ -39,3 +42,12 @@ platform_check_image() {
return 0
}
+
+platform_pre_upgrade() {
+ local board=$(cat /tmp/sysinfo/board_name)
+ case "$board" in
+ NAND)
+ nand_do_upgrade $1
+ ;;
+ esac
+}
diff --git a/target/linux/mediatek/config-4.4 b/target/linux/mediatek/config-4.4
index 78c9aa80e1..45fd2dc92b 100644
--- a/target/linux/mediatek/config-4.4
+++ b/target/linux/mediatek/config-4.4
@@ -98,6 +98,11 @@ CONFIG_CRC16=y
# CONFIG_CRC32_SARWATE is not set
CONFIG_CRC32_SLICEBY8=y
CONFIG_CROSS_MEMORY_ATTACH=y
+CONFIG_CRYPTO_DEFLATE=y
+CONFIG_CRYPTO_LZO=y
+CONFIG_CRYPTO_RNG2=y
+CONFIG_CRYPTO_WORKQUEUE=y
+CONFIG_CRYPTO_XZ=y
CONFIG_DCACHE_WORD_ACCESS=y
CONFIG_DEBUG_BUGVERBOSE=y
CONFIG_DEBUG_GPIO=y
@@ -181,11 +186,6 @@ CONFIG_HAVE_FUNCTION_TRACER=y
CONFIG_HAVE_GENERIC_DMA_COHERENT=y
CONFIG_HAVE_IDE=y
CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y
-CONFIG_HAVE_KERNEL_GZIP=y
-CONFIG_HAVE_KERNEL_LZ4=y
-CONFIG_HAVE_KERNEL_LZMA=y
-CONFIG_HAVE_KERNEL_LZO=y
-CONFIG_HAVE_KERNEL_XZ=y
CONFIG_HAVE_MEMBLOCK=y
CONFIG_HAVE_MOD_ARCH_SPECIFIC=y
CONFIG_HAVE_NET_DSA=y
@@ -260,6 +260,12 @@ CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_NAND_MTK=y
CONFIG_MTD_SPI_NOR=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BEB_LIMIT=20
+CONFIG_MTD_UBI_BLOCK=y
+# CONFIG_MTD_UBI_FASTMAP is not set
+# CONFIG_MTD_UBI_GLUEBI is not set
+CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTK_INFRACFG=y
CONFIG_MTK_PMIC_WRAP=y
CONFIG_MTK_SCPSYS=y
@@ -271,7 +277,6 @@ CONFIG_MUTEX_SPIN_ON_OWNER=y
CONFIG_NEED_DMA_MAP_STATE=y
# CONFIG_NEON is not set
CONFIG_NET_FLOW_LIMIT=y
-CONFIG_NET_INGRESS=y
CONFIG_NET_MEDIATEK_SOC=y
# CONFIG_NET_VENDOR_AURORA is not set
CONFIG_NET_VENDOR_MEDIATEK=y
@@ -380,11 +385,17 @@ CONFIG_SYS_SUPPORTS_APM_EMULATION=y
# CONFIG_THUMB2_KERNEL is not set
CONFIG_TICK_CPU_ACCOUNTING=y
CONFIG_TIMER_STATS=y
+CONFIG_UBIFS_FS=y
+# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
+CONFIG_UBIFS_FS_LZO=y
+CONFIG_UBIFS_FS_XZ=y
+CONFIG_UBIFS_FS_ZLIB=y
CONFIG_UEVENT_HELPER_PATH=""
CONFIG_UNCOMPRESS_INCLUDE="debug/uncompress.h"
CONFIG_UNINLINE_SPIN_UNLOCK=y
CONFIG_USB=y
CONFIG_USB_COMMON=y
+# CONFIG_USB_EHCI_HCD is not set
CONFIG_USB_SUPPORT=y
# CONFIG_USB_UHCI_HCD is not set
CONFIG_USB_XHCI_HCD=y
@@ -402,4 +413,6 @@ CONFIG_XZ_DEC_ARM=y
CONFIG_XZ_DEC_BCJ=y
CONFIG_ZBOOT_ROM_BSS=0
CONFIG_ZBOOT_ROM_TEXT=0
+CONFIG_ZLIB_DEFLATE=y
+CONFIG_ZLIB_INFLATE=y
CONFIG_ZONE_DMA_FLAG=0
diff --git a/target/linux/mediatek/files/arch/arm/boot/dts/mt7623-NAND.dts b/target/linux/mediatek/files/arch/arm/boot/dts/mt7623-NAND.dts
index 43551f7a07..15b7da9a76 100644
--- a/target/linux/mediatek/files/arch/arm/boot/dts/mt7623-NAND.dts
+++ b/target/linux/mediatek/files/arch/arm/boot/dts/mt7623-NAND.dts
@@ -360,7 +360,6 @@
nand@0 {
reg = <0>;
spare_per_sector = <64>;
- nand-on-flash-bbt;
nand-ecc-mode = "hw";
nand-ecc-strength = <12>;
nand-ecc-step-size = <1024>;
@@ -390,7 +389,7 @@
};
partition@4140000 {
- label = "rootfs";
+ label = "ubi";
reg = <0x4140000 0x1000000>;
};
};
diff --git a/target/linux/mediatek/image/Makefile b/target/linux/mediatek/image/Makefile
index b88d2dce2f..3139197dd3 100644
--- a/target/linux/mediatek/image/Makefile
+++ b/target/linux/mediatek/image/Makefile
@@ -30,12 +30,13 @@ define Image/Build/squashfs
$(CP) $(KDIR)/root.squashfs $(BIN_DIR)/$(IMG_PREFIX)-root.squashfs
$(call Image/Build/SysupgradeCombined,eMMC,squashfs)
-endef
-
-define Image/Build/jffs2-128k
- $(CP) $(KDIR)/root.jffs2-128k $(BIN_DIR)/$(IMG_PREFIX)-root.jffs2
- $(call Image/Build/SysupgradeCombined,NAND,jffs2-128k)
+ $(call Image/BuilduImage,NAND)
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+ $(call Image/BuilduImage,NAND,-initramfs)
+ $(CP) $(KDIR)/uImage-NAND-initramfs $(BIN_DIR)/$(IMG_PREFIX)-uImage-NAND-initramfs
+endif
+ $(call Image/Build/SysupgradeNAND,NAND,$(1),$(KDIR)/uImage-NAND)
endef
define Image/Build
diff --git a/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch b/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch
index ccbf8d0fb2..7e7a5de1c8 100644
--- a/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch
+++ b/target/linux/mediatek/patches-4.4/0072-mtd-backport-v4.7-0day-patches-from-Boris.patch
@@ -31,11 +31,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
drivers/mtd/tests/mtd_nandecctest.c | 2 +-
drivers/mtd/tests/oobtest.c | 49 ++-
drivers/mtd/tests/pagetest.c | 3 +-
- drivers/mtd/ubi/cdev.c | 4 +-
- drivers/mtd/ubi/misc.c | 49 +++
- drivers/mtd/ubi/ubi.h | 16 +-
- drivers/mtd/ubi/upd.c | 2 +-
- drivers/mtd/ubi/wl.c | 21 +-
include/linux/mtd/bbm.h | 1 -
include/linux/mtd/fsmc.h | 18 --
include/linux/mtd/inftl.h | 1 -
@@ -4654,178 +4649,6 @@ Signed-off-by: John Crispin <blogic@openwrt.org>
addr0 = 0;
for (i = 0; i < ebcnt && bbt[i]; ++i)
---- a/drivers/mtd/ubi/cdev.c
-+++ b/drivers/mtd/ubi/cdev.c
-@@ -174,9 +174,9 @@ static int vol_cdev_fsync(struct file *f
- struct ubi_device *ubi = desc->vol->ubi;
- struct inode *inode = file_inode(file);
- int err;
-- mutex_lock(&inode->i_mutex);
-+ inode_lock(inode);
- err = ubi_sync(ubi->ubi_num);
-- mutex_unlock(&inode->i_mutex);
-+ inode_unlock(inode);
- return err;
- }
-
---- a/drivers/mtd/ubi/misc.c
-+++ b/drivers/mtd/ubi/misc.c
-@@ -153,3 +153,52 @@ int ubi_check_pattern(const void *buf, u
- return 0;
- return 1;
- }
-+
-+/* Normal UBI messages */
-+void ubi_msg(const struct ubi_device *ubi, const char *fmt, ...)
-+{
-+ struct va_format vaf;
-+ va_list args;
-+
-+ va_start(args, fmt);
-+
-+ vaf.fmt = fmt;
-+ vaf.va = &args;
-+
-+ pr_notice(UBI_NAME_STR "%d: %pV\n", ubi->ubi_num, &vaf);
-+
-+ va_end(args);
-+}
-+
-+/* UBI warning messages */
-+void ubi_warn(const struct ubi_device *ubi, const char *fmt, ...)
-+{
-+ struct va_format vaf;
-+ va_list args;
-+
-+ va_start(args, fmt);
-+
-+ vaf.fmt = fmt;
-+ vaf.va = &args;
-+
-+ pr_warn(UBI_NAME_STR "%d warning: %ps: %pV\n",
-+ ubi->ubi_num, __builtin_return_address(0), &vaf);
-+
-+ va_end(args);
-+}
-+
-+/* UBI error messages */
-+void ubi_err(const struct ubi_device *ubi, const char *fmt, ...)
-+{
-+ struct va_format vaf;
-+ va_list args;
-+
-+ va_start(args, fmt);
-+
-+ vaf.fmt = fmt;
-+ vaf.va = &args;
-+
-+ pr_err(UBI_NAME_STR "%d error: %ps: %pV\n",
-+ ubi->ubi_num, __builtin_return_address(0), &vaf);
-+ va_end(args);
-+}
---- a/drivers/mtd/ubi/ubi.h
-+++ b/drivers/mtd/ubi/ubi.h
-@@ -49,15 +49,19 @@
- /* UBI name used for character devices, sysfs, etc */
- #define UBI_NAME_STR "ubi"
-
-+struct ubi_device;
-+
- /* Normal UBI messages */
--#define ubi_msg(ubi, fmt, ...) pr_notice(UBI_NAME_STR "%d: " fmt "\n", \
-- ubi->ubi_num, ##__VA_ARGS__)
-+__printf(2, 3)
-+void ubi_msg(const struct ubi_device *ubi, const char *fmt, ...);
-+
- /* UBI warning messages */
--#define ubi_warn(ubi, fmt, ...) pr_warn(UBI_NAME_STR "%d warning: %s: " fmt "\n", \
-- ubi->ubi_num, __func__, ##__VA_ARGS__)
-+__printf(2, 3)
-+void ubi_warn(const struct ubi_device *ubi, const char *fmt, ...);
-+
- /* UBI error messages */
--#define ubi_err(ubi, fmt, ...) pr_err(UBI_NAME_STR "%d error: %s: " fmt "\n", \
-- ubi->ubi_num, __func__, ##__VA_ARGS__)
-+__printf(2, 3)
-+void ubi_err(const struct ubi_device *ubi, const char *fmt, ...);
-
- /* Background thread name pattern */
- #define UBI_BGT_NAME_PATTERN "ubi_bgt%dd"
---- a/drivers/mtd/ubi/wl.c
-+++ b/drivers/mtd/ubi/wl.c
-@@ -628,6 +628,7 @@ static int do_sync_erase(struct ubi_devi
- return __erase_worker(ubi, &wl_wrk);
- }
-
-+static int ensure_wear_leveling(struct ubi_device *ubi, int nested);
- /**
- * wear_leveling_worker - wear-leveling worker function.
- * @ubi: UBI device description object
-@@ -649,6 +650,7 @@ static int wear_leveling_worker(struct u
- #endif
- struct ubi_wl_entry *e1, *e2;
- struct ubi_vid_hdr *vid_hdr;
-+ int dst_leb_clean = 0;
-
- kfree(wrk);
- if (shutdown)
-@@ -753,6 +755,7 @@ static int wear_leveling_worker(struct u
-
- err = ubi_io_read_vid_hdr(ubi, e1->pnum, vid_hdr, 0);
- if (err && err != UBI_IO_BITFLIPS) {
-+ dst_leb_clean = 1;
- if (err == UBI_IO_FF) {
- /*
- * We are trying to move PEB without a VID header. UBI
-@@ -798,10 +801,12 @@ static int wear_leveling_worker(struct u
- * protection queue.
- */
- protect = 1;
-+ dst_leb_clean = 1;
- goto out_not_moved;
- }
- if (err == MOVE_RETRY) {
- scrubbing = 1;
-+ dst_leb_clean = 1;
- goto out_not_moved;
- }
- if (err == MOVE_TARGET_BITFLIPS || err == MOVE_TARGET_WR_ERR ||
-@@ -827,6 +832,7 @@ static int wear_leveling_worker(struct u
- ubi->erroneous_peb_count);
- goto out_error;
- }
-+ dst_leb_clean = 1;
- erroneous = 1;
- goto out_not_moved;
- }
-@@ -897,15 +903,24 @@ out_not_moved:
- wl_tree_add(e1, &ubi->scrub);
- else
- wl_tree_add(e1, &ubi->used);
-+ if (dst_leb_clean) {
-+ wl_tree_add(e2, &ubi->free);
-+ ubi->free_count++;
-+ }
-+
- ubi_assert(!ubi->move_to_put);
- ubi->move_from = ubi->move_to = NULL;
- ubi->wl_scheduled = 0;
- spin_unlock(&ubi->wl_lock);
-
- ubi_free_vid_hdr(ubi, vid_hdr);
-- err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
-- if (err)
-- goto out_ro;
-+ if (dst_leb_clean) {
-+ ensure_wear_leveling(ubi, 1);
-+ } else {
-+ err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
-+ if (err)
-+ goto out_ro;
-+ }
-
- mutex_unlock(&ubi->move_mutex);
- return 0;
--- a/include/linux/mtd/bbm.h
+++ b/include/linux/mtd/bbm.h
@@ -166,7 +166,6 @@ struct bbm_info {
diff --git a/target/linux/mediatek/patches-4.4/0103-nand_fixes.patch b/target/linux/mediatek/patches-4.4/0103-nand_fixes.patch
new file mode 100644
index 0000000000..5e18fb4760
--- /dev/null
+++ b/target/linux/mediatek/patches-4.4/0103-nand_fixes.patch
@@ -0,0 +1,22 @@
+--- a/drivers/mtd/nand/mtk_nand.c
++++ b/drivers/mtd/nand/mtk_nand.c
+@@ -1017,8 +1017,8 @@
+ if (section >= eccsteps)
+ return -ERANGE;
+
+- oob_region->length = fdm->reg_size - fdm->ecc_size;
+- oob_region->offset = section * fdm->reg_size + fdm->ecc_size;
++ oob_region->length = fdm->reg_size - 1;
++ oob_region->offset = section * fdm->reg_size + 1;
+
+ return 0;
+ }
+@@ -1058,7 +1058,7 @@
+ fdm->reg_size = NFI_FDM_MAX_SIZE;
+
+ /* bad block mark storage */
+- fdm->ecc_size = 1;
++ fdm->ecc_size = fdm->reg_size;
+ }
+
+ static void mtk_nfc_set_bad_mark_ctl(struct mtk_nfc_bad_mark_ctl *bm_ctl,