【TINY4412】U-BOOT移植笔记:(19)TFTP更新固件

【TINY4412】U-BOOT移植笔记:(19)TFTP更新固件

宿主机 : 虚拟机 Ubuntu 16.04 LTS / X64
目标板[底板]: Tiny4412SDK - 1506
目标板[核心板]: Tiny4412 - 1412
U-BOOT版本: 2017.03
交叉编译器: gcc-arm-none-eabi-5_4-2016q3
日期: 2017-7-12 21:11:04
作者: SY

简介

  • TFTP(Trivial File Transfer Protocol,简单文本传输协议),一般用于在局域网内传输升级固件,待更新的文件比较小。默认使用69号端口。
  • 使用以太网传输数据
  • 使用流程:
    • 从机使用69号端口,向服务器发送一个写请求
    • 服务器收到数据后,使用一个随机端口X(4096~65535),回复数据包
    • 从机以后使用X端口发送数据包。

DFU TFTP命令

开发板

  • 通过make menuconfig 使能dfu tftp功能

    root@ubuntu:/opt/u-boot-2017.03# 
    root@ubuntu:/opt/u-boot-2017.03# make menuconfig
    Device Drivers  ---> 
        DFU support  ---> 
             [*] DFU via TFTP 
  • 设置环境变量:

    setenv loadaddr 0x43E00000
    setenv filename u-boot.bin
    setenv ipaddr 192.168.2.39
    setenv serverip 192.168.2.40
    setenv updatefile u-boot.bin

主机Ubuntu

  • 安装tftp

    root@ubuntu:/opt/u-boot-2017.03# apt-get install tftp-hpa tftpd-hpa
  • 修改配置文件

    root@ubuntu:/opt/u-boot-2017.03# cat /etc/default/tftpd-hpa 
    
    # /etc/default/tftpd-hpa
    
    
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/opt/tftpboot"
    TFTP_ADDRESS=":69"
    TFTP_OPTIONS="-l -c -s"
    
    root@ubuntu:/opt/u-boot-2017.03# man tftp
    OPTIONS
         -4     Connect with IPv4 only, even if IPv6 support was compiled in.
    
         -6     Connect with IPv6 only, if compiled in.
    
         -c command
                Execute command as if it had been entered on the tftp prompt.  Must be specified  last  on
                the command line.
    
         -l     Default to literal mode. Used to avoid special processing of ':' in a file name.
    
         -m mode
                Set the default transfer mode to mode.  This is usually used with -c.
    
         -R port:port
                Force the originating port number to be in the specified range of port numbers.
    
         -v     Default to verbose mode.
    
         -V     Print the version number and configuration to standard output, then exit gracefully.
  • 重启TFTP服务

    root@ubuntu:/opt/u-boot-2017.03# service tftpd-hpa restart

测试

  • 主机端

    root@ubuntu:/opt/u-boot-2017.03# cp u-boot.bin /opt/tftpboot/
  • 开发板

    TINY4412 # dfu tftp 0 ram 0
    
    Auto-update from TFTP: trying update file 'u-boot.bin'
    
    Waiting for Ethernet connection... done.
    
    Using Davicom DM96xx U device
    
    TFTP from server 192.168.2.195; our IP address is 192.168.2.194
    
    Filename 'u-boot.bin'.
    
    Load address: 0x43e00000
    
    Loading: #################################
    
    239.3 KiB/s
    
    done
    
    Bytes transferred = 482506 (75cca hex)
    
    Bad FIT format of the update file, aborting auto-update
    
    TINY4412 # go 43E00000
    U-Boot 2017.03-ge4aa2a4-dirty (Jul 09 2017 - 10:49:03 +0800) for TINY4412
    
    CPU:   Exynos4412 @ 1.4 GHz
    Model: Tiny4412 based on Exynos4412
    Board: Tiny4412 based on Exynos4412
    DRAM:  1 GiB
    WARNING: Caches not enabled
    MMC:   SAMSUNG SDHCI: 2, EXYNOS DWMMC: 4
    ** First descriptor is NOT a primary desc on 4:1 **
    Net:   No ethernet found.
    Hit any key to stop autoboot:  0 

TFTP命令

主机端

  • 拷贝烧录文件

    root@ubuntu:/opt/linux-4.12# cat tftp.sh 
    
    #!/bin/bash
    
    
    
    # Developer: SY
    
    
    # Data     : 2017-7-12 20:47:29
    
    
    # Function : TFTP Upgrade
    
    
    TFTP_PATH=/opt/tftpboot/
    
    echo "------------------------------"
    echo "TFTP uImage"
    cp arch/arm/boot/uImage $TFTP_PATH
    
    echo "------------------------------"
    echo "TFTP ramdisk"
    cp /opt/rootfs/ramdisk.img $TFTP_PATH
    
    echo "------------------------------"
    echo "TFTP exynos4412-tiny4412.dtb"
    cp arch/arm/boot/dts/exynos4412-tiny4412.dtb $TFTP_PATH
    
    echo "------------------------------"
    echo "done!"
    
    root@ubuntu:/opt/linux-4.12# chmod 755 tftp.sh
    root@ubuntu:/opt/linux-4.12# ./tftp.sh

开发板

  • 设置环境变量

    TINY4412 # setenv bootcmd usb start\;tftp 0x41000000 uImage\;tftp 0x42000000 ramdisk.img\;tftp 0x43000000 exynos4412-tiny4412.dtb\;bootm 0x41000000 0x42000000 0x43000000
    TINY4412 # saveenv
  • 重启开发板测试

    
    U-Boot 2017.03-ge4aa2a4-dirty (Jul 09 2017 - 10:49:03 +0800) for TINY4412
    
    CPU:   Exynos4412 @ 1.4 GHz
    Model: Tiny4412 based on Exynos4412
    Board: Tiny4412 based on Exynos4412
    DRAM:  1 GiB
    WARNING: Caches not enabled
    MMC:   SAMSUNG SDHCI: 2, EXYNOS DWMMC: 4
    ** First descriptor is NOT a primary desc on 4:1 **
    Net:   No ethernet found.
    Hit any key to stop autoboot:  0 
    starting USB...
    USB0:   USB EHCI 1.00
    scanning bus 0 for devices... 4 USB Device(s) found
         scanning usb for storage devices... 0 Storage Device(s) found
         scanning usb for ethernet devices... 1 Ethernet Device(s) found
    Using DM9621A0 device
    TFTP from server 192.168.2.40; our IP address is 192.168.2.39
    Filename 'uImage'.
    Load address: 0x41000000
    Loading: EHCI timed out on TD - token=0x8008d80
    Rx: failed to receive
    EHCI timed out on TD - token=0x8008d80
    Rx: failed to receive
    
    #################################################################
    
           #################################################################
           #################################################################
           #################################################################
           #################################################################
           ####
           364.3 KiB/s
    done
    Bytes transferred = 4827960 (49ab38 hex)
    Using DM9621A0 device
    TFTP from server 192.168.2.40; our IP address is 192.168.2.39
    Filename 'ramdisk.img'.
    Load address: 0x42000000
    Loading: #################################################################
           ##############
           1.5 MiB/s
    done
    Bytes transferred = 1152831 (11973f hex)
    Using DM9621A0 device
    TFTP from server 192.168.2.40; our IP address is 192.168.2.39
    Filename 'exynos4412-tiny4412.dtb'.
    Load address: 0x43000000
    Loading: ####
           1.6 MiB/s
    done
    Bytes transferred = 46445 (b56d hex)
    
    ## Booting kernel from Legacy Image at 41000000 ...
    
     Image Name:   Linux-4.12.0-gd593bff-dirty
     Image Type:   ARM Linux Kernel Image (uncompressed)
     Data Size:    4827896 Bytes = 4.6 MiB
     Load Address: 40008000
     Entry Point:  40008000
     Verifying Checksum ... OK
    
    ## Loading init Ramdisk from Legacy Image at 42000000 ...
    
     Image Name:   Tiny4412 Ramdisk Image
     Image Type:   ARM Linux RAMDisk Image (gzip compressed)
     Data Size:    1152767 Bytes = 1.1 MiB
     Load Address: 00000000
     Entry Point:  00000000
     Verifying Checksum ... OK
    
    ## Flattened Device Tree blob at 43000000
    
     Booting using the fdt blob at 0x43000000
     Loading Kernel Image ... OK
     Loading Ramdisk to 4fee6000, end 4ffff6ff ... OK
     Loading Device Tree to 4fed7000, end 4fee556c ... OK
    
    Starting kernel ...
    
    Uncompressing Linux... done, booting the kernel.
    [    0.000000] Booting Linux on physical CPU 0xa00
    [    0.000000] Linux version 4.12.0-gd593bff-dirty (root@ubuntu) (gcc version 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496] (GNU Tools for ARM Embedded Processors) ) #18 SMP PREEMPT Tue Jul 11 22:51:08 CST 2017
    [    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d
    [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
    [    0.000000] OF: fdt: Machine model: FriendlyARM TINY4412 board based on Exynos4412
    [    0.000000] bootconsole [earlycon0] enabled
    [    0.000000] Memory policy: Data cache writealloc
    [    0.000000] cma: Reserved 96 MiB at 0x7a000000
    [    0.000000] Samsung CPU ID: 0xe4412011
    [    0.000000] percpu: Embedded 16 pages/cpu @ef78f000 s34968 r8192 d22376 u65536
    [    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260608
    [    0.000000] Kernel command line: initrd=0x42000040,0x800000 root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 init=/linuxrc earlyprintk
    [    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
    [    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
    [    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
    [    0.000000] Memory: 919504K/1048576K available (7168K kernel code, 334K rwdata, 2448K rodata, 1024K init, 326K bss, 30768K reserved, 98304K cma-reserved, 163840K highmem)
    [    0.000000] Virtual kernel memory layout:
    [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    [    0.000000]     vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
    [    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
    [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
    [    0.000000]       .text : 0xc0008000 - 0xc0800000   (8160 kB)
    [    0.000000]       .init : 0xc0b00000 - 0xc0c00000   (1024 kB)
    [    0.000000]       .data : 0xc0c00000 - 0xc0c538d0   ( 335 kB)
    [    0.000000]        .bss : 0xc0c5b0e4 - 0xc0caca20   ( 327 kB)
    [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
    [    0.000000] Preemptible hierarchical RCU implementation.
    [    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
    [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
    [    0.000000] NR_IRQS:16 nr_irqs:16 16
    [    0.000000] L2C: platform modifies aux control register: 0x02070000 -> 0x3e470001
    [    0.000000] L2C: platform provided aux values permit register corruption.
    [    0.000000] L2C: DT/platform modifies aux control register: 0x02070000 -> 0x3e470001
    [    0.000000] L2C-310 enabling early BRESP for Cortex-A9
    [    0.000000] L2C-310: enabling full line of zeros but not enabled in Cortex-A9
    [    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
    [    0.000000] L2C-310 cache controller enabled, 16 ways, 1024 kB
    [    0.000000] L2C-310: CACHE_ID 0x4100c4c8, AUX_CTRL 0x4e470001
    [    0.000000] Exynos4x12 clocks: sclk_apll = 700000000, sclk_mpll = 800000000
    [    0.000000]  sclk_epll = 96035156, sclk_vpll = 108035156, arm_clk = 1400000000
    [    0.000000] Switching to timer-based delay loop, resolution 41ns
    [    0.000000] clocksource: mct-frc: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
    [    0.000003] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
    [    0.008063] Console: colour dummy device 80x30
    [    0.012419] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
    [    0.022835] pid_max: default: 32768 minimum: 301
    [    0.027578] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
    [    0.034199] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
    [    0.041627] CPU: Testing write buffer coherency: ok
    [    0.046603] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
    [    0.084750] Setting up static identity map for 0x40100000 - 0x40100060
    [    0.144728] smp: Bringing up secondary CPUs ...
    [    0.204788] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
    [    0.284779] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
    [    0.364780] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
    [    0.364827] smp: Brought up 1 node, 4 CPUs
    [    0.386284] SMP: Total of 4 processors activated (192.00 BogoMIPS).
    [    0.392612] CPU: All CPU(s) started in SVC mode.
    [    0.397893] devtmpfs: initialized
    [    0.407825] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
    [    0.415561] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
    [    0.425308] futex hash table entries: 1024 (order: 4, 65536 bytes)
    [    0.434432] pinctrl core: initialized pinctrl subsystem
    [    0.440107] /lcd0-power-domain@10023C80 has as child subdomain: /tv-power-domain@10023C20.
    [    0.448865] NET: Registered protocol family 16
    [    0.454619] DMA: preallocated 256 KiB pool for atomic coherent allocations
    [    0.462440] cpuidle: using governor menu
    [    0.485222] SCSI subsystem initialized
    [    0.489020] usbcore: registered new interface driver usbfs
    [    0.494465] usbcore: registered new interface driver hub
    [    0.499874] usbcore: registered new device driver usb
    [    0.505465] Advanced Linux Sound Architecture Driver Initialized.
    [    0.512149] clocksource: Switched to clocksource mct-frc
    [    0.524545] missing cooling_device property
    [    0.528637] failed to build thermal zone cpu-thermal: -2
    [    0.534098] NET: Registered protocol family 2
    [    0.538784] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
    [    0.545805] TCP bind hash table entries: 8192 (order: 5, 163840 bytes)
    [    0.552460] TCP: Hash tables configured (established 8192 bind 8192)
    [    0.558850] UDP hash table entries: 512 (order: 2, 24576 bytes)
    [    0.564789] UDP-Lite hash table entries: 512 (order: 2, 24576 bytes)
    [    0.571286] NET: Registered protocol family 1
    [    0.575865] RPC: Registered named UNIX socket transport module.
    [    0.581688] RPC: Registered udp transport module.
    [    0.586480] RPC: Registered tcp transport module.
    [    0.591236] RPC: Registered tcp NFSv4.1 backchannel transport module.
    [    0.597883] Trying to unpack rootfs image as initramfs...
    [    0.603589] rootfs image is not initramfs (no cpio magic); looks like an initrd
    [    0.637571] Freeing initrd memory: 8196K
    [    0.642248] audit: initializing netlink subsys (disabled)
    [    0.647685] audit: type=2000 audit(0.645:1): state=initialized audit_enabled=0 res=1
    [    0.647776] workingset: timestamp_bits=30 max_order=18 bucket_order=0
    [    0.652657] NFS: Registering the id_resolver key type
    [    0.652670] Key type id_resolver registered
    [    0.652673] Key type id_legacy registered
    [    0.652694] romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
    [    0.655827] bounce: pool size: 64 pages
    [    0.655856] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
    [    0.655860] io scheduler noop registered
    [    0.655862] io scheduler deadline registered
    [    0.655878] io scheduler cfq registered (default)
    [    0.655881] io scheduler mq-deadline registered
    [    0.655884] io scheduler kyber registered
    [    0.666087] dma-pl330 12680000.pdma: Loaded driver for PL330 DMAC-141330
    [    0.666092] dma-pl330 12680000.pdma:         DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
    [    0.667947] dma-pl330 12690000.pdma: Loaded driver for PL330 DMAC-141330
    [    0.667953] dma-pl330 12690000.pdma:         DBUFF-32x4bytes Num_Chans-8 Num_Peri-32 Num_Events-32
    [    0.668655] dma-pl330 12850000.mdma: Loaded driver for PL330 DMAC-141330
    [    0.668661] dma-pl330 12850000.mdma:         DBUFF-64x8bytes Num_Chans-8 Num_Peri-1 Num_Events-32
    [    0.766629] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
    [    0.774148] 13800000.serial: ttySAC0 at MMIO 0x13800000 (irq = 46, base_baud = 0) is a S3C6400/10
    [    0.783005] console [ttySAC0] enabled
    [    0.783005] console [ttySAC0] enabled
    [    0.790305] bootconsole [earlycon0] disabled
    [    0.790305] bootconsole [earlycon0] disabled
    [    0.799183] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 47, base_baud = 0) is a S3C6400/10
    [    0.799493] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 48, base_baud = 0) is a S3C6400/10
    [    0.799805] 13830000.serial: ttySAC3 at MMIO 0x13830000 (irq = 49, base_baud = 0) is a S3C6400/10
    [    0.812565] brd: module loaded
    [    0.818069] loop: module loaded
    [    0.818792] libphy: Fixed MDIO Bus: probed
    [    0.818936] usbcore: registered new interface driver r8152
    [    0.819182] usbcore: registered new interface driver asix
    [    0.824612] usbcore: registered new interface driver ax88179_178a
    [    0.830633] usbcore: registered new interface driver cdc_ether
    [    0.836506] usbcore: registered new interface driver smsc75xx
    [    0.842207] usbcore: registered new interface driver smsc95xx
    [    0.847905] usbcore: registered new interface driver net1080
    [    0.853577] usbcore: registered new interface driver cdc_subset
    [    0.859449] usbcore: registered new interface driver zaurus
    [    0.865034] usbcore: registered new interface driver cdc_ncm
    [    0.871137] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
    [    0.877174] ehci-exynos: EHCI EXYNOS driver
    [    0.881405] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
    [    0.887486] ohci-exynos: OHCI EXYNOS driver
    [    0.891949] usbcore: registered new interface driver usb-storage
    [    0.898329] s3c-rtc 10070000.rtc: failed to find rtc source clock
    [    0.903733] s3c-rtc: probe of 10070000.rtc failed with error -2
    [    0.909759] i2c /dev entries driver
    [    0.914751] s3c2410-wdt 10060000.watchdog: watchdog inactive, reset disabled, irq disabled
    [    0.921698] device-mapper: ioctl: 4.35.0-ioctl (2016-06-23) initialised: [email protected]
    [    0.931259] sdhci: Secure Digital Host Controller Interface driver
    [    0.935920] sdhci: Copyright(c) Pierre Ossman
    [    0.940517] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (20000000 Hz)
    [    1.002196] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
    [    1.002369] Synopsys Designware Multimedia Card Interface Driver
    [    1.006913] s5p-secss 10830000.sss: s5p-sss driver registered
    [    1.007365] usbcore: registered new interface driver usbhid
    [    1.007420] usbhid: USB HID core driver
    [    1.013702] NET: Registered protocol family 10
    [    1.014333] Segment Routing with IPv6
    [    1.016389] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
    [    1.022620] NET: Registered protocol family 17
    [    1.026695] NET: Registered protocol family 15
    [    1.031152] Key type dns_resolver registered
    [    1.035537] Registering SWP/SWPB emulation handler
    [    1.051195] mmc0: new high speed SDHC card at address 0007
    [    1.051588] mmcblk0: mmc0:0007 SD16G 14.5 GiB 
    [    1.051652] hctosys: unable to open rtc device (rtc0)
    [    1.055690] ALSA device list:
    [    1.058020]   No soundcards found.
    [    1.062939] RAMDISK: gzip image found at block 0
    [    1.188044] EXT4-fs (ram0): mounted filesystem with ordered data mode. Opts: (null)
    [    1.188174] VFS: Mounted root (ext4 filesystem) on device 1:0.
    [    1.188592] devtmpfs: mounted
    [    1.189887] Freeing unused kernel memory: 1024K
    
    Processing /etc/profile... Done
    
    [root@TINY4412:/]# 
  • 环境变量

    TINY4412 # printenv
    arch=arm
    baudrate=115200
    board=tiny4412
    board_name=tiny4412
    bootargs=initrd=0x42000040,0x800000 root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 init=/linuxrc 
    bootcmd=usb start;tftp 0x41000000 uImage;tftp 0x42000000 ramdisk.img;tftp 0x43000000 exynos4412-tiny4412.dtb;bootm 0x41000000 0x42000000 0x43000000
    bootdelay=2
    bootenv=uEnv.txt
    bootfile=/opt/linux-4.12/arch/arm/boot/uImage
    bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
    console=ttySAC0,115200n8
    cpu=armv7
    dfu_alt_info=uImage ram 0x41000000 0xA00000;ramdisk.img ram 0x42000000 0x800000;exynos4412-tiny4412.dtb ram 0x43000000 0x100000
    ethact=DM9621A0
    fdtcontroladdr=7ae467d8
    fileaddr=43000000
    filesize=b56d
    importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
    ipaddr=192.168.2.39
    kerneladdr=0x40008000
    loadaddr=0x40008000
    loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}
    loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
    mmcdev=0
    ramdiskaddr=48000000
    rdaddr=48000000
    serverip=192.168.2.40
    soc=exynos
    updatefile=u-boot.bin
    usbethaddr=00:00:ff:ff:00:00
    vendor=samsung
    
    Environment size: 1182/16380 bytes

你可能感兴趣的:(TINY4412,U-BOOT)