SDK2.0 MTD UBOOT NOR Partition Configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SDK2.0 MTD UBOOT NOR Partition Configuration

2,953 Views
tracysmith
Contributor IV

How do I configure MTD NOR partitions in uboot on SDK 2.0? 

Assume no recipes are needed.  Just .config and any driver or device tree configuration that might be needed.  For instance why are these .config options not accepted by uboot in SDK 2.0 and should MTD PARTITIONS be set in .config?  Is the

CONFIG_MTD_PARTITIONS=y
CONFIG_MTD_DEVICE=y

CONFIG_CMD_MTDPARTS * MTD partition support

CONFIG_MTD_PARTITIONS Memory Technology Device partition table.

Under devices->mtd there are driver options.  Trying to configure IFS NOR and not SPI.  Is the CFI flash driver required in uboot or kernel configuration to list the NOR partitions using mtdinfo? 

This is what I want to be able to see when I do a mtdinfo in linux. What is needed to make this happen for SDK 2.0. NOR IFS is working fine.  I do not see a /dev/mtd in linux either.  What uboot configuration and kernel configuration is needed?

#define MTDPARTS_DEFAULT "mtdparts=60000000.nor:1m(nor_bank0_rcw)," \

                        "1m(nor_bank0_uboot),1m(nor_bank0_uboot_env)," \

                        "1m(nor_bank0_fman_uconde),40m(nor_bank0_fit)," \

                        "1m(nor_bank4_rcw),1m(nor_bank4_uboot)," \

                        "1m(nor_bank4_uboot_env),1m(nor_bank4_fman_ucode)," \

                        "40m(nor_bank4_fit);7e800000.flash:" \

                        "4m(nand_uboot),36m(nand_kernel)," \

                        "472m(nand_free);spi0.0:2m(uboot)," \

                        "14m(free)"

Labels (1)
0 Kudos
5 Replies

2,365 Views
Pavel
NXP Employee
NXP Employee

See the following pages about MTD unlock and erasing:

http://www.infradead.org/pipermail/linux-mtd-cvs/2006-September/005586.html

 

https://opensourceforu.com/2012/01/working-with-mtd-devices/

 

https://www.kernel.org/doc/html/v4.14/driver-api/mtdnand.html

Have a great day,
Pavel Chubakov

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,366 Views
Pavel
NXP Employee
NXP Employee

See u-boot documentation about MTD:

https://www.denx.de/wiki/view/DULG/BootTimeConfigurationOfMTDPartitions

 

https://www.denx.de/wiki/view/DULG/FlashFilesystemsMTD

 

https://www.denx.de/wiki/DULG/UBootCmdGroupFlash

 

http://u-boot.10912.n7.nabble.com/how-to-use-mtdparts-command-in-uboot-td30435.html

 

See also mtdparts.c file:

https://github.com/u-boot/u-boot/blob/master/cmd/mtdparts.c

Have a great day,
Pavel Chubakov

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,366 Views
tracysmith
Contributor IV

Hi Pavel,

NOR is now configured with four NOR banks. Total size is 256M @ 64M each. The bank 0 and 1 are erasable, but the two new nor banks are not erasable.  For example, the /dev/mtd3 is not erasable, not R/W. What do I need to do to fix this? I need to be able to write to /dev/mtd3.

root@ls1043ardb:~# cat /proc/mtd
dev: size erasesize name
mtd0: 04000000 00020000 "norv1"
mtd1: 04000000 00020000 "norv2"
mtd2: 04000000 00020000 "norv3"
mtd3: 04000000 00020000 "norv4"

 

root@ls1043ardb:~# /usr/sbin/flash_unlock /dev/mtd3
flash_unlock: error!: could not unlock device: /dev/mtd3

root@ls1043ardb:~# flash_eraseall /dev/mtd3
flash_eraseall has been replaced by `flash_erase <mtddev> 0 0`; please use it
Erasing 128 Kibyte @ 0 -- 0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 0 (mtd3)
error 5 (Input/output error)
flash_erase: error!: /dev/mtd3: MTD Erase failure
error 5 (Input/output error)
Erasing 128 Kibyte @ 20000 -- 0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 1 (mtd3)
error 5 (Input/output error)
flash_erase: error!: /dev/mtd3: MTD Erase failure

root@ls1043ardb:~# cat /sys/class/mtd/mtd3/flags
0xc00

root@ls1043ardb:~# hexdump /dev/mtdblock3
0000000 0100 0100 0100 0100 0100 0100 0100 0100
*
4000000
root@ls1043ardb:~# hexdump /dev/mtd3r0
hexdump: /dev/mtd3r0: No such file or directory
hexdump: all input file arguments failed
root@ls1043ardb:~# hexdump /dev/mtd3ro
0000000 0100 0100 0100 0100 0100 0100 0100 0100
*
4000000
root@ls1043ardb:~# hexdump /dev/mtd3
0000000 0100 0100 0100 0100 0100 0100 0100 0100
*
4000000
root@ls1043ardb:~# hexdump /dev/mtdblock3
0000000 0100 0100 0100 0100 0100 0100 0100 0100
*
4000000ls

0 Kudos

2,365 Views
tracysmith
Contributor IV

Does the MTD driver support an unlock or an erase operation for new nor banks?  I have been unable to erase or unlock either of the two NOR banks added. 

 

flash_unlock: error!: could not unlock device: /dev/mtd3

               error 95 (Operation not supported)

 

Unless there is a read only flag in the device tree, then we may be missing the necessary support for erasing either bank.  Is there a read only flag set for either of the two new NOR banks in the device tree?  I didn’t see anything.

 

Here is a similar issue:

 

https://stackoverflow.com/questions/19706584/erasing-flash-nor-ioctlmemunlock-return-status

 

root@ls1043ardb:~# cat /sys/class/mtd/mtd3/flags

0xc00

 

A hexadecimal value representing the device flags, ORed

               together:

 

               0x0400: MTD_WRITEABLE - device is writable

               0x0800: MTD_BIT_WRITEABLE - single bits can be flipped

               0x1000: MTD_NO_ERASE - no erase necessary

               0x2000: MTD_POWERUP_LOCK - always locked after reset

 

root@ls1043ardb:~# cat /sys/class/mtd/mtd3/dev

90:6

 

Major and minor numbers of the character device corresponding

               to the read-only variant of this MTD device (in

               <major>:<minor> format).  In this case <minor> will be odd.

 

root@ls1043ardb:~# ls -lia /dev/mtd3*

1322 crw------- 1 root root 90, 6 Jan  1  1970 /dev/mtd3

1323 crw------- 1 root root 90, 7 Jan  1  1970 /dev/mtd3ro

1326 brw-rw---- 1 root disk 31, 3 Jan 24 05:42 /dev/mtdblock3

 

root@ls1043ardb:~# ls -l /dev/mtd*

crw------- 1 root root 90, 0 Jan  1  1970 /dev/mtd0

crw------- 1 root root 90, 1 Jan  1  1970 /dev/mtd0ro

crw------- 1 root root 90, 2 Jan  1  1970 /dev/mtd1

crw------- 1 root root 90, 3 Jan  1  1970 /dev/mtd1ro

crw------- 1 root root 90, 4 Jan  1  1970 /dev/mtd2

crw------- 1 root root 90, 5 Jan  1  1970 /dev/mtd2ro

crw------- 1 root root 90, 6 Jan  1  1970 /dev/mtd3

crw------- 1 root root 90, 7 Jan  1  1970 /dev/mtd3ro

brw-rw---- 1 root disk 31, 0 Jan  1  1970 /dev/mtdblock0

brw-rw---- 1 root disk 31, 1 Jan  1  1970 /dev/mtdblock1

brw-rw---- 1 root disk 31, 2 Jan  1  1970 /dev/mtdblock2

brw-rw---- 1 root disk 31, 3 Jan 24 05:42 /dev/mtdblock3

 

The minor numbers for /dev/mtdX look fine. /dev/mtd0 should have a minor

  1. of 0, /dev/mtd1 should have 2, /dev/mtd2 should have 4 etc. The

odd-numbered minor numbers are intended for read-only devices.

 

These devices should be writable and the minor number appear fine.  Is there MTD driver support for the new NORs?  This may need to be added to the driver.

0 Kudos

2,364 Views
tracysmith
Contributor IV

root@ls1043ardb:~# cat /proc/mtd
dev: size erasesize name
mtd0: 04000000 00020000 "norv1"
mtd1: 04000000 00020000 "norv2"
mtd2: 04000000 00020000 "norv3"
mtd3: 04000000 00020000 "norv4"

root@ls1043ardb:~# flash_eraseall -j /dev/mtd3
flash_eraseall has been replaced by `flash_erase <mtddev> 0 0`; please use it
Erasing 128 Kibyte @ 0 -- 0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 0 (mtd3)
error 5 (Input/output error)
flash_erase: error!: /dev/mtd3: MTD Erase failure
error 5 (Input/output error)
Erasing 128 Kibyte @ 20000 -- 0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 1 (mtd3)
error 5 (Input/output error)
flash_erase: error!: /dev/mtd3: MTD Erase failure
error 5 (Input/output error)
Erasing 128 Kibyte @ 40000 -- 0 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 2 (mtd3)
error 5 (Input/output error)
flash_erase: error!: /dev/mtd3: MTD Erase failure

0 Kudos