Compiling the firmware on Windows

Firmware/software/electronics/mechanics
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Compiling the firmware on Windows

Post by TheFrog4u »

Hi guys,

I tried to compile the cf firmware on Windows 7 64 bit using MinGW and Sourcery CodeBench Lite. It was surprisingly easy and everthing seems to build fine (not tested yet) with only one little issue: I can not use the repository (didn't manage to get hg to work, yet) so I downloaded the software from bitbucket directly, but you guys use some scripts to create version.c from the repository.
So there was one little change nessescary in the Makefile to create a "fake" version.c

Code: Select all

clean_version:
ifeq ($(SHELL),/bin/sh)
	@echo "  CLEAN_VERSION"
#	@rm -f version.c
	@cp ./utils/src/version.vtpl ./version.c
endif
So no virtual machine needed any more :) I hope this will be usefull for the Developers using Windows out there.
BTW: According to the documentation "make compile" should not replace version.c, but it does!

EDIT: Just saw that Sourcery CodeBench only works for the crazyflie firmware, because the crazyradio uses "sdcc" instead of "arm-none-eabi": I'll try to intall and test this later, too..
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Compiling the firmware on Windows

Post by TheFrog4u »

OK, update: the crazyradio firmware also just builds fine when installing sdcc. Another mini-change in the makefile was nessecary, though:

Code: Select all

#CFLAGS = -Iinc/ --model-large --std-sdcc99
CFLAGS = -Iinc --model-large --std-sdcc99
Don't know why.. might be windows issue.
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Compiling the firmware on Windows

Post by TheFrog4u »

Ok since some new update on version.c, my discribed procedure from above is not working any more, because of the added values irevision0 and irevision1. Therefore I created a small script "scripts/update_version_local.sh" which changes the values in "utils/src/version.vtpl":

Code: Select all

#!/usr/bin/env bash

FILE=version.c

#Set the relevant informations
LOCAL=local
REV=$(date)
TAG=none
BRANCH=TheFrog4u
MODIFIED=1

REVISION0=0xFF
REVISION1=0xFF

#Patch version.c
sed -i "s/SLOCAL_REVISION=\".*\";\$/SLOCAL_REVISION=\"$LOCAL\";/" $FILE
sed -i "s/STAG=\".*\";\$/STAG=\"$TAG\";/" $FILE
sed -i "s/SREVISION=\".*\";\$/SREVISION=\"$REV\";/" $FILE
sed -i "s/V_BRANCH=\".*\";\$/V_BRANCH=\"$BRANCH\";/" $FILE
sed -i "s/MODIFIED=.*;\$/MODIFIED=$MODIFIED;/" $FILE

sed -i "s/V_REVISION_0=.*;\$/V_REVISION_0=$REVISION0;/" $FILE
sed -i "s/V_REVISION_1=.*;\$/V_REVISION_1=$REVISION1;/" $FILE
my Makefile changed to:

Code: Select all

clean_version:
ifeq ($(SHELL),/bin/sh)
	@echo "  CLEAN_VERSION"
	@rm -f version.c
	@cp utils/src/version.vtpl version.c
	@scripts/update_version_local.sh
endif
It compiles fine, however I am unsure if this "REVISION0=0xFF" is a good idea. Am I doding something nasty here? I don't see that its used somewhere, though.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Compiling the firmware on Windows

Post by tobias »

It compiles fine, however I am unsure if this "REVISION0=0xFF" is a good idea. Am I doding something nasty here? I don't see that its used somewhere, though.
I don't think it is used right now but in the future it is intended to be used to check that the cf-client and the cf-firmware is compatible. Or if there is a never sable release available.
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Compiling the firmware on Windows

Post by TheFrog4u »

Ok another update: I just installed TortoiseHg and EVERTHING works now out of the box! No chaning of make files and adding scripts any more. Thats so cool. Just to summarize it (maby it could be added to the wiki?):

Setting up the crazyflie developter tool chain on Windows (without using a virtual machine)

0. Install the crazyradio driver (there is no way around it :p )
1. Install MinGW/MSYS (Shell and GNU tools like 'make' for Windows)
2. Install Python + needed packages (for the cfclient software and scripts)
3. Install Sourcery Arm Compiler (for crazyflie firmware)
4. Install SDCC (for the crazyradio firmware)
5. Install TortoiseHg
6. Check your Windows path varable and add all missing main folders from the software you just installed

7. You are ready to go!
mrb0y
Beginner
Posts: 25
Joined: Thu Mar 07, 2013 1:18 am

Re: Compiling the firmware on Windows

Post by mrb0y »

Ok everything went fine until I got to VTMPL version.c ? I have installed both pythons 2.7 and the latest and I set the environment path to the newest one. Maybe I should change it to the 2.7 if it has anything to do with the error?

Image
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Compiling the firmware on Windows

Post by TheFrog4u »

Try running make in the MSYS shell, not in cmd.exe .. and I would recommend installing everthing in folders without any space in the path (could work with, but often leads to troubles)
mrb0y
Beginner
Posts: 25
Joined: Thu Mar 07, 2013 1:18 am

Re: Compiling the firmware on Windows

Post by mrb0y »

I didn't change any of the files from the clone to my machine. I wasn't sure how to interpret everything is working out of the box statement after the tortoise install. I uninstalled MSYS and as I suspected it did not change anything as far as the build error is concerned. I already have some arm compilers / tool chains installed on my machine as you can see from the environment path. Maybe I should post this as a separate topic?
TheFrog4u
Expert
Posts: 113
Joined: Fri Feb 08, 2013 6:59 pm
Location: Bremen, Germany

Re: Compiling the firmware on Windows

Post by TheFrog4u »

mrb0y wrote:Ok everything went fine until I got to VTMPL version.c ? I have installed both pythons 2.7 and the latest and I set the environment path to the newest one. Maybe I should change it to the 2.7 if it has anything to do with the error?
After reading your comment carefully I understood that the error you get is related to a python script that wants create version.c from the file utils/src/version.vtpl and copy it into the main crazyflie-firmware folder. I got a similar problem when I did not have hg.exe installed (which is needed to check for the version string that goes into version.c), and I don't see in your path that you have it installed. So, either you install hg (e.g. TortoiseHg as mentioned above) or you try the workaround I already mentioned here
mrb0y
Beginner
Posts: 25
Joined: Thu Mar 07, 2013 1:18 am

Re: Compiling the firmware on Windows

Post by mrb0y »

I do have HG installed and I can run HG from the command line. I also cloned again into a new directory and still the same error. I'm running windows 8 (server 2012) but I would not think that is the problem. Thanks for the replies!
I ran each one of the commands in the script from the command line and it looks like it did create the version.c file. Now when I use the make command it get the following error! lol
Image
Post Reply