飞凌-chaosk 发表于 2011-8-23 11:12:17

给Uboot添加一个设置LCD尺寸的命令setlcd

本帖最后由 飞凌-chaosk 于 2011-9-22 11:17 编辑

Step 1: Open uboot source code file /common/command.c

Step 2:   Add the following code:
int
do_setlcd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{   
        int i = 0;
        char *pch = NULL;
        char bootargstr;

        bool isValidArg = true;
        if((strcmp(argv,"35") != 0) &&
                (strcmp(argv,"43") != 0) &&
                (strcmp(argv,"56") != 0) &&
                (strcmp(argv,"70") != 0) &&
                (strcmp(argv,"VGA800") != 0) &&
                (strcmp(argv,"VGA1024") != 0) )
        {
                isValidArg = false;
        }

        if (!isValidArg)
        {
                printf("*** Invalid command %s \n", argv);
                printf("Valid command must be one of the following: \n");
                printf("setlcd 35\n");
                printf("setlcd 43\n");
                printf("setlcd 56\n");
                printf("setlcd 70\n");
                printf("setlcd VGA800\n");
                printf("setlcd VGA1024\n");
                return -1;
        }

       
        strcpy(bootargstr, getenv("bootargs"));

        /* remove previous setting */
        pch = strstr (bootargstr," lcdsize");
        if(pch != NULL)
        {
                for(i = pch-bootargstr; i<300; i++)
                {
                        bootargstr = '\0';
                }
        }

        strcat(bootargstr, " lcdsize=");
        strcat(bootargstr, argv);

        setenv("bootargs", bootargstr);
        printf("set string:%s\n", bootargstr);
        saveenv();

        return 0;
}

U_BOOT_CMD(
        setlcd,        2,                1,        do_setlcd,
        "setlcd- set lcd size\n",
        "command: \n"
        "setlcd 35          -- set LCD as 3.5 inches screen 320x240\n"
        "setlcd 43          -- set LCD as 4.3 inches screen 480x272\n"
        "setlcd 56          -- set LCD 5.6 inches screen 640x480\n"
        "setlcd 70          -- set LCD 7.0 inches screen 800x480\n"
        "setlcd VGA800      -- set LCD 8.0 inches screen 800x600\n"
        "setlcd VGA1024   -- set LCD screen with size 1024x768\n"       
);
Step 3: Compile Uboot sourcecode to create uboot.bin

Step 4: Reburn your system with the new uboot.bin

Step 5: Restart the board, and press SPACE to enter uboot menu.

Step 6: Then you can set the lcd size with only one single command: setlcd XX

SMDK6410 # help setlcd
setlcd command:
setlcd 35          -- set LCD as 3.5 inches screen 320x240
setlcd 43          -- set LCD as 4.3 inches screen 480x272
setlcd 56          -- set LCD 5.6 inches screen 640x480
setlcd 70          -- set LCD 7.0 inches screen 800x480
setlcd VGA800      -- set LCD 8.0 inches screen 800x600
setlcd VGA1024   -- set LCD screen with size 1024x768

SMDK6410 # setlcd VGA800
set string:root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc nconsole=tty1 console=ttySAC0,115200 lcdsize=VGA800
Erasing Nand...Writing to Nand... done
:handshake

mycent 发表于 2011-9-17 20:25:10

飞凌-chaosk 发表于 2011-9-22 09:50:45

Thank mycent for pointing out the bug! I just have it updated.

mycent 发表于 2011-9-22 17:44:29

jxheliang001 发表于 2012-6-1 19:50:08

页: [1]
查看完整版本: 给Uboot添加一个设置LCD尺寸的命令setlcd