|
Author |
Message |
|
|
Posted Dec 30, 2008 at 4:36:31 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
Hi world,
I'm starting to develop an embeded project based on an ICOP small board : the VSX-6154 ...
-> The board : http://www.icop.com.tw/products_detail.asp?ProductID=275
On this board, I've install the Linux (v5.51) provided by ICOP, this is OK, I've got my shel command line.
-> Some details about this Linux : http://www.dmp.com.tw/tech/os-xlinux/
[quote][b]Linux Kernel 2.6.23[/b] /boot/linux
[b]Loader SysLinux 2.13[/b] /boot
[b]Shell BusyBox 1.10.4[/b] /bin/busybox
[b]FTP Server vsftpd 2.0.3[/b] /usr/sbin/ftpd
[b]TELNET Server BusyBox 1.10.4[/b] /usr/sbin/telnetd
[b]HTTP Server WN Server 2.4.6[/b] /usr/httpd
[b]DHCP Client BusyBox 1.01[/b] /sbin/udhcpc
[b]Share Library glibc 2.7[/b] /lib
[b]PPP Daemon pppd 2.4.1[/b] /sbin
[b]NFS NFS-Utils 1.0.6[/b] /sbin[/quote]
I actually use this on a PC's CRT screen on VGA output.
For my project, I will need to draw some birmaps on screen, so I will probably use framebuffer, or a small lib like Nano-X, if framebuffer is too borring...
So, I've found this small piece of C code on the www :
[quote]#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <errno.h>
int main(int argc, char *argv[])
{
int fbfd = 0;
struct fb_var_screeninfo vinfo;
struct fb_fix_screeninfo finfo;
long int screensize = 0;
char *fbp = 0;
int x = 0, y = 0;
long int location = 0;
// Open the file for reading and writing
fbfd = open("/dev/fb0", O_RDWR);
if (fbfd<0) {
printf("Error: cannot open framebuffer device.\nreturn=%d\n",fbfd);
return(1);
}
printf("The framebuffer device was opened successfully.\n");
// Get fixed screen information
if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
printf("Error reading fixed information.\nerrno=%d\n",errno);
return(2);
}
// Get variable screen information
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
printf("Error reading variable information.\n");
return(3);
}
printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
// Figure out the size of the screen in bytes
screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
// Map the device to memory
fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
fbfd, 0);
if ((int)fbp == -1) {
printf("Error: failed to map framebuffer device to memory.\n");
return(4);
}
printf("The framebuffer device was mapped to memory successfully.\n");
x = 100; y = 100; // Where we are going to put the pixel
// Figure out where in memory to put the pixel
for (y = 100; y < 300; y++)
for (x = 100; x < 300; x++) {
location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
(y+vinfo.yoffset) * finfo.line_length;
if (vinfo.bits_per_pixel == 32) {
*(fbp + location) = 100; // Some blue
*(fbp + location + 1) = 15+(x-100)/2; // A little green
*(fbp + location + 2) = 200-(y-100)/5; // A lot of red
*(fbp + location + 3) = 0; // No transparency
} else { //assume 16bpp
int b = 10;
int g = (x-100)/6; // A little green
int r = 31-(y-100)/16; // A lot of red
unsigned short int t = r<<11 | g << 5 | b;
*((unsigned short int*)(fbp + location)) = t;
}
}
munmap(fbp, screensize);
close(fbfd);
return(0);
}
[/quote]
( sorry for "quoting" code, but code display strange results... )
I've build it with Code::Block on my Kubuntu station ( I'm new to dev on Linux ! ... I'm a pro-dev on Windows classicaly ) ... and it does'nt work on my station ...
Got this :
[quote]Error: cannot open framebuffer device.
return=-1[/quote]
So, the [i]open("/dev/fb0", O_RDWR)[/i] fails ...
( same result when calling by sudo )
first : Is that normal on Kunbuntu ?
Now, I want to test this on my embeded board, but when I call ldd to know dependecies, I don't know where to found that files ( to put them in /lib/ of target system ) ... there is no "simple way" for Code::Block to serach them for me, and put them in my project ( in lib directory for exemple )
Thanks for help, and a merry chrismas to you ! *<Bo)
Seb.
|
tophandcwby
Joined Apr 10, 2008 Posts: 81
Other Topics
|
Posted:
Dec 30, 2008 8:37:31 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
Have you enabled your frame buffer at boot time?
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Dec 30, 2008 11:18:24 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
I don't know ...
I've done the linux install by restoring a GHOST image directly to the HDD, so I don't know what is installed and what isn't ...
-> how could I know if it's done or not ?
thanks for your reply ;o)
[Modified by: Seb.26 on December 30, 2008 11:19 PM]
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Dec 31, 2008 10:20:31 AM
Subject: [Resolved] [Help on starting] About FrameBuffer
Hi world ...
About my problem : the framebuffer is not enabled in my actual Kernel ... so it cannot work !
I'm about to rebuild the Kernel to enable framebuffer
( now, I remember better why I've hesitate a lot before lauching this project under Linux !!! lol )
Thanks for your help, I will post kernel build & installation results soon ( I hope ! )
<< May Tux's spirit be with me ... >>
Seb.
[Edit] If you know a good tutorial on how to build kernel for a target under Kunbuntu : don't hesitate to mention it ! .... thanks
[Modified by: Seb.26 on December 31, 2008 01:15 PM]
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Dec 31, 2008 4:03:45 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
Arrgghhh ... it's not easy to build a standard kernel on Kunbuntu !!!
Does anybody have a tutorial for this special need ???
Thanks
|
tophandcwby
Joined Apr 10, 2008 Posts: 81
Other Topics
|
Posted:
Dec 31, 2008 6:01:16 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
http://beginlinux.wordpress.com/2008/12/03/how-to-compile-an-ubuntu-810-kernel/
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 01, 2009 11:58:54 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
[quote=tophandcwby]http://beginlinux.wordpress.com/2008/12/03/how-to-compile-an-ubuntu-810-kernel/[/quote]
Hi tophandcwby,
thanks a lot for the link ...
But this is for building an Ubuntu Kenel, no ?
I'm probably wrong, but I have the feel that ubuntu use a special kernel ... ( Am I wrong ? )
... And, I need to build a classic kernel for embeded target from ICOP ... ?!
Or maybe could I just follow this steps and replace the .config by mine ?
All of that is pretty confused in my mind ... sorry ...
[Modified by: Seb.26 on January 02, 2009 12:05 AM]
|
tophandcwby
Joined Apr 10, 2008 Posts: 81
Other Topics
|
Posted:
Jan 02, 2009 2:40:44 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
I did not re-read your entire post and thought that you were trying to build a kernel for kubuntu.
The steps for compiling a standard kernel are documented in the README file found in the top level of the kernel source.
What steps are you having trouble with?
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 02, 2009 3:55:30 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
OK, so I've restart from scratch :
1) I've downloading latests stable full sources from www.kernel.org ( linux-2.6.28.tar.bz2 )
2) I've put the file in a local directory ( /home/dev/kernel/ )
3) I've unpack files : bzip2 -dc linux-2.6.XX.tar.bz2 | tar xvf -
4) I've done a "make mrproper" to clean all ( in the case of ??? )
5) I've put my .config file ( provided by ICOP ) in root of source files
6) I've done a "make oldconfig" to set all new setup ( by the default value each time )
7) I've done a "make" to build all ... this take some times ( with some warnings about )
8) I've take the original "linux" file (1.8MB) in /boot/ , rename it as "linux.old"
9) I've copy in place the "bzimage" (1.3MB) and rename it as "linux"
Then, I've boot my board with new kernel ... it's start, but hangup ...
last lines are :
[quote]TCP cubic registered
NET: Regstered protocol familly 17
Using IPI Shortcut mode
VFS: Cannot open root device "hda2" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions :
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)[/quote]
Hum ... sincerly : I don't understand anything exept that's is like my seond partition (hda2) is bad/locked ?! ... I will try to restore the "linux.old" as "linux" to see what happen ...
If you have an idea ... thanks ... ;o)
[Modified by: Seb.26 on January 02, 2009 07:53 PM]
|
tophandcwby
Joined Apr 10, 2008 Posts: 81
Other Topics
|
Posted:
Jan 02, 2009 7:28:37 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
Steps 4 and 5 are reversed. Do make mrproper before you copy your old .config file. mrproper deletes the .config.
Is the system expecting a initrd file?
I use the initrd-tools
mkinitrd -o /boot/initrd.img-2.6.28 2.6.28
You must tell your boot loader about this as well. If you use grub as part of the menu.lst
title kernel 2.6.28
root (hd0,1)
kernel /boot/vmlinuz-2.6.28 root=/dev/hda2 ro
initrd /boot/initrd.img-2.6.28
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 02, 2009 7:51:41 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
[quote=tophandcwby]Steps 4 and 5 are reversed. Do make mrproper before you copy your old .config file. mrproper deletes the .config.[/quote]
Yes, sorry ... in reality, I've done them in the right order ... (I will edit my post)
[quote=tophandcwby]Is the system expecting a initrd file?[/quote]
I don't know ... how could I know ?
Note : my loader is SysLinux 2.13
|
tophandcwby
Joined Apr 10, 2008 Posts: 81
Other Topics
|
Posted:
Jan 03, 2009 2:42:30 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
In your syslinux directory there should be a file called SYSLINUX.CFG . I'm not sure where the syslinux directory lives on your system, I don't have access to it. It should be in /syslinux or maybe /boot/syslinux, you'll have to find it. The config file SYSLINUX.CFG should look something like the following.
DEFAULT linux
LABEL linux
SAY Now booting the kernel from SYSLINUX...
KERNEL vmlinuz.img
APPEND ro root=/dev/sda1 initrd=initrd.img
The initrd=initrd.img is the file you must create for your kernel. See the documentation for syslinux.
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 03, 2009 6:06:06 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
my boot partition ( hda1 in MS DOS type ) contains 4 files :
<<
LDLINUX.SYS (7KB)
linux (1700KB)
SYSLINUX.CFG (1KB)
SYSLINUX.COM (20KB)
>>
And the SYSLINUX.CFG file contain this text :
<<
DEFAULT linux
LABEL linux
KERNEL linux
APPEND root=/dev/hda2
>>
no "initrd" in it ...
but you are probably near the problem : my root partition is not compliant with my kernel build ...
IMO, there are 2 ways :
1 > it's due to the hda2 partition type : Linux, ID = 83
... but since I cannot found information about that in changelog, I don't think ...
2 > something in the partition data is bad for the new kernel, so I have to check what the kernel look for in the root filesystem ...
Any idea/sugestion ?
... to be continued ...
In any case : a big thanks to you tophandcwby for your help from the start of this post
( and also for your patience ! ... I know how it's hard to help newbies ... )
[Modified by: Seb.26 on January 03, 2009 06:07 PM]
[Modified by: Seb.26 on January 03, 2009 06:36 PM]
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 03, 2009 11:39:22 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
If that can help, here is the fdisk -l result :
Disk /dev/hda: 1024 MB, 1024966656 bytes
16 heads, 63 sectors/track, 1986 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 167 84136+ 6 FAT16
/dev/hda2 168 428 131544 83 Linux
Disk /dev/sda: 1031 MB, 1031798272 bytes
64 heads, 32 sectors/track, 983 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sda4 * 1 983 1006576 b W95 FAT32
... thanks for any idea ... ;-)
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 04, 2009 6:22:46 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
Hi world ...
Great news : my kernel is working ... bad news : I don't know if framebuffer is OK !
Borring with that strange problem, I've just take previous kernel sources (2.6.24.7) and build them with same .config, and all is OK at the first time ...
And since I probably won't need new features like ext4 & co ... it's enought for the moment ...
So that's cool !
But now, I'm back with my first problem : using framebuffer !!!
my .config include vesa drivers, the fb console is activated, but I cannot see Tux on boot ( I think this is the first think visible when framebuffer is corectly set )
In my syslinux:cfg, I've add "vga=ask", but this only offer me some 80x25 / 80x50 ...etc... setup, no one looks like graphic : 800x600 @ 24bpp ...
Any idea ???
Thanks
|
Seb.26
Joined Dec 30, 2008 Posts: 11
Other Topics
|
Posted:
Jan 04, 2009 7:15:56 PM
Subject: [Resolved] [Help on starting] About FrameBuffer
It's a good day !
It's OK, the problem was in the .config provided by ICOP ... the wrong driver was selected ... after install the right one, all is OK ...
Tux is on my screen !!!
BIG thanks again tophandcwby for your help and your time !
Regards,
Sebastien.
|