Text file reading and writing based on QEMU file system
Create and mount virtual SD card
env/tools/fatdisk/
Create the sd folder in the ENV installation directory
and modify the parameters in fatdisk.xml, as shown in the figure below.
Use the ENV tool in this directory to input the fatdisk
generated sd.bin
file . Copy
the above figure sd.bin
to the relevant directory of the rt-thread source code, and replace the corresponding sd.bin
file, as shown in the figure below.
The source code for mounting filesystems is in qemu-vexpress-a9\applications\mnt.c
. In the actual code, the file system in the block device sd0 will be mounted to the root directory /
, and you can also make some modifications according to your needs.
#include <rtthread.h>
#ifdef RT_USING_DFS
#include <dfs_fs.h>
int mnt_init(void)
{
rt_thread_delay(RT_TICK_PER_SECOND);
if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
{
rt_kprintf("file system initialization done!\n");
}
return 0;
}
INIT_ENV_EXPORT(mnt_init);
#endif
File creation sample program writing
ENV configuration
Open ENV in this directory and
open the following directory
Open the example
After exiting, update and scons compile
test
Open the ENV input in the following directory .\qemu.bat
and the following effect will appear
Use the example to generate directories and files (the error occurred because of the original operation), and the cat will display hello world after printing!