Documentation:Linux/Framebuffer
From AVRFreaks Wiki
Contents |
[edit] Introduction
This tutorial will describe how to add video hardware to your NGW100 and to get the Framebuffer driver for the kernel working (with buildroot 2.3)
The following steps need to be done:
- Hardware considerations
- The PCP LCD
- VGA with the ADV7125
- Software
- Installing buildroot (not discussed)
- Modifying the kernel
- Recompiling the Kernel
- Copying the Root Filesystem to the SD-Card
- Updating the NGW100
- Add the fbmem Parameter
- Boot from SD Card
- Copy the kernel image to the flash
[edit] Hardware considerations
It is quite easy to equip the NGW100 with video hardware thus all needed signals are wired to the J7 expansion header connector. Here is the Pinout of J7:
The 47/50Ohm resistor is not required, but improves the signal quality of the clk line.
[edit] The PSP LCD
The PSP LCD (it the LCD used in Sony's PSP, it's a sharp LQ043T3DX02) can be bought at sparkfun.com (sku: LCD-08335) and is a damn cheap, but really high quality 480x272 large TFT-Display. The main disadvantages of using such a TFT are the needed supply voltages. It needs 3.3V digital (2.5V according to the datasheet, but 3.3V are in the absolute maximum ratings and work fine), 5V analog and somewhat around 20V @ 15mA for the background light.
The Interface of the diplay is quite easy, 8 Red Signals, 8 Blue Signals, 8 Green Signals, PCLK, VSYNC, HSYNC and LCDON:
Note: For the 5V supply i simply used a linear regulator and the Supply voltage on the small 2-pin connector of the NGW100. In this version i used a good old 7805, might not be the best choise in case of effiency, but i used an MIC5205 before - not short circuit safe - what cost me my first prototype =)
The background voltage generation for the display is really tricky, due to the need of a Boost or Step-Up Converter. Most DC/DC converter IC's have two operation mode, a current limiting mode and a voltage limiting mode. You should consider a current limiting boost convert with about 15 to 20mA of output current (there are a lot of Background LED Drivers arround, just use what you prefer). BUT! if you unplug the Display while the converter is on, it will die within seconds, thus the there is no current through the load and most converters try to regulate that with a higher output voltage...until they thermaly die.
Note: Most commonly used IC's have that problem without a display plugged in, after a few unsuccessfull tries I decieded to build my own boost convert using an ATTiny85, here's the schematic:
Just write me a mail to bwa@berniwa.com to get the firmware for the ATTiny.
The Boost Converter is voltage & current limiting and all limit can be controlled of I²C (dynamic background voltage adjustment,...).
Layout considerations: The PSP LCD is very lenient in case of signal quality and clock speed, so there shouldn't be any problems.
[edit] VGA with the ADV7125
The ADV7125 is i fast Digital to Analog converter specially designed for VGA Signals.
The schematic should be very easy to understand and is copied directly from the datasheet of the chip, HSYNC and VSYNC are buffer with double inverters, that's copied from the STK1000 datasheet and should prevent the AP7000 from damages through too much load on the HYNC and VSYNC Pins.
The only thing that might seem strange is the supply voltage decuppling using two inductors, that is also copied from the STK1000 schematic and should separate analog and digital ground planes to reduce noise in the video signal.
Layout considerations
- Keep the analog traces as short as possible and the 75Ohm Resitors as close to the connector as possible
- Be sure what you do the the ground plane (seperate gnd plane arount all the whole VGA Part)
- Place the ADV7125 as far away as possible from the boost converter of the NGW100 (the "bad" inductor is next to the RS232)
[edit] Software
[edit] Modifying the
To get a useable framebuffer devices preconfigured with the right settings, you need to modify a bit of the kernel source. Normally you would add a new device configuration to the kernel, but the Quick'n Dirty way (just modify the NGW100 setup) will do also.
This requires a configured and working buildroot 2.3 installation!
The Kernel you need to modify is located in your buildroot directory in the
project_build_avr32/xMedia/linux-2.6.27.6/
directory
Open the file
arch/avr32/boards/atngw100/setup.c
and add the initialisation for the VGA Display (there are already some files for the evklcd10x, but i haven't tried to get those working)
At first we need to add the include of the LCDC Driver somewhere at the top of the file:
#include <video/atmel_lcdc.h>
LCD
Then we have to add some general settings (display and lcdc settings) also in the upper area of the setup file:
static struct fb_videomode __initdata lcd_modes[] = {
{
.name = "LCD",
.refresh = 25,
.xres = 480, .yres = 272,
.pixclock = KHZ2PICOS(9072),
.left_margin = 2, .right_margin = 2,
.upper_margin = 2, .lower_margin = 2,
.hsync_len = 41, .vsync_len = 10,
.sync = 0,
.vmode = FB_VMODE_NONINTERLACED,
}
};
static struct fb_monspecs __initdata xmedia_default_monspecs = {
.manufacturer = "BWA",
.monitor = "SHARP LQ043",
.modedb = lcd_modes,
.modedb_len = ARRAY_SIZE(lcd_modes),
.hfmin = 19948,
.hfmax = 31478,
.vfmin = 25,
.vfmax = 67,
.dclkmax = 28330000,
};
static struct atmel_lcdfb_info __initdata xmedia_lcdc_data = {
.default_bpp = 24,
.default_dmacon = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
.default_lcdcon2 = (ATMEL_LCDC_DISTYPE_TFT
| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
| ATMEL_LCDC_MEMOR_BIG),
.default_monspecs = &xmedia_default_monspecs,
.guard_time = 2,
};
This setup is suitable for the PSP Display and provides the capability to switch to VGA mode.
VGA
The setup for the VGA out looks something like that (untested but should work):
static struct fb_videomode __initdata lcd_modes[] = {
{
.name = "VGA 640x480 @ 60Hz",
.refresh = 60,
.xres = 640, .yres = 480,
.pixclock = KHZ2PICOS(23856),
.left_margin = 16, .right_margin = 48,
.upper_margin = 11, .lower_margin = 31,
.hsync_len = 96, .vsync_len = 2,
.sync = FB_SYNC_HOR_HIGH_ACT,
.vmode = FB_VMODE_NONINTERLACED,
}
};
static struct fb_monspecs __initdata xmedia_default_monspecs = {
.manufacturer = "BWA",
.monitor = "VGA Output",
.modedb = lcd_modes,
.modedb_len = ARRAY_SIZE(lcd_modes),
.hfmin = 19948,
.hfmax = 31478,
.vfmin = 25,
.vfmax = 67,
.dclkmax = 28330000,
};
static struct atmel_lcdfb_info __initdata xmedia_lcdc_data = {
.default_bpp = 16,
.default_dmacon = ATMEL_LCDC_DMAEN | ATMEL_LCDC_DMA2DEN,
.default_lcdcon2 = (ATMEL_LCDC_DISTYPE_TFT
| ATMEL_LCDC_CLKMOD_ALWAYSACTIVE
| ATMEL_LCDC_MEMOR_BIG),
.default_monspecs = &xmedia_default_monspecs,
.guard_time = 2,
};
Thus the 16bit memory bottleneck the pixel depth has to be reduced to 16 bits if you want to use VGA.
And then we have to initialize everything with the folling command added to the "atngw100_init" function.
at32_add_device_lcdc(0, &xmedia_lcdc_data, fbmem_start, fbmem_size, ATMEL_LCDC_ALT_24BIT | ATMEL_LCDC(PE, DVAL));
Done =)
[edit] Recompiling the kernel
At first we have to clean up everything
cd project_build_avr32/xMedia/linux-2.6.27.6/ make ARCH=avr32 CROSS_COMPILE=avr32-linux- clean
Now we need to do some modifications in the settings:
make ARCH=avr32 CROSS_COMPILE=avr32-linux- menuconfig
And enable:
Device Drivers -> Graphics Support -> Support for frame buffer devices -> AT91/AT32 LCD Controller support
Exit the config and rebuild the hole buildroot package (easiest way, to get a whole image):
cd ../../../ make menuconfig
Enable:
Target Filesystem -> tar the root filesystem
To get a tarred package for the SD Card
make
And get a cup of coffee =)
[edit] Copying the Root Filesystem to the SD-Card
To get your filesystem to the SD Card you need to reformat the card with gparted (most likely) 1 EXT2 partition as large as possbile 1 SWAP partition with 64 or 128 MB or so...
Copy your root filesystem to the SD Card
cd /media/disk/ sudo tar xfv /xmedia/buildroot2_3/binaries/xMedia/rootfs.avr32.tar
"/media/disk" should be the path to your SD Card "/xmedia/buildroot2_3/" should be the path to your buildroot installation
[edit] Updating the NGW100
[edit] Add the fbmem Parameter
To tell the kernel to reserve some memory for the framebuffer you need to add the fbmem parameter into your u-boot configuration:
- Start the NGW100
- Press Space to halt the kernel from booting
- Type "askenv bootargs"
- Enter "console=ttyS0 root=/dev/mmcblk0p1 fbmem=600k" - already with the SD Card as root device
- Type "saveenv" to save the environment variables
- Reboot
[edit] Boot from SD Card
- Start the NGW100
- Press Space to halt the kernel from booting
- Type "askenv bootcmd"
- Enter "mmcinit; ext2load mmc 0:1 0x10200000 /boot/uImage; bootm 0x10200000"
- Type "saveenv" to save the environment variables
- Reboot
[edit] Alternative: Copy the kernel image to the flash
The following steps will speed up the boot sequence by copying the kernel to the flash:
- Start the NGW100
- Press Space to halt the kernel from booting
- Enter "protect off 0x20000 0x7EFFFF;erase 0x20000 0x7EFFFF;mmcinit;ext2load mmc 0:1 0x90000000 /boot/uImage;cp.b 0x90000000 0x20000 0200000;"
- Wait...
- Type "askenv bootcmd"
- Enter "bootm 0x20000"
- Type "saveenv" to save the environment variables
- Reboot
--Berniwa 15:20, 15 March 2009 (EET)






