binary - 如何将二进制闪存文件发送到只有串行控制台的嵌入式系统?

标签 binary console serial-port embedded-linux file-transfer

我有一个使用 ramdisk 引导的嵌入式 Linux 系统,因此它在运行时没有可用的持久存储(它有闪存来存储内核和 ramdisk)。

唯一的连接是 RS-232 串行登录控制台。所以我受限于其内置的 busybox 所提供的功能。我想找回 ramdisk,修改它,重写 ramdisk。内核没有内置的 Flash 文件系统支持。 ramdisk 分区大小约为 10 MBytes。删除用户目录下的所有文件后,可用的虚拟磁盘大小约为 14 MBytes。

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

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

我研究了以下内容,但没有一个对我有用:

  • 使用硬件流控制将二进制文件发送到串行端口的 Linux 命令?在 stackoverflow
  • 串行终端上的二进制数据 stackoverflow
  • k.japko.eu 上使用串行控制台传输文件
  • superuser.com 上通过串行线路传输文件
  • 当您只有一个串行控制台时,如何将文件发送到主机?在 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

最佳答案

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

流程应该是这样的:

  1. 在 uboot 中运行 loady enter image description here
  2. 使用teraterm发送数据 enter image description here
  3. 文件正在传输到您设备内存中的 0x01000000。

关于binary - 如何将二进制闪存文件发送到只有串行控制台的嵌入式系统?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44595089/

相关文章:

winapi - 使用 Windows 10 访问 COM 端口

serial-port - 从 arduino 到处理的多个序列值?

java - .subString 方法无法正常工作,Java

复制二进制文件 - C 编程中的源文件和目标文件

java - 如何为已运行的应用程序打开 Java 控制台?

linux - 如何从 Linux 串行端口读取

有人可以帮我解释一下银行选择寄存器的概念吗?

c++ - 将从数据库读取的数据写入二进制文件

java - 控制台输出流的类型

linux - 是否有 Linux 控制台命令行 MVC 框架?