0
\$\begingroup\$

For a uni project I am tasked with programming embedded C onto an ATMEGA 8 uC, and there aren't enough development boards for everyone to use at uni, so I have an ingenious solution. I have several arduino uno's lying around, and I've replaced the ATMEGA328P chip on the Uno with an ATMEGA 8 chip.

Now I want to program the chip while it is on the arduino uno board, using Atmel Studio instead of Arduino IDE in Embedded C (not C++).

From what I hear, first, I'll need to burn a bootloader onto the ATMEGA 8 chip before I can do anything else. But which bootloader do I burn? Will the Arduino Bootloader work for the ATMEGA 8? or do I need the bootloader made specifically for the ATMEGA 8 in embedded C? I need to program it in Atmel Studio afterwards as well, instead of using the Arduino IDE.

\$\endgroup\$
  • \$\begingroup\$ As an alternative, you could use another Arduino running an ISP sketch to program it, though it's likely that suitable bootloaders exist. How specific the bootloader needs to be would depend on the specific details that differ. Do differentiate between the process of developing embedded software, vs. the process of loading the result into a chip. Also be aware that both the Arduino IDE and Atmel Studio are front ends for the same avr-gcc compiler suite, though the former modifies code before compiling it. \$\endgroup\$ – Chris Stratton Aug 22 '18 at 1:58
  • 3
    \$\begingroup\$ For that matter it's also possible you can do much of your work on an ATmega328p as long as you take care to beware of differences. Or in a simulator... \$\endgroup\$ – Chris Stratton Aug 22 '18 at 2:01
  • \$\begingroup\$ I have tried to use another Uno to load the bootloader onto the current board, i.e. burning bootloader from ArduinoISP sketch. But I get an error when I burn it - probably perhaps due to the programmer not realising the chip was swapped. \$\endgroup\$ – Simon Yu Aug 22 '18 at 2:29
  • 1
    \$\begingroup\$ Of course the work you turn in must work on the intended target, but with care to note differences in the data manuals you can probably do most of the "figuring out" with a chip that is similar (or with a simulator) and then do a final test with the official lab boards. In terms of an ISP error, you can't just allude to an error, you need to actually post it. But an ISP solution will definitely know the chip has been changed, since each version has its own ID code and that is pretty much the first thing an ISP setup checks, in order to verify the connection. \$\endgroup\$ – Chris Stratton Aug 22 '18 at 3:39
  • 1
    \$\begingroup\$ What are your classmates - the ones who got the dedicated Atmega8 boards - using to upload their firmware? \$\endgroup\$ – Nick Alexeev Aug 22 '18 at 5:58
2
\$\begingroup\$

I recommend to use one of the unaltered Arduinos as a regular ISP programmer for the tweaked ATmega8 ones. The reason is a bootloader requires some of the flash memory on the ATmega8. The ISP mechanism in contrary is built into the chip so you can use all of the flash memory for your user program.

Arduino as an ISP programmer is supported e.g. by the avrdude programmer software.

\$\endgroup\$
1
\$\begingroup\$

I had written an Instructables on this topic a year back or so. They contain the instructions on how to do so. They are:

ATmega8 as Arduino(uses Internal 8Mhz Crystal)

This covers how to burn the bootloader into ATmega8. Once done, simply insert it in your board.

How to burn bootloaders into AVRs

\$\endgroup\$
  • \$\begingroup\$ An answer here should stand on its own, not merely be a link to offsite resources, even if they are of your own authorship. The standard is that the answer must still be useful even if all the links in it cease working, and at present this posting is not. \$\endgroup\$ – Chris Stratton Aug 22 '18 at 3:41
  • \$\begingroup\$ Good point, I understand that, but what should I do if the procedure is big? \$\endgroup\$ – Utkarsh Verma Aug 22 '18 at 3:48
  • 1
    \$\begingroup\$ Explain the key, unique parts that are specifically applicable within your posting itself. For example, only what needs to be different when using an ATmega8 rather than an ATmega328p/168/88. Keep in mind also that the asker is not intending to do Arduino development, but rather to specifically target the ATmega8 for what it actually is. So Arduino methods are only relevant to the degree that they help with that goal - things that are only applicable to Arduino development are irrelevant to the asker's goal. \$\endgroup\$ – Chris Stratton Aug 22 '18 at 4:22
  • \$\begingroup\$ I have taken a look at your instructable, and I am planning to use Atmel studio instead of Arduino IDE afterwards. Would the bootloader still be the same? i would like to think that the arduino bootloader is for C++ and the Atmel Studio bootloader is for embedded C. Correct me if I'm wrong. \$\endgroup\$ – Simon Yu Aug 22 '18 at 4:24
  • \$\begingroup\$ @SimonYu - no, the bootloader has nothing to do with the main program's source language. It is only concerned with hardware differences and the mechanism of transferring control to the main program. Atmel studio may offer a unique bootloader, but you can also use an Arduino style one with a program built via Atmel studio, as long as the software you use to do the actual transfer is something (like avrdude) that knows how to talk to the bootloader you are using. \$\endgroup\$ – Chris Stratton Aug 22 '18 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.