Build Guide for Mini Arcade MachinesJune 10, 2015 6:35 pm Projects
Edit: Updated instructions to discuss the game ROM
These directions assume you are running Linux.
Also go out and find the game ROM on the internet and put it in ../roms/. The file should be called “Battlezone” or “Asteroids”. The project makefile looks for it at this location.
Download the STM32F4-Discovery firmware libraries.
You’ll also need a toolchain. I’ve been using the prebuilt GCC 4.8 from here. Once you’ve installed it make sure it works by typing
Then you will need to edit the makefile in the asteroids/bzone directory and set up the library path. Look for the line
and set it to point to the ST firmware libraries you downloaded earlier. Try to build it by typing
If all goes well, it will generate the main.axf output file.
Now for programming the Discovery board itself. Get OpenOCD version 0.8 or above (many Linux distributions still have older versions in their repositories, so be careful). Make sure your udev rules include an entry for the ST-Link debugger:
Put this in a file “99-stm” (or whatever) and put it in /etc/udev/rules.d. Then run
sudo udevadm control --reload-rules
Plug in the Discovery board and open two console windows. In the first, run
openocd -f board/stm32f4discovery.cfg
And make sure it connects to the board.
In the other window, go to the directory which has the main.axf file you built earlier, and run
In the GDB console, you’ll need to attach to the openocd session and flash the firmware, as follows
target extended-remote localhost:3333
mon reset halt
mon reset init
…I just typed that out from memory. If it worked, you’ll see a blinking LED on the Discovery board, and analog vectors should be coming out of PA4 and PA5. Whew!