wokwi-features icon indicating copy to clipboard operation
wokwi-features copied to clipboard

Add STM32 microcontrollers

Open ghost opened this issue 3 years ago • 27 comments
trafficstars

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

ghost avatar Jun 14 '22 15:06 ghost

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?

urish avatar Jun 14 '22 20:06 urish

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:

  • using vscode accross all embedded dev
  • support differents boards (arduino, esp32, stm32..)
  • support arduino framework for cross platforms compilation. https://docs.platformio.org/en/stable/platforms/ststm32.html

ghost avatar Jun 15 '22 08:06 ghost

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?

urish avatar Jun 15 '22 15:06 urish

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

prisar avatar Jun 20 '22 14:06 prisar

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

urish avatar Jun 21 '22 17:06 urish

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

prisar avatar Jun 21 '22 18:06 prisar

This is my first chip

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

urish avatar Jun 21 '22 19:06 urish

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

prisar avatar Jun 22 '22 04:06 prisar

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.

dzid26 avatar Apr 18 '23 21:04 dzid26

Initial STM32 support is now available!

Starting with NUCLEO-C031C6:

Supported peripherals:

  • Cortex M0+ (including SysTick, NVIC)
  • GPIO
  • USART
  • SPI
  • I2C
  • ADC
  • RCC (partial)

Missing peripherals:

  • CRC
  • DBG
  • DMA
  • EXTI
  • IWDG
  • PWR
  • RTC
  • SYSCFG
  • TIM1/3/14/16/17
  • WWDG

Documentation and new project templates coming soon!

urish avatar May 23 '23 22:05 urish

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

urish avatar May 27 '23 22:05 urish

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

urish avatar Jun 11 '23 13:06 urish

Hello,

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

mirkomatontispire avatar Aug 14 '23 12:08 mirkomatontispire

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

urish avatar Aug 14 '23 21:08 urish

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

mirkomatontispire avatar Aug 15 '23 11:08 mirkomatontispire

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

urish avatar Aug 15 '23 20:08 urish

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

brightproject avatar Sep 09 '23 06:09 brightproject

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.

urish avatar Sep 18 '23 05:09 urish

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.

brightproject avatar Sep 18 '23 13:09 brightproject

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.

urish avatar Sep 18 '23 13:09 urish

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.

brightproject avatar Sep 18 '23 13:09 brightproject

@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.

urish avatar Sep 25 '23 17:09 urish

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

Tyrn avatar Dec 05 '23 14:12 Tyrn

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.

urish avatar Dec 05 '23 19:12 urish

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

krr-hws avatar Oct 01 '24 19:10 krr-hws