cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tanveeriitg
Visitor
Visitor
10,461 Views
Registered: ‎12-18-2013

Unable to read/write flash

hi

 

I was trying to reduce the size of kernel by removing unnecessary feautres by configuring the kernel and then compiling it again. For this i was using Petalinux SDK 2013.10. I am able to boot linux from SD card. But i want to boot linux from flash.  So i was using "flashcp" command to load images from SD Card to mtd partions of flash.But this command behave strangly

when i try to load one of my image i.e. BOOT.BIN to mtd0 partition,it loads this successfully in mtd0 partition.

But when i try to load my second image in mtd2 partition it issues a msg:"While trying to open /dev/mtd2 for read/write access: Permission denied"

root@Xilinx-ZC702-14_7:~# flashcp -v /mnt/image.ub /dev/mtd2
While trying to open /dev/mtd2 for read/write access: Permission denied

Here are flash mtd partition:

 

root@Xilinx-ZC702-14_7:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00500000 00010000 "boot"
mtd1: 00020000 00010000 "bootenv"
mtd2: 00a5324c 00010000 "image"
mtd3: 0008cdb4 00010000 "spare"

 Note: i am able to readwrite only in mtd0 partition.

i am not understanding why permission is denied for mtd2 partition.

please help me to resolve this issue.

 

 

 

 

0 Kudos
9 Replies
milosoftware
Scholar
Scholar
10,427 Views
Registered: ‎10-26-2012

Most likely the partition table for the MTD device has it marked "read-only".

 

The partition table is usually in the device-tree, but can also be passed down from the bootloader, and as a last resort, reside in the kernel itself.

0 Kudos
alishah
Explorer
Explorer
10,313 Views
Registered: ‎02-27-2014

I am also facing the same issue. This is teh partition section in the dts. 

 

 

ps7_qspi_0: ps7-qspi@e000d000 {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        clock-names = "ref_clk", "aper_clk";
                        clocks = <&clkc 10>, <&clkc 43>;
                        compatible = "xlnx,ps7-qspi-1.00.a";
                        interrupt-parent = <&ps7_scugic_0>;
                        interrupts = <0 19 4>;
                        is-dual = <0>;
                        num-chip-select = <1>;
                        reg = <0xe000d000 0x1000>;
                        xlnx,fb-clk = <0x1>;
                        xlnx,qspi-mode = <0x0>;
                        primary_flash: ps7-qspi@0 {
                               	#address-cells = <1>;
                               	#size-cells = <1>;
                               	reg = <0x0>;
                                spi-max-frequency = <50000000>;
                                compatible = "micron,n25q128";
                                partition@0x00000000 {
                                        label = "boot";
                                        reg = <0x00000000 0x00500000>;
                                };
                                partition@0x00500000 {
                                        label = "bootenv";
                                        reg = <0x00500000 0x00020000>;
                                };
                                partition@0x00520000 {


         label = "image";
                                        reg = <0x00520000 0x001202c0>;
                                };
                                partition@0x006402c0 {
                                        label = "jffs2";
                                        reg = <0x006402c0 0x00500000>;
                                };
                        } ;
                } ;

I can not see if the partition is write protected or not. Any comments ?    

 

How can I sove this issue from u-boot?

0 Kudos
alishah
Explorer
Explorer
10,311 Views
Registered: ‎02-27-2014

This might also be helpfulin debugging:

 

 

    root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd3
    mtd.type = MTD_NORFLASH
    mtd.flags = MTD_BIT_WRITEABLE
    mtd.size = 5242880 (5M)
    mtd.erasesize = 65536 (64K)
    mtd.writesize = 1
    mtd.oobsize = 0
    regions = 0
    
    root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd2
    mtd.type = MTD_NORFLASH
    mtd.flags = MTD_BIT_WRITEABLE
    mtd.size = 1180352 (1M)
    mtd.erasesize = 65536 (64K)
    mtd.writesize = 1
    mtd.oobsize = 0
    regions = 0
    
    root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd1
    mtd.type = MTD_NORFLASH
    mtd.flags = MTD_CAP_NORFLASH
    mtd.size = 131072 (128K)
    mtd.erasesize = 65536 (64K)
    mtd.writesize = 1
    mtd.oobsize = 0
    regions = 0
    
    root@Xilinx-ZC702-2013_3:/mnt/flash# mtd_debug info /dev/mtd0
    mtd.type = MTD_NORFLASH
    mtd.flags = MTD_CAP_NORFLASH
    mtd.size = 5242880 (5M)
    mtd.erasesize = 65536 (64K)
    mtd.writesize = 1
    mtd.oobsize = 0
    regions = 0
    
    root@Xilinx-ZC702-2013_3:/mnt/flash#

 

0 Kudos
rfs613
Scholar
Scholar
10,306 Views
Registered: ‎05-28-2013

Your partition sizes must be a multiple of the block-size of the flash chip, likely 64kB. The value 0x001202c0 is not correct. You have to round it up to the next flash block boundary.
0 Kudos
alishah
Explorer
Explorer
10,300 Views
Registered: ‎02-27-2014

(001202c0)16 = (1180352)10

1180352/64= 18443

 Thanks for replying. Well  I think it is indeed a multiple of 64. The issue is then something else . 

0 Kudos
alishah
Explorer
Explorer
10,297 Views
Registered: ‎02-27-2014

I found in dmesg output the following:


4 ofpart partitions found on MTD device spi32766.0
Creating 4 MTD partitions on "spi32766.0":
0x000000000000-0x000000500000 : "boot"
0x000000500000-0x000000520000 : "bootenv"
0x000000520000-0x0000006402c0 : "image"
mtd: partition "image" doesn't end on an erase block -- force read-only
0x0000006402c0-0x000000b402c0 : "jffs2"
mtd: partition "jffs2" doesn't start on an erase block boundary -- force read-on


I am assuming erase block boundary should be a multiple of 64, And I can see the boundaries above are indeed multiple of 64. So what is wrong here
0 Kudos
alishah
Explorer
Explorer
10,294 Views
Registered: ‎02-27-2014

BTW this is my mtdparts output from u-boot command prompt: 'mtdparts=0:5M(boot),128K(bootenv),1152K(image),5M(jffs2)'

I see the output of cat /proc/mtd and mtdparts (in uboot) are not matching in 'image'
0 Kudos
alishah
Explorer
Explorer
10,293 Views
Registered: ‎02-27-2014

This issue is solved. I need to make  that partition size is a multiple of 65536 (10000 in hex),and not 64 which I was assuming. After making these corrections I did not face the issue.  

0 Kudos
alishah
Explorer
Explorer
10,292 Views
Registered: ‎02-27-2014

@rfs613' your hint solved my issue.But I don't see any option to chose this answer
0 Kudos