[LEDE-DEV] [PATCH 2/3] mtd: ubiblock: introduce ubiblock_create_dev

2016-08-27 Thread Daniel Golle
Define function ubiblock_create_dev(char *name, dev_t *bdev)
which returns the created device by setting the point bdev.
This is useful for in-kernel users creating a ubiblock device
in order to mount the root filesystem.

Signed-off-by: Daniel Golle 
---
 drivers/mtd/ubi/block.c | 11 ++-
 drivers/mtd/ubi/ubi.h   |  2 ++
 include/linux/mtd/ubi.h | 16 
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index ebf46ad..58b818f 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -49,6 +49,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ubi-media.h"
@@ -356,7 +357,11 @@ static struct blk_mq_ops ubiblock_mq_ops = {
 
 static DEFINE_IDR(ubiblock_minor_idr);
 
-int ubiblock_create(struct ubi_volume_info *vi)
+int ubiblock_create(struct ubi_volume_info *vi) {
+   return ubiblock_create_dev(vi, NULL);
+}
+
+int ubiblock_create_dev(struct ubi_volume_info *vi, dev_t *bdev)
 {
struct ubiblock *dev;
struct gendisk *gd;
@@ -448,6 +453,10 @@ int ubiblock_create(struct ubi_volume_info *vi)
add_disk(dev->gd);
dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
 dev->ubi_num, dev->vol_id, vi->name);
+
+   if (bdev)
+   *bdev = MKDEV(gd->major, gd->first_minor);
+
return 0;
 
 out_free_queue:
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index de1ea2e4..7700752 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "ubi-media.h"
@@ -917,6 +918,7 @@ static inline int ubi_update_fastmap(struct ubi_device 
*ubi) { return 0; }
 int ubiblock_init(void);
 void ubiblock_exit(void);
 int ubiblock_create(struct ubi_volume_info *vi);
+int ubiblock_create_dev(struct ubi_volume_info *vi, dev_t *bdev);
 int ubiblock_remove(struct ubi_volume_info *vi);
 #else
 static inline int ubiblock_init(void) { return 0; }
diff --git a/include/linux/mtd/ubi.h b/include/linux/mtd/ubi.h
index 0b92aa5..3d6444f 100644
--- a/include/linux/mtd/ubi.h
+++ b/include/linux/mtd/ubi.h
@@ -21,7 +21,9 @@
 #ifndef __LINUX_UBI_H__
 #define __LINUX_UBI_H__
 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -282,4 +284,18 @@ static inline int ubi_read_sg(struct ubi_volume_desc 
*desc, int lnum,
 {
return ubi_leb_read_sg(desc, lnum, sgl, offset, len, 0);
 }
+
+
+/*
+ * This function allows in-kernel users to create a ubiblock device and
+ * get to know about the created device.
+ */
+#ifdef CONFIG_MTD_UBI_BLOCK
+int ubiblock_create_dev(struct ubi_volume_info *vi, dev_t *bdev);
+#else
+int ubiblock_create_dev(struct ubi_volume_info *vi, dev_t *bdev) {
+   return -ENOTSUPP;
+}
+#endif
+
 #endif /* !__LINUX_UBI_H__ */
-- 
2.9.3


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 1/3] UBIFS, UBI: move volume string parser from UBIFS to UBI

2016-08-27 Thread Daniel Golle
Signed-off-by: Daniel Golle 
---
 drivers/mtd/ubi/kapi.c  | 65 +
 fs/ubifs/super.c| 64 +---
 include/linux/mtd/ubi.h |  1 +
 3 files changed, 67 insertions(+), 63 deletions(-)

diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index e844887..3dda9c3 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -20,6 +20,7 @@
 
 /* This file mostly implements UBI kernel API functions */
 
+#include 
 #include 
 #include 
 #include 
@@ -329,6 +330,69 @@ struct ubi_volume_desc *ubi_open_volume_path(const char 
*pathname, int mode)
 EXPORT_SYMBOL_GPL(ubi_open_volume_path);
 
 /**
+ * ubi_open_volume_str - parse UBI device name string and open the UBI device.
+ * @name: UBI volume name
+ * @mode: UBI volume open mode
+ *
+ * The primary method of mounting UBIFS is by specifying the UBI volume
+ * character device node path. However, UBIFS may also be mounted withoug any
+ * character device node using one of the following methods:
+ *
+ * o ubiX_Y- mount UBI device number X, volume Y;
+ * o ubiY  - mount UBI device number 0, volume Y;
+ * o ubiX:NAME - mount UBI device X, volume with name NAME;
+ * o ubi:NAME  - mount UBI device 0, volume with name NAME.
+ *
+ * Alternative '!' separator may be used instead of ':' (because some shells
+ * like busybox may interpret ':' as an NFS host name separator). This function
+ * returns UBI volume description object in case of success and a negative
+ * error code in case of failure.
+ */
+struct ubi_volume_desc *ubi_open_volume_str(const char *name, int mode)
+{
+   struct ubi_volume_desc *ubi;
+   int dev, vol;
+   char *endptr;
+
+   /* First, try to open using the device node path method */
+   ubi = ubi_open_volume_path(name, mode);
+   if (!IS_ERR(ubi))
+   return ubi;
+
+   /* Try the "nodev" method */
+   if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
+   return ERR_PTR(-EINVAL);
+
+   /* ubi:NAME method */
+   if ((name[3] == ':' || name[3] == '!') && name[4] != '\0')
+   return ubi_open_volume_nm(0, name + 4, mode);
+
+   if (!isdigit(name[3]))
+   return ERR_PTR(-EINVAL);
+
+   dev = simple_strtoul(name + 3, , 0);
+
+   /* ubiY method */
+   if (*endptr == '\0')
+   return ubi_open_volume(0, dev, mode);
+
+   /* ubiX_Y method */
+   if (*endptr == '_' && isdigit(endptr[1])) {
+   vol = simple_strtoul(endptr + 1, , 0);
+   if (*endptr != '\0')
+   return ERR_PTR(-EINVAL);
+   return ubi_open_volume(dev, vol, mode);
+   }
+
+   /* ubiX:NAME method */
+   if ((*endptr == ':' || *endptr == '!') && endptr[1] != '\0')
+   return ubi_open_volume_nm(dev, ++endptr, mode);
+
+   return ERR_PTR(-EINVAL);
+}
+EXPORT_SYMBOL_GPL(ubi_open_volume_str);
+
+/**
  * ubi_close_volume - close UBI volume.
  * @desc: volume descriptor
  */
@@ -365,6 +429,7 @@ void ubi_close_volume(struct ubi_volume_desc *desc)
 }
 EXPORT_SYMBOL_GPL(ubi_close_volume);
 
+
 /**
  * leb_read_sanity_check - does sanity checks on read requests.
  * @desc: volume descriptor
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 1fd90c0..a59fa2f 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1887,68 +1887,6 @@ const struct super_operations ubifs_super_operations = {
.sync_fs   = ubifs_sync_fs,
 };
 
-/**
- * open_ubi - parse UBI device name string and open the UBI device.
- * @name: UBI volume name
- * @mode: UBI volume open mode
- *
- * The primary method of mounting UBIFS is by specifying the UBI volume
- * character device node path. However, UBIFS may also be mounted withoug any
- * character device node using one of the following methods:
- *
- * o ubiX_Y- mount UBI device number X, volume Y;
- * o ubiY  - mount UBI device number 0, volume Y;
- * o ubiX:NAME - mount UBI device X, volume with name NAME;
- * o ubi:NAME  - mount UBI device 0, volume with name NAME.
- *
- * Alternative '!' separator may be used instead of ':' (because some shells
- * like busybox may interpret ':' as an NFS host name separator). This function
- * returns UBI volume description object in case of success and a negative
- * error code in case of failure.
- */
-static struct ubi_volume_desc *open_ubi(const char *name, int mode)
-{
-   struct ubi_volume_desc *ubi;
-   int dev, vol;
-   char *endptr;
-
-   /* First, try to open using the device node path method */
-   ubi = ubi_open_volume_path(name, mode);
-   if (!IS_ERR(ubi))
-   return ubi;
-
-   /* Try the "nodev" method */
-   if (name[0] != 'u' || name[1] != 'b' || name[2] != 'i')
-   return ERR_PTR(-EINVAL);
-
-   /* ubi:NAME method */
-   if ((name[3] == ':' || name[3] == '!') && name[4] != '\0')
-   return 

[LEDE-DEV] [PATCH/RFC 0/3] UBI: unify mouting rootfs based on cmdline parameter

2016-08-27 Thread Daniel Golle
Hi!

In an attempts to fix the flaws of the current set of UBI-related
patches we are carrying in OpenWrt, I re-wrote the way mounting the
rootfs from UBI in OpenWrt/LEDE works. The main requirement I face
which cannot be easily addressed using other means which are already
available in the kernel is the fact that UBIFS and squashfs-on-UBI
require different parameters to be set on the cmdline, e.g.
for UBIFS: ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs
for squashfs: ubi.mtd=ubi ubiblock=0,1 root=/dev/ubiblock0_1 rootfstype=squashfs

The idea behind this patchset is to provide a single syntax which
allows mouting rootfs in both cases. To achieve that, the parsing of
the volume name string from UBIFS is moved to UBI, so it can be
reused by other in-kernel users. This is then used by init/do_mounts.c
to create a ubiblock device if the filesystem on the device is
non-UBIFS. To actually set this device to be ROOT_DEV, ubiblock_create
is extended to allow passing-back the created ubiblock device.

With those changes, a single set of cmdline parameters is
sufficient to mount either UBIFS or any other block filesystem
by creating a ubiblock device:
ubi.mtd=ubi root=ubi0:rootfs rootfstype=ubifs,squashfs

Please comment on the code, which is to considered a loose draft hacked
up during this evening -- it's untested and certainly still has a lot
of flaws. Yet, I felt it'd be good to discuss the general direction at
this early stage.

Cheers

Daniel


Daniel Golle (3):
  UBIFS, UBI: move volume string parser from UBIFS to UBI
  mtd: ubiblock: introduce ubiblock_create_dev
  init: auto-create ubiblock device for non-UBIFS rootfs on UBI

 drivers/mtd/ubi/block.c | 11 -
 drivers/mtd/ubi/kapi.c  | 65 +
 drivers/mtd/ubi/ubi.h   |  2 ++
 fs/ubifs/super.c| 64 +---
 include/linux/mtd/ubi.h | 17 +
 init/do_mounts.c| 62 --
 6 files changed, 150 insertions(+), 71 deletions(-)

-- 
2.9.3


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] VRV9510KWAC23

2016-08-27 Thread Juan Rios
Hello,
   I managed to get this router and want to get lede on it. The hardware is this

Lantiq VRX288 500Mhz
2 NANYA NT5TU128M8HE-AC  256MB RAM
ZENTEL A501GA31ATS 8G 128MB NAND FLASH.
Wireless 2.4Ghz BCM43222KFBG
Wireless 5Ghz BCM4360KMLG
VDSL/ADSL2+ XWAY VRX208
5 port GB Ethernet

I already found serial port pins and got the console log. The log is
almost silent. I managed to get to the brnboot shell short cutting
pins in the flash but cant do a flash dump.

ERASE Flash
---
AreaAddress  Length
---
[0] Boot0x1024K
[1] Image 0 0x0010   10240K
[2] Image 1 0x00B0   10240K
[3] Configuration   0x01502048K
[4] Boot Params 0x01702048K
[5] Nvram   0x01901024K
[6] Cert0x01A0   32768K
[7] EmergencyValue  0x03A06144K
[8] Configuration2  0x04002048K
[9] All area0x   67584K

If I try to read from above address the router gets locked.

I can read from certain area like memory or 0xBC00 or 0xBE00
but others locks the router.

The boot ask for a password and continues booting.

The emergency boot kernel is openwrt 10.3

I found out that short cutting R201 I get CFG 07 instead of CFG 06 so
maybe UART Mode is R201 + R203 but not sure. Not quite sure to try
it...

I can load to memory using xmodem transfer and run but all I tried get
locked without any output.

What I want is first dump the current content of the flash. Any ideas?

Thanks in advance
JRios

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev