There are two paths to performing such an upgrade. Buy a chip with the software pre-programmed or buy a blank part and program it your self. There are many Posts on upgrading Sanguinololu boards and boot loaders; this blog documents using an AVRISP mkII as the AVR programmer under Arduino 23 to install the necessary boot loader in place on a Sanguinolou board. Any software can then be downloaded into the AVR part once the boot loader has been programmed.
| Sanguinololu Boot Loader Via AVRISP MkII |
The following hardware configuration is assumed:
Windows XP (SP3)
Huxley ( eMaker )
Sanguinololu board 1.3a ( RepRap Wiki )
Arduino ( version 23 )
AVRISP mkII ( Atmel )
I acquired the AVR programmer to install software onto a McWire as I had the time but not the money. Now I have the money, but not the time. "C'est la vie". At this time the fist thing I discovered was that Arduino IDE (Integrated Development Environment) needs a different driver for the AVRISP mkII than the Atmel programming environment uses. So its important to ensure that if you wish to use the AVRISP programmer, you install the correct driver that works with Arduino IDE. I think that using an Arduino as an ISP to program a boot loader is really cool. But if you use the same Arduino board as both boot loader programer and development board then one day you are going to end up stuck! A spare Arduino board of course is always cool.
Installing the correct AVRISP driver for Arduino 23
Assuming you have the Arduino IDE installed, the driver for the AVRISP mkII is bundled with the Arduino IDE software distribution. So on a clean system, its simply a matter of installing the driver.
If you have installed the Atmel IDE (Studio), I suggest you remove the software as both device drivers enabled will conflict. It can always be re-installed later. Alternatively you could disable the Atmel driver and switch between them, I haven't tried this but it should work in principle.
With Windows and USB devices, frequently the software is installed prior to plugging in the device. If, like me, you do it the other way round; follow the screen shots shown.
Hardware found dialog box
Install new hardware software search location dialog box
Install new hardware, software location selection dialog box
Install new hardware, software location specification dialog box
On my system this was:
C:\arduino-0023\hardware\tools\avr\utils\libusb\bin
Install new hardware, software installation dialog box
The net result of all this effort should be a driver which shows up in the device manger as a LibUSB-Win32 Device.
Sanguinololu board connections ready for boot loader programming
| Sanguinololu re-programming connections |
Sanity warning
Incorrectly removing or inserting the chip is almost certainly going to retire the device and potentially the PCB as well. Check many times BEFORE powering up!!
Removal of the original device can be tricky! The PCB and chip are easily damaged. On the board in the picture the 40 pin device is inserted into a socket allowing removal of the device. My 'weapon of choice' for such activities is a small 3mm diameter terminal screw driver with a shank around 10cm long. Keeping the screw driver as parallel as possible ease the screwdriver under the device and lever up at a small angle evenly lifting the device up by around 2 mm. Then move the screwdriver further in and repeat, trying to keep the device parallel to the PCB as you lever it out of the chip holder (IC Socket). With care and patience the device will pop out without so much as a disturbed leg. Be careful to lever only against the ribs of the socket under the chip and not components or the PCB. If you do you will damage the point you are reacting against.
You can see that two type B USB connections are being used here. The Sanguinololu USB connection is to power the board from the 5v of the host computer. The AVRISP mkII also needs a connection and is plugged into the Sanguinololu ISP/SPI port, so this may require you to unplug an SD card adapter from the ISP/SPI port if fitted.
This image is shown with the board not connected to Huxley #710. In fact Huxley #710 was re-programmed in-situ i.e. all motors and other connections in place. The picture was taken to make it clearer what's needed for reprogramming. We also have a spare Sanguinololu, so it was easier to take a nice picture. I intend to donate the old chips to the RepRap foundation.
With these connections were now ready to program the boot loader.
Sanguinololu AVRISP MkII boot loader programming
With everything installed and the board connected we are now ready to program the ATmega 1284P-PU part with a boot loader.
First select the correct target device
Next select the programmer device to be used to program or 'burn' the boot loader code onto the ATmega 1284P-PU
Whilst the boot loader is being upload the Arduino 23 IDE displays the 'please wait' message
When the boot loader has been uploaded the Arduino 23 IDE displays the done message. We are now ready to load the firmware of our choice onto the target through the USB serial port without the need for the AVRISP.
Of course the connections etc. work just as well if you want to burn a boot loader onto an ATmeage 644P-PU devices as well.
Next step is to load the firmware code of your choice
Downloading Marlin onto ATmega 1284P-PU
If you haven't downloaded code before then these are the steps necessary to put Marlin onto your ATmega 1284P-PU
Press and hold the reset button until you see the text in the 'Binary sketch size ....' text. As soon as this text is displayed release the reset button. On Arduino 23 no indication is given that anything is happening over the next stage.
If you get an error message similar to the one shown, here are a few of the most common causes (not in any order):
Target device not plugged in correctly
- check chip seating
- check USB cable connections
Reset link on PCB in wrong state
- make sure the reset link is in the correct state on the Sanguinololu PCB
FTDI Driver not installed correctly
- Use the Arduino 023 FTDI drivers
Wrong board type selected as the target device
- select correct board type in the Arduino IDE
- ensure board type settings in boards.txt and avrdude.conf of the Arduine IDE are correct
Target device won't respond
- baud rate too high for computer or cable, lower baud rate and get a better cable
Target device really is the wrong one
- put in the correct device
Target device is incorrectly inserted (wrong way round)
- buy a new target device
Device is not correctly synchronizing with Arduino IDE
- re program boot loader code
- re load firmware
Useful links
http://stevesfixitshop.blogspot.co.uk/2011/12/sanguinololu-13a-part-2-trouble-in.html
https://s3.amazonaws.com/rms-projects/Sanguino-0023/Wire-Sanguino-0023.zip
http://code.google.com/p/sanguino/downloads/detail?name=Sanguino-0023r4.zip&can=2&q=
Marlin ( ErikZalm / Marlin )
Pronterface ( eMaker Sources )
Wikipedia ( Arduino )
Contents of boards.txt for the 1284P
##############################################################
atmega1284.name=Sanguino W/ ATmega1284p 16mhz
atmega1284.upload.protocol=stk500
atmega1284.upload.maximum_size=131072
atmega1284.upload.speed=38400
atmega1284.bootloader.low_fuses=0xFF
atmega1284.bootloader.high_fuses=0x99
atmega1284.bootloader.extended_fuses=0xFF
atmega1284.bootloader.path=atmega
atmega1284.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
atmega1284.bootloader.unlock_bits=0x3F
atmega1284.bootloader.lock_bits=0x0F
atmega1284.build.mcu=atmega1284p
atmega1284.build.f_cpu=16000000L
atmega1284.build.core=arduino
Contents of arduino.conf
#------------------------------------------------------------
# ATmega1284P
#------------------------------------------------------------
# similar to ATmega164p
part
id = "m1284p";
desc = "ATMEGA1284P";
has_jtag = yes;
stk500_devcode = 0x82; # no STK500v1 support, use the ATmega16 one
avr910_devcode = 0x74;
signature = 0x1e 0x97 0x05;
pagel = 0xd7;
bs2 = 0xa0;
chip_erase_delay = 9000;
pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
"x x x x x x x x x x x x x x x x";
chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
"x x x x x x x x x x x x x x x x";
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 1;
pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02;
hventerstabdelay = 100;
progmodedelay = 0;
latchcycles = 6;
togglevtg = 1;
poweroffdelay = 15;
resetdelayms = 1;
resetdelayus = 0;
hvleavestabdelay = 15;
chiperasepulsewidth = 0;
chiperasepolltimeout = 10;
programfusepulsewidth = 0;
programfusepolltimeout = 5;
programlockpulsewidth = 0;
programlockpolltimeout = 5;
idr = 0x31;
spmcr = 0x57;
allowfullpagebitstream = no;
memory "eeprom"
paged = no; /* leave this "no" */
page_size = 8; /* for parallel programming */
size = 4096;
min_write_delay = 9000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 1 1 0 0 0 0 0 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
" 0 0 0 0 0 a2 a1 a0",
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 0 0 0",
" x x x x x x x x";
mode = 0x41;
delay = 10;
blocksize = 128;
readsize = 256;
;
memory "flash"
paged = yes;
size = 131072;
page_size = 256;
num_pages = 512;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
read_hi = " 0 0 1 0 1 0 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
loadpage_lo = " 0 1 0 0 0 0 0 0",
" 0 0 x x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_hi = " 0 1 0 0 1 0 0 0",
" 0 0 x x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 x x x x x x x",
" x x x x x x x x";
mode = 0x41;
delay = 10;
blocksize = 256;
readsize = 256;
;
memory "lock"
size = 1;
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x x x o o o o o o";
write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
"x x x x x x x x 1 1 i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "lfuse"
size = 1;
read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x o o o o o o o o";
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
"x x x x x x x x i i i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "hfuse"
size = 1;
read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
"x x x x x x x x i i i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "efuse"
size = 1;
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
"x x x x x x x x 1 1 1 1 1 i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "signature"
size = 3;
read = "0 0 1 1 0 0 0 0 x x x x x x x x",
"x x x x x x a1 a0 o o o o o o o o";
;
memory "calibration"
size = 1;
read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
"0 0 0 0 0 0 0 0 o o o o o o o o";
;
;

No comments:
Post a Comment