Program arduino without using arduino ide

Discussion in 'Linux Ubuntu' started by lozo2010, Jul 23, 2014.

  1. lozo2010

    lozo2010 New Member

    Joined:
    Jul 23, 2014
    Messages:
    6
    Likes Received:
    0
    Hello. I have a hex file and would like program in arduino but i dont use arduido ide. How i do it? Sorry for my english
     
  2. emil01

    emil01 New Member

    Joined:
    Nov 29, 2013
    Messages:
    6
    Likes Received:
    0
    Check out this website for more information http://playground.arduino.cc/Code/ArduinoUpload


    You will need avrdude in order to program the arduino

    AVRDUDE INSTALLATION INSTRUCTIONS

    You can get the latest tarball from http://www.nongnu.org/avrdude/

    extract it and install by
    Code:
    tar -xvf avrdude-6.1.tar.gz
    cd avrdude-6.1/
    sudo apt-get install libftdi-dev libusb-1.0-0-dev flex byacc bison
    ./configure
    sudo make
    sudo make install
    
    UPLOADING INSTRUCTIONS

    If you do not know the settings required to program the Arduino, I would recommend that you open the arduino IDE -> File -> Preferences -> check Show verbose output during upload and upload any of the examples (here I am uploading the blink program to my arduino duemilanove) and in the command window in the second line you will see something like this

    Code:
    /<Arduino Location>/arduino-1.0.5/hardware/tools/avrdude -C/<Arduino Location>/arduino-1.0.5/hardware/tools/avrdude.conf -v -v -v -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/tmp/build664219145326192481.tmp/Blink.cpp.hex:i 
    now lets break this down parameter by parameter ( you can find the same information at http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions )

    /<Arduino Location>/arduino-1.0.5/hardware/tools/avrdude - location of avrdude in our case it will be just avrdude

    -C /<Arduino Location>/arduino-1.0.5/hardware/tools/avrdude.conf - the location of the configuration file, we dont need this as the latest version of avrdude already has the configuration for arduino, but if you are using a custom version you will need to point to your configuration file

    -v -v -v -v - verbose mode, no idea why there are four of them, we dont need this unless you want it of course ONE will suffice :D

    -p atmega328p - My microcontroller

    -carduino - The programmer used

    -P/dev/ttyUSB0 - Port at which the arduino is located, you will have to figure this part out on your own or you could always open the arduino IDE and check the port (i.e if you are doing it on the same computer)

    -b57600 - the baud rate at which it is to be uploaded

    -D - Disable auto erase

    -Uflash:w:/tmp/build664219145326192481.tmp/Blink.cpp.hex:i - File to be uploaded

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------

    Here is a generic commandline for uploading code to the arduino (I am assuming the same code can be used for the arduino UNO as well) :
    Code:
     sudo avrdude -F -p <microcontroller> -c arduino -P <Port> -u -Uflash:w:<HEX Code>:i -b 57600 


    regards

    Emil
     
  3. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    avrdude only works for AVR-based Arduinos (Uno, Leonardo, etc.), not the ARM-based one built into a Udoo, which is modeled after the Arduino Due design. A utility called "bossac" is required instead, and it needs to be a patched version that knows about the Udoo's special reset and erase procedure (controlled by two GPIO outputs from the main i.MX6 CPU, rather than by opening the USB-Serial link at 1200bps as on a normal Due.)

    This 'bossac' gets automatically installed as part of Udoo's version of the Arduino IDE, and is what the IDE uses to flash in new code, but it can also be invoked directly from the command line, e.g.

    bossac --port=ttymxc3 -U false -e -w -v -b programname.bin -R

    On my Debian system it is in /opt/arduino-1.5.4/hardware/tools/bossac.

    I'll try to attach a ZIP'ed copy of this bossac utility, so you don't have to install the full IDE to get it.

    Note that compiled/assembled code for the Due/Udoo's SAM3X CPU will normally have a *.bin extension, rather than .hex ... and of course if you don't want to use the Arduino sketch system & libraries, you'll need some other cross-compiler and assembler capable of producing code for the SAM3X, a Cortex-M3 type ARM chip (quite different from the larger i.MX6 ARM used for Udoo's main CPU).

    The free version of Codesourcery from Mentor Graphics, built around GNU tools is one option. I've also been playing with an open-source RTOS called "NuttX", which has an Arduino Due board target and its own cross-build toolchain, but haven't gotten very far with it yet. The nice thing about NuttX is that you can multitask several threads at once under a realtime scheduler, and even have an interactive, Unix-like shell (nsh) running on the serial console (back to i.MX6) at the same time your app(s) are executing. New code could potentially be uploaded and added to the scheduler even as existing tasks continue to run, rather than having to erase and reflash anew for any change.

    Parts of NuttX were inspired by the commercial RTOS vxWorks, for anyone familiar with that, with some Unix/Posix bits added.

    NuttX provides an IP stack too, along with Telnet server, TFTP client, etc. but all that's fairly useless on a Due/Udoo since no network interface is exposed-- the SAM3X has an Ethernet controller built in, but the pins aren't wired to any headers, and this requires an outboard MAC chip anyway. Serial I/O back to the i.MX6 will be good enough for me. Fortunately, features that are unnecessary or useless for a particular application can be stripped out of the OS to save space, making for a smaller flash footprint.
     

    Attached Files:

  4. hillcz

    hillcz Member

    Joined:
    Oct 3, 2013
    Messages:
    72
    Likes Received:
    1
    Please how install bossac without IDE?
    If I try copy bossac from package and set chmod 755.

    Code:
     -rwxrwxrwx 1 ubuntu root 423514 Jul 11  2013 bossac 
    But ./bossac --port=ttymxc3 -U true -e -w -v -b prog.bin -R returns

    Code:
    -bash: ./bossac: No such file or directory
    THX
     
  5. fetcher

    fetcher Member

    Joined:
    Mar 9, 2014
    Messages:
    166
    Likes Received:
    20
    Does a basic invokation of bossac, (e.g. just pulling up its helpscreen -- ./bossac -h ) work?

    If so, try installing 'strace' (system call tracer), and using that to see what bossac is trying to do at the time it fails.

    If not, and you're using the bossac binary I posted above, that was taken from a Debian install, and although Ubuntu is Debian-derived, it's possible your shared libraries are too different from those the binary was linked against. Try running 'ldd' against it to check:

    Code:
    $ ldd `which bossac`
            libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x2ac49000)
            libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x2aba8000)
            libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x2acf3000)
            /lib/ld-linux-armhf.so.3 (0x2ab66000)
            libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x2addb000)
    
    This is one downside of exchanging binaries rather than source code, but apparently the Udoo people haven't released source to the GPIO reset/erase patch they made against standard Bossac -- see the recent "bossac patch" thread on this forum where someone is asking about that.

    Oh, any reason you specified "-U true" instead of "-U false"? I think that option is only for USB programming of an Arduino Due, which doesn't apply to a Udoo, since communication with the SAM3X is via a serial interface (/dev/ttymxc3) rather than USB.
     
  6. TomFreudenberg

    TomFreudenberg Member

    Joined:
    May 12, 2014
    Messages:
    59
    Likes Received:
    2
    hi all

    I was also looking for a suitable solution for having a script to compile and flash the Arduino Due directly on my UDOO boards. Just shell based, no X, no Java, ...

    Maybe this will do some help: https://github.com/TomFreudenberg/udoo-arduino-cli

    Cheers,
    Tom
     
    graugans likes this.

Share This Page