You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

STM32F3Discovery开发:arm-none-eabi-gdb连接GDB服务器失败求助

Troubleshooting GDB File Not Found Issue for STM32F3Discovery Rust Project on Windows

Hey there! Let's work through this problem step by step. That "No such file or directory" error—even though you swear the file exists—is super common on Windows thanks to path handling quirks, so let's break down fixes that should get you connected:

1. Fix Path Separators (Windows vs. Unix)

Windows uses backslashes (\) for paths instead of Unix-style forward slashes (/), and GDB on Windows can be finicky about this swap. Try adjusting your command to use Windows-native separators:

arm-none-eabi-gdb -q target\thumbv7em-none-eabihf\debug\led-roulette

If you're using a shell like Git Bash that supports forward slashes, wrap the path in quotes to avoid parsing issues:

arm-none-eabi-gdb -q "target/thumbv7em-none-eabihf/debug/led-roulette"

2. Make Sure You're in the Right Working Directory

Double-check that you're running the GDB command from your project root folder (where your Cargo.toml lives!). If you're in a subfolder, the relative path target/... won't point to the right place.

  • Navigate to the root first with cd C:\path\to\your\stm32-project.
  • Or skip the guesswork entirely by using an absolute path to your ELF file:
    arm-none-eabi-gdb -q "C:\path\to\your\stm32-project\target\thumbv7em-none-eabihf\debug\led-roulette"
    

3. Verify the ELF File Actually Exists (Double-Check!)

Even though you confirmed it, let's confirm via command line to be 100% sure. Open Command Prompt or PowerShell in your project root and run:

dir target\thumbv7em-none-eabihf\debug

Look for a file named led-roulette—no .exe extension! Rust compiles bare-metal targets to ELF files, not Windows executables. If it's missing, re-run cargo build --target thumbv7em-none-eabihf to ensure the build completed without silent errors.

4. Fix the Index Cache Warning (Optional but Clean)

That warning about the index cache directory is harmless, but if you want to get rid of it, set the GDB_CACHE_DIR environment variable to a valid folder before launching GDB:

set GDB_CACHE_DIR=C:\Users\YourUsername\.gdb-cache
arm-none-eabi-gdb -q target\thumbv7em-none-eabihf\debug\led-roulette

Replace YourUsername with your actual Windows username, and create the .gdb-cache folder if it doesn't exist already.

5. Connect to OpenOCD Automatically

Once GDB loads your ELF file successfully, you still need to connect to the OpenOCD server. Skip manual input by adding the connection command to your GDB launch:

arm-none-eabi-gdb -q target\thumbv7em-none-eabihf\debug\led-roulette -ex "target remote localhost:3333"

This will automatically link GDB to OpenOCD's default port (3333) as soon as GDB starts up.


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

火山引擎 最新活动