Getting Started with DUO on Ubuntu 20.04
I’ve had my DUO for over a week now and decided to start by creating a simple “Hello, World!” program. Here’s a step-by-step guide:
Environment: Ubuntu 20.04
1. Compilation Tools
The official DUO host-tools provide three types of tools. You can check your system’s compilation tool information by running a command on your DUO system:

As you can see, the official DUO system image uses the musl-gcc tool.
2. Add Toolchain to PATH
To add the toolchain from host-tools to your Ubuntu system’s PATH environment variable, modify the ~/.bashrc file. Add the following at the end of the file:
export PATH=/home/xxx/host-tools/gcc/riscv64-linux-musl-x86_64/bin:$PATH
After adding this, source the bashrc file in the terminal, and then, when you type riscv64 and press “Tab,” you should see that the GCC toolchain has been successfully installed.

You can also check if the toolchain’s path has been added by running echo $PATH.
4. Confirm Tool Installation
After making sure that the above tools are installed, you can start compiling your “Hello, World!” program.
Hello, World! Program:
#include <stdio.h>
int main() {
printf("Hello, world!\r\n");
return 0;
}
You can use CMake for compilation. Create a CMakeLists.txt file:
PROJECT(HELLO)
SET(SRC_LIST hello.c)
SET(CMAKE_SYSTEM_NAME LINUX)
SET(CMAKE_C_COMPILER riscv64-unknown-linux-musl-gcc)
SET(CMAKE_CXX_COMPILER riscv64-unknown-linux-musl-g++)
ADD_EXECUTABLE(hello ${SRC_LIST})
Then, execute cmake . to generate the Makefile, and use make to compile and generate the hello executable.
Copy the hello program to DUO using scp hello root@192.168.42.1:/root/. You can run ./hello to see the result.

Note: Since this program uses dynamic linking, you need to copy the dynamic linking library (.so files) to DUO’s lib folder in addition to the hello file. Otherwise, you may encounter a “not found” error. To find out which library you need, you can use the file command.
![]()
In this case, the hello program requires ld-musl-riscv64xthead.so.1, which can be found in the host-tools directory. Copy it to DUO’s lib folder.
With these steps, you have successfully compiled a simple “Hello, World!” program.
FTP Server with vsftpd
You can compile vsftpd to turn DUO into an FTP server for easier file transfers. Here’s the process:
1. Modify Makefile:

Modify the cross-compile toolchain and linking parameters, as shown in the image above.
2. Deal with Compilation Errors
When compiling with the musl toolchain, you might need to add the following definition:
#define WTMPX_FILE "/var/log/wtmp"
3. Compile vsftpd:
Execute make, and if successful, it will generate vsftpd and vsftpd.conf files.

4. Copy Files to DUO:
Use the scp command to copy the vsftpd and vsftpd.conf files to DUO. Place vsftpd in /usr/sbin/ and vsftpd.conf in /etc/.
5. Configure vsftpd.conf:
Customize the vsftpd.conf file based on your requirements. You can find configuration guides online.
6. Start vsftpd:
Reboot DUO, and then execute vsftpd & to run the server in the background. You can also set it to start automatically.
7. Use FileZilla:
Run FileZilla, input the relevant parameters, and connect to the FTP server.

Now, you can easily use an FTP client to transfer files.