{"id":4430,"date":"2015-12-10T14:01:44","date_gmt":"2015-12-10T14:01:44","guid":{"rendered":"http:\/\/blog.bachi.net\/?p=4430"},"modified":"2015-12-14T16:50:50","modified_gmt":"2015-12-14T16:50:50","slug":"ubifs-nandsim-on-fedora-20","status":"publish","type":"post","link":"https:\/\/blog.bachi.net\/?p=4430","title":{"rendered":"UBIFS \/ nandsim on Fedora 20"},"content":{"rendered":"<p><a href=\"http:\/\/www.linux-mtd.infradead.org\/faq\/ubi.html\">Memory Technology Devices &#8211; UBI<\/a><br \/>\n<a href=\"http:\/\/www.linux-mtd.infradead.org\/faq\/ubifs.html\">Memory Technology Devices &#8211; UBIFS<\/a><br \/>\n<a href=\"http:\/\/www.linux-mtd.infradead.org\/faq\/nand.html\">Memory Technology Devices &#8211; NAND<\/a><\/p>\n<h3>FreeBSD<\/h3>\n<p><a href=\"https:\/\/wiki.freebsd.org\/NAND\">NAND Flash Framework Introduction<\/a>, experimental<\/p>\n<h3>Own try&#8230;<\/h3>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# file \/tmp\/nandimg_.JeCb7JOv\/common.fs\r\n\/tmp\/nandimg_.JeCb7JOv\/common.fs: UBIfs image, sequence number 8, length 4096, CRC 0x151054e7\r\n\r\n# mount -t ubifs \/tmp\/nandimg_.JeCb7JOv\/common.fs \/mnt\/common\r\nmount: unknown filesystem type 'ubifs'\r\n<\/pre>\n<h3>Should work, but&#8230;<\/h3>\n<p><a href=\"https:\/\/ask.fedoraproject.org\/en\/question\/58933\/where-are-the-sources-for-mtdnandnandsim-kernel-module\/\">Where are the sources for mtd\/nand\/nandsim kernel module?<\/a><br \/>\n<a href=\"http:\/\/nothingtechnicalaboutit.blogspot.ch\/2010\/01\/ubi-ubifs-on-nandsim-simulator.html\">UBI \/ UBIFS on NANDSIM simulator<\/a><br \/>\n<a href=\"http:\/\/tjworld.net\/wiki\/Linux\/Kernel\/SimulateNandMtdDevice\">Simulate NAND MTD Device<\/a><br \/>\n<a href=\"http:\/\/www.slatedroid.com\/topic\/3394-extract-and-rebuild-a-ubi-image\/\">Extract and rebuild a UBI image<\/a> (on Ubuntu)<\/p>\n<pre class=\"brush: plain; title: Extract; notranslate\" title=\"Extract\">\r\n$ mkdir \/mnt\/ubi\r\n$ modprobe mtdblock\r\n$ modprobe ubi\r\n$ modprobe nandsim \\\r\nfirst_id_byte=0x20 \\\r\nsecond_id_byte=0xaa \\\r\nthird_id_byte=0x00 \\\r\nfourth_id_byte=0x15\r\n$ cat \/proc\/mtddev\r\n$ ls -l \/dev\/mtd*\r\n$ dd if=ubi.img of=\/dev\/mtdblock&#x5B;COLOR=red]0&#x5B;\/COLOR] bs=2048\r\n$ ubiattach \/dev\/ubi_ctrl -m 0\r\n$ ls -l \/dev\/ubi*\r\n$ mount -t ubifs ubi0_0 \/mnt\/ubi\r\n<\/pre>\n<pre class=\"brush: plain; title: Rebuild; notranslate\" title=\"Rebuild\">\r\n$ mkfs.ubifs -m 2048 -e 129024 -c 2047 -r \/mnt\/ubi ubifs.img\r\n$ nano ubi.ini\r\n&#x5B;ubifs]mode=ubi\r\nimage=ubifs.img\r\nvol_id=0\r\nvol_size=200MiB\r\nvol_type=dynamic\r\nvol_name=rootfs\r\nvol_flags=autoresize\r\n$ ubinize -o ubi.img -p 131072 -m 2048 -s 512 ubi.ini\r\n<\/pre>\n<h3>Compile kernel module<\/h3>\n<p><a href=\"https:\/\/docs.fedoraproject.org\/en-US\/Fedora_Core\/6\/html\/Release_Notes\/ar01s07s07.html\">Fedore &#8211; Building Only Kernel Modules<\/a><br \/>\n<a href=\"http:\/\/www.cyberciti.biz\/tips\/compiling-linux-kernel-module.html\">How to: Compile Linux kernel modules<\/a><br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/3140478\/fatal-module-not-found-error-using-modprobe\">\u201cFATAL: Module not found error\u201d using modprobe<\/a><br \/>\n<a href=\"http:\/\/comments.gmane.org\/gmane.linux.drivers.mtd\/56473\">Building nandsim for Fedora<\/a><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n$ yum install mtd-utils\r\n$ yum install kernel-devel\r\n$ mkdir -p ~\/src\/nand\r\n$ cd ~\/src\/nand\r\n$ fetch &lt;URL&gt;\/nandsim.c\r\n$ vi Makefile &lt;= (as in Fedora: Building Only Kernel Modules)\r\n$ make\r\nmake -C \/lib\/modules\/3.11.10-301.fc20.x86_64\/build M=\/home\/andreas\/src\/nand modules\r\nmake&#x5B;1]: Entering directory `\/usr\/src\/kernels\/3.11.10-301.fc20.x86_64'\r\n  CC &#x5B;M]  \/home\/andreas\/src\/nand\/nandsim.o\r\n\/home\/andreas\/src\/nand\/nandsim.c: In function \u2018alloc_device\u2019:\r\n\/home\/andreas\/src\/nand\/nandsim.c:581:25: error: \u2018FMODE_CAN_READ\u2019 undeclared (first use in this function)\r\n   if (!(cfile-&gt;f_mode &amp; FMODE_CAN_READ)) {\r\n                         ^\r\n\/home\/andreas\/src\/nand\/nandsim.c:581:25: note: each undeclared identifier is reported only once for each function it appears in\r\n\/home\/andreas\/src\/nand\/nandsim.c:586:25: error: \u2018FMODE_CAN_WRITE\u2019 undeclared (first use in this function)\r\n   if (!(cfile-&gt;f_mode &amp; FMODE_CAN_WRITE)) {\r\n                         ^\r\nmake&#x5B;2]: *** &#x5B;\/home\/andreas\/src\/nand\/nandsim.o] Error 1\r\nmake&#x5B;1]: *** &#x5B;_module_\/home\/andreas\/src\/nand] Error 2\r\nmake&#x5B;1]: Leaving directory `\/usr\/src\/kernels\/3.11.10-301.fc20.x86_64'\r\nmake: *** &#x5B;default] Error 2\r\n\r\n$ uname -a\r\nLinux nch-w-andreasb.advaoptical.com 3.11.10-301.fc20.x86_64 &#x5B;...]\r\n\r\n$ grep -r FMODE_CAN_READ \/usr\/src\/kernels\/3.11.10-301.fc20.x86_64\/\r\n&lt;empty&gt;\r\n\r\n$ grep -r FMODE_CAN_READ \/usr\/src\/kernels\/3.19.8-100.fc20.x86_64\r\n\/usr\/src\/kernels\/3.19.8-100.fc20.x86_64\/include\/linux\/fs.h:#define FMODE_CAN_READ          ((__force fmode_t)0x20000)\r\n\r\n$ rpm -qa kernel\r\nkernel-3.19.8-100.fc20.x86_64\r\nkernel-3.11.10-301.fc20.x86_64\r\n\r\n$ grub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\n$ grub2-install \/dev\/sda\r\n\r\n&lt;Reboot&gt;\r\n\r\n$ yum remove kernel-3.11.10-301.fc20.x86_64\r\n$ yum remove kernel-devel-3.11.10-301.fc20.x86_64\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Memory Technology Devices &#8211; UBI Memory Technology Devices &#8211; UBIFS Memory Technology Devices &#8211; NAND FreeBSD NAND Flash Framework Introduction, experimental Own try&#8230; # file \/tmp\/nandimg_.JeCb7JOv\/common.fs \/tmp\/nandimg_.JeCb7JOv\/common.fs: UBIfs image, sequence number 8, length 4096, CRC 0x151054e7 # mount -t ubifs \/tmp\/nandimg_.JeCb7JOv\/common.fs \/mnt\/common mount: unknown filesystem type &#8216;ubifs&#8217; Should work, but&#8230; Where are the sources for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4430","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4430"}],"version-history":[{"count":17,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4430\/revisions"}],"predecessor-version":[{"id":4469,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=\/wp\/v2\/posts\/4430\/revisions\/4469"}],"wp:attachment":[{"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bachi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}