Arduino IDE with own target PCB

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello clever people, long time since I've been here...

I would like to use the Arduino IDE, but instead of uploading through the serial port, I would like to use my own PCB, and load through ISP, like a normal AVR.
Why do I want to use Arduino? Because I like the look of the pre-built libraries for common tasks, and it's free and legal.
Why use my own boards then? Because the board gets built for each project, no one-size-fits-all hardware.

What I currently do:
>Use AVR Studio to set fuses (important because Arduino boards are usually 16Mhz, I want to use 8Mhz internal osc)
>Write in Arduino, hit compile.
>Find the hex file in C:\Users\myname\AppData\Local\Temp\build5903074505980011522.tmp\file.cpp.hex
>Load into AVR Studio
>Burn with AVR Studio

What I want to do:
>Write in Arduino, hit compile.
>Hit 'upload' and have it magically go to the PCB.

From the Arduino IDE, I have selected Programmer -> avr isp mkii.
From the Arduino IDE, I have selected Board -> -- AVRISP mkII - ATmega328 --

I got this board type by editing boards.txt, and adding:

avrispmkii328.name=-- AVRISP mkII - ATmega328 --

avrispmkii328.upload.using=avrispmkii
avrispmkii328.upload.maximum_size=32768
avrispmkii328.upload.speed=115200

avrispmkii328.build.mcu=atmega328p
avrispmkii328.build.f_cpu=8000000L
avrispmkii328.build.core=arduino
avrispmkii328.build.variant=standard

The error I get is:
"avrdude: usbdev_open(): did not find any USB device on "usb"

So, there we have it.
Does anybody know if/how this can be done the way I would like it?

Thanks
Pete

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For your own PCB design, you can still use the Arduino IDE. You will need their boot loader. And, as well, you will need to go into one of the configuration files and alter the base operating frequency of the AVR for the crystal frequency you want to use.

I did the above once with one of my custom PCB designs. But I prefer to use ImageCraft C compiler, giving me complete control of my own functions that I write. And so, I simply keep an instance of Image Craft and AVRStudio open and simply tab from one to the other, using an ATISP-MKII for programming. In fact, I have been using the Arduino PCBs for experiments and using my ATISP-MKII on the built-in ISP programming header that is on every standard (not the DIP versions) Arduino board that I've seen.

You can avoid reality, for a while.  But you can't avoid the consequences of reality! - C.W. Livingston

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
avrispmkii328.upload.using=avrispmkii
avrispmkii328.upload.maximum_size=32768
avrispmkii328.upload.speed=115200

This sort of definition is supposed to work, but it looks like it's broken and is not providing the sort of "port" name that avrdude expects for an avrispmkii. That could be just random breakage, or a change in the way that avrdude works. (does the avrispmkii emulate a serial port? At least some programmers that connect via usb are/were automatically detected via libusb based on their usb id info.)

You can try fiddling with .../hardware/arduino/programmers.txt

Note that Arduino will ALWAYS use avrdude for the upload, even when uploading via a programmer. (At least, prior to 1.5.x) You can also experiment with using avrdude from the command line to make sure that it can establish communications with your programmer.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I do this all the time with our custom boards. Instead of editing the .upload lines in boards.txt, I only editted the fuse and clock speed settings. You can then also burn the fuses from Arduino by uploading the bootloader, as this will also set the fuses. It's a bit of overhead because you will also burn the bootloader which never gets used, but it's more convenient than having to switch over to AVR Studio.

For burning using the programmer, I've simply gotten used to hitting Ctrl+Shift+U, which forces to upload using the selected programmer.

If that still doesn't work, it's likely that you are trying to use Arduino/avrdude using the Jungo USB driver that Atmel Studio requires. Avrdude requires the libusb-win32 driver.

For programming lots of devices, we've written a build script that calls avrdude twice, once to set the fuses and once to upload the sketch. You can take the commands form the verbose output when uploading in the Arduino IDE.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks guys, couple of things for me to check out there.
Cheers