Replies: 28 comments 5 replies
-
Hi @fariouche, congratulations for the great job! I compiled your fork with the configure below and it worked 99% (apparently only the ADC converter is not working)
My PR took more than years to be accepted on qemu stm32, apparently the project is stalled. I'm not very familiar with the inner workings of qemu, currently I don't find the integration with PICSimLab satisfactory. The performance is pretty bad and it usually crashes a lot. If you have this kind of knowledge and are available, we can try to improve it. As qemu stm32 support in PICSimLab didn't work entirely as I wanted, qemu stm32 is not under active development and my time is short, I prioritized other parts of the simulator. I've also thought about integrating qemu-esp32 into PICSimLab, but as it still doesn't support WIFI, which is the main peripheral, and with the low performance already mentioned, I haven't been interested yet. But it shouldn't be more complex than the integration of qemu-stm32. |
Beta Was this translation helpful? Give feedback.
-
Hum, strange. I have the adc working as it was one of the peripheral I wanted. About esp32, I have found a qemu fork with wifi and bluetooth support. However, it is using a stub static library to replace the esp32's one. Didn't had time to look at it yet. |
Beta Was this translation helpful? Give feedback.
-
I tested using an example that reads the adc and writes to the serial using the arduino stm32 support. It didn't work because I hadn't committed the change to github, so your code doesn't have the changes. Without them the analogRead function always returns 0. (Apparently there is some ADC mode with incomplete implementation in qemu-stm32 ) https://github.com/lcgamboa/qemu_stm32/commit/6aa558cb1a898d8e9f84533f3bdf1ebd6edad0e0 The stm32 arduino uses the peripheral DWT (Data watchpoint trigger) to implement the micros() function, as it is not implemented in qemu-stm32 several libraries do not work without changing the code. PICSimLab's integration with qemu stm32 works well with synchronous signals. Asynchronous signals or signals that need exact timing don't work (like the stepper motor for example), this is a problem to be solved. How has your experience been using zephyr with PICSimLab + qemu-stm32? As for the implementation of ESP32 support, I believe we will have the same problem with the synchronism of qemu-stm32 signals. It would be interesting to solve this problem, but on the part of qemu I don't have enough knowledge to implement it and I don't have time to study it for a while. |
Beta Was this translation helpful? Give feedback.
-
I will have a look at the modifications. About zephyr, For now I only test blinky test app. So task scheduling is now working (was crashing before), GPIO and uart are also working. Didn't test much more than that yet as I would like to focus on ESP32 first. |
Beta Was this translation helpful? Give feedback.
-
In this link there is an example of code that uses the DWT to generate delays: STM32 Delay Microsecond Millisecond Utility | DWT Delay & Timer Delay What is your goal in focusing on the ESP32 simulation? |
Beta Was this translation helpful? Give feedback.
-
I've found a number of issues using the arduino stm32 adc example. For the esp32, to be honest, I didn't find any better program than picsimlab. Easy to use, user friendly, with a scope and ability to check all pin and manipulate them! A lot of applications exists with the esp32, and they are easy to program and work with. |
Beta Was this translation helpful? Give feedback.
-
I agree that my patch is not an efficient solution. I'm not very familiar with low-level stm32 hardware, but the arduino example works on real hardware, so there's something missing in the qemu-stm32 ADC implementation. The key to using qemu with PICSimLab would be the sync between instructions and hardware. PICSimLab executes an instruction and updates the hardware. I couldn't find a way to run qemu-stm32 instruction by instruction (and compile it as a library). Do you know if this is possible? Another project called unicorn implements just that, but without the hardware part (and without support for esp32 and gdb). |
Beta Was this translation helpful? Give feedback.
-
So, I fixed the adc with what I believe is a correct fix regarding the HW datasheet. As for your question, I'm not sure I understand. I've looked at unicorn, and it seems like they have rewritten all the qemu makefiles. I don't know of a way to compile qemu as a library, but I'm no expert :) |
Beta Was this translation helpful? Give feedback.
-
I tested it here and it worked without problems. I will update the PICSimLab scripts to use your fork which is more up to date. Do you intend to continue making improvements to qemu-stm32? Or do you intend to focus on the integration of qemu-esp32? The PICSimLab uses several simulators libraries that have functions that execute one instruction at a time: PICsim has the pic_step(), simavr the avr_run() and ucSim the ucsim_step() . |
Beta Was this translation helpful? Give feedback.
-
Ok, I'm starting to understand. But why do picsimlab need exact timings? Is it because you can connect to real hardware? One possible optimizations I see is to avoid the sockets and use shared memories instead. You will then have close to a library performance. But there is no portable implementation (maybe by using a third-party helper library?) |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
it's so nice to see everything moving with good looking animations 😍 Now I see where come from the real time constraints. They are from the simulated parts. At least now I see how to reproduce the issue so that I can try to have a look at it. I hope that qemu timers will not be the limiting factor. |
Beta Was this translation helpful? Give feedback.
-
Hi @fariouche , I found this gist Build qemu as a library and with some modifications I was able to create a library with your fork of qemu-stm32. It will make possible to remove socket communication with PICSimLab. When I have time I will implement and test it. Now only the part of synchronism of the execution of the instructions with the update of the IO is missing. Modified unicorn_but_worse.sh script:
|
Beta Was this translation helpful? Give feedback.
-
Interesting! |
Beta Was this translation helpful? Give feedback.
-
I modified PICSimLab to work with the qemu-stm32 library. It was much faster because it doesn't use sockets (and doesn't crash like the previous one), but it doesn't work with the official version of PICSimLab yet. The official version uses wxwidgets, which on Linux uses gtk/glib which conflicts with qemu main_loop (glib). The X11 and SDL2 version works without problems, I haven't tested it on the windows version that uses wxwidgets, but it should work because it doesn't use glib. I'm not very familiar with glib, I'll try to solve the problem. If anyone is familiar with using glib and wants to help feel free to get in touch. |
Beta Was this translation helpful? Give feedback.
-
Love it! |
Beta Was this translation helpful? Give feedback.
-
I solved the incompatibility problem with wxwidgets. |
Beta Was this translation helpful? Give feedback.
-
Hi @fariouche I have updated PICSimLab to use your new version of qemu-stm32. The upcoming stable release 0.8.10 will use your version of qemu-stm32 still with sockets. The version using the library without sockets will need a lot of improvements and will be left for another future version. |
Beta Was this translation helpful? Give feedback.
-
@fariouche the RTC code example https://github.com/beckus/stm32_p103_demos/tree/master/demos/rtc fail in your qemu_stm32 fork with message:
Binary image in attachment. |
Beta Was this translation helpful? Give feedback.
-
After thinking a lot I managed to solve (almost totally) the problem of IO synchronization between PICSimLab and qemu_stm32. Using the |
Beta Was this translation helpful? Give feedback.
-
Configuring the systick to change a pin every second in qemu-stm32 and measuring with the function qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) the pulse value is always
Using shift with value 5 is the closest to the correct value of one second. |
Beta Was this translation helpful? Give feedback.
-
@fariouche this commit https://github.com/lcgamboa/qemu_stm32/commit/6a8fb3d576b7500f8ea1d16cd6964d6e1ea784c1 fix the systick bug in clock tree. Least one problem. |
Beta Was this translation helpful? Give feedback.
-
This fork of esp32 qemu has support to wifi and a easy mode to test . When I have time I'll try to merge it in the same library as qemu-stm32. |
Beta Was this translation helpful? Give feedback.
-
Hi @fariouche ,
I will provide binaries soon. I tested it on Windows and the only thing that still didn't work was to uploud the esp32 directly from the Arduino IDE (using esptool.py ), on Linux it works without problems. |
Beta Was this translation helpful? Give feedback.
-
Wow! Good job! I will test it as soon as possible :) |
Beta Was this translation helpful? Give feedback.
-
Hi @fariouche , the binaries are already available in the Latest code build release. Serial flash programming is now working on Windows as well (requires com0com). I tested ESP32 support with some simple Arduino, IDF and Zephyr programs and it worked without any issues. It was nice to use because it can be programmed directly by the development tools like a real board (using |
Beta Was this translation helpful? Give feedback.
-
wow, great job! I wish I had some free time, but these days my job is taking me too much time :( |
Beta Was this translation helpful? Give feedback.
-
Now, await esp32s3 support (WiP) |
Beta Was this translation helpful? Give feedback.
-
Hello,
This is not really a bug, but a feature request maybe: The qemu stm32 is too old, and projects using zephyr are crashing the emulator.
So I've created a branch and ported the stm32 machines to the latest qemu. You can give it a try in my fork, branch is picsimlab :)
i don't know when the maintainer of the stm32 port of qemu will do the merge.
I would like to add esp32 support too. but this is an other story.
Beta Was this translation helpful? Give feedback.
All reactions