maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Nokia N900 (https://talk.maemo.org/forumdisplay.php?f=44)
-   -   [Solved] /dev/mmcblk* missing when in /sbin/preinit? (https://talk.maemo.org/showthread.php?t=85588)

bozoid 2012-07-20 09:21

[Solved] /dev/mmcblk* missing when in /sbin/preinit?
 
Hi.

/dev/mmcblk* missing when in /sbin/preinit?
Anyone knows what I need to do to get them to appear?

At various spots in preinit, i tried following command:
find / > /zlog.txt

zlog.txt somehow only shows a few devices.
mmcblk* is missing.
Tried above command even jst before preinit executes /sbin/init, but no diff...
I had also ensured various mmc kernel modules are loaded.

I wanted to mount /dev/mmcblk0p2 but can't coz of above.

Strange thing is, it is the same file system that is booted to. So, after full boot up, I can see /dev/mmcblk* files.
I did a grep in /etc/event.d also but can't find a clue.

I am doing above on a freshly PR1.3 flashed N900.

Thanks n best regards,

kh

reinob 2012-07-20 10:57

Re: /dev/mmcblk* missing when in /sbin/preinit?
 
/home is mounted on /etc/event.d/rcS-late. Way after preinit.

bozoid 2012-07-21 04:22

Re: /dev/mmcblk* missing when in /sbin/preinit?
 
thanks yes i am aware.
am trying to move rootfs to emmc.
am also aware another thread discusses rootfs on emmc.
that one didnt work for me, and i had some personal prefs as well.

so, am still wondering how i can get /dev/mmcblk* devices during preinit stage? anyone?

kh

Hurrian 2012-07-21 07:11

Re: /dev/mmcblk* missing when in /sbin/preinit?
 
Quote:

Originally Posted by bozoid (Post 1240609)
thanks yes i am aware.
am trying to move rootfs to emmc.
am also aware another thread discusses rootfs on emmc.
that one didnt work for me, and i had some personal prefs as well.

so, am still wondering how i can get /dev/mmcblk* devices during preinit stage? anyone?

kh

You need to insmod the OMAP HSMMC drivers and the filesystem drivers yourself.

I don't have the list with me right now, but you can check dependencies in lsmod.

bozoid 2012-07-22 12:40

Re: /dev/mmcblk* missing when in /sbin/preinit?
 
Quote:

Originally Posted by Hurrian (Post 1240635)
You need to insmod the OMAP HSMMC drivers and the filesystem drivers yourself.

I don't have the list with me right now, but you can check dependencies in lsmod.

Thanks! But still no go... :(

(Checking that makes me feel more & more that /sbin/preinit is just quite broken... :( modules it loads are very short but yet it has script commands that access mmc partitions)

The modules are (in order they should be loaded):
mbcache ext2 jbd ext3 mmc_core mmc_block omap_hsmmc

I've loaded them in that manner; lsmod from within preinit shows them loaded but still no /dev/mmcblk* devices.

I happen to looked at /bootmenu.sh this time round & saw something interesting in it:

# eMMC and SD
cd /dev; /sbin/MAKEDEV input; cd /
insmod $MODULE_PATH/mmc_core.ko
insmod $MODULE_PATH/mmc_block.ko
insmod $MODULE_PATH/omap_hsmmc.ko
rm -f /dev/mmcblk*
sleep 2
for p in /sys/block/mmcblk*/ /sys/block/mmcblk*/mmcblk*p*/; do
n=`basename $p`
rm -f /dev/$n
mknod /dev/$n b `cat $p/dev | sed "s/:/ /g"`
done

More devices appeared in /dev but still no /dev/mmcblk*...

Best regards,

kh

reinob 2012-07-23 07:26

Re: /dev/mmcblk* missing when in /sbin/preinit?
 
Can you try to do

ls -lR /sys/block/mmcblk*/

in preinit, after loading the modules?

bozoid 2012-12-13 06:16

Re: /dev/mmcblk* missing when in /sbin/preinit?
 
I'm sorry I forgot to respond to this!
Came across this thread again when I was debugging some stuff.

Anyway, I've found the solution.

Modules must be loaded using insmod or similar in preinit in this order:
mmc_core mmc_block omap_hsmmc mbcache jbd ext2 ext3
(ext2 only as necessary)

mmcblk* will only show under /sys/block after a bit of time (ie: 1 second).
So, a sleep of 1 second was added in my script after loading above modules.

Then..., in my case, using various dev files under /sys/block/mmcblk*, I had some commands do following:
mknod /dev/mmcblk0 b 179 0
(where the last 2 values are obtained from dev files; ie: /sys/block/mmcblk0/dev)

That created devices in /dev for me.

I've got that all in some loop and script in my preinit script of course...

Thanks again for the help!

kh

bozoid 2012-12-13 06:21

Re: [Solved] /dev/mmcblk* missing when in /sbin/preinit?
 
Oh, one thing to note. One might want to identify the correct storage to do further stuff from this...
(ie: find the eMMC or the storage card).

As noted in other threads (rootfs on emmc), N900 swaps mmcblk0 and mmcblk1 at some point after preinit.

The solution I did was to use sfdisk -l, coupled with some greps, etc, to identify the partition (in a very flaky way, by looking at count of cylinders).
I noted that both eMMC & SD use the same kernel drivers... hence trying to identify them by hardware type proved a bit difficult.
Didn't try too hard to find other ways yet.

Options I can think of offhand to identify the storage are:
- lshal
- parameters of the device in /sys/block/mmcblk*
- probably some storage label tool.

kh

reinob 2012-12-13 11:49

Re: [Solved] /dev/mmcblk* missing when in /sbin/preinit?
 
@bozoid,

Thanks for your findings!

I haven't investigated this yet, but I think the /dev/mmcblk* devices are created by udev, which is started in /etc/init.d/rcS, which is the first script run by upstart after /sbin/preinit passes control to it.

Have a look in /etc/udev/rules.d/92-n770.rules as well as /lib/udev/mmc_id (which provides a suitable name to udev). mmc_id gives the SLOT_NUM 1 to the external MMC and SLOT_NUM 0 to the internal MMC (even though the kernel appears to detect the external MMC first and then the internal one, so udev effectively swaps the slot numbers).

Hurrian 2012-12-14 05:54

Re: [Solved] /dev/mmcblk* missing when in /sbin/preinit?
 
Quote:

Originally Posted by reinob (Post 1304103)
(even though the kernel appears to detect the external MMC first and then the internal one, so udev effectively swaps the slot numbers).

Physically, the SD card is wired to the first MMC interface on the OMAP.

I speculate this was to aid during testing/development of the N900, as IIRC the only way you're feeding the OMAP ROM with an easily replacable (NAND doesn't count) second stage bootloader was by writing it to the first MMC device.


All times are GMT. The time now is 23:15.

vBulletin® Version 3.8.8