LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 09-22-2015, 01:08 PM   #1
prutser60
LQ Newbie
 
Registered: Sep 2015
Posts: 2

Rep: Reputation: Disabled
Nand flash write from userspace application


Raw write to MTD is not possible due to bad block handling. There are some command line utilities like nandwrite and nanddump. I am however looking for a library which implements this functionality. I notied a libmtd, but this does not seem to be usable for NAND flash.

Is anybody aware of a library which can be used for userspace read/write of NAND flash ?
 
Old 09-22-2015, 03:29 PM   #2
blue_z
Member
 
Registered: Jul 2015
Location: USA
Distribution: Ubuntu, Lubuntu, Mint, custom embedded
Posts: 104

Rep: Reputation: Disabled
Quote:
Originally Posted by prutser60 View Post
I notied a libmtd, but this does not seem to be usable for NAND flash.
What's your basis for that conclusion?
I've never used libmtd, but that seems to be an illogical conclusion.
Libmtd purports to be for "manipulating MTD devices". MTD is an abstraction layer for raw flash devices. NAND is a type of raw flash device.
Ergo libmtd should be able to access NAND flash.

A quick scan of source code for libmtd/mtdlib.c found comments and routines for reading and writing NAND (and even seems to check for bad blocks, e.g. uses MEMGETBADBLOCK ioctl).

Consider using UBI volumes instead of just MTD.

Regards

Last edited by blue_z; 09-22-2015 at 04:18 PM.
 
Old 09-23-2015, 12:41 AM   #3
prutser60
LQ Newbie
 
Registered: Sep 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
The MTD layer does not handle bad blocks. That's f.i the reason that UBI exists on top of MTD.

My conclusion was based on the the libmtd source code. The read and write functions do not handle bad blocks (e.g. skip them) (unless of course I overlooked something)
The only relation with nand I found was indeed the MEMGETBADBLOCK ioctl, which was used in a function to check if a block was marked bad.

Of couse a NAND aware file system is the way to go, but if you want to ba able to write raw flash from an application (e.g. to update
a kernel) then you need to be able to deal with bad blocks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
U-Boot: nand write problem tompo Linux - Embedded & Single-board computer 0 10-24-2011 11:04 AM
[SOLVED] What are the NAND(MTD) read and write commands? dbrazeau Linux - Software 3 11-05-2010 06:31 PM
Nand flash boot Roger03 Programming 1 04-03-2010 05:19 AM
R/W from nand flash linux_newbie79 Linux - Newbie 3 08-19-2009 08:35 AM
nand flash: need help jier Programming 0 05-03-2006 11:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 10:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration