Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

Flash locked !

Altera_Forum
Honored Contributor II
2,215 Views

Hi all, 

 

My configuration for uClinux is : 

 

uClinux-dist-20090618.tar.bz2 

nios2gcc-20080203.tar.bz2 

 

I followed this tutorial to instanciate a "Spansion S29GL01GP 64Mx16bit (128Mbyte) Nor Flash" on a DBM3C40 devboard : 

 

http://www.nioswiki.com/index.php?title=mtd&highlight=mtd 

 

When I boot uClinux after a "make", here is the log concerning the flash part : 

 

-------------------------------------------------------------------------- 

physmap platform flash device: 02000000 at 00000000 

physmap-flash.0: Found 1 x16 devices at 0x0 in 8-bit bank 

Amd/Fujitsu Extended Query Table at 0x0040 

physmap-flash.0: CFI does not contain boot bank location. Assuming top. 

number of CFI chips: 1 

cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. 

cmdlinepart partition parsing not available 

RedBoot partition parsing not available 

Using physmap partition information 

Creating 2 MTD partitions on "physmap-flash.0": 

0x000000200000-0x000000400000 : "romfs/jffs2" 

0x000000000000-0x000000200000 : "loader/kernel" 

-------------------------------------------------------------------------- 

 

Then I try the traditionnal command to mount something : 

 

-------------------------------------------------------------------------- 

/> mkdir /mnt/configflash 

/> chmod 777 /mnt/configflash 

/> mount -t jffs2 /dev/mtdblock0 /mnt/configflash 

-------------------------------------------------------------------------- 

 

But after 1 or 2 seconds, I got these lines (automatically) : 

 

-------------------------------------------------------------------------- 

/> MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x001c0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x001a0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00180000 failed: -5 

MTD do_write_buffer(): software timeout 

...... 

..... 

-------------------------------------------------------------------------- 

 

Then I tried another command to first erase all the blocks but one more time, the same error : 

 

-------------------------------------------------------------------------- 

/> flash_eraseall -j dev/mtd0 

Erasing 128 Kibyte @ 0 -- 0 % complete.MTD do_write_buffer(): software timeout 

 

flash_eraseall: dev/mtd0: MTD write failure: Input/output error 

Erasing 128 Kibyte @ 20000 -- 6 % complete.MTD do_write_buffer(): software timeout 

.... 

.... 

(up to 100%) 

-------------------------------------------------------------------------- 

 

After searching the web concerning this error, I found this : 

 

3) "eraseall: /dev/mtd0: MTD Erase failure: Input/output error" 

Possible reason: If you get this message for each block than probably write protection is on. Check the WP pin 

 

So I decided to activate the "unlock" option in "make menuconfig" -> MTD-utils section but unfortunately it doesn't generate a "flash_unlock" executable after a "make" so I add some lines to the Makefile located in (~/nios2-linux/uClinux-dist/user/mtd-utils) : 

 

TARGETS-$(CONFIG_USER_MTDUTILS_UNLOCK) += flash_unlock 

$(ROMFSINST) -e CONFIG_USER_MTDUTILS_UNLOCK build-$(VER)/flash_unlock /bin/flash_unlock 

 

After a "make", I successfully obtain a "flash_unlock" executable in (~/romfs/bin) but when I try this : 

 

-------------------------------------------------------------------------- 

/> flash_unlock /dev/mtd0 

/> Could not unlock MTD device: /dev/mtd0 

-------------------------------------------------------------------------- 

 

I don't understand what is wrong in my procedure... Can the NOR Flash on DBM3C40 have a write protection (PIN) enabled by default (to the VCC) and which must be disabled manually (with pin assignements in Quartus) ? 

 

Thanks for your help ! 

 

Papy
0 Kudos
5 Replies
Altera_Forum
Honored Contributor II
902 Views

There was a problem in avalon cfi flash access. And this needs patches on the flash drivers. Please use the community distro instead of the uclinux.org

 

http://www.nioswiki.com/installnios2linux 

 

- Hippo
0 Kudos
Altera_Forum
Honored Contributor II
902 Views

I install "nios2-linux-20090730.tar" following this tutorial : 

 

http://www.nioswiki.com/installnios2linux 

 

But still the same problem : 

 

physmap platform flash device: 02000000 at 00000000 

physmap-flash.0: Found 1 x16 devices at 0x0 in 8-bit bank 

Amd/Fujitsu Extended Query Table at 0x0040 

physmap-flash.0: CFI does not contain boot bank location. Assuming top. 

number of CFI chips: 1 

cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness. 

cmdlinepart partition parsing not available 

RedBoot partition parsing not available 

Using physmap partition information 

Creating 2 MTD partitions on "physmap-flash.0": 

0x000000200000-0x000000400000 : "romfs/jffs2" 

0x000000000000-0x000000200000 : "loader/kernel" 

... 

Sash command shell (version 1.1.1) 

/> flash_unlock /dev/mtd0 

Could not unlock MTD device: /dev/mtd0 

/> flash_eraseall /dev/mtd0 

Erasing 128 Kibyte @ 200000 -- 100 % complete. 

/> mount -t jffs2 /dev/mtdblock0 /mnt 

/> MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x001c0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x001a0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00180000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00160000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00140000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00120000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00100000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x000e0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x000c0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x000a0000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00080000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00060000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00040000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00020000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x00000000 failed: -5 

MTD do_write_buffer(): software timeout 

Write clean marker to block at 0x001e0000 failed: -5 

 

I don't understand what i'm doing wrong... 

Maybe the Avalon bridge shared between SRAM and CFI Flash ?  

Do I must force the SRAM pin to be disabled ? 

 

Thanks for your help ! 

 

Papy 

0 Kudos
Altera_Forum
Honored Contributor II
902 Views

The datasheet was totally wrong : 

 

The flash is a Spansion GL256P11FF (128Kbytes x 256 = 256M)... 

 

Do I must change the config.c file ? 

 

Please help ! 

 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
902 Views

You should create an entry of your mtd map in config.c. Especially, you need to tell it the flash bus width, 8 or 16 bits. Please see flash programming for de2-70 post. 

 

- hippo 

0 Kudos
Altera_Forum
Honored Contributor II
902 Views

Thanks Hippo it works perfectly with this config.c : 

 

------------------------------------------------------------------------# define CONFIG_DBM3C40 

# if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) 

static struct mtd_partition nios2_partitions[] = {# if defined(CONFIG_DBM3C40) 

.name = "jffs2_config", 

.size = 0x01000000, /* 16 Mo */ 

.offset = na_ext_flash_size-0x01000000,  

},  

.name = "sof_and_zimage", 

.size = na_ext_flash_size-0x01000000, /* 16 Mo */ 

.offset = 0, 

}# elif ... 

... 

}; 

.... 

static struct physmap_flash_data nios2_flash_data = {# if defined(CONFIG_DBM3C40) 

.width = 2, /* 16 bits data bus */# elif ... 

... 

}; 

------------------------------------------------------------------------ 

 

I can successfully store any data to /dev/mtd0 like IP configuration file or some PDF files... 

 

Now I follow the tutorial "Flash Programmer" but I don't understand well the sof2flash parameter --offset in "sof in CFI, program in CFI" paragraph : 

 

# Creating .flash file for the FPGA configuration 

sof2flash --offset=0xc00000 --input=$SOPC_KIT_NIOS2/examples/verilog/niosII_cycloneII_2c35/standard/standard.sof --output=standard.flash 

 

For me, it only means that the size of (zImage+boot_loader), which is programmed just after this step, must be lower than 0xC00000, otherwise writing zImage or boot loader will erase some part (or full) of the SOF configuration file... 

 

Do I misunderstand the --offset parameter ? I mean it could be a "devboard-dependent" parameter for example... 

 

Thanks for your reply ! 

 

Papy
0 Kudos
Reply