SD2IEC development environment for Windows
I wanted to compile my own SD2IEC firmware version for a long time. I started to create my environment several times but failed. Then came a bit stronger motivation: IEC-ATA made his SD1551 which is an SD2IEC (hardware) based device that connects to the Commodore 264 series (C16, C116, plus/4 and the rarities/prototypes: C232, C264, V364) expansion port and uses the TCBM protocol of the 1551 with SD card bases storage but with custome firmware.
My idea was that as the SD2IEC firmware already supports different hardware variants and bus implementations (Commodore serial, DophinDOS parallel, IEEE-488) we could easily add support for TCBM too and use all the other (like SD-card handling, filesystem, disk image and file handling, firmware update) functions from the original SD2IEC software. Of course I jumped on it but as soon as I was able to compile and flash firmware for my SD2IEC my enhusiasm faded as other projects got in focus. (I didn't give up but it got back beside the other numerous things :) )
So: this post was created to document what do you need to compile the firmware.
I found that the compilation does not work with the generally suggested WinAVR package. (At least I wasn't able to make it work) because it's heavily based on the gcc toolchain with make avr-gcc and perl. I've installed Ubuntu Linux to try out the compilation and of course everything worked perfectly for the first try after installing the acr packages. But I wanted to use Windows.
What you need to download and Install:
- Git: SD2IEC firmware is in a Git repository. This is required to download the source code.
- MinGW/MSys: *nix shell console and development toolkit support for Windows.
- AVR GNU toolchain: AVR specific cross-compiler tools, C, C++, assembler and other compilers, linker and others.
- Strawberry PERL: unfortunately we need a separate PERL because MSys has version 5.8 (at least the one I installed had that one) but SD2IEC compilation requires version 5.10 at least. Searching the Internet I found Strawberry PERL as the recommended one so I've decided to use this one..
- AVRDude: not for the compilation itself but for flashing the compiled firmware to the AVR. (SD2IEC has a make target for flashing)
I've downloaded the most recent version of all the tools but it should work with slightly older and newer versions too..
Foreword: if an installer wants to add something to the PATH we should let it do it. Otherwise there is a good chance that the build will fail.
We can download it from https://git-scm.com/downloads We just need to install it, nothing extra.
We can download it from http://strawberryperl.com/ We just need to install this one too, nothing extra.
We can download from https://sourceforge.net/projects/mingw/files/MSYS/ mingw-get-setup which is recommended on the top of the page. This is an installer. We have to select what we need to be installed. It will download and install the selected items only. VERY slow.
It offers several installation possibilites (pre-selected packages – Basic Setup) or we can select what we need (All Packages). I didn't bother too much and selected 3 of basic ones:
- és msys-base
AVR GNU toolchain
We can download from http://www.atmel.com/tools/ATMELAVRTOOLCHAINFORWINDOWS.aspx the Atmel AVR 8-bit Toolchain and install it.
What we need to be in PATH and work from Windows command line too:
- perl: use command perl -v to check
- avr-gcc: use command avr-gcc -v to check
If we have these we can start MSys-t (for example c:\mingw\msys\1.0\msys.bat).
IMPORTANT: in MSys the root directory (/) is the directory of MSys. The Windows drives can be accessed under the path /<drive letter without colon>. For exmple the path of C:\Work will be /c/Work.
We must setup Strawberry to be used instead of the built-in one (but we need to install that to as it installs some required tools):
- Go to directory /bin (cd /bin)
- Rename to old one (mv perl.exe perl.exe.msys)
- Create a symlink for Strawberry: (ln -s <Strawberry perl binary path> perl.exe, for example ln -s /c/Development/Strawberry/perl/bin/perl.exe perl.exe)
- Check with perl -v if it's the same as from Windows command line.
No we have a complete development environment.
In MSys shell create a git working directory. For example:
- cd /c/Work
- mkdir git
- cd git
Check out (download) the current SD2IEC version:
- git clone http://sd2iec.de/sd2iec.git
Let's try our luck:
- cd sd2iec
- make CONFIG=configs/config-larsp
(or any other configuration except example. My device uses this hardware variant so I've used this one).
Later we can copy one of the configurations in the sd2iec main directory with the name config and then we can use
only to start build.
If you use a smaller AVR (my device has a 644p) we probably need to disable some parts in the config as the current software can be quite big and does not fit in the small AVRs.
If you create your own hardware most probably you need to create your own hardware variant config too.