Sepehr's Blog

A place to begin

How to run FatFS on QEMU+STM32

In this post I want to share my experience on running FatFS on STM32 using QEMU. First we need to obtain the FatFS sample projects from here.

Next, make sure you have build-essensials installed on your machine. I am using a linux (fedora) and have the full development setup environment ready. For this setup, you also need qemu-system-arm as well.

Now navigate to the correct folder:

$ cd ffsample/stm32

I have noticed the QEMU can’t emulate the clock properly here, so just commenting out a bunch of lines for a way around is required. You need to modify startup_stm32100.c file and get rid of these two lines:

while (RCCCR_HSE && !(RCC_CR & 0x00020000)) ;
...

while (!(RCC_CR & 0x02000000)) ;

Then make the project:

$ make

If the build is successful, it will create an obj folder which contains necessary files for running.

Then run the QEMU:

$ qemu-system-arm -M stm32vldiscovery -kernel obj/ff_stm32.elf -serial stdio

You should see an output (on your terminal) like this:

Now you can interact with your terminal, to show the available commands enter ?.