Sunday, 14 December 2014

Arduino Due code development without the Java IDE

The arduino Due is quite a nice cortex M3 board to play with, and the whole arduino concept is great;  but I personally dislike IDEs and I do not want to clutter my laptop with Java VM - It would be nice if could develop in my usual vi and makefiles.
As described in this blog,  someone else had the same issue and found a way around it. The only problem is the php script included ,  which refused to execute in my machine. Instead of trying to fix it, it was easy enough to transfer php to a bash script:
Due with usb cable connected to the programming port. Click to enlarge
First download the Arduno IDE for Due. We need the 1.5.8 beta for Due, and extract ii
 wget http://arduino.cc/download.php?f=/arduino-1.5.8-linux64.tgz
 tar -xvf arduino-1.5.8-linux64.tgz -C /tmp/foo/
download and extract atwillys script
 wget http://atwillys.de/content/cc/using-custom-ide-and-system-library-on-arduino-due-sam3x8e/arduino-due-build-tools-setup.tgz  
 tar -xvf arduino-due-build-tools-setup.tgz -C /tmp/foo/  
This will create two directories in /tmp/foo/
 drwxrwxr-x 8 1000 1000 4096 Oct 1 15:57 arduino-1.5.8  
 drwxr-xr-x 3 1000 1000 4096 Sep 10 2013 install  
change to install directory  and remove ._* files  and create a bash script
 cd install  
 find . -name ._* -delete  
 cat > script <<EOF  
 #!/bin/bash  
 if [ $# -eq 0 ]  
 then  
   echo "arduino tool path missing in command line"  
   exit 0  
 else  
 ROOT_DIR=due  
 SCRIPT_RESOURCE_DIR=resources  
 TOOLS_DIR=$ROOT_DIR/tools  
 GCC_EABI_DIR=$TOOLS_DIR/g++_arm_none_eabi  
 BOSSAC=$TOOLS_DIR/bossac  
 HARDW_DIR=$ROOT_DIR/sam  
 DIST_LIB_DIR=$ROOT_DIR/lib  
 DIST_INC_DIR=$ROOT_DIR/include  
 DIST_SRC_DIR=$ROOT_DIR/src  
 SRC_DIR=$1  
 mkdir $ROOT_DIR  
 mkdir $TOOLS_DIR  
 mkdir $HARDW_DIR  
 mkdir $DIST_LIB_DIR  
 mkdir $TOOLS_DIR/g++_arm_none_eabi  
 cp -av $SRC_DIR/hardware/tools/gcc-* $TOOLS_DIR/  
 cp -av $SRC_DIR/hardware/tools/bossac $BOSSAC  
 cp -av $SRC_DIR/hardware/arduino/sam/system/CMSIS $HARDW_DIR/  
 cp -av $SRC_DIR/hardware/arduino/sam/system/libsam $HARDW_DIR/  
 cp -av $SRC_DIR/hardware/arduino/sam/variants/arduino_due_x/linker_scripts $HARDW_DIR/  
 cp -av $SRC_DIR/hardware/arduino/sam/variants/arduino_due_x/libsam_sam3x8e_gcc_rel.a $DIST_LIB_DIR/   
 find $HARDW_DIR -type f -exec chmod 644 {} \;  
 find $HARDW_DIR -type d -exec chmod 755 {} \;  
 find $HARDW_DIR -type f -name *.a -exec cp -av {} $DIST_LIB_DIR/ \;   
 cp -R $SCRIPT_RESOURCE_DIR/include $DIST_INC_DIR/  
 cp -R $SCRIPT_RESOURCE_DIR/make $ROOT_DIR/  
 cp -R $SCRIPT_RESOURCE_DIR/example $ROOT_DIR/  
 sed -i 's/g++_arm_none_eabi/gcc-arm-none-eabi-4.8.3-2014q1/g' $ROOT_DIR/make/make_due_firmware.mk  
 sed -i 's/cu.usbmodemfa141/ttyACM0/g' $ROOT_DIR/make/make_due_firmware.mk  
 sed -i 's/stty -f/stty -F/g' $ROOT_DIR/make/make_due_firmware.mk  
 echo "all done.."  
 fi  
 exit 0  
 EOF  

make the script executable and run it wil the path to the extracted arduino toolchain
 chmod +x script  
 ./script ../arduino-1.5.8  

Once the script is finished, there will be a directory called Due. which is the top directory of the command-line tool chain. cd to examples directory and do a make, with arduino due connected to usb port (/dev/ttyACM0)

Thanks to atwillys.de for all the hard work ..

building the code and programming the Due - click to enlarge

No comments:

Post a Comment