1. Introduction
In previous articles, we developed applications that were embedded into the kernel within initramfs. Each time we needed to change the application, recompiling the kernel was cumbersome. Now, we will port lrzsz to enable file import and export via the serial port, making it easier to update applications by importing them into the RAM file system through the serial port, although this will not persist after power loss. In the future, we can add FLASH drivers to mount the FLASH file system and store programs in FLASH.
PS: After reaching a certain progress in subsequent articles, we will consider releasing a matching development board. Follow our public account and like/share to receive discounts when the board is available. In the meantime, feel free to check out my personal shop on Xianyu, where there are many brand new, cost-effective development boards.Xianyu ID: tbNick_r2v35. Followers of the public account who purchase any development board can enjoy a 10% discount.
2. Process
lrzsz is an open-source x/y/z modem implementation under Unix, see https://ohse.de/uwe/software/lrzsz.html.
We enter the working directory
cd ~/linux/src
Download the source code
wget https://ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz
Extract the source code
tar -xvf lrzsz-0.12.20.tar.gzcd lrzsz-0.12.20/
Configure
CFLAGS="-Os -static" CC=arm-buildroot-uclinux-uclibcgnueabi-gcc ./configure
Compile
make
An error occurred
error.c:(.text+0x0): multiple definition of `error'
Modify error.c
Add conditional compilation
#if HAVE_STRERROR==0#endif


The compiled programs are located in src as lrz, lsz
qinyunti@qinyunti:~/linux/src/lrzsz-0.12.20$ ls src/lrz -al-rwxr--r-- 1 qinyunti qinyunti 116048 May 20 22:30 src/lrzqinyunti@qinyunti:~/linux/src/lrzsz-0.12.20$ ls src/lsz -al-rwxr--r-- 1 qinyunti qinyunti 115896 May 20 22:30 src/lszqinyunti@qinyunti:~/linux/src/lrzsz-0.12.20$
According to the previous article, add lrz to initramfs. Rebuild the kernel and flash it.
3. Testing
Due to space limitations, we only included lrz in the kernel.
So we first use lrz to import lsz
chmod +x ~/linux/src/lrzsz-0.12.20/src/lszcp ~/linux/src/lrzsz-0.12.20/src/lsz /mnt/d
Here, the host computer uses SecureCRT
In the shell, type lrz, a file selection dialog will pop up to select lsz

Import completed as shown below

Next, we test using lsz to export
chmod +x lsz./lsz bin/lrz

Export location as shown below

We can see that we can now import and export files using lrz, lsz. Since the internal FLASH is only 2M, we should embed as few things in the kernel as possible, only embedding lrz. The remaining RAM has over 4M.

So after booting, we can import files into the RAM file system using lrz.
Here, after using lsz, the terminal will hang; we will address this issue later.
4. Conclusion
We have successfully ported lrzsz and implemented file import and export functionality. With larger RAM, importing files into RAM is more convenient. In the future, we can test programs without modifying the kernel, making development and testing easier.