LinuxConsulting

- Nicu Pavel personal page

PaNiC Random Rant (or how we used to call it: .plan)


Using both memory controllers with SPARSE_MEM on Atmel SAM9G45/M10


Atmel AT91SAM9G45 and AT91SAM9M10 (AT91SAM9263 has a similar layout) have two memory controllers providing 128Mb at locations 0x20000000 and 0x70000000. To use both banks of memory SPARSE_MEM support must be enabled in kernel and phys_to_virt() and virt_to_phys() macros defined. The actual mapping is configured in kernel by boot params.

Both banks must be initialized by AT91Bootstrap, if you use AT91Bootstrap from AT91SAM9G45/M10 SDK see the patch below. Also if u-boot is used as bootloader and you want to use second bank it needs to be patched too.
My patches wore made for 2.6.30 kernel updated patches should be available below:

AT91Bootstrap (from G45 SDK):
 0001-Init-second-bank-of-memory-0x20000000.patch

U-Boot:
0001-add-support-for-both-banks-of-memory-on-Atmel-G45-bo.patch


Kernel:
Add to boot params to enable both mem banks(for example on u-boot bootparams=) :
mem=128M@0x20000000 mem=128M@0x70000000

For kernels <= 2.6.30: 0001-Add-SPARSEMEM-support-for-Atmel-CPU-for-2-banks-of-m.patch

0010-Fix-memory-mapping-for-SPARSEMEM-to-use-both-banks-o.patch

For kernels >2.6.30 (patch is for 2.6.34):

http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=6143/1

Labels: , ,

2 Comments


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.

Labels: ,

2 Comments