Sunday, August 17, 2014

developing for bitbox under windows

Even if I'm personally working under linux, it is quite possible to develop for bitbox under windows.

The following article / page is a reference for it, and will be updated accordingly. Also, if there is any part missing, please tell it !

A very thorough reference can be found by example there : http://www.jann.cc/2013/10/10/embedded_development_with_open_source_tools_on_windows.html#install-the-gcc-arm-embedded-toolchain

Most of the current guide is taken from there.

It targets development on a cortex-m4 chip so it's quite similar and adds a ton of optional software which can be very useful. The proposed method is quite barebones (or light), because, well I tend to prefer lighter solutions, but integration with eclipse could be done I'm sure.

Alternatively, DIYDSP has an page with instructions to setup a linux virtual machine suitable for stm32 development, as well as various other tips.


arm-gcc

To compile the bitbox software, first you will need to get (suprise !) a compiler. The preferred compiler for bitbox is the gnu compiler gcc, so we will use the pre-compiled distribution for windows.

Download the windows installer from the launchpad site here : https://launchpad.net/gcc-arm-embedded/+download

Install it to a path where that is not containing a space, like c:\bitbox or c:\tools. This will avoid some later headaches.


Don't forget to check "add path to environment variable" when installing.

Adding a minimal environment (MSYS / MinGW)

The build environment relies on a few elements, which are provided by the mingw / msis installer.
Please download the installer from here : https://sourceforge.net/projects/mingw/files/latest/download

Add the graphical one, it's easier.

Run it and select msys-core and msys-make (no need to add any other package to compile for bitbox) and install it. They are located under MSYS / MSYS Base system.



Add the path c:\dev\minGW\msys\1.0\bin to your windows path so that the programs can be used from the command line.

Compiling a bitbox program

By example, we'll compile the bitbox kernel test. This is one of the most basic application but it uses video and input devices.
Download a .zip (or use git to checkout a copy) of the main bitbox kernel libraries :
https://github.com/makapuf/bitbox (Use Download  Zip icon in the bottom right)

Open a comandline and cd to the test-kernel directory.

Type make. It will fail, of course, telling that you don't have the lib directory. The lib directory contains the base libraries that the bitbox uses. It is common to several projects so we'll create a link from there to the lib directory where the kernel is located.

( note : maybe this way of doing will change later. plese prompt me to change this doc if I forgot to change it :)).

type :
ln -s <path of the lib directory> .
here we will use :
ln -s ../lib .
because our lib directory is just there, but if you created your program elsewhere please locate lib accordingly. Now, type

make

And .. it will fail !

Well, not completely. You can see that the .elf and .bin files have been produced : you've just built your first bitbox binary successfully (line arm-none-eabi-objcopy -O binary testkernel.elf testkernel.bin), but it failed to compile the emulator (following lines).

This is normal since the emulator runs on your PC and you have no gcc to compile for your x86 PC. MinGW can provide it to you by example (see additional software hereafter).

To compile just the ARM binary for bitbox, you will need to type by example (check the Makefile for the name of your binary) :
make testkernel.bin

Deploying to the bitbox

To deploy to the bitbox, there are several options. The simplest one is to use the bootloader (see blog posts). Either copy the second bootloader and your program (as well as its pbm icon) to the root directory of your microSD card. Then, boot the console and enjoy your hard work !

Alternatively (again, look at the deploying to the bitbox posts on the blog) you can use DFU and / or ST Util to use the swd connection (which will be useful to debug also !)

Additional, useful software

  • To compile the emulator, you will need to add a compiler for your PC / windows such as gcc / mingw from the mingw installer. Alternatively, any other IDE for windows will do. Remember that the emulator is based on SDL so you will need the SDL dll and .h. MinGW has a package for SDL development.
  • Please add python if you want to use the python scripts (from python.org main site, as well as the python image library or PILlow for image scripts)
  • mintty seems to be a nice terminal
  • Also the Git client will help you get information from the github acount, or publish your code there (or track its development locally)
  • Of course you should have a good text editor : gvim, sublime-text, eclipse, emacs, notepad++ ... the list is long but don't use notepad (or word), please.

No comments:

Post a Comment