{"id":46,"date":"2025-06-06T18:44:27","date_gmt":"2025-06-06T18:44:27","guid":{"rendered":"https:\/\/blog.ganji.dev\/?p=46"},"modified":"2025-06-06T18:44:27","modified_gmt":"2025-06-06T18:44:27","slug":"how-to-run-fatfs-on-qemustm32","status":"publish","type":"post","link":"https:\/\/blog.ganji.dev\/?p=46","title":{"rendered":"How to run FatFS on QEMU+STM32"},"content":{"rendered":"\n<p>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 <a href=\"https:\/\/elm-chan.org\/fsw\/ff\/ffsample.zip\">here<\/a>.<\/p>\n\n\n\n<p>Next, make sure you have <code>build-essensials<\/code> installed on your machine. I am using a linux (fedora) and have the full development setup environment ready. For this setup, you also need <code>qemu-system-arm<\/code> as well.<\/p>\n\n\n\n<p>Now navigate to the correct folder:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cd ffsample\/stm32<\/code><\/pre>\n\n\n\n<p>I have noticed the QEMU can&#8217;t emulate the clock properly here, so just commenting out a bunch of lines for a way around is required. You need to modify <code>startup_stm32100.c<\/code> file and get rid of these two lines:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>while (RCCCR_HSE &amp;&amp; !(RCC_CR &amp; 0x00020000)) ;\n...\n\nwhile (!(RCC_CR &amp; 0x02000000)) ;<\/code><\/pre>\n\n\n\n<p>Then make the project:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ make<\/code><\/pre>\n\n\n\n<p>If the build is successful, it will create an obj folder which contains necessary files for running.<br><\/p>\n\n\n\n<p>Then run the QEMU:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ qemu-system-arm -M stm32vldiscovery -kernel obj\/ff_stm32.elf -serial stdio<\/code><\/pre>\n\n\n\n<p>You should see an output (on your terminal) like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"230\" height=\"87\" src=\"https:\/\/blog.ganji.dev\/wp-content\/uploads\/2025\/06\/image.png\" alt=\"\" class=\"wp-image-47\"\/><\/figure>\n\n\n\n<p>Now you can interact with your terminal, to show the available commands enter <code>?<\/code>.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-gsoc"],"_links":{"self":[{"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":1,"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ganji.dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}