Skip to contentSkip to conversation

Basic Unsorted Block Image (UBI) support v3 (#5)

PATCH New Kyungmin Park 2 participants 2 messages Oct 28, 2008 – Nov 2, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support v3 (#5)

UBI (Latin: "where?") stands for "Unsorted Block Images". It is a volume management system for flash devices which manages multiple logical volumes on a single physical flash device and spreads the I/O load (i.e, wear-leveling) across the whole flash chip.

In a sense, UBI may be compared to the Logical Volume Manager (LVM). Whereas LVM maps logical sectors to physical sectors, UBI maps logical eraseblocks to physical eraseblocks. But besides the mapping, UBI implements global wear-leveling and I/O errors handling.

For more details, Please visit the following URL.
http://www.linux-mtd.infradead.org/doc/ubi.html

---

Makefile +1 -0
index 9a132f7..93759e4 100644
@@ -230,6 +230,7 @@ LIBS += drivers/mtd/libmtd.a
 LIBS += drivers/mtd/nand/libnand.a
 LIBS += drivers/mtd/nand_legacy/libnand_legacy.a
 LIBS += drivers/mtd/onenand/libonenand.a
+LIBS += drivers/mtd/ubi/libubi.a
 LIBS += drivers/mtd/spi/libspi_flash.a
 LIBS += drivers/net/libnet.a
 LIBS += drivers/net/phy/libphy.a
drivers/mtd/ubi/wl.c new file +1670 -0

1,670 lines not on this page · raw message

include/linux/crc32.h new file +27 -0
new file mode 100644
index 0000000..ac4aed1
@@ -0,0 +1,27 @@
+/*
+ * crc32.h
+ * See linux/lib/crc32.c for license and changes
+ */
+#ifndef _LINUX_CRC32_H
+#define _LINUX_CRC32_H
+
+#include <linux/types.h>
+/* #include <linux/bitrev.h> */
+
+extern u32  crc32_le(u32 crc, unsigned char const *p, size_t len);
+/* extern u32  crc32_be(u32 crc, unsigned char const *p, size_t len); */
+
+#define crc32(seed, data, length)  crc32_le(seed, (unsigned char const *)data, length)
+
+/*
+ * Helpers for hash table generation of ethernet nics:
+ *
+ * Ethernet sends the least significant bit of a byte first, thus crc32_le
+ * is used. The output of crc32_le is bit reversed [most significant bit
+ * is in bit nr 0], thus it must be reversed before use. Except for
+ * nics that bit swap the result internally...
+ */
+/* #define ether_crc(length, data)    bitrev32(crc32_le(~0, data, length)) */
+/* #define ether_crc_le(length, data) crc32_le(~0, data, length) */
+
+#endif /* _LINUX_CRC32_H */
include/linux/mtd/ubi.h new file +186 -0

186 lines not on this page · raw message

include/linux/types.h +24 -0
index df4808f..1b0b4a4 100644
@@ -119,6 +119,30 @@ typedef		__s64		int64_t;
  * Below are truly Linux-specific types that should never collide with
  * any application/library that wants linux/types.h.
  */
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#ifdef __CHECK_ENDIAN__
+#define __bitwise __bitwise__
+#else
+#define __bitwise
+#endif
+
+typedef __u16 __bitwise __le16;
+typedef __u16 __bitwise __be16;
+typedef __u32 __bitwise __le32;
+typedef __u32 __bitwise __be32;
+#if defined(__GNUC__)
+typedef __u64 __bitwise __le64;
+typedef __u64 __bitwise __be64;
+#endif
+typedef __u16 __bitwise __sum16;
+typedef __u32 __bitwise __wsum;
+
+
+typedef unsigned __bitwise__	gfp_t;
 
 struct ustat {
 	__kernel_daddr_t	f_tfree;
include/ubi_uboot.h new file +218 -0

218 lines not on this page · raw message

#1 lore raw

PATCH 1/1 Basic Unsorted Block Image (UBI) support v3 (#5)

Dear Kyungmin Park,

2008/10/28 Kyungmin Park <[email protected]>:

Quoted 52 lines

UBI (Latin: "where?") stands for "Unsorted Block Images". It is a volume management system for flash devices which manages multiple logical volumes on a single physical flash device and spreads the I/O load (i.e, wear-leveling) across the whole flash chip.

In a sense, UBI may be compared to the Logical Volume Manager (LVM). Whereas LVM maps logical sectors to physical sectors, UBI maps logical eraseblocks to physical eraseblocks. But besides the mapping, UBI implements global wear-leveling and I/O errors handling.

For more details, Please visit the following URL.
http://www.linux-mtd.infradead.org/doc/ubi.html

---

include/ubi_uboot.h new file +37 -0
new file mode 100644
index 0000000..b4b2fa2
@@ -0,0 +1,218 @@
+/*
+ * Header file for UBI support for U-Boot
+ *
+ * Adaptation from kernel to U-Boot
+ *
+ *  Copyright (C) 2005-2007 Samsung Electronics
+ *  Kyungmin Park <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __UBOOT_UBI_H
+#define __UBOOT_UBI_H
+
+#include <common.h>
+#include <malloc.h>
+#include <div64.h>
+#include <linux/crc32.h>
+#include <linux/mtd/mtd.h>
+
+#ifdef CONFIG_CMD_ONENAND
+#include <onenand_uboot.h>
+#endif
+
+#include <asm/errno.h>
+
+#define DPRINTK(format, args...)                                       \
+do {                                                                   \
+       printf("%s[%d]: " format "\n", __func__, __LINE__, ##args);     \
+} while (0)
+
+/* configurable */
+#define CONFIG_MTD_UBI_WL_THRESHOLD    4096
+#define CONFIG_MTD_UBI_BEB_RESERVE     1
+#define UBI_IO_DEBUG                   0

include/ubi_uboot.h line 47

Quoted 10 lines
include/ubi_uboot.h new file +10 -0
+
+/* #define CONFIG_MTD_UBI_DEBUG */
+/* #define CONFIG_MTD_UBI_DEBUG_PARANOID */
+
+#define CONFIG_MTD_UBI_DEBUG_DISABLE_BGT
+/* #define CONFIG_MTD_UBI_DEBUG_MSG */
+/* #define CONFIG_MTD_UBI_DEBUG_MSG_EBA */
+/* #define CONFIG_MTD_UBI_DEBUG_MSG_WL */
+/* #define CONFIG_MTD_UBI_DEBUG_MSG_IO */
+/* #define CONFIG_MTD_UBI_DEBUG_MSG_BLD */

These configs should be documented somewhere, e.g. in doc/README.ubi .

Regards, Magnus