{"id":291,"date":"2015-06-10T18:35:59","date_gmt":"2015-06-11T01:35:59","guid":{"rendered":"http:\/\/tubetime.us\/?p=291"},"modified":"2015-06-10T18:35:59","modified_gmt":"2015-06-11T01:35:59","slug":"build-guide-for-mini-arcade-machines","status":"publish","type":"post","link":"https:\/\/tubetime.us\/index.php\/2015\/06\/10\/build-guide-for-mini-arcade-machines\/","title":{"rendered":"Build Guide for Mini Arcade Machines"},"content":{"rendered":"<p><strong>Edit: Updated instructions to discuss the game ROM<\/strong><\/p>\n<p>Have an STM32F407 Discovery board? Have a CRT scope with XY inputs? Try out <a href=\"http:\/\/tubetime.us\/?p=173\" target=\"_blank\">Asteroids<\/a> and <a href=\"http:\/\/tubetime.us\/?p=280\" target=\"_blank\">Battlezone<\/a> for yourself.<\/p>\n<p><!--more--><\/p>\n<p>These directions assume you are running Linux.<\/p>\n<p>First, get (git?) the source code: <a href=\"https:\/\/github.com\/morbos\/asteroids\" target=\"_blank\">Asteroids<\/a> <a href=\"https:\/\/github.com\/morbos\/bzone\" target=\"_blank\">Battlezone<\/a><\/p>\n<p>Also go out and find the game ROM on the internet and put it in ..\/roms\/. The file should be called &#8220;Battlezone&#8221; or &#8220;Asteroids&#8221;. The project makefile looks for it at this location.<\/p>\n<p>Download the <a href=\"http:\/\/www.st.com\/web\/en\/catalog\/tools\/PF257904\" target=\"_blank\">STM32F4-Discovery firmware libraries<\/a>.<\/p>\n<p>You&#8217;ll also need a toolchain. I&#8217;ve been using the prebuilt GCC 4.8 from <a href=\"https:\/\/launchpad.net\/gcc-arm-embedded\" target=\"_blank\">here<\/a>. Once you&#8217;ve installed it make sure it works by typing<\/p>\n<p><code>arm-none-eabi-gcc -v<\/code><\/p>\n<p>Then you will need to edit the makefile in the asteroids\/bzone directory and set up the library path. Look for the line<\/p>\n<p><code>STM32F4_PERIPH_PATH=\/rnasbkup\/STM32F4\/STM32F4-Discovery_FW_V1.1.0<\/code><\/p>\n<p>and set it to point to the ST firmware libraries you downloaded earlier. Try to build it by typing<\/p>\n<p><code>make<\/code><\/p>\n<p>If all goes well, it will generate the main.axf output file.<\/p>\n<p>Now for programming the Discovery board itself. Get <a href=\"http:\/\/openocd.org\/\" target=\"_blank\">OpenOCD<\/a> 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:<\/p>\n<p><code>SUBSYSTEM==\"usb\",ATTRS{idVendor}==\"0483\",ATTRS{idProduct}==\"3748\",GROUP=\"plugdev\",MODE=\"0660\"<\/code><\/p>\n<p>Put this in a file &#8220;99-stm&#8221; (or whatever) and put it in \/etc\/udev\/rules.d. Then run<\/p>\n<p><code>sudo udevadm control --reload-rules<\/code><\/p>\n<p>Plug in the Discovery board and open two console windows. In the first, run<\/p>\n<p><code>openocd -f board\/stm32f4discovery.cfg<\/code><\/p>\n<p>And make sure it connects to the board.<br \/>\nIn the other window, go to the directory which has the main.axf file you built earlier, and run<\/p>\n<p><code>arm-none-eabi-gdb main.axf<\/code><\/p>\n<p>In the GDB console, you&#8217;ll need to attach to the openocd session and flash the firmware, as follows<\/p>\n<p><code>target extended-remote localhost:3333<br \/>\nmon reset halt<br \/>\nload<br \/>\nmon reset init<br \/>\nc<br \/>\n<\/code><\/p>\n<p>&#8230;I just typed that out from memory. If it worked, you&#8217;ll see a blinking LED on the Discovery board, and analog vectors should be coming out of PA4 and PA5. Whew!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Edit: Updated instructions to discuss the game ROM Have an STM32F407 Discovery board? Have a CRT scope with XY inputs? Try out Asteroids and Battlezone for yourself.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p80Z1r-4H","_links":{"self":[{"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/posts\/291"}],"collection":[{"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/comments?post=291"}],"version-history":[{"count":0,"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/posts\/291\/revisions"}],"wp:attachment":[{"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/media?parent=291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/categories?post=291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tubetime.us\/index.php\/wp-json\/wp\/v2\/tags?post=291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}