zoukankan      html  css  js  c++  java
  • I.MX6 天嵌 E9 U-boot menu hacking

    /************************************************************************************
     *                      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",                |
        "
    "                                                                  |
        "	display 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("
    #####     Boot for IMX6 Main Menu    #####
    ");
            printf("[1]boot from emmc
    ");
            printf("[2]boot from sdcard
    ");
            printf("[3]boot from tftp
    ");
            printf("[5]download from sdcard
    ");
            printf("[0]setting boot args
    ");
            printf("[q]exit to command mode
    ");
            printf("Enter your selection: ");
            keyselect = getc();
            printf("%c
    ", 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("
    ##### param setting #####
    ");
            printf("[1]setting nfs args
    ");
            printf("[2]setting tftp args
    ");
            printf("[3]setting display args
    ");
            printf("[4]setting default boot
    ");
            printf("[s]save setting
    ");
            printf("[q]quit
    ");
            printf("Enter your selection: ");
            c = getc();
            printf("%c
    ", 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
    ", 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("
    ##### display select for android #####
    ");
                    printf("[1] 800*600 for LVDS->VGA 
    ");
                    printf("[2] 1024*768 for FPC->VGA 
    ");    // 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
    ");    //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
    ");    //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
    ");    //video=mxcfb1:dev=lcd,if=RGB24,TQ
                    printf("[6] 1366*768 for LVDS->VGA 
    ");
                    printf("[7] 1920*1080 for LVDS (need 2 lvds ports) 
    ");
                    printf("[q] quit 
    ");
                    printf("Enter your selection: ");
                    c = getc();
                    printf("%c
    ", 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
    ");
                }
            }
            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;
            }
        }
    }
  • 相关阅读:
    Node.js安装及环境配置(windows)
    table
    检测浏览器
    ickeck插件
    全国三级联动
    css3-calc用法
    jQuery Portamento 滑动定位
    canvas版《俄罗斯方块》
    canvas入门级小游戏《开关灯》思路讲解
    css3 matrix 2D矩阵和canvas transform 2D矩阵
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/5741439.html
Copyright © 2011-2022 走看看