How to convert binary files to Altera readable input

Just as a reminder for me.
From time to time I need to convert a binary ROM file (bios or cartridge data) to a format which the Altera Quartus Suite can understand. It can be in hex but I chose the Memory Initialization File (MIF) format by Altera.

srec_cat: http://sourceforge.net/projects/srecord/files/srecord-win32/

Compiling the minimig core for the MIST fpga board on windows

Compiling the Atari ST core for the MIST is pretty straight forward like described here. For the minimig core some prerequisites are needed which I’ll describe below.
The amiga_boot.v file is missing and needs to be compiled before using the Altera Web Edition to compile the core.
I was lazy and took the mingw build environment used for XBMC (https://github.com/xbmc/xbmc/tree/master/project/BuildDependencies). I used it to compile vasm which is needed to compile amiga_boot.

  1. Get the sources from here: http://sun.hasenbraten.de/vasm
  2. Unzip it to vasm
  3. Go into vasm and type
    make CPU=m68k SYNTAX=mot

I copied the binary vasm68k_mot.exe to a bin directory in the mingw env. Since the xxd binary was missing as well I download the msys-vim package from sourceforge and installed it in the mingw env as well.
When I got some time I’ll create a stripped down mingw/msys env with the binaries needed to compile the firmware and amiga_boot.
Once done we need python for windows in path. With some smaller changes to the python scripts and the makefile I was able to compile the amiga_boot files. Once finished I’ll submit the changes to the MIST main repo.
Meanwhile you can use the files from here: https://github.com/wsoltys/mist-board/tree/master/cores/minimig/fw/amiga_boot/bin

Copy those files to the same directory structure of the MIST main repo clone and open minimig_mist.qpf with the Altera Web Edition. In the Web Edition you need to enable talkback in order to use the Signaltap which is needed to compile the minimig core.

  1. Go to Options
  2. Internet Connectivity
  3. Talkback options and enable them

Now you can start the compilation and after some minutes its done 🙂

visual studio: what to do if compiling or starting the debugger takes ages?

When compiling XBMC I noticed from time to time that starting the debugger takes up to 10 seconds where it looks like visual studio does nothing. After making the logging more verbose I found out that visual studio tries to read some log files before it starts. They are named *.tlog and in my project are at least 800-900 files:

Deleting them recreates some of them at the next compilation but it doesn’t take ages anymore to start the debugger afterwards.

windows: How to get the tray status of an optical drive

Sometimes you would like to know if the tray of your CD/DVD/Bluray drive is open, closed and if a media is inserted. The following example shows how to archive that with C++. The return codes of the function GetDriveStatus() are:

And now the example:

We first check in line 57 with IOCTL_STORAGE_CHECK_VERIFY2 if we have a media in our drive. If this returns 1 we have a medium loaded and we can early return and save another call to DeviceIoControl().
In line 123 we finally request the tray status with a IOCTL_SCSI_PASS_THROUGH_DIRECT call.

cmake and visual studio

I recently did my first steps with cmake and it wasn’t easy as there’re not much sources on how to use it with visual studio. After some try and error I got some things done which I wanted to document here.

Variables

Build Debug or Release dll’s

cmake offers different ways for building release and debug configs with visual studio depending on the generator.

nmake makefiles:

Visual Studio:

Add preprocessor definitions

Download a file and check the status

Downloads the file BINDING_FILE from http://ws0.org/xbmc/win32/ and puts it into the build directory.

Unpack zip file

execute_process executes the command during compile time and not on configure.

Create an archive with cpack

Adds a new target ‘package’ which could be called with ‘nmake package’ or ‘cmake –build . –target=PACKAGE.’
Inside the zip is the directory visualization.waveform with the contents
of the directory visualization.waveform plus the waveform.dll file.

Use external Visual Studio project file

Generates a target ‘milkdrop’ for use like add dependencies. Visual Studio generators only.
INCLUDE_DIRECTORIES has no affect on those targets.

Set Visual Studio compile parameters

Set compile language per source

Sets the compiler language to C for all sources in ${EVALLIBSRC}

Add additionale include and linker directories