wokwi / wokwi-features

Wokwi Feature requests & Bug Reports
https://wokwi.com
72 stars 17 forks source link

Add STM32 microcontrollers #363

Open ghost opened 2 years ago

ghost commented 2 years ago

I suggest adding stm32 support on wokwi to reach more embedded systems developers. Thanks!

urish commented 2 years ago

Thanks for the feedback! Are you using the STM32 yourself? Can you describe which board / MCU are you working with and what development tools are you using?

ghost commented 2 years ago

hi Uri, yes we used stm32 NUCLEO-F401RE before. we used cubeMx back in 2019 but now rather with platformio extension since it offers more features like:

urish commented 2 years ago

Thanks for the details!

I opened this request for voting.

Do you happen this have an example project with platform io + STM32 that you'd like to be able to simulate on Wokwi?

prisar commented 2 years ago

adding STM32F103C8T6 would be good for me. I am using this mcu

urish commented 2 years ago

Thanks for the feedback, @prisar. What project(s) are you using the STM32F103 for ?

prisar commented 2 years ago

Not any specific project yet. This is my first chip. I'm using it to learn. Started with things like LED blinking, programming various pins

urish commented 2 years ago

This is my first chip

Good luck in your journey! What makes this specific chip appealing for you as a first chip for learning?

prisar commented 2 years ago

Thank you for providing such a convenient platform to experiment various projects online.

What makes this specific chip appealing for you as a first chip for learning?

I wanted to start with an arm microprocessor because I'm thinking of using some in my future projects. And, it has ARM Cortex-M3. So, I decided to tinker STM32F103

dzid26 commented 1 year ago

Thank you for providing such a convenient platform to experiment various projects online.

What makes this specific chip appealing for you as a first chip for learning?

I wanted to start with an arm microprocessor because I'm thinking of using some in my future projects. And, it has ARM Cortex-M3. So, I decided to tinker STM32F103

I saw this: https://wokwi.com/projects/334824244586218068 But when I upload my binary I get 2% performance and ports aren't set according to my settings, and instead they stay the same as in the demo.

image

EDIT: Finally, I made it work by making sure the crystal frequency was 8Mhz, as in blue pill. At least that's what I thought. Because then I reverted back to 16Mhz, and it still works. Wtf.

urish commented 1 year ago

Initial STM32 support is now available!

Starting with NUCLEO-C031C6:

Supported peripherals:

Missing peripherals:

Documentation and new project templates coming soon!

urish commented 1 year ago

Initial docs for the new Nucleo-C031C6 board: https://docs.wokwi.com/parts/board-st-nucleo-c031c6

urish commented 1 year ago

Nucleo-L031K6 is now available too: https://docs.wokwi.com/parts/board-st-nucleo-l031k6

mirkomatontispire commented 1 year ago

Hello,

would it be possible to extend support to other STM32 families like L45X or L4X

urish commented 1 year ago

L432KC is available is early alpha: https://wokwi.com/projects/364373191510788097

mirkomatontispire commented 1 year ago

Do you offer paid support/sdk in case we'd like to add custom support to specific boards?

urish commented 1 year ago

This is definitely something we can discuss. What's your use case? (we can also discuss over email, if you prefer)

brightproject commented 1 year ago

@urish Is it possible to add a blue (stm32f103) and black (stm32f401) pill to the project?

urish commented 1 year ago

stm32f103 is already partially implemented: https://wokwi.com/projects/334824244586218068

If we see a good business case, we might add the black pill as well.

brightproject commented 1 year ago

If we see a good business case, we might add the black pill as well.

As far as I understand, it is not possible to achieve at least approximate speeds for performing certain operations and simulating SRAM memory from a simulator? I thought that changing ESP32 modules changes the execution time of programs on them, but there is no change. Therefore, adding a black pill in addition to the blue pill is probably pointless.

urish commented 1 year ago

As far as I understand, it is not possible to achieve at least approximate speeds for performing certain operations and simulating SRAM memory from a simulator?

It really depends - some things simulate fast, some things simulate slower. There are also certain optimizations that we can employ for certain use cases. Unfortunately, simulation is not a one-size-fits-all solution: there's always a tradeoff between speed, accuracy and complexity.

brightproject commented 1 year ago

As far as I understand, it is not possible to achieve at least approximate speeds for performing certain operations and simulating SRAM memory from a simulator?

It really depends - some things simulate fast, some things simulate slower. There are also certain optimizations that we can employ for certain use cases. Unfortunately, simulation is not a one-size-fits-all solution: there's always a tradeoff between speed, accuracy and complexity.

I would like to simulate some things for esp32 and stm32 at at least 1/4 of the real speed. But in fact, I get a simulation on ESP32 at a speed 10 times lower than on a real STM32. For example, the project in the simulator is “executed” on ESP32 at a very low speed. But on a real stm32 it works great with fps of about 16.

urish commented 1 year ago

@brightproject I looked into the project, and done some initial experimentation.

It seems like there are two ways to considerably speed up the simulation:

  1. Skip the full SPI protocol emulation in your project - I assume it'll give us x2 speedup
  2. Use DMA for SPI transactions - I anticipate another speed-up, but it's hard to know how much without trying.

The first item is a kind of optimization that we have to make available in the simulation engine. Instead of transmitting one bit at a time, we will just transmit whole bytes between the simulated MCU and the ILI9341 module.

The second one is something that has to be done in the code that runs in the simulator. Your code currently uses the CPU to write SPI data directly, byte by byte. Using DMA enables to write larger buffers, so it is likely to generate additional speed up.

Tyrn commented 10 months ago

But how can I start a project based on the Blue Pill? The dropdown menus don't offer it.

urish commented 10 months ago

But how can I start a project based on the Blue Pill? The dropdown menus don't offer it.

Blue Pill is not officially supported at the moment. You can try to copy from an existing project, but YMMV.

krr-hws commented 5 days ago

Many thanks to the developer of the STM32-devices :) . Is it planned to implement support for hardware timer e.g. TIM1 and TIM3 ?