PaNiC Random Rant (or how we used to call it: .plan)
Using video RAM ...
Since I was playing with some jffs images, I wanted to quickly write to a "dummy" mtd device and test the image from there. I remembered some time ago on slashdot there was an interesting article on how to use the video ram as storage. As I couldn't find it anymore I decided to try it myself.
Usually mounting jffs images requires some steps and the mtd2block kernel module:
losetup /dev/loop0 rootfs.jffs2
modprobe block2mtd block2mtd=/dev/loop0,131072
modprobe jffs2
modprobe mtdblock
mkdir /mnt/loop0
mount -t jffs2 -o ro /dev/mtdblock0 /mnt/loop0
Using the video ram:
1. Find out the starting address of video memory:
> lspci -v
2:00.0 VGA compatible controller: nVidia Corporation G94 [GeForce 9600 GT] (rev a1)
Subsystem: LeadTek Research Inc. Device 2ac1
Flags: bus master, fast devsel, latency 0, IRQ 18
Memory at fd000000 (32-bit, non-prefetchable) [size=16M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
Memory at fa000000 (64-bit, non-prefetchable) [size=32M]
I/O ports at ec00 [size=128]
[virtual] Expansion ROM at feb80000 [disabled] [size=512K]
As above the video memory starts at 0xd0000000
2. Map the video ram into a mtd block
> modprobe slram map=VRAM,0xd2000000,+0x4000000
Note that I maped from 0xd0000000 + 32Mb to let some video memory to be used by framebuffer/X (if you use nv driver you can specify VideoRam 32765 in xorg.conf to limit the memory mappings).
The third parameter (+0x4000000) is the memory size (64Mb)
If everything is ok you should see something like this in dmesg log:
slram: Mapped from 0xf8f00000 to 0xfaf00000
slram: devname=VRAM, devstart=0xd2000000, devlength=0x2000000
devstart and devlength depend on your parameters.
Doing cat /proc/mtd should output:
mtd0: 02000000 00004000 "VRAM"
3. Add the kernel mtd modules and create the mtdblock devices
modprobe mtd
modprobe mtd_blkdevs
modprobe mtdblock
mknod /dev/mtdblock0 b 31 0
mknod /dev/mtd0 c 90 0
Now you can use the /dev/mtdblock0 to write jffs images or use it as a very fast swap (mkswap /dev/mtdblock0, swapon)
Notice that you can't create partitions directly in /dev/mtdblock0 with fdisk and use /dev/mtdblock0p1. Partitions are usually created in a device driver mapping or by specifing mtdparts= parameter at kernel boot.
posted by panic @ 7:39 PM
Hi, i have the same card Nvidia 9600GT M and a 8600GT,i am using kernel 2.6.30.2, for some reason i cant modprobe slram,
FATAL: Error inserting slram (/lib/modules/2.6.30-ARCH/kernel/drivers/mtd/devices/slram.ko): Invalid argument
if you had this error before can you tell me what u did to solve it.
here is lspci -vvv of my card
http://pastebin.com/f29c516a8
also u can reach me at princeamd.elive@gmail.com.
thanks , please reply
That error is usually from incorrect memory regions or you try to allocate too much memory, first try to allocate less memory for example:
modprobe slram map=VRAM,0xd2000000,+0x2000000
You should also try to map from your prefetchable memory addresses 0xc0000000 in your case.