am335x通過串口燒寫u-boot

通過串口將u-boot-spl.bin 和u-boot.img 燒寫到DRAM後,u-boot自動運行,再通過u-boot提供的網卡驅動和tftp服務通過網口將MLO、u-boot.img等文件燒寫到nand flash中。
注意:系統在SD卡啓動和nand flash啓動的時候燒寫的是MLO和u-boot.img ,而nor flash 和ddr啓動的時候燒寫的是u-boot-spl.bin和u-boot.img。(MLO和u-boot-spl.bin具體有何區別有待深入探究)
實測SecureCRT 8.5串口工具可用於串口傳輸(不是100%成功),teraterm-4.103和xshell6不可用。SecureCRT 8.5破解版下載鏈接
將開發板相關跳線帽接到mmc上,上電後串口打印“C”說明串口連接成功,具體燒寫過程如下:
CCCCCCCC
Transferring u-boot-spl.bin, errors 1...to cancel.
  100%      53 KB       2 KB/sec    00:00:19       1 Errors  //串口燒寫u-boot-spl.bin耗時19秒


U-Boot SPL 2016.05 (May 11 2017 - 16:23:54)
Trying to boot from UART
C
Transferring u-boot.img, errors 2...l+C to cancel.
  100%     313 KB       2 KB/sec    00:02:27       3 Errors  //串口燒寫u-boot.img耗時2分27秒


Loaded 321292 bytes

燒寫完u-boot-spl.bin和u-boot.img後自動運行u-boot,打印如下:
U-Boot 2016.05 (Mar 10 2017 - 12:39:43 +0800)

       Watchdog enabled
I2C:   ready
DRAM:  512 MiB
NAND:  512 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
*** Warning - bad CRC, using default environment

Net:   cpsw
Press SPACE to abort autoboot in 2 seconds //按空格鍵進入u-boot命令行
MYIR>#      <INTERRUPT>
MYIR># <INTERRUPT>
MYIR># <INTERRUPT>
MYIR># pritenv
Unknown command 'pritenv' - try 'help'
MYIR># printenv  //查看u-boot 環境變量
arch=arm
args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
baudrate=115200
board=myd_c335x
board_name=myd_c335x
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_efi_binary=load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} efi/boot/bootarm.efi; if fdt addr ${fdt_addr_r}; then bootefi ${kernel_addr_r} ${fdt_addr_r};elsebootefi ${kernel_addr_r} ${fdtcontroladdr};fi
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
boot_fdt=try
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=mmc0 legacy_mmc0 mmc1 legacy_mmc1 nand0 pxe dhcp 
bootcmd=run findfdt; run init_console; run envboot; run distro_bootcmd
bootcmd_dhcp=if dhcp ${scriptaddr} ${boot_script_dhcp}; then source ${scriptaddr}; fi
bootcmd_legacy_mmc0=setenv mmcdev 0; setenv bootpart 0:2 ; run mmcboot
bootcmd_legacy_mmc1=setenv mmcdev 1; setenv bootpart 1:2 ; run mmcboot
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_nand0=run nandboot
bootcmd_pxe=dhcp; if pxe get; then pxe boot; fi
bootdelay=2
bootdir=/boot
bootenvfile=uEnv.txt
bootfile=zImage
bootm_size=0x10000000
bootpart=0:2
bootscript=echo Running bootscript from mmc${mmcdev} ...; source ${loadaddr}
console=ttyO0,115200n8
cpu=armv7
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
efi_dtb_prefixes=/ /dtb/ /dtb/current/
envboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootscript; then run bootscript;else if run loadbootenv; then echo Loaded env from ${bootenvfile};run importbootenv;fi;if test -n $uenvcmd; then echo Running uenvcmd ...;run uenvcmd;fi;fi;fi;
eth1addr=fc:69:47:c0:67:6a
ethact=cpsw
ethaddr=fc:69:47:c0:67:68
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtfile=undefined
findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A335BNLT; then setenv fdtfile am335x-boneblack.dtb; fi; if test $board_name = BBG1; then setenv fdtfile am335x-bonegreen.dtb; fi; if test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $board_name = A335X_SK; then setenv fdtfile am335x-evmsk.dtb; fi; if test $board_name = A335_ICE; then setenv fdtfile am335x-icev2.dtb; fi; if test $board_name = myd_c335x; then setenv fdtfile myd_c335x.dtb; fi; if test $fdtfile = undefined; then echo WARNING: Could not determine device tree to use; fi; 
finduuid=part uuid mmc ${bootpart} uuid
importbootenv=echo Importing environment from mmc${mmcdev} ...; env import -t ${loadaddr} ${filesize}
init_console=if test $board_name = A335_ICE; then setenv console ttyO3,115200n8;else setenv console ttyO0,115200n8;fi;
kernel_addr_r=0x82000000
load_efi_dtb=load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}${efi_fdtfile}
loadaddr=0x82000000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
loadfdt=load mmc ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load mmc ${mmcdev} ${rdaddr} ramdisk.gz
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi
mmcboot=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};run envboot; if run loadimage; then run mmcloados;fi;fi;
mmcdev=0
mmcloados=run args_mmc; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdtaddr}; else if test ${boot_fdt} = try; then bootz; else echo WARN: Cannot load the DT; fi; fi; else bootz; fi;
mmcrootfstype=ext4 rootwait
mtdparts=mtdparts=nand.0:128k(NAND.SPL),128k(NAND.SPL.backup1),128k(NAND.SPL.backup2),128k(NAND.SPL.backup3),256k(NAND.u-boot-spl-os),1m(NAND.u-boot),128k(NAND.u-boot-env),128k(NAND.u-boot-env.backup1),8m(NAND.kernel),118m(NAND.rootfs),-(NAND.userdata)
nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${fdtaddr} NAND.u-boot-spl-os; nand read ${loadaddr} NAND.kernel; bootz ${loadaddr} - ${fdtaddr}
nandroot=ubi0:rootfs rw ubi.mtd=NAND.rootfs,2048
nandrootfstype=ubifs rootwait=1
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
netboot=echo Booting from network ...; setenv autoload no; run netloadimage; run netloadfdt; run netargs; bootz ${loadaddr} - ${fdtaddr}
netloadfdt=tftp ${fdtaddr} ${fdtfile}
netloadimage=tftp ${loadaddr} ${bootfile}
nfsopts=nolock
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
pxefile_addr_r=0x80100000
ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
ramboot=echo Booting from ramdisk ...; run ramargs; bootz ${loadaddr} ${rdaddr} ${fdtaddr}
ramdisk_addr_r=0x88080000
ramroot=/dev/ram0 rw
ramrootfstype=ext2
rdaddr=0x88080000
rootpath=/export/rootfs
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;run scan_dev_for_efi;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
scan_dev_for_efi=setenv efi_fdtfile ${fdtfile}; if test -z "${fdtfile}" -a -n "${soc}"; then setenv efi_fdtfile ${soc}-${board}${boardver}.dtb; fi; for prefix in ${efi_dtb_prefixes}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${efi_fdtfile}; then run load_efi_dtb; fi;done;if test -e ${devtype} ${devnum}:${distro_bootpart} efi/boot/bootarm.efi; then echo Found EFI removable media binary efi/boot/bootarm.efi; run boot_efi_binary; echo EFI LOAD FAILED: continuing...; fi; setenv efi_fdtfile
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0x80000000
soc=am33xx
spiargs=setenv bootargs console=${console} ${optargs} root=${spiroot} rootfstype=${spirootfstype}
spiboot=echo Booting from spi ...; run spiargs; sf probe ${spibusno}:0; sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; bootz ${loadaddr}
spibusno=0
spiimgsize=0x362000
spiroot=/dev/mtdblock4 rw
spirootfstype=jffs2
spisrcaddr=0xe0000
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=ns16550_serial
stdin=ns16550_serial
stdout=ns16550_serial
updatesys=nand erase.chip;mmc dev 0; mmc rescan; fatload mmc 0 0x82000000 MLO;                          nand write 0x82000000 0 ${filesize};fatload mmc 0 0x82000000 myd_c335x.dtb;  nand write 0x82000000 0x80000 ${filesize};fatload mmc 0 0x82000000 u-boot.img;          nand write 0x82000000 0xc0000 ${filesize};fatload mmc 0 0x82000000 zImage;  nand write 0x82000000 0x200000 ${filesize};fatload mmc 0 0x82000000 rootfs.ubi;          nand write 0x82000000 0xa00000 ${filesize};mtdids=nand0=nand.0 //按照上述地址逐個燒寫MLO、u-boot.img、myd_c335x.dtb、zImage、rootfs.ubi
vendor=myirtech
ver=U-Boot 2016.05 (Mar 10 2017 - 12:39:43 +0800)

Environment size: 7811/131067 bytes
MYIR># nandecc
Unknown command 'nandecc' - try 'help'
MYIR># set ipaddr 10.0.0.77
Unknown command 'set' - try 'help'
MYIR># setenv ipaddr 10.0.0.77
MYIR># setenv serverip 10.0.0.75
MYIR># saveenv  //配置開發板和服務器IP地址

Saving Environment to NAND...
Erasing redundant NAND...
Erasing at 0x1e0000 -- 100% complete.
Writing to redundant NAND... OK
MYIR># ping 10.0.0.75 //檢查網絡是否連接
link up on port 0, speed 100, full duplex
Using cpsw device
host 10.0.0.75 is alive //說明網絡已連接
MYIR># tftp 0x82000000 MLO      //下載MLO文件到開發板ROM的0x82000000處
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 10.0.0.75; our IP address is 10.0.0.77
Filename 'MLO'.
Load address: 0x82000000
Loading: ####
         1.2 MiB/s
done
Bytes transferred = 55092 (d734 hex)
MYIR># nand erase.chip  //將整個nand flash擦除乾淨

NAND erase.chip: device 0 whole chip
Erasing at 0x1ffe0000 -- 100% complete.
OK
MYIR># nand write 0x82000000 0 0xd734  //從開發板ROM的0x82000000處拷貝0xd734這麼大的數據到nand flash 的 0x0地址處,下面的操作也是如此,只是地址和數據大小不同。

NAND write: device 0 offset 0x0, size 0xd734
 55092 bytes written: OK
MYIR># tftp 0x82000000 u-boot.img
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 10.0.0.75; our IP address is 10.0.0.77
Filename 'u-boot.img'.
Load address: 0x82000000
Loading: ######################
         1.1 MiB/s
done
Bytes transferred = 321292 (4e70c hex)
MYIR># nand write 0x82000000 0xc0000 0x4e70c

NAND write: device 0 offset 0xc0000, size 0x4e70c
 321292 bytes written: OK
MYIR># 
MYIR># tftp 0x82000000 zImage 
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 10.0.0.75; our IP address is 10.0.0.77
Filename 'zImage'.
Load address: 0x82000000
Loading: #################################################################
         #################################################################
         #################################################################
         ##################################
         1.3 MiB/s
done
Bytes transferred = 3349272 (331b18 hex)
MYIR># nand write 0x82000000 0x200000 0x331b18

NAND write: device 0 offset 0x200000, size 0x331b18
 3349272 bytes written: OK
MYIR># tftp 0x82000000 myd_c335x.dtb
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 10.0.0.75; our IP address is 10.0.0.77
Filename 'myd_c335x.dtb'.
Load address: 0x82000000
Loading: ###
         1.1 MiB/s
done
Bytes transferred = 39284 (9974 hex)
MYIR># nand write 0x82000000 0x80000 0x9974

NAND write: device 0 offset 0x80000, size 0x9974
 39284 bytes written: OK
MYIR># tftp 0x82000000 rootfs.ubi
link up on port 0, speed 100, full duplex
Using cpsw device
TFTP from server 10.0.0.75; our IP address is 10.0.0.77
Filename 'rootfs.ubi'.
Load address: 0x82000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #
         1.3 MiB/s
done
Bytes transferred = 71565312 (4440000 hex)
MYIR># nand write 0x82000000 0xa00000 0x4440000;mtdids=nand0=nand.0 

NAND write: device 0 offset 0xa00000, size 0x4440000
 71565312 bytes written: OK
MYIR>#

至此,完成整個系統的燒寫。
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章