Hello Community,
I have a question regarding the Arduino Due and the SAM3X ARM MCU. I have prototyped a project of mine over multiple stages and I am developing a board using the SAM3X. I was wondering if it possible to compile Arduino sketches onto a SAM3X embedded on a custom board rather than the Arduino.
Derek Malloy shows how to do this using the Arduino Uno and another ATMEGA328. He essentially removes the DIP package ATMEGA328 chip from the Arduino board and pulls out the RX/TX lines to compile programs onto another ATMEGA328.
http://www.youtube.com/watch?v=_m9aciePKEk
I want to do the same process but using the Arduino Due and the SAM3X. Unfortunately you cannot take off the chip from the Arduino and try to do the same thing. I would like some advice on how to do this.
I have a couple of ideas, but I am unsure if it will work:
1 - On my custom board, pull out the ICSP pins from the SAM3X and attempt to serial program using an external ARM-type programmer with the Arduino IDE.
* I am unsure if this will work because I do not know if compiling code on an ARM chip is a similar process as compiling on an AVR chip.
2 - Somehow prevent the SAM3X on the board to get programmed (perhaps damaging the board ) and then passing the RX/TX lines to the SAM3X on my custom board.
* I do not know how, but if it is possible to bypass the SAM3X on the Arduino Due and compiling the code on another bootloaded SAM3X, that would be optimal.
I hope the community can help me out
Thanks,
Daniel
Arduino Due on a Breadboard
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 466
- Joined: Thu Aug 30, 2012 1:34 am
Re: Arduino Due on a Breadboard
on my linux system output from the build process goes into a temporary directory at /tmp/build{long string of decimal digits}. this morning that directory happened to be /tmp/build7788414026333503033.tmp.
a listing of that directory reveals
whatever os you are using, this stuff has to go somewhere.
i would guess you want the bin file. it should be loadable onto your board using whatever utility arduino uses to upload sketches to the arm based board, much like avrdude can be used by those of us who have yet to move on from avr devices.
the tool you want is probably one of those in your arduino install in arduino-1.5/hardware/tools.
sorry i can't be more helpful, but i don't have a due, yet.
a listing of that directory reveals
Code: Select all
ls -l /tmp/build7788414026333503033.tmp/
total 1384
-rwxr-xr-x 1 otto users 9744 Jul 18 05:04 Blink.cpp.bin
-rwxr-xr-x 1 otto users 225058 Jul 18 05:04 Blink.cpp.elf
-rw-r--r-- 1 otto users 359075 Jul 18 05:04 Blink.cpp.map
-rw-r--r-- 1 otto users 4488 Jul 18 05:04 Blink.cpp.o
-rw-r--r-- 1 otto users 26652 Jul 18 05:04 CDC.cpp.o
-rw-r--r-- 1 otto users 404564 Jul 18 05:04 core.a
-rw-r--r-- 1 otto users 5752 Jul 18 05:04 cortex_handlers.c.o
-rw-r--r-- 1 otto users 2284 Jul 18 05:04 cxxabi-compat.cpp.o
-rw-r--r-- 1 otto users 23664 Jul 18 05:04 HID.cpp.o
-rw-r--r-- 1 otto users 910 Jul 18 05:04 iar_calls_sam3.c.o
-rw-r--r-- 1 otto users 14664 Jul 18 05:04 IPAddress.cpp.o
-rw-r--r-- 1 otto users 6112 Jul 18 05:04 itoa.c.o
-rw-r--r-- 1 otto users 4720 Jul 18 05:04 main.cpp.o
-rw-r--r-- 1 otto users 32936 Jul 18 05:04 Print.cpp.o
-rw-r--r-- 1 otto users 6252 Jul 18 05:04 Reset.cpp.o
-rw-r--r-- 1 otto users 4744 Jul 18 05:04 RingBuffer.cpp.o
-rw-r--r-- 1 otto users 25000 Jul 18 05:04 Stream.cpp.o
-rw-r--r-- 1 otto users 9492 Jul 18 05:04 syscalls_sam3.c.o
-rw-r--r-- 1 otto users 24072 Jul 18 05:04 UARTClass.cpp.o
-rw-r--r-- 1 otto users 24564 Jul 18 05:04 USARTClass.cpp.o
-rw-r--r-- 1 otto users 34044 Jul 18 05:04 USBCore.cpp.o
-rw-r--r-- 1 otto users 21312 Jul 18 05:04 variant.cpp.o
-rw-r--r-- 1 otto users 4892 Jul 18 05:04 WInterrupts.c.o
-rw-r--r-- 1 otto users 22720 Jul 18 05:04 wiring_analog.c.o
-rw-r--r-- 1 otto users 6440 Jul 18 05:04 wiring.c.o
-rw-r--r-- 1 otto users 10024 Jul 18 05:04 wiring_digital.c.o
-rw-r--r-- 1 otto users 9108 Jul 18 05:04 wiring_pulse.cpp.o
-rw-r--r-- 1 otto users 5604 Jul 18 05:04 wiring_shift.c.o
-rw-r--r-- 1 otto users 5980 Jul 18 05:04 WMath.cpp.o
-rw-r--r-- 1 otto users 63588 Jul 18 05:04 WString.cpp.o
i would guess you want the bin file. it should be loadable onto your board using whatever utility arduino uses to upload sketches to the arm based board, much like avrdude can be used by those of us who have yet to move on from avr devices.
the tool you want is probably one of those in your arduino install in arduino-1.5/hardware/tools.
Code: Select all
ls -l arduino-1.5/hardware/tools/
total 2888
-rwxr-xr-x 1 otto users 248 Oct 22 2012 adk2install
-rwxr-xr-x 1 otto users 11899 Oct 22 2012 adk2tool
drwxr-xr-x 6 otto users 4096 Feb 23 2012 avr
-rwxr-xr-x 1 otto users 960618 Oct 22 2012 avrdude
-rw-r--r-- 1 otto users 960618 Oct 22 2012 avrdude64
-rw-r--r-- 1 otto users 550213 Oct 22 2012 avrdude.conf
-rwxr-xr-x 1 otto users 388904 Oct 22 2012 bossac
-rwxr-xr-x 1 otto users 58216 Oct 22 2012 bossac64
drwxr-xr-x 6 otto users 4096 Sep 5 2010 g++_arm_none_eabi
-rw-r--r-- 1 otto users 950 Feb 23 2012 readme.txt
- dgelman
- Posts: 12
- Joined: Thu Jan 10, 2013 7:05 pm
Re: Arduino Due on a Breadboard
Hello Tldr,
Sorry, but I have no idea what you are talking about. This has nothing to do with my concern in regard methods of compiling code onto an embedded SAM3X.
Please look at the YouTube video but replace the Arduino Uno with the Due and the DIP ATMEGA328 with the SMD SAM3X. This is what I am essentially trying to accomplish.
I hope my question isn't so difficult to understand.
Thank you
Sorry, but I have no idea what you are talking about. This has nothing to do with my concern in regard methods of compiling code onto an embedded SAM3X.
Please look at the YouTube video but replace the Arduino Uno with the Due and the DIP ATMEGA328 with the SMD SAM3X. This is what I am essentially trying to accomplish.
I hope my question isn't so difficult to understand.
Thank you
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Arduino Due on a Breadboard
Do you really need to use the Arduino IDE? The easiest way to do what you're talking about is to simply download Atmel Studio 6, which has full support for the entire SAM family. You will get a much more capable IDE, and a full-featured SDK. And, you will gain the ability to use a JTAG debugger.
Atmel Studio uses the same GNU compiler system as Arduino, but it is actively maintained. Arduino 1.5.2 is out-of-date and the board-support package is buggy. Atmel Studio actually has better board support for the Due than Arduino 1.5.2.
Atmel Studio 6 is free.
http://www.atmel.com/microsite/atmel_studio6/
Atmel Studio uses the same GNU compiler system as Arduino, but it is actively maintained. Arduino 1.5.2 is out-of-date and the board-support package is buggy. Atmel Studio actually has better board support for the Due than Arduino 1.5.2.
Atmel Studio 6 is free.
http://www.atmel.com/microsite/atmel_studio6/
- dgelman
- Posts: 12
- Joined: Thu Jan 10, 2013 7:05 pm
Re: Arduino Due on a Breadboard
Hello Rick,
I am very interest in using Atmel Studio. I have a couple of questions though:
1 - can you compile sketches or code directly onto the Arduino Due or do I have to purchase the hardware kit which would include the SAM3X. I have little experience with AVR Studio and have purchased pricy development boards to use them. I do not want to do the same on the ARM side of things.
2 - using Atmel Studio doesn't really give me a method of compling code on my own SAM3X. If Atmel Studio may compile on the Arduino Due or onto one of there development boards, I dont know how this would help me to compile the code onto my standalone chip
I became very adamant about the Arduino IDE because I love it and its simple. I feel that joining Atmel Studio or other programs like Keil would be a huge learning curve. Also I am not that strong in C.
Your comments are appreciated
Daniel.
I am very interest in using Atmel Studio. I have a couple of questions though:
1 - can you compile sketches or code directly onto the Arduino Due or do I have to purchase the hardware kit which would include the SAM3X. I have little experience with AVR Studio and have purchased pricy development boards to use them. I do not want to do the same on the ARM side of things.
2 - using Atmel Studio doesn't really give me a method of compling code on my own SAM3X. If Atmel Studio may compile on the Arduino Due or onto one of there development boards, I dont know how this would help me to compile the code onto my standalone chip
I became very adamant about the Arduino IDE because I love it and its simple. I feel that joining Atmel Studio or other programs like Keil would be a huge learning curve. Also I am not that strong in C.
Your comments are appreciated
Daniel.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Arduino Due on a Breadboard
Atmel Studio includes direct support for the Due. You simply select it as the target for your program. You don't need to buy a special development board.dgelman wrote:1 - can you compile sketches or code directly onto the Arduino Due or do I have to purchase the hardware kit which would include the SAM3X. I have little experience with AVR Studio and have purchased pricy development boards to use them. I do not want to do the same on the ARM side of things.
The last time I looked, you couldn't compile arduino sketches directly. However, I recently ran across this post on our forums, announcing Arduino IDE support under Atmel Studio. I haven't investigated it at all, and I don't know if it includes support for the Due.
http://forums.adafruit.com/viewtopic.ph ... hilit=+tip
In any case, once you understand that there is no significant difference between a sketch and any other C program, the ability to compile an unmodified sketch may not seem like such a big deal. When you run a sketch, the man behind the curtain is nothing more than a main program that does exactly this:
Code: Select all
void main()
{
setup();
while (true) {
loop();
}
}
Actually, the opposite is true. Atmel Studio gives you the flexibility to program any sort of target board you design. Arduino limits you to boards that conform to Arduino designs.dgelman wrote:2 - using Atmel Studio doesn't really give me a method of compling code on my own SAM3X. If Atmel Studio may compile on the Arduino Due or onto one of there development boards, I dont know how this would help me to compile the code onto my standalone chip
Whether or not you're comfortable with a new IDE is, of course, up to you. However, the learning curve may not be quite as steep as you anticipate. The Atmel Software Framework, which is part of Atmel Studio, can give you a head-start. You can create new projects which already include full support for many common functions, such as USB drivers and other sorts of hardware interfaces and I/O drivers.dgelman wrote:I became very adamant about the Arduino IDE because I love it and its simple. I feel that joining Atmel Studio or other programs like Keil would be a huge learning curve. Also I am not that strong in C.
The only way to know for sure is to give it a try and see what you think.
- dgelman
- Posts: 12
- Joined: Thu Jan 10, 2013 7:05 pm
Re: Arduino Due on a Breadboard
Hello Rick,
Thank you for responding to me and giving me your advice. I am still confused how switch to Atmel Studio will help me compile my code onto a board that I have designed that will be using the SAM3X.
Currently, I have my prototype with the specified code. Switching to Atmel Studio, I will still have a prototype in my hand but now on software provided by Atmel. I will still be confused on how to develop my own board that contains the ARM chip and and upload that code.
I agree that I should expand my knowledge into Atmel Studio and that will help, but I do not/will not understand how to get my code on a SAM3X embedded on my own board.
I feel like I am missing a small understanding. Perhaps Atmel Studio will provide guidance on how to create custom boards and chips? My experience with this is along the lines of AVR development, in which I was required to purchase the development kit. I feel that switching to ARM will require me to re-purchase all the development tools to get started.
I like the "Arduino on a Breadboard" concept because it is straight forward, I need a little bit a guidance to get me started in ARM.
Are there tutorials anywhere that show how to do this, similar what Derek Malloy showed - but for ARM?
Thank you kindly,
Daniel
Thank you for responding to me and giving me your advice. I am still confused how switch to Atmel Studio will help me compile my code onto a board that I have designed that will be using the SAM3X.
Currently, I have my prototype with the specified code. Switching to Atmel Studio, I will still have a prototype in my hand but now on software provided by Atmel. I will still be confused on how to develop my own board that contains the ARM chip and and upload that code.
I agree that I should expand my knowledge into Atmel Studio and that will help, but I do not/will not understand how to get my code on a SAM3X embedded on my own board.
I feel like I am missing a small understanding. Perhaps Atmel Studio will provide guidance on how to create custom boards and chips? My experience with this is along the lines of AVR development, in which I was required to purchase the development kit. I feel that switching to ARM will require me to re-purchase all the development tools to get started.
I like the "Arduino on a Breadboard" concept because it is straight forward, I need a little bit a guidance to get me started in ARM.
Are there tutorials anywhere that show how to do this, similar what Derek Malloy showed - but for ARM?
Thank you kindly,
Daniel
- dgelman
- Posts: 12
- Joined: Thu Jan 10, 2013 7:05 pm
Re: Arduino Due on a Breadboard
Rick,
Perhaps I have to get started on ARM external programming. Essentially, using Atmel Studio or Arduino IDE to upload the sketch/code and use the ARM external programmer to compile the code onto some pins broken out onto the custom board.
I know in AVR we use the ICSP, but I have been looking at something called JTAG Programmer. Do you know of tutorials, possibly provided by Adafruit I may use to get started in ARM programming and programmers.
I feel like this is the best solution to my issue. Design the board > bring out specific pins > ARM external programmer.
Daniel
Perhaps I have to get started on ARM external programming. Essentially, using Atmel Studio or Arduino IDE to upload the sketch/code and use the ARM external programmer to compile the code onto some pins broken out onto the custom board.
I know in AVR we use the ICSP, but I have been looking at something called JTAG Programmer. Do you know of tutorials, possibly provided by Adafruit I may use to get started in ARM programming and programmers.
I feel like this is the best solution to my issue. Design the board > bring out specific pins > ARM external programmer.
Daniel
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Arduino Due on a Breadboard
Regarding loading code onto your target: The SAM3X8E bootloader comes preprogrammed in ROM from the Atmel factory. The Programming Port on Due is connected to an ATmega16U2 which serves as a USB-Serial interface. This connects to UART0 on the SAM.
So, your target will automatically have the same serial bootloader as is used by the Due. You should be able to load your target from Arduino by connecting a USB-Serial cable to RX0/TX0.
You can also download code via JTAG. The Due has a 10-pin JTAG header near the upper-left-hand corner of the board. You can add a similar header to your target - it connects directly to the SAM.
Arduino has no JTAG support. You will need Atmel Studio for that. The JTAG pod is a small box which connects to your computer via USB, and connects to the target via a small ribbon cable. Atmel Studio will automatically recognize the pod; to use it with your project, you simply select it from a drop-down list - similar to selecting a Serial Port in Arduino.
JTAG not only allows you to download your code, but it also supports line-by-line debugging and allows you to examine memory and CPU registers in real-time. It eliminates the necessity of debugging with Serial.print() statements.
This is the JTAG pod I bought for my Due:
ATMEL - AT91SAM-ICE - JTAG EMULATOR, FOR SAM3, SAM7, SAM9, SUPPORT SWD
The JTAG pod has a 20-pin ribbon cable. Since the Due has a 10-pin header, you need a little adapter to connect the pod to the Due:
Texas Instruments MDL-ADA2 JTAG 20-pin-10-pin adapter cable
So, your target will automatically have the same serial bootloader as is used by the Due. You should be able to load your target from Arduino by connecting a USB-Serial cable to RX0/TX0.
You can also download code via JTAG. The Due has a 10-pin JTAG header near the upper-left-hand corner of the board. You can add a similar header to your target - it connects directly to the SAM.
Arduino has no JTAG support. You will need Atmel Studio for that. The JTAG pod is a small box which connects to your computer via USB, and connects to the target via a small ribbon cable. Atmel Studio will automatically recognize the pod; to use it with your project, you simply select it from a drop-down list - similar to selecting a Serial Port in Arduino.
JTAG not only allows you to download your code, but it also supports line-by-line debugging and allows you to examine memory and CPU registers in real-time. It eliminates the necessity of debugging with Serial.print() statements.
This is the JTAG pod I bought for my Due:
ATMEL - AT91SAM-ICE - JTAG EMULATOR, FOR SAM3, SAM7, SAM9, SUPPORT SWD
The JTAG pod has a 20-pin ribbon cable. Since the Due has a 10-pin header, you need a little adapter to connect the pod to the Due:
Texas Instruments MDL-ADA2 JTAG 20-pin-10-pin adapter cable
- ajienikicio
- Posts: 26
- Joined: Tue Aug 27, 2013 11:20 pm
Re: Arduino Due on a Breadboard
Hi!
I'm currently trying to develop a similar thing.
I'm going to get a SAM3S chip and develop a prototype board (like common arduino boards) out of it. I have looked up a few schematics on similar boards, arduino due, olimex SAM3-P256 dev board, and atmel's SAM3S-EK dev board. Based on these schematics, I've decided the clock circuit, regulator circuits (VIN to 5V and 5V to 3.3V), RESET and ERASE, JTAG circuit, and some caps to take care of the VDDs inside the chip according to the schematic check list http://www.atmel.com/Images/11061.pdf.
Are there anything else critical to get the board working?
I'm planning to get a SAM-ICE to program and debug the board via JTAG, so I don't need any USB interface, do I?
Lastly, once I get all the components connected, any one have any suggestions on how do I start working on the software? I guess I need to work on bootloaders etc before I can code into it like a common development board, right?
Any one here have ever done something like this? Developing a board out of the core and other components?
I would be really helped if anyone could share.
Thank you
I'm currently trying to develop a similar thing.
I'm going to get a SAM3S chip and develop a prototype board (like common arduino boards) out of it. I have looked up a few schematics on similar boards, arduino due, olimex SAM3-P256 dev board, and atmel's SAM3S-EK dev board. Based on these schematics, I've decided the clock circuit, regulator circuits (VIN to 5V and 5V to 3.3V), RESET and ERASE, JTAG circuit, and some caps to take care of the VDDs inside the chip according to the schematic check list http://www.atmel.com/Images/11061.pdf.
Are there anything else critical to get the board working?
I'm planning to get a SAM-ICE to program and debug the board via JTAG, so I don't need any USB interface, do I?
Lastly, once I get all the components connected, any one have any suggestions on how do I start working on the software? I guess I need to work on bootloaders etc before I can code into it like a common development board, right?
Any one here have ever done something like this? Developing a board out of the core and other components?
I would be really helped if anyone could share.
Thank you
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Arduino Due on a Breadboard
Not for programming. But USB is nice for serial debug, data communications, etc.ajienikicio wrote:I'm planning to get a SAM-ICE to program and debug the board via JTAG, so I don't need any USB interface, do I?
If you've got JTAG, you don't need any bootloaders. JTAG will download to flash.ajienikicio wrote:Lastly, once I get all the components connected, any one have any suggestions on how do I start working on the software? I guess I need to work on bootloaders etc before I can code into it like a common development board, right?
Download Atmel Studio 6 (free from Atmel). It will automatically generate basic board support for you. It also comes with the Atmel Software Framework, which is a suite of drivers and sample code. You can use it to generate large parts of your application.
I recently built a fairly large system based on a the ATmega32U4. Job 1 was figuring out if the part could actually do what I needed it to do. That process involved untangling and assigning all the GPIO pins with all of their alternate functions, allocating timers, and evaluating memory requirements. I put all that into a spreadsheet so I could keep track of it all.ajienikicio wrote:Any one here have ever done something like this? Developing a board out of the core and other components?
I didn't use any driver packages except the excellent LUFA USB package, so I started by writing initialization code, a state-machine foundation, timer queues, and some memory management routines. Once the framework was in place, I just went along adding drivers and application subsystems one by one.
- ajienikicio
- Posts: 26
- Joined: Tue Aug 27, 2013 11:20 pm
Re: Arduino Due on a Breadboard
Rick
Thank you so much for your reply!
And if I want to use USB, I'll have to touch on the bootloader. Am I correct?
Thank you so much for your reply!
So if I use JTAG, I'll be able to use the MCU to control LEDs and all that stuff just like any development board?If you've got JTAG, you don't need any bootloaders. JTAG will download to flash.
Download Atmel Studio 6 (free from Atmel). It will automatically generate basic board support for you. It also comes with the Atmel Software Framework, which is a suite of drivers and sample code. You can use it to generate large parts of your application
And if I want to use USB, I'll have to touch on the bootloader. Am I correct?
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Arduino Due on a Breadboard
If you want to use the Arduino IDE, then you'll need to put a bootloader on the chip. The Arduino IDE doesn't support JTAG. The standard Arduino Due bootloader will include USB access.
However, once you've used Atmel Studio and JTAG, you probably won't want to go back to the Arduino IDE.
However, once you've used Atmel Studio and JTAG, you probably won't want to go back to the Arduino IDE.
- ajienikicio
- Posts: 26
- Joined: Tue Aug 27, 2013 11:20 pm
Re: Arduino Due on a Breadboard
I'm going to use Atmel Studio! So I don't need any bootloader even if I use USB to program the chip?
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: Arduino Due on a Breadboard
If you use USB to program the chip, then you DO need a bootloader. If you use JTAG to program the chip, then you DON'T need a bootloader.
Please be positive and constructive with your questions and comments.