On Fri, Sep 27, 2024 at 2:24 AM <michal.lyszc...@bofc.pl> wrote: > On 2024-09-26 21:58:38, Matteo Golin wrote: > > Hello all, > > We figured we should check here first if anyone who had > > experimented with STM32 chips knows offhand whether or not it's > > possible to program over a USB interface, how to do it with the > > NuttX build environment, or if it requires additional hardware. > Hi, you should be able to flash and debug board via onboard stlink. All > nucleos > should have built-in stlink I think. So just connect nucleo via usb and > check > in lsusb if you have any stlink device. It should be visible like > "STMicroelectronics STLINK-V3" > > I flash my boards with openocd: > > openocd -f interface/stlink.cfg -f target/stm32f3x.cfg -c 'program > nuttx.bin 0x08000000' > > You will need to change your target, there is target/stm32f7x.cfg and > target/stm32h7x.cfg already in the openocd. I am not sure if start of flash > is 0x08000000 on f7 and h7, but I suppose it should be. > > This command will leave openocd opened with gdb server so you can start > debugging it anytime you want with: > > arm-none-eabi-gdb nuttx "target remote 127.0.0.1:3333" >
Something along these lines should be added to Documentation. I just had an idea that it would be neat to write a utility, which could live under 'tools' (to be run on a developer machine) that would analyze the current configuration and automatically generate the correct openocd and gdb incantations. I haven't thought this through yet, so I don't know if it's feasible and what might be involved, but I thought I'd mention it here as food for thought. Another debugging idea, if you want a convenient GUI single-step debugger, is to install the vendor's STM32Cube IDE, which (last I looked) is (was?) an Eclipse-based IDE. You would need to fiddle with it to set up an IDE project that calls the NuttX build system, loads the correct flash image, and associates addresses to the correct source files (for source level debugging), but I know it is possible. Regarding USB bootloaders, in general (across all MCUs from all vendors) you do need to first flash your bootloader to the chip using the chip's primary flash/debug interface (be it SWD, JTAG, etc), *unless* the chip already comes with a bootloader, either preprogrammed into the chip by the vendor or in ROM. Off the top of my head I don't remember whether the STMF7 family has a ROM bootloader. If it does, you probably need to pay attention to a BOOT pin on the chip. Most development boards that you can buy from MCU vendors will connect to your PC to be flashed and debugged through USB. However in most of those cases, the board has a second smaller MCU from the same vendor which implements the bridge between USB <-> JTAG/SWD/whatever and sometimes supplies other information like the board's voltage. (It might be an option for you to implement that kind of hardware on your custom board *BUT* I would not recommend to attempt it unless the vendor supplies the hardware schematics and firmware source code for it. Some vendors supply that, sometimes in an Application Note, but many don't. Additional hardware also means additional weight, which might be a bad thing in a weight-sensitive application, not to mention additional cost.) Hope this helps, Nathan