LeMaker Guitar:The instructions on display

From BananaPro/Pi
Jump to: navigation, search
This page is a translated version of the page LeMaker Guitar:The instructions on display and the translation is 100% complete.

Other languages:

Display Devices

The lasted display framwork for s500 have updated on the images v1601. It can support several kind of screens:

  • HDMI
  • CVBS

Now, the combination LeMaker Guitar v1.3 + LeMaker Guitar Base Board B only support HDMI and LCD, CVBS will be supported at the combination of LeMaker Guitar Base Board B Plus + LeMaker Guitar v1.4.
The software have already updated to GitHub. Next, we will tell you how to use the HDMI and LCD.

Display Mode

LeMaker Guitar can support Different screen with the same display and Different screen with the different display mode, and it can two display devices output at the same time, for example: HDMI+LCD, HDMI+DSI, CVBS+LCD, CVBS+DSI or HDMI+CVBS.

Different screen with the same display

The system runs on this mode by default: use HDMI as master device and LCD as slave device.If the HDMI output is 1080P and the LCD is [1024*600], there will be a scale processing while the image map to slave device(LCD) from master device(HDMI), and the display on LCD will be fuzzy. If the LCD is 1080P too, the output images will be point to point without affected.

Different screen with the different display

You can change the LeMaker Guitar worked on this display mode by the next command:

# echo 0 > /sys/class/graphics/fb0/mirror_to_hdmi

On this mode, the HDMI device is the master divice(/dev/fb0) and the LCD is slave device(/dev/fb1). You can write the display content to the LCD's framebuffer through /dev/fb1.
And there have a test code:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/fb.h>
#define FB_FILE "/dev/fb1"
#define FAIL -1
#define SUCC 0
int fb = 0;
char *pFb = NULL;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
void draw_square(char *fp, int row, int colum, int color)
	int i, j;
	int bpp = vinfo.bits_per_pixel;
	int steps = finfo.line_length /(bpp >>3);
	int *buf = (int *)fp;
	for(i=0; i < row; i++)
		for(j=0;j < colum; j++)
			buf[i*steps+j] = color;
int main(void)
	fb = open(FB_FILE, O_RDWR);
	if(fb < 0)
		printf("Don't open the framebuffer device\n");
		return FAIL;
	if(ioctl(fb, FBIOGET_FSCREENINFO, &finfo))
		printf("Reading fixed information failed\n");
		return FAIL;
	if(ioctl(fb,FBIOGET_VSCREENINFO, &vinfo))
		printf("Reading variable information failed\n");
		return FAIL;
	pFb = (char *)mmap(NULL, finfo.smem_len, PROT_READ | PROT_WRITE,
	MAP_SHARED, fb, 0);
	if(pFb == MAP_FAILED)
		printf("Error: Failed to map framebuffer device to memory\n");
		return FAIL;
	memset(pFb, 0x0, finfo.smem_len); //clear buffer
	printf("start to draw red...\n");
	draw_square(pFb, vinfo.yres, vinfo.xres, 0x00ff0000);
	printf("start to draw green...\n");
	draw_square(pFb, vinfo.yres, vinfo.xres, 0x0000ff00);
	printf("start to draw blue...\n");
	draw_square(pFb, vinfo.yres, vinfo.xres, 0x000000ff);
	munmap(pFb, finfo.smem_len);
	return SUCC;

Configuration of display devices

The HDMI is the master display device by default, you can change the LCD to be master device by next configurations:
NOTE: The DTS file of uboot and kernel shouled be modified both.

Edit the DTS file

Path of uboot dts file: u-boot-actions/arch/arm/dts/lemaker_guitar.dts
Path of kernel dts file: linux-actions/arch/arm/boot/dts/lemaker_guitar_bbb.dts

  • Let LCD to be master device:

Modified the DTS file both in uboot and kernel:

framebuffer {
    compatible = "actions,framebuffer";
    def_display = "lcd";//The master device could be:"hdmi","lcd","cvbs","dsi"
  • Close other display devices:

Modified the DTS file both in uboot and kernel:
If the CVBS or DSI devices' mode is 'okay', change it to 'disabled'. Because the display framework can only support two different display devices at the same time.

dsi: dsi@b0220000 {
    status = "disabled";
cvbs: cvbs@b02b0000 {
    status = "disabled";

Update the DTB file

  • Recompile the u-boot-dtb.img and kernel.dtb, refer this:

After compile, you could find in this two path:
u-boot-dtb.img: linux-actions-bsp/build/s500/u-boot/u-boot-dtb.img
kernel.dtb: linux-actions-bsp/build/s500/misc/kernel.dtb

  • Update

Copy the u-boot-dtb.img and kernel.dtb to /home/lemaker on LeMaker Guitar. And updete these like this:

//Update uboot image file:
# sudo dd if=/home/lemaker/u-boot-dtb.img of=/dev/mmcblk0 bs=512 seek=6144
//Update kernel DTB file
# sudo mount /dev/mmcblk0p1 /mnt
# sudo cp -f /home/lemaker/kernel.dtb /mnt
# sudo umount /mnt
//Synchronize file and reboot LeMaker Guitar
# sudo sync && reboot

NOTE; 1. The DTS file and image file of uboot are all in u-boot-dtb.img; So you can update the DTB file by update u-boot-dtb.img.
2. If you do not have a HDMI screen, you can change the LCD to be master device.

Configure HDMI resolution

Under the new display framework, there have a resolution list can be set:

VID Resolution
2 720*480p-60
4 1280*720p-60
16 1920*1080-60
17 720*576p-50
19 1280*720p-50
31 1920*1080p-50

Resolution self-adaption of HDMI

The system image support resolution self-adaption of HDMI according to the EDID information getted from uboot stage.
You should plugin the HDMI device before start Guitar, and you can judge it via the uboot log information:

parse hdmi edid information successfully
In: serial
Out: serial
Err: serial
Net: owl_mac

If you get the EDID successfully, you will see "successfully".

Manually set the resolution of HDMI

You can manually set the resolution of HDMI when the self-adaption of HDMI failed(720P@60Hz by default).
Do this by modified the DTS files, for example, Set the default resolution to "720*480P@60Hz":

hdmi: hdmi@b02c0000{
    default_resolution = "720x480p-60";

NOTE: The resolution should choosed from the supported resolution list.

How to get the resolution of HDMI

  • HDMI as the master device

You can get the resolution by this command on X-Window:

# xrandr
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 720 x 480, current 720 x 480, maximum 720 x 480
default connected 720x480+0+0 0mm x 0mm
720x480 0.00*
  • HDMI as the slave device

Use this way:

# cat /sys/devices/b02c0000.hdmi/vid

Check the supported resolution list, and it shows that the resolution of HDMI is "720*480P-60".

Configure CVBS resolution

The CVBS supported two standard by default:
1) PAL: 720*576i-50Hz
2) NTSC: 720*486i-60Hz
The configuration of CVBS is similar to HDMI, but don't need to get the EDID.

    default_mode = "PAL";

default_mode: choose "PAL" or "NTSC".


Note: The S500 do not support DVI screen. You can use a HDMI or VGA screen.