博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
I.MX6 天嵌 E9 U-boot menu hacking
阅读量:6631 次
发布时间:2019-06-25

本文共 11483 字,大约阅读时间需要 38 分钟。

/************************************************************************************ *                      I.MX6 天嵌 E9 U-boot menu hacking * 说明: *     天嵌在U-boot中添加了自己的选择menu,想看一下怎么实现的。 * *                                                  2016-8-5 深圳 南山平山村 曽剑锋 ***********************************************************************************/void start_armboot (void){    ......    /* main_loop() can return to retry autoboot, if so just run it again. */    e9_board_lcd_poweron(0);    for (;;) {        main_loop ();         ---------------------------------------------+    }                                                                      |                                                                           |    /* NOTREACHED - no way out of command loop except booting */           |}                                                                          |                                                                           |void main_loop (void)           <------------------------------------------+{    ......    /*     * Main Loop for Monitor Command Processing     */#ifdef CONFIG_CMD_MENU    run_command("menu", 0);                   ----------+#endif                                                  |    ......                                              |}                                                       |                                                        |U_BOOT_CMD(                                             |    menu,   3,  0,  do_menu,                  <---------+-----------------+    "display a menu, to select the items to do something",                |    "\n"                                                                  |    "\tdisplay a menu, to select the items to do something"               |);                                                                        |                                                                          |int do_menu (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])    <-----+{                                          ---------+    menu_shell();                                   |    return 0;                                       |}                                                   |                                                    |void menu_shell(void)                      <--------+{    char keyselect;    char cmd_buf[512];    char *ptmp;    do    {        printf("\r\n#####     Boot for IMX6 Main Menu    #####\r\n");        printf("[1]boot from emmc\n");        printf("[2]boot from sdcard\n");        printf("[3]boot from tftp\n");        printf("[5]download from sdcard\n");        printf("[0]setting boot args\n");        printf("[q]exit to command mode\n");        printf("Enter your selection: ");        keyselect = getc();        printf("%c\n", keyselect);        switch (keyselect)        {#if 0            case '1':                if(refresh_bootargs("emmc")==0)                    run_command("booti mmc3",0);            break;            case '2':                if(refresh_bootargs("sdcard")==0)                    run_command("booti mmc1",0);            break;            case '3':                if(refresh_bootargs("tftp_nfs")==0)                {                    ptmp = getenv("kernelimgname");                    sprintf(cmd_buf,"tftp 0x10800000 %s;bootm 0x10800000",ptmp);                    run_command(cmd_buf,0);                }            break;            case '0':                do_boot_para_setting(NULL);            break;            case '5':                sprintf(cmd_buf,"booti mmc1 recovery",ptmp);                run_command(cmd_buf,0);            break;#endif            case '1':            ptmp = getenv("bootcmd");            if(strcmp(ptmp,"run bootcmd_mmc_ubuntu") == 0)                run_command("run bootcmd_mmc_ubuntu", 0);            else if (strcmp(ptmp,"run bootcmd_mmc_android") == 0)                run_command("run bootcmd_mmc_android", 0);            else                run_command("run bootcmd_mmc_linux", 0);            break;            case '2':            break;            case '3':                run_command("run bootcmd_net", 0);            break;            case '0':                do_boot_para_setting(NULL);           -------------+            break;                                                 |            case '5':                                              |                sprintf(cmd_buf,"run bootargs_base_andorid;        |                        booti mmc1 recovery",ptmp);                |                run_command(cmd_buf,0);                            |            break;                                                 |                                                                   |        }                                                          |                                                                   |    }                                                              |    while ((keyselect != 'q') && (keyselect != 'Q'));              |}                                                                  |                                                                   |static int do_boot_para_setting(char *pbuf)           <------------+{    int i;    char c;    do    {        printf("\r\n##### param setting #####\r\n");        printf("[1]setting nfs args\n");        printf("[2]setting tftp args\n");        printf("[3]setting display args\n");        printf("[4]setting default boot\n");        printf("[s]save setting\n");        printf("[q]quit\n");        printf("Enter your selection: ");        c = getc();        printf("%c\n", c);        switch (c)        {        case '1':            do_nfs_para_setting(NULL);            break;        case '2':            do_tftp_para_setting(NULL);            break;        case '3':            do_disp_para_setting(NULL);         -------------+            break;                                           |        case '4':                                            |            do_media_para_setting(NULL);                     |            break;                                           |        case 's':                                            |            run_command("saveenv", 0);                       |            break;                                           |        }                                                    |    }                                                        |    while (c != 'q');                                        |}                                                            |                                                             |static int do_disp_para_setting(char *pbuf)     <------------+{    lcd_menu_shell();            -----------+    return 0;                               |}                                           |                                            |void lcd_menu_shell()            <----------+{    char c;    char cmd_buf[256];    char cmd_buf_all[256];    int need_renew = 0;    while (1)    {        lcd_menu_usage();        c = getc();        printf("%c\n", c);        if ((c == '1'))        {            sprintf(cmd_buf, " video=mxcfb0:");            if (lcd_setting(&cmd_buf[strlen(cmd_buf)]) != 0)            {                strcat(cmd_buf, " video=mxcfb1:off video=mxcfb2:off fbmem=48M");                sprintf(cmd_buf_all, "setenv displayArgs %s", cmd_buf);                run_command(cmd_buf_all, 0);            }        }        else if (c == '2')        {            for (;;)            {                printf("\r\n##### display select for android #####\r\n");                printf("[1] 800*600 for LVDS->VGA \r\n");                printf("[2] 1024*768 for FPC->VGA \r\n");    // video=mxcfb0:dev=lcd,if=RGB24,TQ-VGA_1024768,bpp=32 video=mxcfb1:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M                printf("[3] 1280*768 for FPC->VGA\r\n");    //video=mxcfb1:dev=lcd,if=RGB24,TQ-VGA_1280768,bpp=32 video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB2em4,bpp=32 video=mxcfb2:off fbmem=28M,48M                printf("[4] 1360*768 for FPC->VGA\r\n");    //video=mxcfb1:dev=lcd,if=RGB24,TQ-VGA_1360768,bpp=32 video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB2em4,bpp=32 video=mxcfb2:off fbmem=28M,48M                printf("[5] 1920*1080 for FPC->VGA\r\n");    //video=mxcfb1:dev=lcd,if=RGB24,TQ                printf("[6] 1366*768 for LVDS->VGA \r\n");                printf("[7] 1920*1080 for LVDS (need 2 lvds ports) \r\n");                printf("[q] quit \r\n");                printf("Enter your selection: ");                c = getc();                printf("%c\n", c);                if (c == '1')                {                    sprintf(cmd_buf_all, "dev=ldb,TQ-ldb_800600,if=RGB666,bpp=32 ldb=dul0");                    sprintf(cmd_buf_all, "setenv displayArgs %s", cmd_buf);                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == '2')                {                    sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb0:dev=lcd,if=RGB24,TQ-VGA_1024768,bpp=32 video=mxcfb1:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M");                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == '3')                {                    sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb1:dev=lcd,if=RGB24,TQ-VGA_1280768,bpp=32 video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M");                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == '4')                {                    sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb1:dev=lcd,if=RGB24,TQ-VGA_1360768,bpp=32 video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M");                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == '5')                {                    sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb1:dev=lcd,if=RGB24,TQ-VGA_19201080,bpp=32 video=mxcfb0:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M");                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == '6')                {                    sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb0:dev=ldb,LDB-XGA,if=RGB666,bpp=32 ldb=dul0 video=mxcfb1:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M");                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == '7')                {                    sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb0:dev=ldb,LDB-1080P60,if=RGB24,bpp=32 ldb=spl0 video=mxcfb1:dev=hdmi,1280x720M@60,if=RGB24,bpp=32 video=mxcfb2:off fbmem=28M,48M");                    run_command(cmd_buf_all, 0);                    break;                }                else if (c == 'q')                {                    break;                }                printf("ill param\n");            }        }        else if(c == '3')        {
//video=mxcfb0:dev=ldb,TQ-ldb_1024768,if=RGB666 ldb=sep1 sprintf(cmd_buf_all, "setenv displayArgs video=mxcfb0:dev=ldb,TQ-ldb_1024768,if=RGB666 ldb=sep1"); run_command(cmd_buf_all, 0); } else if(c == 's') { run_command("saveenv", 0); } else if (c == 'q') { break; } }}

 

转载地址:http://qhzvo.baihongyu.com/

你可能感兴趣的文章
团队冲刺第二天
查看>>
sed删除空行和开头的空格和tab键
查看>>
php扩展安装
查看>>
15个重要的Android代码
查看>>
(转)android 牛人必修 ant 编译android工程
查看>>
求最大公约数与最小公倍数
查看>>
C# Winform 跨线程更新UI控件常用方法总结(转)
查看>>
eclipse菜单栏不显示 + the system is running in lou-graphics mode问题
查看>>
【WebService】使用jaxb完成对象和xml的转换
查看>>
如何去除My97 DatePicker控件上右键弹出官网的链接 - 如何debug混淆过的代码
查看>>
输入5个学生的信息(包括学号,姓名,英语成绩,计算机语言成绩和数据库成绩), 统计各学生的总分,然后将学生信息和统计结果存入test.txt文件中...
查看>>
BZOJ2337 [HNOI2011]XOR和路径
查看>>
C# 该行已经属于另一个表 ...
查看>>
android 避免线程的重复创建(HandlerThread、线程池)
查看>>
SQL Lazy Spool Eager Spool
查看>>
type的解释
查看>>
从自动驾驶到学习机器学习:解读2017科技发展的15大趋势
查看>>
在Linux中永久并安全删除文件和目录的方法
查看>>
全民直播时代 内容监管还得靠技术
查看>>
c++ 类的对象与指针
查看>>