Is there an up-to-date uTVM code that I can refer to?

Hi, all. I am trying out MicroTVM by running code under tests/micro/ However, the code does not run and gets the following error at the import: ImportError: cannot import name 'create_micro_mod' from 'tvm.micro' I tried searching create_mocro_mod inside the entire TVM repo but couldn’t find where that function is defined, so I wonder if the code is outdated. If so, is there any up-to-date reference code that I can look at?

I also looked at this:, which runs okay, but it actually does not flash to a real device. I am not sure by only looking at this example how I can actually flash code to my STM32 board. Can someone point me to an up-to-date equivalent of tests/micro/, or let me know if there is a simple fix to make it run?

Thank you, Best regards, Kiwan

1 Like

hi @kwmaeng,

apologies, we’re just finishing transitioning to a new runtime. it’s not quite a tutorial, but you might have a look at this PR (specifically, the end-to-end test), which does exercise the new runtime on-device. I’ve tested that with an STM32 Nucleo-F746ZG board locally and that seems to work fine.

I will publish a revised tutorial soon–until then, let me know if i can give you any more pointers.



Thank you for your reply! I looked at the code and it seems like it is now using Zephyr compiler to build a runtime for the MCU. Do I need to set up Zephyr for my environment and if so, are there any instructions for that? Or is it somehow already contained in TVM so I can just run the python script? (I just tried running the script but it gave me an error saying environment variable ZEPHYR_BASE was not set).

I tried looking into your PR (frankly, which I am not familar in doing), and tried to trace your code but it seems like the base-box folder is not there anymore, so I am a bit lost. If you can help me figuring out the high level workflow on how to make it work, it would be really helpful (e.g., do I have to set up Zephyr? Can I run without it or is it now an essential part of microTVM?).

Thank you!

hi @kwmaeng,

unfortunately that PR isn’t quite merged yet. you can try it out by fetching it:

$ git fetch utvm-vm
$ git checkout utvm-vm

then you should see an apps/microtvm-vm directory in your git repository.

µTVM can be used without Zephyr, but that example test uses Zephyr, so it’s easiest to start with that. you do need to either install Zephyr 2.4.0 or use the Virtual Machine included with that PR (it has all you need pre-installed). may I ask which RTOS or environment you want to use?

to get started with the Virtual Machine, install Vagrant, VirtualBox, and the VirtualBox Extension Pack. then:

$ cd apps/microtvm-vm/vm
$ vagrant up --provider=virtualbox

this will download the VM and build your local branch of TVM inside. you should then be able to execute the test using the command from the PR:

$ ssh tvm@microtvm
Password: tvm
$ cd /Users/kwmaeng/path/to/tvm
$ TVM_LIBRARY_PATH=build-microtvm poetry run python3 tests/micro/qemu/ --microtvm-platforms=stm32f746xx -s

make sure you’ve connected your local dev board to the VM using the VirtualBox UI.

I think we’ll need to post a more detailed tutorial with these steps once my PR is merged. if you prefer to wait for that, I can ping this thread when it’s ready.


1 Like

Thank you for your detailed comments! I will start with the VM and see how it goes. To answer your question, I am using STM32F7508-DK dev board. Mostly stm32f750 is compatible with stm32f746 so I think I have a good chance. I don’t use any RTOS and planning to run on bare-metal. Does current uTVM assume an OS?

Thank you, Best regards, Kiwan

great, let me know if you run into trouble. µTVM doesn’t assume an OS–you just need to implement TVMPlatform functions. Note that a couple will be added as we merge the AutoTVM functionality (next PR after this one).

we don’t have anything checked-in that runs models standalone right now, so you’ll need to either

  1. use the µTVM RPC server to drive model execution at the graph level (this is what test_zephyr does). this means you’ll need to implement functionality to send and receive data using the UART, as is done in the main used with Zephyr.
  2. port apps/bundle_deploy to run on µC. see this discuss thread for more.

we hope to have a better story on standalone execution soon.


1 Like

Any updates on this? I looked at the repo today (I was away for something else) and it seems the repo has changed quite a bit and your previous instructions does not work anymore?


hi @kwmaeng,

I gave a tutorial at TVMconf demoing these two approaches. There are still some significant limitations of approach #2 mentioned above–particularly around memory usage. I’m working to address those.

Code for the tutorial, plus instructions on how to replicate it, is at

Let me know if you’re able to get it running!


Dear Andrew. This is an old thread, but I finally managed my time to try uTVM out. I am following GitHub - areusch/microtvm-blogpost-eval and set up zephyr-2.5 VM. However, I cannot log in to the VM both with/without SSH. Because the SSH with Vagrant was not working, I manually tried turning on the VM (with Virtualbox GUI) and logging in using the ID and PW you gave me earlier: tvm/tvm. It says invalid login. What is the ID/PW for the generated VM?

Thank you, Best regards, Kiwan


hey Kiwan,

Seems like if the VM was off, you need to run vagrant up to turn it on and provision it. I’d suggest first destroying the VM with vagrant destroy, then following the microTVM Reference VM tutorial again.

Since we’ve merged that PR, the username/password now follows the vagrant convention (I believe ubuntu/vagrant, but vagrant ssh should take care of these details for you).


Never mind. It was vagrant/vagrant, I guess which is the default. I am trying to do ssh which is failing, but I’ll try more.

Hi, Andrew. I can now log in with the default ID/PW like I said above, but my vagrant ssh is not working properly. I am using WSL2, and with some searching I think this is the main problem. Instead of trying to fix my WSL2+Vagrant problem, since I now have a VM generated by Vagrant. Will it work the same if I just clone the TVM/blogpost-eval repo inside the VM (currently, it only has a few Zephyr files) and run the rest of the steps from here?: GitHub - areusch/microtvm-blogpost-eval

If so, where should I put tvm / blogpost-eval repo inside the VM? I don’t fully understand what it would have been like if the Vagrant up process + ssh was entirely successful, so if you can hint me with some workaround it would be great.

Thank you, Best regards, Kiwan Maeng

hi @kwmaeng,

could you try running apps/microtvm/reference-vm/zephyr/ inside your VM? that should ensure that all of the provision steps ran by vagrant up are executed.

btw, I haven’t used WSL2 before, but I think there may be an issue using WSL2 to communicate with usb devices. I’m not sure it would make too much sense to continue to push on this direction (would suggest using Virtualbox) if it can’t communicate with USB-Serial or J-Link devices.


[EDIT] This is fixed. No need to look into this. Though, I leave this for any future reference.

Thank you for the help. Though I thought the device must be connected to the VM itself, not the host (which is WSL2). Isn’t it the case?

I have successfully connected the device USB to the VM. Currently, the VM runs outside WSL2. WSL2 can talk to the Virtualbox running outside WSL2 with a proper setup.

However, running segfaults while trying to build TVM. I have no idea why this is the case because the VM is provided by your Vagrant cloud and I didn’t modify anything. If the build was segfaulting on my machine I would be suspicious about the compiler version etc., but I’m using your VM so I am clueless.

Do you have any suggestion on why it may be segfaulting? Does it have any possible dependency with my host Windows/WSL? I thought everything that is running inside the VM is self-contained (e.g., compiler, etc).

I posted the log in a separate post:

Thank you for your help.

Dear Andrew,

Is the current microtvm-blogpost-eval repo supposed to work with the latest TVM repo? If not, can you tell me the commit of TVM that microtvm-blogpost-eval master would work with? I am seeing several issues, that seems like an incompatible TVM version issue, including: AttributeError: module ‘’ has no attribute ‘_CRT_GENERATED_LIB_OPTIONS’ Also, there’s many deprecated warnings.

Thank you, Best regards, Kiwan

hi Kiwan,

Let me have a look at this and I’ll reply back here when I have an answer. I think this has happened a few times, and µTVM is under a lot of development right now. I have some updates to push to this repo, I’ll try to pin microtvm-blogpost-eval to a TVM revision via submodule first.



You’re right, that repo is busted at master. I made several fixes, which you could test if you like:

  1. pull this branch of microtvm-blogpost-eval: GitHub - areusch/microtvm-blogpost-eval at pin-tvm-repo
  2. git submodule update --init --recursive
  3. cherry-pick PR 7854 and PR 7853
  4. launch the reference VM with tools/ (you may need to adapt these steps to WSL2).

After the two PRs land, I will merge pin-tvm-repo to master.


Dear Andrew. Thank you for the fix!

This almost works, except it is not flashing properly. After flashing, checksum mismatch occurs. It says “Warn : no flash bank found for address 0x08010000”, I think might be the source of the problem.

I want to fix it by looking at the flash command, but cannot locate it (e.g., I used to flash to 0x08000000 instead of 0x08010000, which might not be relevant, but…). Can you help me understand which part of the repo sets such flash-related configs? (I used to have a file called stm32f746g_disco.cfg or so for my prior experience with STM32F board. I wonder if there is something similar in the current setup)

Thank you for your help! I think I am already there. Best regards, Kiwan

Hi Kiwan,

Ah, I’m testing on the STM32F746-Nucleo board. Did you adjust the zephyr_board option (or provide the equivalent command-line flag) in microtvm-blogpost-eval scripts?


Oops, sorry. I was connected to a wrong board (I have several boards attached to my system and it was flashing to a wrong one). Now it is finally working!! Thank you so much for your help!

Is there a way for me to try out autotuning on the current branch, or is it broken at this point? Thanks for your help.