Using Arduino hex file in atmega 8

Go To Last Post
99 posts / 0 new

Pages

Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello friends,

I have a problem, please take a look at this code first.

 

#define F_CPU 1000000

int IRpin=A0;       // Analog pin A0 used as an analog input
int IRemitter=2;    //Pin 2 on the arduino board used the ir emmiter pin
int ambientIR;
int obstacleIR;
int value[10];
int distance;

void setup() {
Serial.begin(9600);         //Enable serial communication
pinMode(IRemitter,OUTPUT);  //IRemitter pin set as output
digitalWrite(IRemitter,LOW);
}

void loop() {
distance=readIR(5);
Serial.println(distance);
}

int readIR(int times){
  for(int x=0; x<times; x++)
  { 
    digitalWrite(IRemitter,LOW);
    delay(1);
    ambientIR=analogRead(IRpin);
    digitalWrite(IRemitter,HIGH);
    delay(1);
    obstacleIR+analogRead(IRpin);
    value[x]=ambientIR-obstacleIR;
  }
  for(int x=0; x<times; x++)
  {
    distance+=value[x];
  }
  return(distance/times);
}
    

 

I have this code nicely working on my arduino Uno. The thing is, i have an atmega 8-8pu, running at default 1 mhz. 

Setting to Verbose output during compilation, i got the hex file which i burned on the atmega 8 using command line. 

But when i connect the tx pin of the mega8 to the rx pin of the serial to ttl converter and open up my serial monitor in the arduino ide, i see nothing, no values show up but the scrollbar automatically starts moving as if blank spaces are being print. 

 

Whilst using this code on arduino, i saw values being printed, continuously, but now nothing prints but the scroll bar keeps moving on its own as if blank spaces are being print.

I have set the F_CPU to 1 mhz, because im using it for atmega8 running at 1 mhz.

 

I am not able to figure out the error.  Is there any problem with wrong baudrate getting set ?

Please help find out the possible errors and suggest changes.

 

ps: I am using arduino ide version 1.6.4

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

Rudro17 wrote:
atmega8 running at 1 mhz

Are you sure about that?

 

Also:

What clock frequency does a genuine Arduino run on? How is the Arduino Serial library compute the baud rate register value? Is the Arduino Serial library at all using F_CPU for this?

 

If you dig into the Arduino sources, you'll probably find out most of this.

 

Or, go for running the mega8 at the same frequency as a genuine Arduino.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Thu. Dec 31, 2015 - 11:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes.
Its rather a new chip. Had just burned arduino atmega8 bootloader without changing any fuses. Then had burned a simple led program and now this. Never changed any fuse setting. Could burning the bootloader cause it not to run at 1 mhz ?

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

A Genuine arduino runs at 16 mhz. But this chip is atmega8- 8pu. So it can run at 8mhz maximum, i wont be able to run it at 16mhz.

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

How is the Arduino Serial library compute the baud rate register value? Is the Arduino Serial library at all using F_CPU for this?

Regarding this, i thought about it once. Should i look into the hardware serial library ?
If not, which library to look up ?

Last Edited: Thu. Dec 31, 2015 - 12:01 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Arduino 1.6.4 doesn't support the ATmega8 natively, except via the 'Arduino NG or older w/ ATmega8' board selection, which 1.6.4 doesn't even show in the boards menu.  Which third-party core have you installed?

 

I assume you know you can't just build for the UNO and upload to an m8.

 

How did you place the bootloader onto the m8?  If you managed to do it through the Arduino IDE via the above board selection, that will set the fuses for an external resonator.

 

You need to tell us more.  There are too many unanswered questions at the moment.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Sorry for providing less information.
I know i cant chose directly atmega 8 in 1.6.4. What i did is-
I went to the bootloaders folder in the avr folder which is located in the hardware folder. I searched up the atmega8 bootloader 'hex' file and then burned it using command line in my atmega8. Since i didnt write any command to change the fuses, i expect it isnt changed.
Now, what i did, i found out the temporary build folder and copied out the hex file of my program. Now, burned it again using command line. Since, this is spi programming, the bootloader must have been erased whilst this new program was flashed.

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

As JohanEkdahl wrote:

How is the Arduino Serial library compute the baud rate register value? Is the Arduino Serial library at all using F_CPU for this?

I dont know exactly which header file source i should look up. There are many, hardwareserial.cpp, stk500.cpp etc which one should i look upon to find if they use F_CPU in calculating baudrate or not ?

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

This is a code snippte from hardwareserial.cpp.

void HardwareSerial::begin(unsigned long baud, byte config)

{

  // Try u2x mode first

  uint16_t baud_setting = (F_CPU / 4 / baud - 1) / 2;

  *_ucsra = 1 << U2X0;

  // hardcoded exception for 57600 for compatibility with the bootloader

  // shipped with the Duemilanove and previous boards and the firmware

  // on the 8U2 on the Uno and Mega 2560. Also, The baud_setting cannot

  // be > 4095, so switch back to non-u2x mode if the baud rate is too

  // low.

  if (((F_CPU == 16000000UL) && (baud == 57600)) || (baud_setting >4095))

  {

    *_ucsra = 0;

    baud_setting = (F_CPU / 8 / baud - 1) / 2;

  }

  // assign the baud_setting, a.k.a. ubrr (USART Baud Rate Register)

  *_ubrrh = baud_setting >> 8;

  *_ubrrl = baud_setting;

  _written = false;

  //set the data bits, parity, and stop bits

#if defined(__AVR_ATmega8__)

  config |= 0x80; // select UCSRC register (shared with UBRRH)

#endif

  *_ucsrc = config;

  

  sbi(*_ucsrb, RXEN0);

  sbi(*_ucsrb, TXEN0);

  sbi(*_ucsrb, RXCIE0);

  cbi(*_ucsrb, UDRIE0);

}

Does it keep any connection with what i am searching for ?

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

I dare say it does. Arduino has a boards.h file that defines the parameters for each type of board. You need to add your custom settings to this and the rest should work itself out.

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

Hang on.  You said:

I know i cant chose directly atmega 8 in 1.6.4.

But then you said:

Now, what i did, i found out the temporary build folder and copied out the hex file of my program. Now, burned it again using command line

So how did you build that hex file for the m8?  It has to be >>built<< for the m8, not just uploaded to an m8.  If you're building for an UNO, or and NG w/ 168, it will not work on an m8.

 

Attach the .hex file you uploaded to your m8 to a post here in this thread.

 

As David Kartman says, you can add a 'board' to the file boards.txt in the Arduino IDE to describe your m8.  Then you'll be able to build and upload directly from the Arduino IDE using your ISP programmer.

 

edit: attribution.

Edit by Joey: Thanks.  As I said in another thread, new glasses are on the way ;-)

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Fri. Jan 1, 2016 - 06:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So how did you build that hex file for the m8?  It has to be >>built<< for the m8, not just uploaded to an m8.  If you're building for an UNO, or and NG w/ 168, it will not work on an m8.

Sorry i forgot to mention that, i chose arduino ng or older with atmega 8, then built it. I used that hex file.

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

As David Kartman says, you can add a 'board' to the file boards.txt in the Arduino IDE to describe your m8.  Then you'll be able to build and upload directly from the Arduino IDE using your ISP programmer.

Just to be sure-
If i add another board meeting my requirements, in the boards.txt file. I will be directly able to upload to the m8 by using 'upload using programmer' and choosing my board from the 'boards' list. My steps are correct, i presume ?
Also, no bootloading the chip. One more thing, which is yet too early to ask, what happens if during uploading using programmer, the ide complains about signature mismatch ? Like what usually happens when we try to bootload an atmega 328-pu instead of atmega328p-pu.

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

I have never used NG. Most boards.txt entries specify the AVR, the F_CPU, the bootloader, the fuses, ...

So you select the NG, burn the bootloader, run like any other Arduino.

If the existing NG entry does not suit, write your own "special" entry.
Make sure to set the fuses to 8MHz RC or 1MHz RC if you don't have a crystal.

Quite honestly, it is cheaper and easier to buy a Nano clone or a Uno clone.

David.

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

Tried to write an extra entry. Please check this out. I am unsure about the fuses.

Attachment(s): 

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

I have no idea what the bootloader that you selected wants or expects.

 

Clearly a 1MHz AVR can never do 19200 baud.

And reserving 2048 bytes for a bootloader in a 8192 byte chip seems over generous.

 

And please note that 1 milli hertz is a very SLOW frequency.

Since the ATmega8 has got a 8 Mega Hertz RC oscillator,  it seems wise to set the fuses for 8MHz RC.

 

David.

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

I have changed it. Please see it now.

 

i also uploaded the bootloader folder.

Attachment(s): 

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

 

Sorry i forgot to mention that, i chose arduino ng or older with atmega 8, then built it. I used that hex file.

But that .hex file will have been built for an m8 running at 16 MHz.  If your m8 has the as-shipped factory default fuse settings, it will be running at 1 MHz.  Therefore the baud rate of the Serial library will be 16 times slower than what you think it is.  You've configured for 9600 baud, but since the m8 is running 16 times slower, the real baud rate will be 600 baud.  Set your serial monitor to 600 baud to see if this is in fact the case.

 

The m8 bootloader which ships with 1.6.4 and which you selected in your boards.txt attached above is built for 16 MHz and 19200 baud.  Again, if your m8 is running at 1 MHz, you'll need to write the board.txt entry to communicate at one sixteenth that rate, or 1200 baud.  If you run it with the 8 MHz RC, set 9600 baud.

 

It also uses the 'arduino' protocol, not the standard 'stk500' protocol.

 

That bootloader is 1K, so the max size should be set to 7168.

 

I recommend putting a crystal and caps on your m8 and fusing it to run with the an external crystal.  If you insist on using the internal RC oscillator, fuse it to run with the 8 MHz RC instead of the 1 MHz RC.  However, the calibration value for the 8 MHz RC isn't automatically loaded by the m8.  You'll need to do that yourself.  An inaccurate RC oscillator will likely prevent serial communications from being reliable, or even working at all.

 

Several other changes are needed.  Here's the entry I'd suggest for running your m8 with the 8 MHz RC:

##############################################################
atmega8_8mhz.name=ATmega8 (Internal 8MHz RC)

atmega8_8mhz.upload.tool=avrdude
atmega8_8mhz.upload.protocol=arduino
atmega8_8mhz.upload.speed=9600

atmega8_8mhz.bootloader.tool=avrdude
atmega8_8mhz.bootloader.unlock_bits=0x3F
atmega8_8mhz.bootloader.lock_bits=0x0F

atmega8_8mhz.build.mcu=atmega8
atmega8_8mhz.build.f_cpu=8000000L
atmega8_8mhz.build.board=AVR_M8
atmega8_8mhz.build.core=arduino
atmega8_8mhz.build.variant=standard

atmega8_8mhz.upload.maximum_size=7168
atmega8_8mhz.upload.maximum_data_size=1024

atmega8_8mhz.bootloader.low_fuses=0xe4
atmega8_8mhz.bootloader.high_fuses=0xda
atmega8_8mhz.bootloader.file=atmega8/ATmegaBOOT-prod-firmware-2009-11-07.hex

Untested.

 

However, to re-iterate, RC oscillators are not well suited to serial comms.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

atmega8_8mhz.bootloader.file=atmega8/ATmegaBOOT-prod-firmware-2009-11-07.hex

Just a thing more, there are two bootloader in the folder, one is ATmegaBOOT.hex and the other one which u chose, any specific reasons, why you chose that bootloader hex file ?

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

I included the new board in the boards.txt file.
Then I tried it, in two different ways and two different things happened-

Trial 1: I uploaded the arduinoisp sketch in the uno, then i selected the atmega8 internal rc board from the boards menu. The port was same as usual. Connected my atmega8 placed in the breadboard with my uno, using 6 wires. Then using arduino as isp selected, i chose burn bootloader.

Outcome: an error message, saying efuse not defined for atmega8.

Trial 2: I pulled out my atmega328p-pu from the uno board, placed the atmega8 and selected atmega 8 internal rc from boards, the port was same. Selected arduino as isp and tried to bootload.

Outcome: it tried 10 times, sometimes said programmer not responding, sometimes said stk500 error, sometimes said error 0x03 not responding.

Which trial of mine was correct at all ? Or were both wrong ? If both were wrong what might have been the problem. Pls help a way out.

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

I suspect that you paid more money for a single ATmega8 chip than it would cost for a Chinese Nano or Uno.

Life is a lot simpler with a fully supported Arduino.

 

I do not own an ATmega8 chip.   It is old and under-endowed.

 

Ah-ha.   You possess a Uno !!!

 

The pcb already has a 16MHz crystal.   

1.  Write a boards.txt entry.

2.  Build the bootloader and fuses for a 16MHz mega8 and plug it into the Uno socket.

3.  It should work first time.

 

Then write another boards.txt entry,  build another bootloader for 8MHz RC

 

Yes,  it is good exercise.    But if you already have a Uno,   why not just use the Uno and throw the mega8 in the bin?

 

Incidentally,   read your post#20.    It is nonsense.   If you installed a bootloader,  you do NOT "Selected arduino as isp "

 

David.

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

I have 3 atmega8. I thought i could bootload them all and put to some use.

  If you installed a bootloader,  you do NOT "Selected arduino as isp "

If i could have bootloaded successfully, why would i have posted the #20 post ? Since i could not, thats why i described two of my attempts, thinking that you will be able to find any fault in any of the given steps.
Also, i know, i dont use 'arduino as isp' with a chip which is already bootloaded. I never said that !
It was wrong from my side because i messed up the post with half information and probably wrong trials. Im sorry for it. Instead i should have asked, i have added the 8mhz internal rc entry for atmega8 in the boards.txt file, what do i do next ?

So, what do i do now ? I am not much familiar with the arduino ide.

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

In fact im even more confused now. Do i even need to bootload the atmega8 ?
If yes, how ?
Or if no, do i only need to select atmega8 8mhz internal rc from boards and do directly 'upload using programmer' after choosing arduino as isp, if i want to upload any sketch to the atmega8 ?
Please make this easy for me or atleast refer something to read so that i can try to get it by myself.
I wont ask anything of this sort again.

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

You have 3 ATmega8 chips. Just program them for whatever purpose that you want as a one-off application.

Use your UNO for repeated development. You can even develop the one-off apps for the mega8 chips.
A bootloader is only convenient if you already have a proper UART interface e.g. a USB adapter like the UNO.

If your mega8 is just on a breadboard or protoboard, it is easy to use your UNO as ArduinoISP to program it.

David.

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

Im so sorry. I just had thought that bootloading is something different. Now i realise, why you called that post irrelevant. I now burned the bootloader hex file using command line. Now, how do i upload sketches to it ?
I tried using an prolific usb to ttl converter, but it says the same- tried 10 times, stk500_recv() error: programmer not responding and stk500_getsync(): error 0x03.
I have tried placing it on the Uno board after removing the m328p but still the same error. I have burned the bootloader hex file using command line. How do i upload sketches to it ?

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

If your mega8 is just on a breadboard or protoboard, it is easy to use your UNO as ArduinoISP to program it.

I am sorry but things are now getting so mixed up for me.
If i have my m8 in my breadboard, u said i can program it by using uno as isp. Will i be able to do it without bootloading ?

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

Rudro,

 

Have a read of this... a couple of times until "it sinks in".

 

https://www.arduino.cc/en/Tutori...

 

Ross McKenzie ValuSoft Melbourne Australia

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

Yes.    There must be hundreds of Arduino internet tutorials, videos,  fairy stories,  ... that show you how to do this.

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

Just a thing more, there are two bootloader in the folder, one is ATmegaBOOT.hex and the other one which u chose, any specific reasons, why you chose that bootloader hex file ?

The only reason I suggested that one is because the board entry for the NG w/ m8 used it.  I have not examined the two to determine the differences, or whether one would be more appropriate.

 

Outcome: an error message, saying efuse not defined for atmega8.

I suppose this >>may<< be a bug in 1.6.4?  The m8 doesn't have an extended fuse.  Many other devices do (like the m168, the m328, etc.).  Perhaps the IDE 1.6.4 expects all devices to have an efuse?  The entry for the NG w/ m8 lacks an efuse, but perhaps the nice folks at Arduino neglected to fully test 1.6.4 when burning bootloaders for all supported devices?  I'm merely speculating.  There may be another reason you got that error.

 

In fact im even more confused now. Do i even need to bootload the atmega8 ?

The answer to that presumes that you know what a bootloader is, and what makes it useful.  Let's see if we can clear that up.

 

Microcontrollers like AVR can be programmed in a few different ways.  Historically, they are programmed through the use of a piece of equipment called a programmer, and external device used to transfer code and data onto the permanent memory of the microcontroller.  Some years ago microcontrollers with the ability to 'self program' were developed.  This made it possible for special software called a bootloader, to be programmed into the device.  The purpose of a bootloader is to allow other software (application software) to be programmed onto the device with the need for a dedicated external programming device.  A bootloader could be written to communicate with a host using any of the existing interfaces (USART, SPI, I2C, etc.).

 

In the context of Arduino, a bootloader is used for the same reason, to allow a user to load software onto the AVR on-board the Arduino without need of an external programmer.

 

One important distinction between the concept of a 'bootloader' and the Arduino IDE's 'burn bootloader' option is that 'burn bootloader' will also set fuses in the same step.

 

If you are familiar with using avrdude on the command line (as it appears you are), and if you are familiar with using an ISP programmer (as it appears you are), then you can skip 'burn bootloader' step in the Arduino IDE and simply program your m8 from avrdude, or from the IDE using 'upload using programmer'.  If you want your m8 to run at 8 MHz, you will need to change the fuses to enable this.  The fuses I mention in the boards.txt entry I posted above will do that, but they will also configure the m8 for a bootloader (without actually burning one).  If >>all<< you want to do is program using ISP but run at 8 MHz, the fuses are:

lfuse: 0xE4

hfuse: 0xD9

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

One important distinction between the concept of a 'bootloader' and the Arduino IDE's 'burn bootloader' option is that 'burn bootloader' will also set fuses in the same step.

Thanks a lot. I didnt know this. This was the reason my arduino board or serial to ttl chip could not communicate with the atmega8. I burned the atmega8 hex file using command line but hadnot set the fuses to a 8mhz internal rc oscillator. It means it is still running at default 1mhz. Thats why serial communications were affected.
Thanks a lot anyways.

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

Just one more thing, in the boards.txt file entry, you wrote high fuse as 0xda but in the previous post you wrote high fuse as 0xD9. Why ?

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

I am sure that Joey had a good reason.
Have you looked at the www.engbedded.com website to see what the fuses mean?

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

Rudro17 wrote:

Just one more thing, in the boards.txt file entry, you wrote high fuse as 0xda but in the previous post you wrote high fuse as 0xD9. Why ?

I thought I explained that pretty clearly at the end of post #29 :)
Fuses in boards.txt set the size of the bootloader section (BLS) and move the reset vector to the BLS. The other fuse values don't.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sat. Jan 2, 2016 - 05:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know what fuses are- i read about them a year ago. They decide how a microcontroller should work. There are high fuse byte and low fuse byte and in some mcu's extended fuse byte.
I was asking that because, since im going to bootload the chip using command line and also change the fuses for 8mhz internal rc using command line, wont there be a problem in the sense- the arduino ide reads from the boards.txt file i suppose, when the ide uploads a sketch, wont it check the fuses (like when i burn using command line, evrytime it says, checking fuses and at the end says fuses ok) and match them with those in the boards.txt file and give an error if there is a mismatch ?
Ps: i dont know much about how the ide works, i rarely used arduino ide before, i have avrstudio 4.19, i build and then burn the hex file using command line.

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

The Arduino IDE only looks at the fuses from boards.txt when 'burning bootloader'. Fuses are neither written nor read when 'uploading' nor when 'uploading using programmer'.
avrdude will by default confirm that the fuse values remain unchanged after programming, but this is not checked against boards.txt, only against their state at the start of programming. The boards.txt file is purely for the IDE. It is unknown to avrdude.
If you will be using an ISP programmer to upload you app code, this is not 'bootloading'. It is just 'programming'. No need for a bootloader, no need for bootloader-specific fuses.
If you want to usethe bootloader which ships with 1.6.4, you will need an FTDI or other serial adapter widget. You will also likely need to calibrate the internal 8 MHz oscillator, or just bite the bullet and fit a crystal and caps.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sat. Jan 2, 2016 - 07:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So suppose i want to bootload my m8 using command line, so my command would me-
avrdude -c avrisp -p m8 -P com37 (in my case) -b 19200 -U lfuse:w:0xE4m -U hfuse:w:0xD9m -U flash:w:name_of_the_hex_file.hex:i
Is it correct ?
Avrisp and baudrate because i upload the arduinoISP sketch and use it to program my target. It shows up as avrisp.

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

Again, that is not 'bootloading'.  That is simply 'programming'.  There is no bootloader involved.

 

The ArduinoISP sketch does not behave like an avrisp.  It actually behaves like a stripped-down stk500v1.  When programming from the Arudino IDE, you must select "Arduino as ISP" as the programmer (>>not<< ArduioISP).  If programming using avrdude on the command line, the correct avrdude command line switch would be -c stk500v1 not -c avrisp.

 

The baud rate (19200) is correct for the ArduinoISP sketch.

 

The fuse options are correct:
-U lfuse:w:0xE4m -U hfuse:w:0xD9m

 

Bear in mind you only have to program the fuses once.  It is not necessary (and not a good idea) to program the fuses every time (unless you are changing them).  This should be sufficient:

avrdude -c stk500v1 -p m8 -P com37 (in your case) -b 19200 -U lfuse:w:0xE4m -U hfuse:w:0xD9m

 

Once the fuses are set to what you want them to be, you need only program the flash each time you want to upload a new program:

avrdude -c stk500v1 -p m8 -P com37 (in your case) -b 19200 -U flash:w:name_of_the_hex_file.hex:i

 

 

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sat. Jan 2, 2016 - 11:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Again, that is not 'bootloading'.  That is simply 'programming'.  There is no bootloader involved.

I got it, i wanted to say, if i program the bootloader hex file after setting the fuses for 8mhz internal rc oscillator, through command line. It would be 'bootloading' in a way. Will it work the same way as bootloading the chip, since during bootloading through the ide, the bootloader hex file is burned and and fuses are set. Thats what i am doing manually, setting the fuses and then flashing the bootloader hex file in the m8. After doing this, will it work in the same way as it would after 'bootloading' ?

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

I got it, i wanted to say, if i program the bootloader hex file after setting the fuses for 8mhz internal rc oscillator, through command line. It would be 'bootloading' in a way.

No it would not.  It would be installing (programming) a bootloader.  Later, using that bootloader, you would bootload an application.  But these are just semantics.  I mention them only so that in the future there might be less confusion.  Words represent concepts.  Use the wrong words, communicate the wrong concept.

 

Will it work the same way as bootloading installing a bootloader onto the chip, since during bootloading installing a bootloader through the ide, the bootloader hex file is burned and and fuses are set. Thats what i am doing manually, setting the fuses and then flashing the bootloader hex file in the m8. After doing this, will it work in the same way as it would after 'bootloading' installing a bootloader via the Arduino IDE ?

Yes it is the same.  All the IDE does is call avrdude to program the bootloader hex file and set the fuses.  Doing so yourself at the command line is of course the same thing, just more typing.  However, if the 1.6.4 IDE is throwing an error because of a 'missing' efuse entry, the command line may be your only option for the m8 anyway.

 

EDIT: typo

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Sun. Jan 3, 2016 - 01:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot for your help :)

Last Edited: Sun. Jan 3, 2016 - 05:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unfortunately typing the above commands and trying to change the fuses yields the following result-
It reads and shows device signature and then
avrdude:reading input file '0xE4m'
avrdude:error opening 0xE4m: No such file ordirectory
avrdude:input file 0xE4m auto detected as invalid format
avrdude:cant open input file 0xE4m: No such file or directory
avrdude:write to file 0xE4m failed
:(

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

I'm late to this thread but I can't believe the hassle involved.  For goodness sake £2/$3 will buy you this:

 

http://www.ebay.co.uk/itm/Arduin...

 

If you want to play the Arduino game is there any reason not to simply buy one when they cost less than a McDonald's burger or Starbucks coffee? 

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

Its true that the thread is over extended on a simple thing :P But since i am on the verge of accomplishing, what i wanted to do, i dont wish to stop now. Only changing the fuses is left. Though i very well agree that buying another one was a lot simpler.
I am happy that atleast i got my doubts cleared in the process for which i thank you people :)

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

Thanks a lot for helping me and spending so much time on a simple thing.
I think i found out my error. After searching i found out this- www.avrfreaks.net/forum/avrdude-error-opening-ff-no-such-file-or-directory
I guess i mistyped the commands.

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

Whoops, I didn't notice a typo in your command line.  It should read like this:

avrdude -c stk500v1 -p m8 -P com37 (in your case) -b 19200 -U lfuse:w:0xE4:m -U hfuse:w:0xD9:m

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Fuses were changed successfully at once. I flashed the bootloader too using command line. I was so happy. I pulled out the m328p from the uno board and placed in the m8. Still very happy. Opened the blink sketch and hit upload. Uploading was in process whilst me getting even more happier. But suddenly at the end an ERROR message ! Stk500_getsync() error: cannot communicate with device. Resp=0x0f. Happiness shattered:( At the moment literally felt like hammering the m8 to pieces.

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

At the moment literally felt like hammering the m8 to pieces.

Take a deep breath ;-)

 

I don't understand why you're making thing so difficult for yourself.  Why are you insisting on using a bootloader?  Especially if you're popping chips out of sockets in order to do so?

 

As for why you got a sync error, you haven't told us enough:

  • You were uploading using the IDE?
  • Which 'board' had you selected?  If it was still UNO, that won't work.  You must select a board with an m8 running 8 MHz.  Have you done this?  Was it the new boards.txt entry suggested many posts ago?

 

Bear in mind that the fuses you programmed select for the internal RC oscillator.  It is almost certainly going to need calibration.  Have you done so?

 

What are you trying to >>accomplish<<?  If it's just 'get code onto the m8', then forget about the bootloader.  Use ArduinoISP to upload code to the m8.  Done.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

As for why you got a sync error, you haven't told us enough:

You were uploading using the IDE?Which 'board' had you selected?  If it was still UNO, that won't work.  You must select a board with an m8 running 8 MHz.  Have you done this?  Was it the new boards.txt entry suggested many posts ago?

I usually havent done such mistakes ever. I selected the right board and the right boards.txt file. To be very true, my motive of getting the bootloader in the atmega8 is- it iss useful during the time when i am making frequent changes to the code. Like a proximity sensor or a light sensor where you need to check the adc values often. Having the bootloader makes it easy to make changes in the code and upload them again and again.

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

Bear in mind that the fuses you programmed select for the internal RC oscillator.  It is almost certainly going to need calibration.  Have you done so?

No, i havent done it. I dont know how to. Referring to any article would help. Wont it work without calibrating the internal oscillator ?
I mean if instead of using avrdude, if i directly would have done 'burn bootloader' from the ide, would the internal oscillator have got auto caliberated ?

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

Having the bootloader makes it easy to make changes in the code and upload them again and again.

How about popping chips in and out.  Is that 'easy'?  Do you have an FTDI or other USB->TTL converter?

 

I selected the right board and the right boards.txt file.

But you haven't said which one.  Is it the one I suggested in #18?

 

If you want to use a bootloader, you will have heartache with the internal RC oscillator.  You can calibrate it, but that can be more of a hassle than it's worth.  Just fit a crystal and caps, and set the fuses for an external crystal (note this is >>not<< the same as an external 'clock' or 'oscillator').  The fuses in the boards.txt entry for the NG /w m8 are correct for that arrangement.  That same entry assumes a 16 MHz clock, so if you want a different clock you'll need to create another entry in boards.txt with the correct clock frequency and correct baud rate.  The bootloader in #18 runs at 9600 baud at 9 MHz.  At 16 MHz, it will run at 19200 baud.

 

Post the full verbose console output resulting from your attempt to upload the blink sketch.  Just click in the console panel (the black strip at the bottom of the IDE), it CTRL-A to select all, CTRL-C to copy, and paste it into a text file in notepad.  Save it and attach it here.  It may help us determine if the issue is calibration, or that the bootloader is not correctly installed.  Then again, it may not tell us anything.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

How about popping chips in and out.  Is that 'easy'?  Do you have an FTDI or other USB->TTL converter?

I have the prolific one.
Just saying- since i have changed the fuses for an 8mhz internal rc oscillator and also i have made the proper boards.txt file as suggested by you, so why not program it using 'arduino as isp' without bootloading. Because the ide will compile the code for an 8mhz internal rc oscillator m8 , so that can be programmed directly so as to avoid the hassle of caliberating the internal rc oscillator for the bootloader ?

Pages