| Electronic Components Datasheet Search |
|
UM0851 Datasheet(PDF) 148 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
UM0851 Datasheet(HTML) 148 Page - STMicroelectronics |
|
148 / 245 page ![]() Non-volatile memory device drivers UM0851 148/245 Doc ID 16604 Rev 2 Raw mode usage from user space MTD Utils can be used to access NOR Flash via the MTD layer without a file-system. The MTD project provides a number of helpful tools for handling NOR Flash. ● flasherase, flasheraseall: erase and format Flash partitions ● flashcp: Write filesystem images to NOR Flash NOR Flash does not have bad blocks so normal busy box commands can also be used to access it. The random access capability of NOR Flash makes it possible to access any address of NOR Flash from user mode, once that address is properly mapped. Raw mode usage from kernel space NOR Flash can be directly accessed. However, MTD calls such as "mtd->read", "mtd- >erase" and "mtd->write" can be used to read, erase and write to MTD devices. The following code snippet shows an example where 4 bytes are read and written in the same location of the MTD partition number 3. struct mtd_info *mtd; int ret = 0; void *buffer; size_t retlen = 0; /* Get MTD info of 3rd partition */ mtd = get_mtd_device(NULL, 3); if (!mtd) { err( "Err in get mtd\n"); return; } /* Read 4 bytes from partition 3 and store in 'buffer' */ ret = mtd->read(mtd, 0, 4, &retlen, buffer); if (ret < 0) { err("Err MTD read=%d\n", ret); return; } /* Write 4 bytes into the partition 3 from the 'buffer' */ ret = (*(mtd->write)) (mtd, 0, 4, &retlen, buffer); if (ret < 0) { err("Err MTD write=%d\n", ret); return; } Logical mode usage from user space The MTD partition can be mounted using a file-system and then can be used. The NOR Flash partition is supported by JFFS2 only, so make sure that a valid JFFS2 image is already present in the partition to avoid getting a lot of JFFS2 errror messages. # mount -t jffs2 /dev/mtdblock3 /mnt #cp /tmp/song.mp3 /mnt/ #ls /mnt Song.mp3 # |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |