[U-Boot] Nokia N900: MTDPARTS_DEFAULT was removed in 43ede0bc (Kconfig: Migrate MTDIDS_DEFAULT / MTDPARTS_DEFAULT)

Pali Rohár pali.rohar at gmail.com
Thu Dec 27 20:35:46 UTC 2018


On Thursday 27 December 2018 20:32:56 Pali Rohár wrote:
> On Thursday 27 December 2018 14:12:35 Tom Rini wrote:
> > On Thu, Dec 27, 2018 at 08:09:56PM +0100, Pali Rohár wrote:
> > > On Thursday 27 December 2018 13:57:59 Tom Rini wrote:
> > > > On Thu, Dec 27, 2018 at 07:52:54PM +0100, Pali Rohár wrote:
> > > > 
> > > > > Hello, it seems that MTD partition definitions for Nokia N900 were
> > > > > removed in commit 43ede0bca7fc1590b623832b743213b818257a27 (Kconfig:
> > > > > Migrate MTDIDS_DEFAULT / MTDPARTS_DEFAULT).
> > > > > 
> > > > > See diff:
> > > > > http://git.denx.de/?p=u-boot.git;a=blobdiff;f=include/configs/nokia_rx51.h;h=b7fe7341e407fd16275ed06d2cd399a3a2fc0e6a;hp=20b8c345f06620210d4852f547b1e64c54e48904;hb=43ede0bca7fc1590b623832b743213b818257a27;hpb=804dcf771aacc75f595d3656be0ca6a7887b6672
> > > > > 
> > > > > Can you bring them back?
> > > > > 
> > > > > Note that those PART*_* macros are used not only for constructing
> > > > > MTDPARTS_DEFAULT, but also for OMAP Nokia N900 atags, which are needed
> > > > > for booting Maemo 5.
> > > > 
> > > > Yes, please update the defconfig file with whatever needs to be in the
> > > > option there, thanks!
> > > 
> > > Looking at it... and it is problematic.
> > > 
> > > At time when Nokia N900 code was put into U-Boot mainline repository,
> > > UBIFS and OneNand code in U-Boot was broken. Therefore I added only
> > > #ifdef switch to enable MTD support optionally. Ideally once, OneNand is
> > > in U-Boot fixed, then it can be enabled. I do not know what is current
> > > state.
> > 
> > OneNAND is probably still broken then, and should probably just be
> > removed if so?
> 
> Now it even does not compile... I'm getting following error:
> 
> drivers/mtd/onenand/onenand_uboot.c: In function ‘onenand_init’:
> drivers/mtd/onenand/onenand_uboot.c:37:31: error: ‘CONFIG_SYS_ONENAND_BASE’ undeclared (first use in this function)
>   onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE;
>                                ^~~~~~~~~~~~~~~~~~~~~~~
> drivers/mtd/onenand/onenand_uboot.c:37:31: note: each undeclared identifier is reported only once for each function it appears in
> 
> After I applied
> 
> diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
> index fe2ecf6c94..905bdee249 100644
> --- a/configs/nokia_rx51_defconfig
> +++ b/configs/nokia_rx51_defconfig
> @@ -36,3 +36,6 @@ CONFIG_TWL4030_USB=y
>  CONFIG_VIDEO=y
>  CONFIG_CFB_CONSOLE_ANSI=y
>  # CONFIG_VGA_AS_SINGLE_DEVICE is not set
> +CONFIG_CMD_ONENAND=y
> +CONFIG_CMD_MTDPARTS=y
> +CONFIG_CMD_UBIFS=y
> 

Compilation is definitely broken in U-Boot.

$ git grep CONFIG_SYS_ONENAND_BASE
include/configs/nokia_rx51.h:#define CONFIG_SYS_ONENAND_BASE            ONENAND_MAP

$ git grep ONENAND_MAP
arch/arm/include/asm/arch-omap3/cpu.h:#define ONENAND_MAP               0x20000000      /* OneNand addr */

I applied following patch and then compilation succeeded.

diff --git a/arch/arm/mach-omap2/mem-common.c b/arch/arm/mach-omap2/mem-common.c
index ff1e3125a0..aca834d0f3 100644
--- a/arch/arm/mach-omap2/mem-common.c
+++ b/arch/arm/mach-omap2/mem-common.c
@@ -138,7 +138,7 @@ void set_gpmc_cs0(int flash_type)
 #if defined(CONFIG_CMD_ONENAND)
 	case MTD_DEV_TYPE_ONENAND:
 		gpmc_regs = gpmc_regs_onenand;
-		base = CONFIG_SYS_ONENAND_BASE;
+		base = 0x20000000;
 		size = GPMC_SIZE_128M;
 		break;
 #endif
diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index fe2ecf6c94..7f817a57cc 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -36,3 +36,11 @@ CONFIG_TWL4030_USB=y
 CONFIG_VIDEO=y
 CONFIG_CFB_CONSOLE_ANSI=y
 # CONFIG_VGA_AS_SINGLE_DEVICE is not set
+CONFIG_MTD_DEVICE=y
+CONFIG_MTDIDS_DEFAULT="onenand0=onenand"
+CONFIG_MTDPARTS_DEFAULT="mtdparts=onenand:128k(bootloader)ro,384k(config),256k(log),2m(kernel),2m(initfs),-(rootfs)"
+CONFIG_CMD_ONENAND=y
+CONFIG_CMD_MTDPARTS=y
+CONFIG_CMD_MTD=y
+CONFIG_CMD_UBI=y
+CONFIG_CMD_UBIFS=y
diff --git a/drivers/mtd/onenand/onenand_uboot.c b/drivers/mtd/onenand/onenand_uboot.c
index c15ec9df07..5f2b094dfc 100644
--- a/drivers/mtd/onenand/onenand_uboot.c
+++ b/drivers/mtd/onenand/onenand_uboot.c
@@ -34,7 +34,7 @@ void onenand_init(void)
 	/* It's used for some board init required */
 	err = onenand_board_init(&onenand_mtd);
 #else
-	onenand_chip.base = (void *) CONFIG_SYS_ONENAND_BASE;
+	onenand_chip.base = (void *) 0x20000000;
 #endif
 
 	if (!err && !(onenand_scan(&onenand_mtd, 1))) {

Looks like that OneNand & UBI code is working, at least in qemu. I have
not tested real N900 device yet. But UBIFS does not work :-( See tests
below.

Nokia RX-51 # onenand info
Muxed OneNAND 256MB 1.8V 16-bit (0x40)
OneNAND version = 0x0121

Nokia RX-51 # mtd list
List of MTD devices:
* onenand0
  - type: Unknown
  - block size: 0x20000 bytes
  - min I/O: 0x800 bytes
  - OOB size: 64 bytes
  - OOB available: 20 bytes
  - 0x000000000000-0x000010000000 : "onenand0"
          - 0x000000000000-0x000000020000 : "bootloader"
          - 0x000000020000-0x000000080000 : "config"
          - 0x000000080000-0x0000000c0000 : "log"
          - 0x0000000c0000-0x0000002c0000 : "kernel"
          - 0x0000002c0000-0x0000004c0000 : "initfs"
          - 0x0000004c0000-0x000010000000 : "rootfs"

Nokia RX-51 # mtd dump bootloader       
Reading 2048 byte(s) at offset 0x00000000

Dump 2048 data bytes from 0x0:
0x00000000:     dc 21 00 00 00 00 20 40  0a 00 00 ea 4e 4f 4c 4f 
0x00000010:     58 6c 64 72 14 0e 00 00  00 00 20 40 09 00 00 00
...

Nokia RX-51 # ubi part rootfs
ubi0: attaching mtd6
ubi0: scanning is finished
ubi0: volume 0 ("rootfs") re-sized from 1870 to 1966 LEBs
ubi0: attached mtd6 (name "rootfs", size 251 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
ubi0: VID header offset: 512 (aligned 512), data offset: 2048
ubi0: good PEBs: 2010, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 1, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 1/1, WL threshold: 4096, image sequence number: 1
ubi0: available PEBs: 0, total reserved PEBs: 2010, PEBs reserved for bad PEB handling: 40


Nokia RX-51 # ubi info l
Volume information dump:
        vol_id          0
        reserved_pebs   1966
        alignment       1
        data_pad        0
        vol_type        3
        name_len        6
        usable_leb_size 129024
        used_ebs        1966
        used_bytes      253661184
        last_eb_bytes   129024
        corrupted       0
        upd_marker      0
        name            rootfs
Volume information dump:
        vol_id          2147479551
        reserved_pebs   2
        alignment       1
        data_pad        0
        vol_type        3
        name_len        13
        usable_leb_size 129024
        used_ebs        2
        used_bytes      258048
        last_eb_bytes   2
        corrupted       0
        upd_marker      0
        name            layout volume

Nokia RX-51 # ubifsmount rootfs
UBIFS error (pid: 1): cannot open "rootfs", error -22
Error reading superblock on volume 'rootfs' errno=-22!
...

Nokia RX-51 # ubifsmount ubi0:rootfs
Error reading superblock on volume 'ubi0:rootfs' errno=-22!
...

> > > And definition for MTD was not moved out of nokia_rx51.h file to
> > > nokia_rx51_defconfig. But if you look at old definition of
> > > MTDPART_DEFAULT it is composed from other macros in that nokia_rx51.h
> > > file.
> > > 
> > > So I cannot move it for obvious reason to nokia_rx51_defconfig, without
> > > including nokia_rx51.h in nokia_rx51_defconfig file. So how to solve
> > > this problem?
> > 
> > You should construct and pass the final string as it doesn't look like
> > it changes dynamically, right?
> 
> Yes, that is possible. But then definition for partitions would be at
> two places. Once in nokia_rx51_defconfig and second time in nokia_rx51.h

-- 
Pali Rohár
pali.rohar at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181227/43baa2b1/attachment.sig>


More information about the U-Boot mailing list