zoukankan      html  css  js  c++  java
  • S905系列的uboot分析

    Ubuntu18.04通过PL2303HX连接TTL

    接线的连接

    PL2303的3.3V悬空, TX接盒子RX, RX接盒子TX, GND接盒子GND

    终端选择

    系统自带pl2303的驱动, 可以通过dmesg看到对应的设备, 例如 /dev/ttyUSB0,

    留意一下设备的用户组, 例如我这个是dialout, 需要把自己这个用户加入这个用户组, 然后通过id检查是否生效, 不生效的话试试退出, 或者重启

    sudo usermod -a -G dialout milton
    

    连接TTL可以直接通过screen 命令, 例如下面的命令, 如果已经添加过dialout用户组, 就不需要sudo, 后面的115200是波特率, 要退出要使用组合键Ctrl + A, K 会提示是否退出

    screen /dev/ttyUSB0 115200
    

    但是screen命令在默认的terminal里面布局是乱的, 换成putty后就好了(如果同时开着screen和putty, 也是乱的), 但是putty无法粘贴复制. 最后换成了GtkTerm

    进入UBOOT

    R3300L的uboot是通过空格键<space>进入, 别的键不起作用, Ctrl+C也不起作用 

    如果以上键都不起作用, fw_printenv检查 bootdelay 的值, 如果为0, 需要改成大于0的值, 例如3

    fw_setenv bootdelay 3
    

     

    Win7连接TTL

    Win7下PL2302会自动安装驱动, 连接软件用putty, securecrt, xshell都可以, 如果用putty出现蓝屏的话, 可以换成其他的软件.

    基础信息

    启动日志输出

    GXBB:BL1:08dafd:0a8993;FEAT:EDFC318C;POC:3;RCY:0;EMMC:0;READ:0;CHK:0;
    TE: 270602
    no sdio debug board detected 
     
    BL2 Built : 13:55:05, Jan 28 2016. 
    gxb g3625dd5 - xiaobo.gu@droid05
     
    Board ID = 1
    set vcck to 1100 mv
    set vddee to 1000 mv
    CPU clk: 1536MHz
    DDR channel setting: DDR0 Rank0+1 diff
    DDR0: 1024MB(auto) @ 912MHz(2T)-13
    DDR1: 1024MB(auto) @ 912MHz(2T)-13
    DataBus test pass!
    AddrBus test pass!
    Load fip header from eMMC, src: 0x0000c000, des: 0x01400000, size: 0x00004000
    New fip structure!
    Load bl30 from eMMC, src: 0x00010000, des: 0x01000000, size: 0x0000a9b0
    Sending bl30...........................................OK. 
    Run bl30...
    Load bl301 from eMMC, src: 0x0001c000, des: 0x01000000, size: 0x00001c20
    Wait bl30...Done
    Sending bl301........OK. 
    Run bl301...
    Load bl31 from eMMC, src: 0x00020000, des: 0x10100000, size: 0x00012130
     
     
    --- UART initialized after reboot ---
    [Reset cause: unknown]
    [Image: unknown, amlogic_v1.1.3054-53e549c 2016-03-31 20:40:25 xing.xu@droid05]
    bl30: check_permit, count is 1
    bl30: check_permit: ok!
    chipid: ef be ad de d f0 aLoad bl33 from eMMC, src: 0x00034000, des: 0x01000000, size: 0x0009fd60
    d ba ef be ad de not ES chip
    efuse init ops = 13
    efuse init hdcp = c, cf9=7
    [0.401121 Inits done]
    secure task start!
    high task start!
    low task start!
    NOTICE:  BL3-1: v1.0(debug):4c66217
    NOTICE:  BL3-1: Built : 17:13:36, Jan 28 2016
    INFO:    BL3-1: Initializing runtime services
    WARNING: No OPTEE provided by BL2 boot loader
    ERROR:   Error initializing runtime service opteed_fast
    INFO:    BL3-1: Preparing for EL3 exit to normal world
    INFO:    BL3-1: Next image address = 0x1000000
    INFO:    BL3-1: Next image spsr = 0x3c9
     
     
    U-Boot 2015.01-ga9e9562-dirty (May 26 2016 - 20:33:11)
     
    DRAM:  2 GiB
    Relocation Offset is: 76ed3000
    register usb cfg[0][1] = 0000000077f62120
    register usb cfg[0][2] = 0000000077f62140
    register usb cfg[2][0] = 0000000077f62160
    vpu detect type: 5
    vpu clk_level = 7
    set vpu clk: 666667000Hz, readback: 666660000Hz(0x300)
    boot_device_flag : 1
    Nand PHY Ver:1.01.001.0006 (c) 2013 Amlogic Inc.
    init bus_cycle=6, bus_timing=8, system=5.0ns
    reset failed
    get_chip_type and ret:fffffffe
    get_chip_type and ret:fffffffe
    chip detect failed and ret:fffffffe
    nandphy_init failed and ret=0xfffffff1
    MMC:   aml_priv->desc_buf = 0x0000000073ec3770
    aml_priv->desc_buf = 0x0000000073ec5900
    SDIO Port B: 0, SDIO Port C: 1
    emmc/sd response timeout, cmd8, status=0x3ff2800
    emmc/sd response timeout, cmd55, status=0x3ff2800
    [mmc_init] mmc init success
    mmc read lba=0x14000, blocks=0x400
          Amlogic multi-dtb tool
          Single dtb detected
    start dts,buffer=0000000073ec7ff0,dt_addr=0000000073ec7ff0
    parts: 11
    00:      logo	0000000002000000 1
    01:  recovery	0000000002000000 1
    02:       rsv	0000000000800000 1
    03:       tee	0000000000800000 1
    04:     crypt	0000000002000000 1
    05:      misc	0000000002000000 1
    06: instaboot	0000000020000000 1
    07:      boot	0000000002000000 1
    08:    system	0000000040000000 1
    09:     cache	0000000020000000 2
    10:      data	ffffffffffffffff 4
    get_dtb_struct: Get emmc dtb OK!
    overide_emmc_partition_table: overide cache 
    [mmc_get_partition_table] skip partition cache.
    Partition table get from SPL is : 
            name                        offset              size              flag
    ===================================================================================
       0: bootloader                         0            400000                  0
       1: reserved                     2400000           4000000                  0
       2: cache                        6c00000          20000000                  2
       3: env                         27400000            800000                  0
       4: logo                        28400000           2000000                  1
       5: recovery                    2ac00000           2000000                  1
       6: rsv                         2d400000            800000                  1
       7: tee                         2e400000            800000                  1
       8: crypt                       2f400000           2000000                  1
       9: misc                        31c00000           2000000                  1
      10: instaboot                   34400000          20000000                  1
      11: boot                        54c00000           2000000                  1
      12: system                      57400000          40000000                  1
      13: data                        97c00000         136500000                  4
    mmc read lba=0x12000, blocks=0x2
    mmc read lba=0x12002, blocks=0x2
    mmc_read_partition_tbl: mmc read partition OK!
    eMMC/TSD partition table have been checked OK!
    mmc env offset: 0x27400000 
    In:    serial
    Out:   serial
    Err:   serial
    [store]To run cmd[emmc dtb_read 0x1000000 0x40000]
    read emmc dtb
          Amlogic multi-dtb tool
          Single dtb detected
    Net:   Meson_Ethernet
    wipe_data=successful
    wipe_cache=successful
    upgrade_step=2
    reboot_mode=cold_boot
    hpd_state=0
    [CANVAS]addr=0x3f800000 width=3840, height=2160
     
    Not find '576cvbs' mapped VIC
    amlkey_init() enter!
    [EFUSE_MSG]keynum is 4
    [KM]Error:f[key_manage_query_size]L504:key[usid] not programed yet
    [KM]Error:f[key_manage_query_size]L504:key[deviceid] not programed yet
    gpio: pin GPIOAO_3 (gpio 122) value is 1
    saradc - saradc sub-system
     
    Usage:
    saradc saradc open <channel>		- open a SARADC channel
    saradc close	- close the SARADC
    saradc getval	- get the value in current channel
    saradc get_in_range <min> <max>	- return 0 if current value in the range of current channel
     
    Enter USB burn
    Try connect time out 701, 700, 640
    Hit any key to stop autoboot:  1  0 
    Booting...
    Unknown command 'unifykey' - try 'help'
    Unknown command 'unifykey' - try 'help'
    [store]To run cmd[emmc dtb_read 0x1000000 0x40000]
    read emmc dtb
          Amlogic multi-dtb tool
          Single dtb detected
    ee_gate_off ...
    ## Booting Android Image at 0x01080000 ...
    reloc_addr =73f481c0
    copy done
          Amlogic multi-dtb tool
          Single dtb detected
    load dtb from 0x1000000 ......
       Uncompressing Kernel Image ... OK
       kernel loaded at 0x01080000, end = 0x01f00fb8
       Loading Ramdisk to 73c2c000, end 73ec1388 ... OK
       Loading Device Tree to 000000001fff4000, end 000000001ffff0ab ... OK
    signature: 
    fdt_instaboot: get header err
     
    Starting kernel ...
     
    uboot time: 2541079 us
    

    从上面的输出中可以得到uboot env的起始位置, 对于后面配置fw_env.config有重要的意义

    Partition table get from SPL is : 
            name                        offset              size              flag
    ===================================================================================
       0: bootloader                         0            400000                  0
       1: reserved                     2400000           4000000                  0
       2: cache                        6c00000          20000000                  2
       3: env                         27400000            800000                  0
       4: logo                        28400000           2000000                  1
       5: recovery                    2ac00000           2000000                  1
       6: rsv                         2d400000            800000                  1
       7: tee                         2e400000            800000                  1
       8: crypt                       2f400000           2000000                  1
       9: misc                        31c00000           2000000                  1
      10: instaboot                   34400000          20000000                  1
      11: boot                        54c00000           2000000                  1
      12: system                      57400000          40000000                  1
      13: data                        97c00000         136500000                  4
    

    uboot配置信息

    baudrate=115200
    bootargs=rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.mem_address=0x20000000 ramoops.mem_size=0x
    100000 ramoops.record_size=0x8000 ramoops.console_size=0x4000 androidboot.selinux=permissive logo=osd1,loaded,0x3f800000,576cvbs hdmimode=1080p60hz cvbsmode=57
    6cvbs hdmitx= androidboot.firstboot=0 mac=c4:2f:ad:XX:XX:XX
    androidboot.mac=c4:2f:ad:XX:XX:XX
    bootcmd=run storeboot
    bootdelay=1
    bootmode_check=get_rebootmode; echo reboot_mode=${reboot_mode};if test ${reboot_mode} = factory_reset; then defenv_reserv aml_dt;setenv upgrade_step 2; save;fi;
    bootup_offset=0x1080240
    bootup_size=0x3f4c8
    cmdline_keys=if keyman init 0x1234; then if keyman read usid ${loadaddr} str; then setenv bootargs ${bootargs} androidboot.serialno=${usid};fi;if keyman read mac ${loadaddr} str; then setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};fi;if keyman read deviceid ${loadaddr} str; then setenv bootargs ${bootargs} androidboot.deviceid=${deviceid};fi;fi;
    cvbsmode=576cvbs
    display_bpp=16
    display_color_bg=0
    display_color_fg=0xffff
    display_color_index=16
    display_height=576
    display_layer=osd1
    display_width=720
    dtb_mem_addr=0x1000000
    edid.crcvalue=0xe2070000
    ethact=Meson_Ethernet
    ethaddr=00:15:18:01:81:31
    factory_reset_poweroff_protect=echo wipe_data=${wipe_data}; echo wipe_cache=${wipe_cache};if test ${wipe_data} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;fi; if test ${wipe_cache} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;fi; 
    fb_addr=0x3f800000
    fb_height=1080
    fb_width=1920
    fdt_high=0x20000000
    firstboot=0
    gatewayip=10.18.9.1
    hdmimode=1080p60hz
    hostname=arm_gxbb
    identifyWaitTime=750
    init_display=hdmitx hpd;osd open;osd clear;vout output ${outputmode};imgread pic logo bootup $loadaddr;bmp display $bootup_offset;bmp scale
    initargs=rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.mem_address=0x20000000 ramoops.mem_size=0x100000 ramoops.record_size=0x8000 ramoops.console_size=0x4000 androidboot.selinux=permissive
    ipaddr=10.18.9.97
    irremote_update=if irkey 0xe31cfb04 0xb748fb04 2500000; then echo read irkey ok!; if itest ${irkey_value} == 0xe31cfb04; then run update;else if itest ${irkey_value} == 0xb748fb04; then run update;fi;fi;fi;
    loadaddr=1080000
    mac=c4:2f:ad:xx:xx:xx
    netmask=255.255.255.0
    outputmode=576cvbs
    preboot=run factory_reset_poweroff_protect;run upgrade_check;run bootmode_check;run init_display;run storeargs;run upgrade_key;run upgrade_sadckey;run switch_b
    ootmode;
    reboot_mode=cold_boot
    recovery_from_flash=if imgread kernel recovery ${loadaddr}; then wipeisb; bootm ${loadaddr}; fi recovery_from_sdcard=if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload mmc 0 ${loadaddr} recovery.img; then if fatload mmc 0
     ${dtb_mem_addr} dtb.img; then echo sd dtb.img loaded; fi;wipeisb; bootm ${loadaddr};fi;
    recovery_from_udisk=if fatload usb 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload usb 0 ${loadaddr} recovery.img; then if fatload usb 0 
    ${dtb_mem_addr} dtb.img; then echo udisk dtb.img loaded; fi;wipeisb; bootm ${loadaddr};fi;
    sdc_burning=sdc_burn ${sdcburncfg}
    sdcburncfg=aml_sdc_burn.ini
    serverip=10.18.9.113
    set=environment variables
    stderr=serial
    stdin=serial
    stdout=serial
    storeargs=setenv bootargs ${initargs} logo=${display_layer},loaded,${fb_addr},${outputmode} hdmimode=${hdmimode} cvbsmode=${cvbsmode} hdmitx=${cecconfig} andro
    idboot.firstboot=${firstboot}; run cmdline_keys;
    storeboot=echo Booting...; if unifykey get usid; then  setenv bootargs ${bootargs} androidboot.serialno=${usid};fi;if unifykey get mac; then setenv bootargs ${
    bootargs} mac=${ethaddr};fi;if imgread kernel boot ${loadaddr}; then store dtb read $dtb_mem_addr; bootm ${loadaddr}; fi;run update;
    switch_bootmode=get_rebootmode;if test ${reboot_mode} = factory_reset; then run recovery_from_flash;else if test ${reboot_mode} = update; then run update;else 
    if test ${reboot_mode} = cold_boot; then run try_auto_burn; fi;fi;fi;
    try_auto_burn=update 700 750;
    update=run usb_burning; run sdc_burning; if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;
    upgrade_check=echo upgrade_step=${upgrade_step}; if itest ${upgrade_step} == 3; then run init_display; run storeargs; run update;else if itest ${upgrade_step} 
    == 1; then defenv_reserv; setenv upgrade_step 2; saveenv;fi;fi;
    upgrade_key=if gpio input GPIOAO_3; then echo detect upgrade key; run update;fi;
    upgrade_sadckey=saradc open 0; if saradc get_in_range 0 0x50; then sleep 1; if saradc get_in_range 0 0x50; then echo update by key...; run update; fi;fi;
    upgrade_step=2
    usb_burning=update 1000
    wipe_cache=successful
    wipe_data=successful
    

      

    不同系统启动后的uboot配置

    以下信息均采集于在同一个Q7 (S905L, 8G eMMC) 上运行的系统

    EmuELEC 3.1 - Kernel 3.14.29

    fw_env.config

    EmuELEC:~ # more /etc/fw_env.config 
    # Configuration file for fw_(printenv/setenv) utility.
    # Up to two entries are valid, in this case the redundant
    # environment sector is assumed present.
    # Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash.
    # Futhermore, if the Flash sector size is ommitted, this value is assumed to
    # be the same as the Environment size, which is valid for NOR and SPI-dataflash
    
    # Amlogic NAND
    /dev/nand_env           0x000000        0x10000         0x10000
    
    # Amlogic eMMC
    /dev/env                0x000000        0x10000         0x10000
    

    fw_printenv

    EmuELEC:~ # fw_printenv
    1080i_h=1037
    1080i_w=1843
    1080i_x=38
    1080i_y=21
    1080p_h=1037
    1080p_w=1843
    1080p_x=38
    1080p_y=21
    576i_h=576
    576i_w=720
    576i_x=0
    576i_y=0
    720p_h=691
    720p_w=1229
    720p_x=25
    720p_y=14
    baudrate=115200
    boot_count=0
    bootcmd=if test ${bootfromnand} = 1; then setenv bootfromnand 0; saveenv; else run bootfromsd; run bootfromusb; fi; run storeboot
    bootcount_check=echo bootcounts=${boot_count}; if itest ${boot_count} == 0; then setenv boot_count 1;saveenv;else if itest ${boot_count} == 1; then setenv boot_count 2;saveenv;else if itest ${boot_count} == 2; then setenv boot_count 3;saveenv;else if itest ${boot_count} == 3; then setenv boot_count 4;saveenv;else if itest ${boot_count} == 4; then run recovery_from_flash;fi;fi;fi;fi;fi
    bootdelay=0
    bootfromnand=0
    bootfromsd=mmcinfo; if fatload mmc 0 ${loadaddr} kernel.img; then run sddtb; setenv bootargs ${bootargs} bootfromsd; bootm; fi
    bootfromusb=usb start 0; if fatload usb 0 ${loadaddr} kernel.img; then run usbdtb; setenv bootargs ${bootargs} bootfromusb; bootm; fi
    bootmode_check=get_rebootmode; echo reboot_mode=${reboot_mode};if test ${reboot_mode} = factory_reset; then defenv_reserv;setenv upgrade_step 2; save;fi;
    cmdline_keys=if keyman init 0x1234; then if sec_keyunify read mac ${loadaddr} str; then setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};fi;fi;
    cvbs_drv=0
    cvbsmode=576cvbs
    digitaudiooutput=HDMI&SPDIF PCM
    display_bpp=24
    display_color_bg=0
    display_color_fg=0xffff
    display_color_index=24
    display_height=1080
    display_layer=osd1
    display_width=1920
    dtb_mem_addr=0x1000000
    factory_reset_poweroff_protect=echo wipe_data=${wipe_data}; echo wipe_cache=${wipe_cache};if test ${wipe_data} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;fi; if test ${wipe_cache} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;fi; 
    fb_addr=0x3d800000
    fb_height=1080
    fb_width=1920
    fdt_high=0x20000000
    firstboot=1
    gatewayip=10.18.9.1
    hdmimode=720p50hz
    hostname=arm_gxbb
    init_display=osd open;osd clear;imgread pic logo bootup $loadaddr;bmp display $bootup_offset;bmp scale
    initargs=rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 androidboot.selinux=permissive
    ipaddr=10.18.9.97
    irremote_update=if irkey 0xf8077748 0x7d824cb3 0x728ddd22 100000; then echo read irkey ok!; if itest ${irkey_value} == 0xf8077748; then run update;else if itest ${irkey_value} == 0x7d824cb3; then run update;else if itest ${irkey_value} == 0x728ddd22; then run update;
    fi;fi;fi;fi;
    jtag=apee
    loadaddr=1080000
    netmask=255.255.255.0
    outputdefault=setenv outputmode 720p50hz;setenv 720p_w 1229;setenv 720p_h 691;setenv 720p_x 25;setenv 720p_y 14;setenv 1080i_w 1843;setenv 1080i_h 1037;setenv 1080i_x 38;setenv 1080i_y 21;setenv 1080p_w 1843;setenv 1080p_h 1037;setenv 1080p_x 38;setenv 1080p_y 21;setenv 576i_w 684;setenv 576i_h 547;setenv 576i_x 18;setenv 576i_y 14;
    outputmode=720p50hz
    preboot=run factory_reset_poweroff_protect;run upgrade_check;run bootmode_check;run init_display;run storeargs;run update_ir;run upgrade_key;run switch_bootmode;
    recovery_from_flash=setenv bootargs ${bootargs} aml_dt=${aml_dt} recovery_part={recovery_part} recovery_offset={recovery_offset};if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then wipeisb; bootm ${loadaddr}; fi
    recovery_from_sdcard=if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload mmc 0 ${loadaddr} recovery.img; then if fatload mmc 0 ${dtb_mem_addr} dtb.img; then echo sd dtb.img loaded; fi;wipeisb; bootm ${loadaddr};fi;
    recovery_from_udisk=if fatload usb 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload usb 0 ${loadaddr} recovery.img; then if fatload usb 0 ${dtb_mem_addr} dtb.img; then echo udisk dtb.img loaded; fi;wipeisb; bootm ${loadaddr};fi;
    recovery_offset=0
    recovery_part=recovery
    screenmode=full
    sdc_burning=sdc_burn ${sdcburncfg}
    sdcburncfg=aml_sdc_burn.ini
    sddtb=if fatload mmc 0 ${dtb_mem_addr} dtb.img; then else store dtb read $dtb_mem_addr; fi
    serverip=10.18.9.113
    storeargs=setenv bootargs ${initargs} logo=${display_layer},loaded,${fb_addr},${outputmode} vout=${outputmode},enable hdmimode=${hdmimode} cvbsmode=${cvbsmode} hdmitx=${cecconfig} cvbsdrv=${cvbs_drv} androidboot.firstboot=${firstboot} quiet jtag=${jtag}; setenv bootargs ${bootargs} androidboot.hardware=amlogic androidboot.boardid=${boardid};run cmdline_keys;
    storeboot=if imgread kernel boot ${loadaddr}; then bootm ${loadaddr}; fi;run update;
    switch_bootmode=get_rebootmode;if test ${reboot_mode} = factory_reset; then run recovery_from_flash;else if test ${reboot_mode} = update; then run update;fi;fi;
    try_auto_burn=update 700 750;
    update=run usb_burning; run sdc_burning; if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;
    update_ir=if irdetect; then run update; fi
    update_sar=saradc open 0;if saradc get_in_range 0x0 0x100; then run update; fi
    upgrade_check=echo upgrade_step=${upgrade_step}; if itest ${upgrade_step} == 3; then run init_display; run storeargs; run update;else if itest ${upgrade_step} == 1; then defenv_reserv; setenv upgrade_step 2; saveenv;else if itest ${upgrade_step} == 4; then defenv_reserv; run outputdefault; setenv upgrade_step 2; saveenv;fi;fi;fi;
    upgrade_key=if gpio input GPIOH_6; then echo detect upgrade key; sleep 3; run update;fi;
    upgrade_step=2
    usb_burning=update 1000
    usbdtb=if fatload usb 0 ${dtb_mem_addr} dtb.img; then else store dtb read $dtb_mem_addr; fi
    wipe_cache=successful
    wipe_data=successful
    

    Armbian 19.11.3 - Kernel 5.3.0

    fw_env.config  和3.14的kernel不一样, mainline kernel 不再有/dev/nand这样的设备了

    root@aml:~# more /etc/fw_env.config 
    # Configuration file for fw_(printenv/saveenv) utility.
    # Up to two entries are valid, in this case the redundant
    # environment sector is assumed present.
    # Notice, that the "Number of sectors" is ignored on NOR.
    
    /dev/mmcblk0  0x27400000 0x10000 0x10000
    

    fw_printenv

    root@aml:~# fw_printenv 
    1080i_h=1037
    1080i_w=1843
    1080i_x=38
    1080i_y=21
    1080p_h=1037
    1080p_w=1843
    1080p_x=38
    1080p_y=21
    576i_h=576
    576i_w=720
    576i_x=0
    576i_y=0
    720p_h=691
    720p_w=1229
    720p_x=25
    720p_y=14
    baudrate=115200
    boot_count=0
    bootcmd=run start_autoscript; run storeboot
    bootcount_check=echo bootcounts=${boot_count}; if itest ${boot_count} == 0; then setenv boot_count 1;saveenv;else if itest ${boot_count} == 1; then setenv boot_count 2;saveenv;else if itest ${boot_count} == 2; then setenv boot_count 3;saveenv;else if itest ${boot_count} == 3; then setenv boot_count 4;saveenv;else if itest ${boot_count} == 4; then run recovery_from_flash;fi;fi;fi;fi;fi
    bootdelay=0
    bootmode_check=get_rebootmode; echo reboot_mode=${reboot_mode};if test ${reboot_mode} = factory_reset; then defenv_reserv;setenv upgrade_step 2; save;fi;
    cmdline_keys=if keyman init 0x1234; then if sec_keyunify read mac ${loadaddr} str; then setenv bootargs ${bootargs} mac=${mac} androidboot.mac=${mac};fi;fi;
    cvbs_drv=0
    cvbsmode=576cvbs
    digitaudiooutput=HDMI&SPDIF PCM
    display_bpp=24
    display_color_bg=0
    display_color_fg=0xffff
    display_color_index=24
    display_height=1080
    display_layer=osd1
    display_width=1920
    dtb_mem_addr=0x1000000
    factory_reset_poweroff_protect=echo wipe_data=${wipe_data}; echo wipe_cache=${wipe_cache};if test ${wipe_data} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;fi; if test ${wipe_cache} = failed; then run init_display; run storeargs;if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;fi; 
    fb_addr=0x3d800000
    fb_height=1080
    fb_width=1920
    fdt_high=0x20000000
    firstboot=1
    gatewayip=10.18.9.1
    hdmimode=720p50hz
    hostname=arm_gxbb
    init_display=osd open;osd clear;imgread pic logo bootup $loadaddr;bmp display $bootup_offset;bmp scale
    initargs=rootfstype=ramfs init=/init console=ttyS0,115200 no_console_suspend earlyprintk=aml-uart,0xc81004c0 ramoops.pstore_en=1 ramoops.record_size=0x8000 ramoops.console_size=0x4000 androidboot.selinux=permissive
    ipaddr=10.18.9.97
    irremote_update=if irkey 0xf8077748 0x7d824cb3 0x728ddd22 100000; then echo read irkey ok!; if itest ${irkey_value} == 0xf8077748; then run update;else if itest ${irkey_value} == 0x7d824cb3; then run update;else if itest ${irkey_value} == 0x728ddd22; then run update;
    fi;fi;fi;fi;
    jtag=apee
    loadaddr=1080000
    netmask=255.255.255.0
    outputdefault=setenv outputmode 720p50hz;setenv 720p_w 1229;setenv 720p_h 691;setenv 720p_x 25;setenv 720p_y 14;setenv 1080i_w 1843;setenv 1080i_h 1037;setenv 1080i_x 38;setenv 1080i_y 21;setenv 1080p_w 1843;setenv 1080p_h 1037;setenv 1080p_x 38;setenv 1080p_y 21;setenv 576i_w 684;setenv 576i_h 547;setenv 576i_x 18;setenv 576i_y 14;
    outputmode=720p50hz
    preboot=run factory_reset_poweroff_protect;run upgrade_check;run bootmode_check;run init_display;run storeargs;run update_ir;run upgrade_key;run switch_bootmode;
    recovery_from_flash=setenv bootargs ${bootargs} aml_dt=${aml_dt} recovery_part={recovery_part} recovery_offset={recovery_offset};if imgread kernel ${recovery_part} ${loadaddr} ${recovery_offset}; then wipeisb; bootm ${loadaddr}; fi
    recovery_from_sdcard=if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload mmc 0 ${loadaddr} recovery.img; then if fatload mmc 0 ${dtb_mem_addr} dtb.img; then echo sd dtb.img loaded; fi;wipeisb; bootm ${loadaddr};fi;
    recovery_from_udisk=if fatload usb 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;if fatload usb 0 ${loadaddr} recovery.img; then if fatload usb 0 ${dtb_mem_addr} dtb.img; then echo udisk dtb.img loaded; fi;wipeisb; bootm ${loadaddr};fi;
    recovery_offset=0
    recovery_part=recovery
    screenmode=full
    sdc_burning=sdc_burn ${sdcburncfg}
    sdcburncfg=aml_sdc_burn.ini
    serverip=10.18.9.113
    start_autoscript=if mmcinfo; then run start_mmc_autoscript; fi; if usb start; then run start_usb_autoscript; fi; run start_emmc_autoscript
    start_emmc_autoscript=if fatload mmc 1 1020000 emmc_autoscript; then autoscr 1020000; fi;
    start_mmc_autoscript=if fatload mmc 0 1020000 s905_autoscript; then autoscr 1020000; fi;
    start_usb_autoscript=for usbdev in 0 1 2 3; do if fatload usb ${usbdev} 1020000 s905_autoscript; then autoscr 1020000; fi; done
    storeargs=setenv bootargs ${initargs} logo=${display_layer},loaded,${fb_addr},${outputmode} vout=${outputmode},enable hdmimode=${hdmimode} cvbsmode=${cvbsmode} hdmitx=${cecconfig} cvbsdrv=${cvbs_drv} androidboot.firstboot=${firstboot} quiet jtag=${jtag}; setenv bootargs ${bootargs} androidboot.hardware=amlogic androidboot.boardid=${boardid};run cmdline_keys;
    storeboot=if imgread kernel boot ${loadaddr}; then bootm ${loadaddr}; fi;run update;
    switch_bootmode=get_rebootmode;if test ${reboot_mode} = factory_reset; then run recovery_from_flash;else if test ${reboot_mode} = update; then run update;fi;fi;
    try_auto_burn=update 700 750;
    update=run usb_burning; run sdc_burning; if mmcinfo; then run recovery_from_sdcard;fi;if usb start 0; then run recovery_from_udisk;fi;run recovery_from_flash;
    update_ir=if irdetect; then run update; fi
    update_sar=saradc open 0;if saradc get_in_range 0x0 0x100; then run update; fi
    upgrade_check=echo upgrade_step=${upgrade_step}; if itest ${upgrade_step} == 3; then run init_display; run storeargs; run update;else if itest ${upgrade_step} == 1; then defenv_reserv; setenv upgrade_step 2; saveenv;else if itest ${upgrade_step} == 4; then defenv_reserv; run outputdefault; setenv upgrade_step 2; saveenv;fi;fi;fi;
    upgrade_key=if gpio input GPIOH_6; then echo detect upgrade key; sleep 3; run update;fi;
    upgrade_step=2
    usb_burning=update 1000
    wipe_cache=successful
    wipe_data=successful
    

    从上面输出的对比可以看出, EmuELEC所在的系统会对uboot增加如下配置

    bootcmd=if test ${bootfromnand} = 1; then setenv bootfromnand 0; saveenv; else run bootfromsd; run bootfromusb; fi; run storeboot
    bootfromnand=0
    bootfromsd=mmcinfo; if fatload mmc 0 ${loadaddr} kernel.img; then run sddtb; setenv bootargs ${bootargs} bootfromsd; bootm; fi
    bootfromusb=usb start 0; if fatload usb 0 ${loadaddr} kernel.img; then run usbdtb; setenv bootargs ${bootargs} bootfromusb; bootm; fi
    sddtb=if fatload mmc 0 ${dtb_mem_addr} dtb.img; then else store dtb read $dtb_mem_addr; fi
    usbdtb=if fatload usb 0 ${dtb_mem_addr} dtb.img; then else store dtb read $dtb_mem_addr; fi
    

    Armbian会对uboot增加如下配置

    bootcmd=run start_autoscript; run storeboot
    start_autoscript=if mmcinfo; then run start_mmc_autoscript; fi; if usb start; then run start_usb_autoscript; fi; run start_emmc_autoscript
    start_emmc_autoscript=if fatload mmc 1 1020000 emmc_autoscript; then autoscr 1020000; fi;
    start_mmc_autoscript=if fatload mmc 0 1020000 s905_autoscript; then autoscr 1020000; fi;
    start_usb_autoscript=for usbdev in 0 1 2 3; do if fatload usb ${usbdev} 1020000 s905_autoscript; then autoscr 1020000; fi; done
    

    Armbian从TF卡启动的机制

    初次启动时, 是通过安卓命令行下的reboot update开始的, 这时候uboot以update模式启动, 依次尝试以下步骤, 进入burning模式或启动recovery系统:

    1. run usb_burning 线刷,
    2. run sdc_burning 卡刷,
    3. recovery_from_sdcard SD/TF卡载recovery,
    4. recovery_from_udisk U盘卡载recovery,
    5. recovery_from flash 本机的recovery

    在卡槽中存在Armbian系统TF时, 会进入第二步, 因为TF卡上有aml_autoscript这个文件, 其源文件如下

    root@aml:/# more /boot/aml_autoscript.cmd
    defenv
    setenv bootcmd 'run start_autoscript; run storeboot'
    setenv start_autoscript 'if mmcinfo; then run start_mmc_autoscript; fi; if usb start; then run start_usb_autoscript; fi; run start_emmc_autoscript'
    setenv start_emmc_autoscript 'if fatload mmc 1 1020000 emmc_autoscript; then autoscr 1020000; fi;'
    setenv start_mmc_autoscript 'if fatload mmc 0 1020000 s905_autoscript; then autoscr 1020000; fi;'
    setenv start_usb_autoscript 'for usbdev in 0 1 2 3; do if fatload usb ${usbdev} 1020000 s905_autoscript; then autoscr 1020000; fi; done'
    setenv upgrade_step 2
    saveenv
    sleep 1
    reboot
    

    .执行此脚本会更新uboot env中的bootcmd, 然后重启. uboot以normal启动后, 会首先执行strart_autoscript, 会依次尝试start_mmc_autoscript, start_usb_autoscript, start_emmc_autoscript, 在卡槽中存在Armbian系统TF时, 会进入第一步, 去执行卡上的s905_autoscript这个脚本, 其源文件内容如下

    if fatload mmc 0 0x11000000 boot_android; then if test ${ab} = 0; then setenv ab 1; saveenv; exit; else setenv ab 0; saveenv; fi; fi;
    if fatload usb 0 0x11000000 boot_android; then if test ${ab} = 0; then setenv ab 1; saveenv; exit; else setenv ab 0; saveenv; fi; fi;
    setenv env_addr 0x10400000
    setenv kernel_addr 0x11000000
    setenv initrd_addr 0x13000000
    setenv boot_start booti ${kernel_addr} ${initrd_addr} ${dtb_mem_addr}
    setenv addmac 'if printenv mac; then setenv bootargs ${bootargs} mac=${mac}; elif printenv eth_mac; then setenv bootargs ${bootargs} mac=${eth_mac}; fi'
    setenv try_boot_start 'if fatload ${devtype} ${devnum} ${kernel_addr} zImage; then if fatload ${devtype} ${devnum} ${initrd_addr} uInitrd; then fatload ${devtype} ${devnum} ${env_addr} uEnv.ini && env import -t ${env_addr} ${filesize} && run addmac; fatload ${devtype} ${devnum} ${dtb_mem_addr} ${dtb_name} && run boot_start; fi; fi;'
    setenv devtype mmc
    setenv devnum 0
    run try_boot_start
    setenv devtype usb
    for devnum in 0 1 2 3 ; do run try_boot_start ; done
    

    其产生的uboot log如下

    ...
    Hit any key to stop autoboot:  0
    card in
    [mmc_init] mmc init success
    Device: SDIO Port B
    Manufacturer ID: 3
    OEM: 5344
    Name: SU16G
    Tran Speed: 50000000
    Rd Block Len: 512
    SD version 3.0
    High Capacity: Yes
    Capacity: 14.8 GiB
    Bus Width: 4-bit
    reading s905_autoscript
    1112 bytes read in 9 ms (120.1 KiB/s)
    ## Executing script at 01020000
    reading boot_android
    ** Unable to read file boot_android **
    ** Bad device usb 0 **
    reading zImage
    27871744 bytes read in 1264 ms (21 MiB/s)
    reading uInitrd
    9994338 bytes read in 452 ms (21.1 MiB/s)
    reading uEnv.ini
    224 bytes read in 3 ms (72.3 KiB/s)
    ## Error: "mac" not defined
    ## Error: "eth_mac" not defined
    reading /dtb/amlogic/meson-gxl-s905x-nexbox-a95x.dtb
    25654 bytes read in 13 ms (1.9 MiB/s)
    ## Loading init Ramdisk from Legacy Image at 13000000 ...
       Image Name:   uInitrd
       Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
       Data Size:    9994274 Bytes = 9.5 MiB
       Load Address: 00000000
       Entry Point:  00000000
       Verifying Checksum ... OK
          Single dtb detected
    load dtb from 0x1000000 ......
    ## Flattened Device Tree blob at 01000000
       Booting using the fdt blob at 0x1000000
       Loading Ramdisk to 33534000, end 33ebc022 ... OK
       Loading Device Tree to 000000001fff6000, end 000000001ffff435 ... OK
    
    Starting kernel ...
    
    uboot time: 4023961 us
    [    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
    [    0.000000] Linux version 5.3.0-aml-g12 (root@os3-362-14133) (gcc version 7.4.1 20181213 [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4] (Linaro GCC 7.4-2019.02)) #5.99 SMP PREEMPT Wed Dec 4 21:34:52 JST 2019
    ...
    

    参考

    https://blog.lvu.kr/page/12/?page=15  很详细的输出记录

  • 相关阅读:
    Java基础——面向对象(继承应用)
    Java基础——数组例题&二维数组
    Java基础——面对对象-继承
    Java基础——this构造器转发 & 实例块、静态块
    spring mvc 映射与适配器
    Spring component-scan 标签的实现
    DUBBO 服务导出实现
    Idea
    ReentrantLock 实现
    C 语言程序设计
  • 原文地址:https://www.cnblogs.com/milton/p/11995396.html
Copyright © 2011-2022 走看看