嵌入式爱好者

查看: 7781|回复: 4

[技术分享] 给Uboot添加一个设置LCD尺寸的命令setlcd

[复制链接]

1

主题

1

帖子

9

积分

扫一扫,手机访问本帖
发表于 2011-8-23 11:12:17 | 显示全部楼层 |阅读模式
本帖最后由 飞凌-chaosk 于 2011-9-22 11:17 编辑

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

Step 2:   Add the following code:

  1. int
  2. do_setlcd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  3. {   
  4.         int i = 0;
  5.         char *pch = NULL;
  6.         char bootargstr[300];

  7.         bool isValidArg = true;
  8.         if((strcmp(argv[1],"35") != 0) &&
  9.                 (strcmp(argv[1],"43") != 0) &&
  10.                 (strcmp(argv[1],"56") != 0) &&
  11.                 (strcmp(argv[1],"70") != 0) &&
  12.                 (strcmp(argv[1],"VGA800") != 0) &&
  13.                 (strcmp(argv[1],"VGA1024") != 0) )
  14.         {
  15.                 isValidArg = false;
  16.         }

  17.         if (!isValidArg)
  18.         {
  19.                 printf("*** Invalid command %s \n", argv[1]);
  20.                 printf("Valid command must be one of the following: \n");
  21.                 printf("setlcd 35\n");
  22.                 printf("setlcd 43\n");
  23.                 printf("setlcd 56\n");
  24.                 printf("setlcd 70\n");
  25.                 printf("setlcd VGA800\n");
  26.                 printf("setlcd VGA1024\n");
  27.                 return -1;
  28.         }

  29.        
  30.         strcpy(bootargstr, getenv("bootargs"));

  31.         /* remove previous setting */
  32.         pch = strstr (bootargstr," lcdsize");
  33.         if(pch != NULL)
  34.         {
  35.                 for(i = pch-bootargstr; i<300; i++)
  36.                 {
  37.                         bootargstr[i] = '\0';
  38.                 }
  39.         }

  40.         strcat(bootargstr, " lcdsize=");
  41.         strcat(bootargstr, argv[1]);

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

  45.         return 0;
  46. }

  47. U_BOOT_CMD(
  48.         setlcd,        2,                1,        do_setlcd,
  49.         "setlcd  - set lcd size\n",
  50.         "command: \n"
  51.         "setlcd 35          -- set LCD as 3.5 inches screen 320x240\n"
  52.         "setlcd 43          -- set LCD as 4.3 inches screen 480x272\n"
  53.         "setlcd 56          -- set LCD 5.6 inches screen 640x480\n"
  54.         "setlcd 70          -- set LCD 7.0 inches screen 800x480\n"
  55.         "setlcd VGA800      -- set LCD 8.0 inches screen 800x600\n"
  56.         "setlcd VGA1024     -- set LCD screen with size 1024x768\n"       
  57. );
复制代码
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 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

1

主题

1

帖子

9

积分

 楼主| 发表于 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 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-5-19 23:15

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表