Skip to contentSkip to conversation

Apollon UBI support v3

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Apollon UBI support v3

Now you can use the UBI at apollon board

---

board/apollon/Makefile +3 -1
index 9bac9a6..4c3e57f 100644
@@ -25,9 +25,11 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= apollon.o mem.o sys_info.o
+COBJS-y	:= apollon.o mem.o sys_info.o
+COBJS-$(CONFIG_CMD_UBI) += ubi.o
 SOBJS	:= lowlevel_init.o
 
+COBJS	:= $(COBJS-y)
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(COBJS))
 SOBJS	:= $(addprefix $(obj),$(SOBJS))
board/apollon/ubi.c new file +48 -0

48 lines not on this page · raw message

include/configs/apollon.h +56 -17

131 lines not on this page · raw message

#1 lore raw

PATCH 1/1 Apollon UBI support v3

Dear Kyungmin Park,

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

Quoted 80 lines

Now you can use the UBI at apollon board

---

board/apollon/Makefile +3 -1
index 9bac9a6..4c3e57f 100644
@@ -25,9 +25,11 @@ include $(TOPDIR)/config.mk
 
 LIB    = $(obj)lib$(BOARD).a
 
-COBJS  := apollon.o mem.o sys_info.o
+COBJS-y        := apollon.o mem.o sys_info.o
+COBJS-$(CONFIG_CMD_UBI) += ubi.o
 SOBJS  := lowlevel_init.o
 
+COBJS  := $(COBJS-y)
 SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS   := $(addprefix $(obj),$(COBJS))
 SOBJS  := $(addprefix $(obj),$(SOBJS))
board/apollon/ubi.c new file +48 -0
new file mode 100644
index 0000000..10dd6e7
@@ -0,0 +1,48 @@
+/*
+ * board/apollon/ubi.c
+ *
+ *  Copyright (C) 2008 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.
+ */
+
+#include <common.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <jffs2/load_kernel.h>
+#include <ubi_uboot.h>
+
+int ubi_board_scan(void)
+{
+       struct mtd_device *dev;
+       struct part_info *part;
+       struct mtd_partition mtd_part;
+       char buffer[32];
+       u8 pnum;
+       int err;
+
+       if (mtdparts_init() != 0)
+               return 1;
+
+       if (find_dev_and_part("onenand0,4", &dev, &pnum, &part) != 0)
+               return 1;
+
+       sprintf(buffer, "mtd=%d", pnum);
+       mtd_part.name = buffer;
+       mtd_part.size = part->size;
+       mtd_part.offset = part->offset;
+       add_mtd_partitions(&onenand_mtd, &mtd_part, 1);
+
+       err = ubi_mtd_param_parse(buffer, NULL);
+       if (err)
+               return err;
+
+       err = ubi_init();
+       if (err)
+               return err;
+
+       return 0;
+}
include/configs/apollon.h +0 -0
index d71ed44..c694989 100644

include/configs/apollon.h line 57

Quoted 5 lines
include/configs/apollon.h +2 -0
@@ -53,6 +53,9 @@
 #define CONFIG_SYS_USE_NOR             1
 #endif
 
+/* uncommnet if you want to use UBI */
+#define CONFIG_SYS_USE_UBI

Seems like the #define has been uncommented already.

Also, a doc/README.ubi or something similar would be nice. Something that contains info on how to enable UBI support for a new board. The board/apollon/ubi.c could perhaps be used as an example but with more comments in it.

Regards, Magnus

#2 lore raw

PATCH 1/1 Apollon UBI support v3

In reply to Kyungmin Park

Dear Kyungmin Park,

I've now used your patch series to add UBI support to the i.MX31 Litekit board (in the NAND device present on that board) and have some additional comments on the series.

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

Quoted 37 lines

Now you can use the UBI at apollon board

---

board/apollon/ubi.c new file +27 -0
new file mode 100644
index 0000000..10dd6e7
@@ -0,0 +1,48 @@
+/*
+ * board/apollon/ubi.c
+ *
+ *  Copyright (C) 2008 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.
+ */
+
+#include <common.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <jffs2/load_kernel.h>
+#include <ubi_uboot.h>
+
+int ubi_board_scan(void)
+{
+       struct mtd_device *dev;
+       struct part_info *part;
+       struct mtd_partition mtd_part;
+       char buffer[32];
+       u8 pnum;
+       int err;
+
+       if (mtdparts_init() != 0)

board/apollon/ubi.c line 37

Quoted 10 lines
board/apollon/ubi.c new file +10 -0
+               return 1;
+
+       if (find_dev_and_part("onenand0,4", &dev, &pnum, &part) != 0)
+               return 1;
+
+       sprintf(buffer, "mtd=%d", pnum);
+       mtd_part.name = buffer;
+       mtd_part.size = part->size;
+       mtd_part.offset = part->offset;
+       add_mtd_partitions(&onenand_mtd, &mtd_part, 1);

I had some problems that boiled down to the fact that the unused fields of mtd_part caused problems in add_mtd_partitions(). Doing a memset(&mtd_part, 0, sizeif (mtd_part)) before the mtd_part.name line solved those problems.

Regards, Magnus

#3 lore raw

PATCH 1/1 Apollon UBI support v3

Quoted 51 lines · Magnus Lilja

Dear Kyungmin Park,

I've now used your patch series to add UBI support to the i.MX31 Litekit board (in the NAND device present on that board) and have some additional comments on the series.

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

Quoted 44 lines

Now you can use the UBI at apollon board

---

board/apollon/ubi.c new file +34 -0
new file mode 100644
index 0000000..10dd6e7
@@ -0,0 +1,48 @@
+/*
+ * board/apollon/ubi.c
+ *
+ *  Copyright (C) 2008 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.
+ */
+
+#include <common.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <jffs2/load_kernel.h>
+#include <ubi_uboot.h>
+
+int ubi_board_scan(void)
+{
+       struct mtd_device *dev;
+       struct part_info *part;
+       struct mtd_partition mtd_part;
+       char buffer[32];
+       u8 pnum;
+       int err;
+
+       if (mtdparts_init() != 0)
+               return 1;
+
+       if (find_dev_and_part("onenand0,4", &dev, &pnum, &part) != 0)
+               return 1;
+
+       sprintf(buffer, "mtd=%d", pnum);
+       mtd_part.name = buffer;
Quoted 9 lines

board/apollon/ubi.c line 37

Quoted 3 lines
board/apollon/ubi.c new file +3 -0
+       mtd_part.size = part->size;
+       mtd_part.offset = part->offset;
+       add_mtd_partitions(&onenand_mtd, &mtd_part, 1);

I had some problems that boiled down to the fact that the unused fields of mtd_part caused problems in add_mtd_partitions(). Doing a memset(&mtd_part, 0, sizeif (mtd_part)) before the mtd_part.name line solved those problems.

Umm it's board specific file but it's reasonable to add the mtd_part initialization.

Thank you,
Kyungmin Park