Problems with make

:smiley: Hi,

I have two Wixels, I’ve run the apps and everything is fine. :smiley:

Pololu have done a fine job with the Wixel. The sample comms apps make it very clear how to develop apps with wixel on a budget. :sunglasses:

Development through the use of a terminal for debug is okay but it can be tedious. I usually make small changes to the code and retest. Its okay, but I end up having to start/stop the terminals quite a lot - after a few iterations it can be a pain. If I have two wixels connected together, eg one as an SPI master and the other as an SPI slave its all too easy to end up sending code to the wrong Wixel - sooner or later something will go bang!

To automate the process in a safe way I run the following batch files which I would like to share with the forum.

They make use of a clever feature in the Pololu command line utility called wixelcmd which is capable of identifying the wixel by serial number before sending code - its been discussed elsewhere.

You will see later I’ve started experimenting with the makefile to see if I can do the same thing via make, but I am running into problems.

Anyway, for my system here are the batch files, xm.bat for the wixel master and xs.bat for the wixel slave.


rem xm (master node) 
rem %1 is the application name in the apps directory 
rem build the program
cd w3
make %1
rem program the wixel
wixelcmd write apps/%1/%1.wxl  -d 2E-E5-98-C7	
sleep 3
rem start Putty - putty is configured for wixel1 on com port 34 no echo
start cmd /c putty.exe -load "wixel_34_ne"
cd ..

thats Wixel1 reprogramed and Putty terminal1 running.


rem xs (slave node) 
rem %1 is the application name in the apps directory 
cd w3
make %1
wixelcmd write apps/%1/%1.wxl  -d 24-F5-DB-66	
sleep 3
rem start Putty - putty is configured for wixel2 on com port 30 no echo
start cmd /c putty.exe -load "wixel_30_ne"
cd ..

same but for Wixel2.

It’s easy to take this a stage further. I could program two at the same time like this,

rem x.bat
call xm spi_m2
call xs spi_s2

Not bad, it does the job in just a few seconds.

So what’s the problem?

I cannot run the batch files from the same directory as the Wixel makefile. If I do I have problems running make - it tries to build my batch files.

On my system the Wixel SDK is located at d:_ws\w3. so I run the batch files from d:_ws - this explains the w3 references in the batch files. Change the batch files for yourself as required.

You will need to identify the serial numbers of you own wixels by running, wixelcmd list from a command line. Change the batch files for yourself as required.

Its easy and worth trying even with one Wixel.

Doing the same with the makefile

I thought it might be better to add a new command to the makefile instead of using the batch files so to start I modified the makefile by appending the following lines,

#placed at the end of
.PHONY : xm
xm : apps/spi_m2b/spi_m2b.wxl
    wixelcmd write apps/spi_m2/spi_m2.wxl  -d 2E-E5-98-C7	
    sleep 3
    start cmd /c putty.exe -load "wixel_34_ne"

Now the problems begin

Make responds,

D:\_ws\w3>make xm
wixelcmd write apps/spi_m2/spi_m2.wxl  -d 2E-E5-98-C7
Sending command to get Wixel in to bootloader mode...
Waiting for Wixel to reconnect...
Progress: |##########################################################| Done.
Progress: |##########################################################| Done.
sleep 3
start putty.exe -load "wixel_34_ne"
/usr/bin/sh: start: command not found
make: *** [xm] Error 127

Why should start work fine in a batch file but fail when it is run by Make? :question:

I noticed /usr/bin/sh: in the response - this looks suspiciously unix-ish. The build tools listed in the SDK package are part of the GNU toolset so I thought you might be using Cygwin. After a fair bit of Googling I managed to find cygstart hoping to try this as a possible replacement for start but that did not work either.

So my first question, how do I get start to work?
The batch files work fine but it would be good to get the makefile working.

Hopefully its an easy fix, but I’m pushing the limits of my knowledge on makefiles. I would be glad of your advice - more questions to follow.

Kind regards,

Hello, Brent!

I’m glad that you like the Wixel. The way you are using wixelcmd is one of the ways I intended for it to be used.

Instead of using “start” in the makefile, try putting an ampersand at the end of the command. Like this:

.PHONY : xm xm: wixelconfig &

The ampersand means to launch the program and not wait for it to finish running. It is a general thing that works in unixy shells.

You said “I cannot run the batch files from the same directory as the Wixel makefile. If I do I have problems running make - it tries to build my batch files.”

That sounds odd. Could you show the output of Make when it tries to “build” you batch file?


Hello David,

I cannot recreate the problem I reported regarding make and the batch files, I must have made a mistake. The batchfiles have been copied back and now share the same command line as the makefile and run without any problems. If I do see it again I’ll let you know.

Also thanks for the tip, the ‘unixy’ thing worked. The makefile approach is now complete. I’ve added some variables APP1, SERNO1, TERM1, etc to make it easier to edit and setup and hopefully make it more robust too. I’m sure it could be improved but it satisfies my needs.

I use the makefile to start the putty terminals because, so far as I am aware, it is not possible to disconnect from a serial port without closing putty. If anyone knows how to do this or how to set the screen locations of the putty terminals at start up please let me know. The Putty Help hints at being able to do such things under remote control but does not give examples.

Next Makefile Question :question:
I’ve created some libraries of my own. Your sample application test_radio_link extends the standard library list via by redefining the makefile macro/variable APP_LIBS.
APP_LIBS := usb_cdc_acm.lib usb.lib etc

So if my applications use my own libraries I add my own file to my application directory but as follows,
APP_LIBS += fred.lib bert.lib jack.lib
It works, but is this okay? Should it be done some other way?

Regards Brent.

P.s. For anyone interested, the makefile code is now as follows,

APP1   = spi_m2b
SERNO1 = 2E-E5-98-C7
TERM1  = "wixel_34_ne"

APP2   = spi_s2
SERNO2 = 24-F5-DB-66 
TERM2  = "wixel_30_ne"

.PHONY : xx
xx : xm xs

.PHONY : xm
xm : apps/$(APP1)/$(APP1).wxl
	wixelcmd write apps/$(APP1)/$(APP1).wxl  -d $(SERNO1)	
	sleep 3
	putty.exe -load $(TERM1) & 

.PHONY : xs
xs : apps/$(APP2)/$(APP2).wxl
	wixelcmd write apps/$(APP2)/$(APP2).wxl  -d $(SERNO2)
	sleep 3
	putty.exe -load $(TERM2) &

To try this, the above makefile code snippet should be appended to the end of file

To use,

  1. edit APP1, SERNO1, TERM1, APP2 etc in to your needs.
  2. run make xx, make xm, or make xs on the command line as required.

I’m glad you are having more success with the Wixel.

Using the “APP_LIBS +=” is fine for now, but in the future we might do away with this concept of a default list of libraries and require every app to specify all the libraries they need. At that point if you updated your Wixel SDK you would get a linker error, but it would not be a big deal to fix it.