I was working with microcontrollers at work, and we were using TFTP to upload the firmware. We sometimes had issues with the u-boot firmware upload — sometimes the board was unable to receive a packet. This issue was quite annoying, as when it worked, it was quite fast, and it made the development and production process much easier.
Timeout on u-boot upload. Image by Lup Yuen Lee
I think that Rust is a great language for writing system software, and to learn it, I decided to write a TFTP server daemon in Rust. I was also interested in learning more about networking, and this project was a great opportunity to learn more about it.
The TFTP Server Daemon is a TFTP server written in pure Rust. I challenged myself to not use any external libraries to gain a deeper understanding of the language. I also wanted it to be an actual production-ready server, so I based it on RFC 1350 with RFC 2347 TFTP Option Extensions. I implemented all the features that I could think of, such as:
There are also additional features that I added, such as multi-client communication, read-only mode, packet duplication, and more. I also added quality of life features, such as configuring the upload and download directories, port selection, and more. Check out the config.rs file to learn more about the configuration options.
To install and run the server, you can use the following command:
cargo install tftpd tftpd --help
Help for TFTP Server.
I’m really glad to see that the project is being used by people. I’ve received a lot of feedback and contributions, and I’m planning to add more features to the project in case someone needs them for their use case. If you have any feedback or feature requests, feel free to open an issue on the GitHub repository.