You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在qemu-stm32运行stm32_p103_demos后,如何模拟按键按下?

How to Simulate Button Presses in qemu-stm32 for stm32_p103_demos

Got it, let's work through how to simulate button presses when running the stm32_p103_demos on qemu-stm32. I’ve tinkered with this setup before, so here’s a straightforward way to get it working:

Step 1: Identify the Button’s GPIO Pin

First, check your button demo code to find which GPIO pin the button is mapped to. For most stm32_p103 button examples, this is typically PA0—but double-check the code’s pin definition to be sure (look for lines like GPIO_PIN_0 or similar).

Step 2: Access the QEMU Monitor

When you launch qemu-stm32, you can switch to its built-in monitor to send hardware control commands:

  • Press Ctrl+Alt+2 to switch from the serial console (where you see "Led ON") to the QEMU monitor window.
  • To switch back to the console later, press Ctrl+Alt+1.

Step 3: Simulate Button Press/Release

Use monitor commands to toggle the GPIO pin state (since buttons usually trigger on a level change, like low for pressed, high for released):

  • Simulate button press: Run this command (replace PA0 with your actual pin if different, and adjust the syscon prefix for your STM32 model—stm32f103-syscon is common for stm32_p103):
    stm32f103-syscon set-gpio-in PA0 0
    
    The 0 sets the pin to low voltage, mimicking a pressed button.
  • Simulate button release: Run this to set the pin back to high:
    stm32f103-syscon set-gpio-in PA0 1
    

Quick Troubleshooting Tip

If you’re unsure about the correct syscon command for your STM32 variant, type help in the QEMU monitor—look for entries starting with stm32*-syscon to find the right prefix for your board.

After sending the press command, switch back to the serial console (Ctrl+Alt+1) and you should see the demo’s response to the button input!

内容的提问来源于stack exchange,提问作者exebook

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.06 16:04:11