cd Misc git clone https://github.com/trebisky/H743.git cd H743 cd blink1 make arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -Os -c blink.c arm-none-eabi-as locore.s -o locore.o arm-none-eabi-ld.bfd -T blink.lds -o blink.elf blink.o locore.o arm-none-eabi-objdump -d blink.elf >blink.dumpWow! Would you look at that? It just works! The end product is "blink.elf" and at this point we would like to load that into the board and see if it runs.
The trick now is to pry the board out of the darn blister wrap that ST ships it in and to find a micro-USB cable -- along with a USB-C to USB-A adapter. I do this and plug it in.
We get LED's! Three of them.
A bright green one next to the power select jumpers. A big red one next to the ST-link USB connector. A blinking green one among the three user LEDsThe blinking LED is probably blinking because the board is running the code I loaded into it a year ago.
/usr/share/openocd/scripts/interface/stlink-v2.cfgThis is not at all surprising. I do some searching and am told that current versions of OpenOCD don't use stlink-v2.cfg but now use a unified file named interface/stlink.cfg. We will also need a target config file
target/stm32f4x.cfgI eliminate the full path and let OpenOCD do something on its own and use this command:
make flash openocd -f interface/stlink.cfg -f target/stm32h7x.cfg -c "program blink.elf verify reset exit"And it works!! I thought there might be some tricky issue of setting up USB drivers or permission -- but it is simple and clean and just works. I get this output, which is familiar and normal:
Open On-Chip Debugger 0.12.0 Info : auto-selecting first available session transport "hla_swd". To override use 'transport selectThe green LED is blinking much faster now. I edit the code and change one parameter to slow down the blinking.'. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD Info : clock speed 1800 kHz Info : STLINK V3J2M1 (API v3) VID:PID 0483:374E Info : Target voltage: 3.293173 Info : [stm32h7x.cpu0] Cortex-M7 r1p1 processor detected Info : [stm32h7x.cpu0] target has 8 breakpoints, 4 watchpoints Info : starting gdb server for stm32h7x.cpu0 on 3333 Info : Listening on port 3333 for gdb connections [stm32h7x.cpu0] halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x08000646 msp: 0x20020000 Info : Unable to match requested speed 4000 kHz, using 3300 kHz Info : Unable to match requested speed 4000 kHz, using 3300 kHz ** Programming Started ** Info : Device: STM32H74x/75x Info : flash size probed value 2048k Info : STM32H7 flash has dual banks Info : Bank (0) size is 1024 kb, base address is 0x08000000 Info : Padding image section 0 at 0x08000108 with 24 bytes (bank write end alignment) Warn : Adding extra erase range, 0x08000120 .. 0x0801ffff ** Programming Finished ** ** Verify Started ** ** Verified OK ** ** Resetting Target ** shutdown command invoked
make make flashIt is all very fast. And the LED blinks at about 1 Hz now.
At some point I want to play with the offical "STM32Cube" code tools from ST. The main point of that would be to find out if I can quickly get access to USB and/or ethernet libraries. I have peeked at their code base before and it is intricate and ugly -- but if I stay at a higher level and ignore details (like I think they intend their users to do), It might be useful.