Pages: 1 [2]   Go Down
Author Topic: Making bootloader for Atmega162  (Read 6766 times)
0 Members and 1 Guest are viewing this topic.
Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You beat me too it, I was just editing my post above.
Jj
I did just that, but doesn't the name mess
If you rename the file, it will trick the arduino IDE into uploading that file.
Hehehe, nice smiley-razz

I did just that.
But i still cant load the firmware on it... No correct device name...
I'll look into it again tomorrow.  I need sleep now...
 smiley-sleep
Logged

Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to be shure,
how did you hookup the 162?
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

UNO -> Atmega162
Miso -> Miso
Mosi -> Mosi
SS -> Reset
+5v -> VCC
GND -> GND



What happens when you try and program it?
Logged

~Tom~

Netherlands
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK that's what I did.

I think the problem is in my x0xb0x.

I put a brand new CPU in today, with firmware, and still... no play time.
So I'll first have to fix the x0xb0x...

I think the bootloader worked just fine.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi TCWORLD
i just want to know, can you run bootloader on ATMega162 to work with Arduino IDE?
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, that is the purpose of it. It is just a modified version of the Arduino Optiboot bootloader to support the Atmega162.

The code supports both serial ports - Serial.begin() and Serial1.begin(). I have checked and they do work. It should also support PWM, but I haven't checked that. See the pins_arduino.h file to find out how the arduino pin numbers (0 to 34 inclusive) relate to the atmega162 chip pins.
Note: The atmega162 has no Analog inputs, but it does have 35 digital outputs, 6 of which work as PWMs. It has 2 serial ports, SPI, and I2C. There is however only 14kB of program space, half what an Uno has.


I found some bugs in the pins_arduino.h file, and there is also a file in the avr folder which doesn't work without a small modification. I have attached a full set of files to this post.

optiboot_atmega162.hex needs to be saved to:
<arduino>\hardware\arduino\bootloaders\optiboot\optiboot_atmega162.hex

iom162.h needs to be saved to:
<arduino>\hardware\tools\avr\avr\include\avr\iom162.h
(This replaces the existing one. There is a bug which prevents code from compiling otherwise. Changing the file won't affect anything other than the Atmega162).

pins_arduino.h needs to be saved to:
<arduino>\hardware\arduino\variants\atmega162\pins_arduino.h

Then in the <arduino>\hardware\arduino\boards.txt file, add these lines to the end:

##############################################################

atmega162.name= ATmega162

atmega162.upload.protocol=arduino
atmega162.upload.maximum_size=14336
atmega162.upload.speed=57600

atmega162.bootloader.low_fuses=0xFF
atmega162.bootloader.high_fuses=0xD8
atmega162.bootloader.extended_fuses=0xFB
atmega162.bootloader.path=optiboot
atmega162.bootloader.file=optiboot_atmega162.hex
atmega162.bootloader.unlock_bits=0x3F
atmega162.bootloader.lock_bits=0x0F

atmega162.build.mcu=atmega162
atmega162.build.f_cpu=16000000L
atmega162.build.core=arduino
atmega162.build.variant=atmega162

##############################################################

* pins_arduino.h (5.16 KB - downloaded 62 times.)
* iom162.h (20.38 KB - downloaded 64 times.)
* optiboot_atmega162.hex (1.41 KB - downloaded 45 times.)
« Last Edit: July 14, 2012, 07:13:22 am by TCWORLD » Logged

~Tom~

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Tom!

You're doing an awesome Job!

I'm trying to program an ATmega162 using the Arduino IDE and the ArduinoISP, so I dont need the bootloader, but i'm having some problems that you had, for instance the problem of the missing definition of USART0_RX_vect.

Your solution is awesome, but I'd recommend to use another definition inside of Arduino.h or even in pins_arduino.h to avoid changes in iom162.h.

I made the following definitions:

Code:
#define USART0_RX_vect USART0_RXC_vect
#define USART1_RX_vect USART1_RXC_vect
#define USART0_TX_vect USART0_TXC_vect
#define USART1_TX_vect USART1_TXC_vect

Worked nicely to compile the affected files, like HardwareSerial.cpp.

Now I "just" need to be able to burn the generated code to the MCU. lol

Regards,
Yuri I.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your solution is awesome, but I'd recommend to use another definition inside of Arduino.h or even in pins_arduino.h to avoid changes in iom162.h.

I made the following definitions:

Code:
#define USART0_RX_vect USART0_RXC_vect
#define USART1_RX_vect USART1_RXC_vect
#define USART0_TX_vect USART0_TXC_vect
#define USART1_TX_vect USART1_TXC_vect

The reason I changed the iom162.h file directly is because Arduino doesn't actually support the 162 natively, so changing it wont do any harm to any of the other processors and examples. It just makes it easier than having to remember to #define them. But either way works smiley Perhaps though you are correct, the pins_arduino.h file for it would be an ideal place to define them as you would only have to change it once...
Logged

~Tom~

Pages: 1 [2]   Go Up
Jump to: