2017-06-16 64 views
2

我有一个使用ramdisk启动的嵌入式Linux系统,所以它的运行时间没有可用的持久存储空间(它有Flash来存储内核和ramdisk)。如何使用串行控制台将二进制闪存文件发送到嵌入式系统?

唯一的连接是RS-232串行登录控制台。所以我受限于其内置的busybox提供的内容。我想检索虚拟盘,修改它,然后重写虚拟盘。内核没有内置的Flash文件系统支持。 ramdisk分区大小约为10 MB。当删除用户目录中的所有文件时,免费ramdisk大小约为14 MB。

命令dd可用,因此我可以将ramdisk分区复制到ramdisk,并且可以从ramdisk文件写入闪存。 flashcp也可用。

所以我的问题是现在如何通过RS-232串行控制台接收和发送二进制文件?

我研究以下内容并没有对我来说是非常有用的:

  • Linux命令二进制文件发送到串行端口硬件流控制?上stackoverflow
  • superuser.com
  • k.japko.eu
  • 文件传输传输使用串行控制台文件通过串口线如何获得文件到一个主机通过串行终端stackoverflow
  • 二进制数据时,你已经是一个串行安慰? on stackexchange

主要是因为x/y/zmodem在busybox中不可用。

有什么想法?谢谢!

根据要求,这里是我应该包括在第一位。

可用的u-boot命令:

U-Boot >? 
?  - alias for 'help' 
askenv - get environment variables from stdin 
base - print or set address offset 
bdinfo - print Board Info structure 
boot - boot default, i.e., run 'bootcmd' 
bootd - boot default, i.e., run 'bootcmd' 
bootm - boot application image from memory 
cmp  - memory compare 
coninfo - print console devices and information 
cp  - memory copy 
crc32 - checksum calculation 
crc32_chk_uimage- checksum calculation of an image for u-boot 
echo - echo args to console 
editenv - edit environment variable 
env  - environment handling commands 
exit - exit script 
false - do nothing, unsuccessfully 
fatinfo - print information about filesystem 
fatload - load binary file from a dos filesystem 
fatls - list files in a directory (default /) 
fatwrite- write file into a dos filesystem 
go  - start application at address 'addr' 
gpio - input/set/clear/toggle gpio pins 
help - print command description/usage 
i2c  - I2C sub-system 
iminfo - print header information for application image 
imxtract- extract a part of a multi-image 
itest - return true/false on integer compare 
loadb - load binary file over serial line (kermit mode) 
loads - load S-Record file over serial line 
loady - load binary file over serial line (ymodem mode) 
loop - infinite loop on address range 
md  - memory display 
mdc  - memory display cyclic 
mm  - memory modify (auto-incrementing address) 
mw  - memory write (fill) 
mwc  - memory write cyclic 
nm  - memory modify (constant address) 
printenv- print environment variables 
reset - Perform RESET of the CPU 
run  - run commands in an environment variable 
saveenv - save environment variables to persistent storage 
saves - save S-Record file over serial line 
setenv - set environment variables 
sf  - SPI flash sub-system 
showvar - print local hushshell variables 
sleep - delay execution for some time 
source - run script from memory 
sspi - SPI utility command 
test - minimal test like /bin/sh 
true - do nothing, successfully 
usb  - USB sub-system 
usbboot - boot from USB device 
version - print monitor, compiler and linker version 
U-Boot > 

可用busybox的命令:

BusyBox v1.13.2 (2015-03-16 10:50:56 EDT) multi-call binary 
Copyright (C) 1998-2008 Erik Andersen, Rob Landley, Denys Vlasenko 
and others. Licensed under GPLv2. 
See source distribution for full notice. 

Usage: busybox [function] [arguments]... 
    or: function [arguments]... 

     BusyBox is a multi-call binary that combines many common Unix 
     utilities into a single executable. Most people will create a 
     link to busybox for each function they wish to use and BusyBox 
     will act like whatever it was invoked as! 

Currently defined functions: 
     [, [[, addgroup, adduser, ar, ash, awk, basename, blkid, 
     bunzip2, bzcat, cat, chattr, chgrp, chmod, chown, chpasswd, 
     chroot, chvt, clear, cmp, cp, cpio, cryptpw, cut, date, 
     dc, dd, deallocvt, delgroup, deluser, df, dhcprelay, diff, 
     dirname, dmesg, du, dumpkmap, dumpleases, echo, egrep, env, 
     expr, false, fbset, fbsplash, fdisk, fgrep, find, free, 
     freeramdisk, fsck, fsck.minix, fuser, getopt, getty, grep, 
     gunzip, gzip, halt, head, hexdump, hostname, httpd, hwclock, 
     id, ifconfig, ifdown, ifup, inetd, init, insmod, ip, kill, 
     killall, klogd, last, less, linuxrc, ln, loadfont, loadkmap, 
     logger, login, logname, logread, losetup, ls, lsmod, makedevs, 
     md5sum, mdev, microcom, mkdir, mkfifo, mkfs.minix, mknod, 
     mkswap, mktemp, modprobe, more, mount, mv, nc, netstat, 
     nice, nohup, nslookup, od, openvt, passwd, patch, pidof, 
     ping, ping6, pivot_root, poweroff, printf, ps, pwd, rdate, 
     rdev, readahead, readlink, readprofile, realpath, reboot, 
     renice, reset, rm, rmdir, rmmod, route, rtcwake, run-parts, 
     sed, seq, setconsole, setfont, sh, showkey, sleep, sort, 
     start-stop-daemon, strings, stty, su, sulogin, swapoff, 
     swapon, switch_root, sync, sysctl, syslogd, tail, tar, tcpsvd, 
     tee, telnet, telnetd, test, tftp, tftpd, time, top, touch, 
     tr, traceroute, true, tty, udhcpc, udhcpd, udpsvd, umount, 
     uname, uniq, unzip, uptime, usleep, vconfig, vi, vlock, 
     watch, wc, wget, which, who, whoami, xargs, yes, zcat 
+0

*“主要是因为x/y/zmodem在busybox中不可用。”* - 不是负面描述,而是让我们玩20个问题的游戏,请发布可用的Busybox命令。你用U-Boot开机?如果是,则列出其可用命令。 – sawdust

+0

*“唯一的连接是RS-232”* - 要说清楚,你声称没有USB,没有MMC或SD卡,没有以太网?如果SBC无法从闪存启动,那么如何恢复? IOW是否有备用的引导方式? – sawdust

+0

那么,以及将'rz' /'sz'添加到busybox有什么问题?只需在Busybox的配置文件中启用它即可。 – 0andriy

回答

0

独立我找到了一种方法,通过在Linux控制台上传二进制文件和我会在这里文件的步骤因为我很难在网上查找这些信息,所以其他人会发现它很有用。

以下是理论:将控制台模式更改为raw,以便所有的二进制流量都不被解释为控制台命令,例如,按Ctrl-C。关闭回声,以免增加额外的串行流量。运行tar接受stdin的输入。由于ctrl-C不能工作,并且tar不知道何时终止,所以使用后台任务来终止登录shell,这样你就可以再次登录来完成你的工作。

步骤:

  1. 创建一个脚本在后台运行。更改myvar变量,以便在传输完成后终止登录shell。目前120对应于1200秒,足够用于10兆字节的文件。另外编辑808,以配合您的登录shell PID:

创建BG文件:

myvar=120 
while [ $myvar -gt 0 ] 
do 
    myvar=$(($myvar-1)) 
    echo -e " $myvar \n" 
    ls -l 
    sleep 10 
done 
kill -9 808 
  • 在后台启动脚本:
  • 在控制台类型:

    source ./bg & 
    
  • 使用的stty改变控制台原始模式和在控制台类型不回声
  • stty raw -echo 
    
  • 开始焦油到解压缩标准输入。注:我不得不用ctrl-J因为在控制台类型stty命令
  • 后不再工作并与CTRL-j中结束,而不是:

    tar zx -f - 1> 1.log 2> 2.log 
    
  • 开始Teraterm发送二进制文件

  • 等待完成和新的登录提示

  • 2

    在uboot中,您可以使用loady/loadx通过uart从pc获取文件。我通常使用teraterm发送文件。

    的过程应该是这样的:

    1. 在uboot的运行loady enter image description here
    2. 使用teraterm发送数据 enter image description here
    3. 的文件转移到位于为0x01000000您设备的内存中。
    相关问题