skyeye下成功运行lcd程序

别来无恙 提交于 2020-01-06 00:52:01

呵呵,往往在经过很复杂的过程之后,回头却发现原来确实如此的简单,为了直观的看到skyeye的仿真效果(呵呵,主要

还是经济原因啊,开发板买不起啊),于是就心血来潮的想要作s3c2410的lcd实验,说起来容易,首先是一直linux内核,

现在的linux内核中已经支持了s3c2410的板子,所以只要作少量的修改即可,然后编写lcd_show.c,最后编译该程序,加

在到linux中,skyeye仿真,但是实际的过程确实相当的困难啊

最初的尝试就是按照上面的思路来的,在网上找了许多的资料

http://www.linuxfans.org/bbs/thread-182101-1-1.html linux内核在skyeye上移植

http://www.linuxfans.org/bbs/thread-182082-1-1.html skyeye上lcd移植

http://www.diybl.com/course/6_system/linux/Linuxjs/200896/139481.html linux上lcd去的驱动

第一次配置内核

make menuconfig

make

最终得到的vmlinux竟然5M还多,于是打算放弃,重新编译linux内核,在第二次编译内核时,删减了大量的无用的driver,

make时,出现一大堆错误,无奈,又经过了几次的尝试还是没有成功,于是放弃了自己现在编译内核的做法,打算使用

skyeye-testuites中的编译好的内核,最终终于找到了一个包含了lcd驱动的linux内核,下载之,编写lcd_show.c

#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <sys/mman.h>

#define RED_COLOR332    0xE0
#define GREEN_COLOR332  0x1C
#define BLUE_COLOR332   0x03

#define RED_COLOR565    0x0F100
#define GREEN_COLOR565  0x007E0
#define BLUE_COLOR565   0x0001F


int main(int argc, char **argv)
{
    int fbfd = 0;
    struct fb_var_screeninfo vinfo;
    struct fb_fix_screeninfo finfo;
    long int screensize = 0;
    short *fbp565 = 0;
    char *fbp332 = 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) {
        printf("Error: cannot open framebuffer device.\n");
        exit(1);
    }
    printf("The framebuffer device was opened successfully.\n");

    // get fixed screen information
    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) {
        printf("Error reading fixed information.\n");
        exit(2);
    }

    // get variable screen information
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
        printf("Error reading variable information.\n");
        exit(3);
    }

    // figure out the size of the screen in bytes
    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;

    printf("%dx%d, %dbpp, screensize = %d\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel, screensize );

    // map the device to memory
    fbp332 = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED,
                       fbfd, 0);
    fbp565 = (short*)fbp332;

    if ((int)fbp332 == -1) {
        printf("Error: failed to map framebuffer device to memory.\n");
        exit(4);
    }
    printf("The framebuffer device was mapped to memory successfully.\n");

    x = 100; y = 100;       // Where we are going to put the pixel

    if(vinfo.bits_per_pixel == 16)  // 8bpp only
    {
        // 8bpp framebuffer test
        printf("16 bpp framebuffer test\n");
        printf("a byte in fbp is a pixel of LCD, just set the value of fbp to put color to LCD\n");
        printf("byte format:\n");
        printf("  bit:| 7  6  5 |  4  3  2 | 1  0 |\n");
        printf("      |  red    |   green  | blue |\n");

        // red Screen
        printf("Red Screen\n");
        for(y = 0; y < vinfo.yres/3;  y++)
        {
            for(x = 0; x < vinfo.xres ; x++)
            {
                *(fbp565 + y * vinfo.xres + x) = 0;
            }
        }

        // green Screen
        printf("Green Screen\n");
        for(y = vinfo.yres/3; y < (vinfo.yres*2)/3; y++)
        {
            for(x = 0; x < vinfo.xres/2 - 59; x++)
            {
                *(fbp565 + y * vinfo.xres + x) =GREEN_COLOR565/2;
            }
        }

        // blue Screen
        printf("Blue Screen\n");
        for(y = (vinfo.yres*2)/3; y < vinfo.yres; y++)
        {
            for(x = 0; x < vinfo.xres; x++)
            {
                *(fbp565 + y * vinfo.xres + x) = BLUE_COLOR565;
            }
        }
    }
    else if(vinfo.bits_per_pixel == 8)
    {
        // 8bpp framebuffer test
        printf("8bpp framebuffer test\n");
        printf("a byte in fbp is a pixel of LCD, just set the value of fbp to put color to LCD\n");
        printf("byte format:\n");
        printf("  bit:| 7  6  5 |  4  3  2 | 1  0 |\n");
        printf("      |  red    |   green  | blue |\n");

        // red Screen
        printf("Red Screen\n");
        for(y = 0; y < vinfo.yres/3;  y++)
        {
            for(x = 0; x < vinfo.xres/2-100; x++)
            {
                *(fbp332 + y * vinfo.xres + x) = RED_COLOR332;
            }
        }

        // green Screen
        printf("Green Screen\n");
        for(y = vinfo.yres/3; y < (vinfo.yres*2)/3; y++)
        {
            for(x = 0; x < vinfo.xres/2-50; x++)
            {
                *(fbp332 + y * vinfo.xres + x) = GREEN_COLOR332;
            }
        }

        // blue Screen
        printf("Blue Screen\n");
        for(y = (vinfo.yres*2)/3; y < vinfo.yres; y++)
        {
            for(x = 0; x < vinfo.xres-10; x++)
            {
                *(fbp332 + y * vinfo.xres + x) = BLUE_COLOR332;
            }
        }
    }
    else
        printf("8/16 bits only!\n");

    munmap(fbp332, screensize);
    close(fbfd);
    return 0;
}

arm-linux-gcc -static -o lcd_show lcd_show.c

sudo mount -o loop initrd.img XXX (XXX -- your mount directory)

sudo cp lcd_show XXX/bin/

sudo umount XXX

skyeye -e vmlinux

xuqiang@ubuntu:~/Embedded/s3c2410x-2.6.14$ skyeye -e vmlinux
big_endian is false.
arch: arm
cpu info: armv4, arm920t, 41009200, ff00fff0, 2
mach info: name s3c2410x, mach_init addr 0x805f030
ethmod num=1, mac addr=0:4:3:2:1:f, hostip=10.0.0.1
failed to setup_module (name:net, type:cs8900a)
tapif_init: icotl TUNSETIFF errorlcd_mod:1
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm920t mmu ops
Loaded RAM   ./initrd.img
start addr is set to 0xc0008000 by exec file.
Linux version 2.6.14 (root@lee) (gcc version 3.4.6) #48 Sat Feb 10 06:29:17 CST 2007
CPU: ARM920Tid(wb) [41009200] revision 0 (ARMvundefined/unknown)
Machine: SMDK2410
Warning: bad configuration page, trying to continue
Memory policy: ECC disabled, Data cache writeback
CPU S3C2410 (id 0x32410000)
S3C2410: core 62.400 MHz, memory 62.400 MHz, peripheral 62.400 MHz
S3C2410 Clocks, (c) 2004 Simtec Electronics
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on
CPU0: D VIVT write-back cache
CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets
Built 1 zonelists
Kernel command line: mem=32M console=ttySAC0 root=/dev/ram initrd=0xc0800000,0x00800000 ramdisk_size=2048 rw
PID hash table entries: 256 (order: 8, 4096 bytes)
timer tcon=00000000, tcnt cb1f, tcfg 00000200,00000000, usec 0000189e
Console: colour dummy device 80x30
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Memory: 32MB = 32MB total
Memory: 22168KB available (1510K code, 373K data, 100K init)
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
checking if image is initramfs...it isn't (bad gzip magic numbers); looks like an initrd
softlockup thread 0 started up.
Freeing initrd memory: 8192K
NET: Registered protocol family 16
S3C2410: Initialising architecture
S3C2410 DMA Driver, (c) 2003-2004 Simtec Electronics
DMA channel 0 at c2800000, irq 33
DMA channel 1 at c2800040, irq 34
DMA channel 2 at c2800080, irq 35
DMA channel 3 at c28000c0, irq 36
NetWinder Floating Point Emulator V0.97 (double precision)
ERROR: s3c2410x_io_write_word(0x4d000060) = 0x00000000
ERROR: s3c2410x_io_write_word(0x4d000050) = 0x00000000
[GTK_LCD]: Can't find LCD DMA from address 0x0
ERROR: s3c2410x_io_write_word(0x4d000060) = 0x00000000
ERROR: s3c2410x_io_write_word(0x4d000050) = 0x00000000
Console: switching to colour frame buffer device 40x29
fb0: s3c2410fb frame buffer device
S3C2410 RTC, (c) 2004 Simtec Electronics
Software Watchdog Timer: 0.07 initialized. soft_noboot=0 soft_margin=60 sec (nowayout= 0)
ttySAC0 at MMIO 0x50000000 (irq = 70) is a S3C2410
ttySAC1 at MMIO 0x50004000 (irq = 73) is a S3C2410
ttySAC2 at MMIO 0x50008000 (irq = 76) is a S3C2410
io scheduler noop registered
io scheduler deadline registered
RAMDISK driver initialized: 16 RAM disks of 2048K size 1024 blocksize
cs89x0:cs89x0_probe(0x0)
ERROR: s3c2410x_io_write_word(0x1900030a) = 0x00000000
cs89x0: no cs8900 or cs8920 detected.  Be sure to disable PnP with SETUP
mice: PS/2 mouse device common for all mice
NET: Registered protocol family 2
IP route cache hash table entries: 512 (order: -1, 2048 bytes)
TCP established hash table entries: 2048 (order: 1, 8192 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
RAMDISK: ext2 filesystem found at block 0
RAMDISK: Loading 2048KiB [1 disk] into ram disk... done.
VFS: Mounted root (ext2 filesystem).
Freeing init memory: 100K
init started:  BusyBox v1.4.1 (2007-02-10 01:19:06 CST) multi-call binary
Starting pid 19, console /dev/console: '/etc/init.d/rcS'
ifconfig: SIOCSIFADDR: No such device
Welcome to
     _      _____      __   __    _      _
    / \    /  __ \    /  \_/  \  | |    |_|                
   / _ \   | |  | |  / /\   /\ \ | |     _ ____  _   _  _  _
  / /_\ \  | |__| | / /  \_/  \ \| |    | |  _ \| | | |\ \/ /
 / /___\ \ | |__\ \ | |       | || |___ | | |_| | |_| |/    \
/_/    \_\| |   \_\|_|       |_||_____||_|_| |_|\____|\_/\_/
      
ARMLinux for Skyeye
For further information please check:
http://www.skyeye.org/



BusyBox v1.4.1 (2007-02-10 01:19:06 CST) Built-in shell (ash)
Enter 'help' for a list of built-in commands.

/bin/ash: can't access tty; job control turned off
/ $ cd bin

/bin $ ./lcd_show
The framebuffer device was opened successfully.
240x320, 16bpp, screensize = 153600
The framebuffer device was mapped to memory successfully.
16 bpp framebuffer test
a byte in fbp is a pixel of LCD, just set the value of fbp to put color to LCD
byte format:
  bit:| 7  6  5 |  4  3  2 | 1  0 |
      |  red    |   green  | blue |
Red Screen
Green Screen
Blue Screen

 上面的整个工程可以在下面下载:

http://hi.csdn.net/link.php?url=http://xuqianghit.download.csdn.net

还有就是注意在编译lcd_show.c时,如果没有使用-static的话,即便在mount之后,拷贝到/bin下,skyeye模拟是存在

该文件,但是无法运行的,一般出现的错误是XXX : not found

最后就是需要说明的是最后使用ctrl + c来结束仿真。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!