Close, but not close enough, to getting an old Atmel classic to work

Hello everybody,

Being a persistent , I am still tinkering with an old AT90S8515-8.
So far, I have connected it to an Arduino Mega 2560 which I intend to use as a programmer, though the ICSP interface.
I also connected a crystal oscillator, as this AVR doesn’t have one and an LED so that I can try the Blink example.

My biggest hurdle (so far) is setting up boards.txt for this chip to work. This is what I have so far:
s8515.name=AT90S8515-8

s8515.upload.tool=avrdude
s8515.upload.maximum_data_size=8192
s8515.upload.maximum_data_size=512
s8515.upload.speed=19200

s8515.build.mcu=at90s8515
s8515.build.f_cpu=8000000L
s8515.build.board=AVR_8515

At this point I am able to select my board, but unable to compile even the blank sketch that loads by default with empty loop and setup routines. As a side note, it complains about missing #include pins_arduino.h when I try that. Edit: I figured that I was missing the build.variant, but that just makes it worse, as I need the pins_arduino.h mapping.

I believe at least part of the settings are right in boards.txt, as initially I was missing the build.board and it said it will use the detected AVR_8515, which I then added to the file.

Other troubleshooting steps I took were an attempt to use avrdude, but it complains about the usb library (I am on 64 bit Windows 7) and also WinAVR, which seems to be missing a front end that I can launch, so I assume it either integrates with some other software or it may just be command line - I haven’t had time to delve deeper into it.

I have a feeling that using Arduino as ISP might be the simplest solution for me, but I am stuck at being able to upload a sketch using the programmer part.
As a side note, using the Arduino IDE to upload “using the programmer” to a Gertboard from a Raspberry Pi worked just fine an I believe the hardware setup is similar in my case.

Does anyone have any experience with adding a new board or the 8515? Maybe even the ATMega, as I understand that, aside from having the internal clock, it is pin-compatible with the 8515.

Thanks for any clues.

You need to create a pin mapping for it. If there isn't one you're planning to use, create one yourself - use the existing ones, and the datasheet, as a guide. There's no deep magic there.

You may also need to make other changes to the core thouh. It's probably best to copy the arduino core into your user hardware folder (and remove all the other entries from boards.txt), and start fiddling with it there.

I think the build.board is wrong. I don't have that option in any of the boards.txt entries I've written, and I don't even know what that option does. Maybe that's where the USB error is coming from?

No idea why you're getting errors relating to usb from avrdude - you're doing something minor wrong that's leading it down a rabbit hole. Enable verbose uploads and look at the command line options it's passing to avrdude.

There should be no upload.speed if using ISP programming.

Thank you Doc.

I tried to figure out the pin mapping, but I can't understand what to map the 8515's pin to. I have the pinout for it in the datasheet, but what does it map into? The Arduino pins? For instance, physical pin 6 of the 8515 is PB5 (MOSI). Would that map to Arduino Pin 11 (MOSI)? Or, because I am using a Mega 2560 as a programmer, that would map into the Mega's MOSI pin 51?

I did create a separate folder and that is where I put my yet unfinished pins_arduino.h file. I will copy the core files in there and try to limit them. Thank you for that.

Any idea if the build.mcu entry has anything to do with the avrdude's part option? I tried at90s8515 but avrdude has simply 8515.

I will remove the extra entries in boards.txt and try again. I am hoping that if I succeed with this exercise it could help others, as I noticed while searching the forums that many have attempted to work with classic Atmel chips.

Thank you very much for taking the time to reply.

Update,

I figured out that the pin mapping refers to the Arduino, so I copied the pin mapping for classic. After making the suggested corrections in boards.txt I have successfully uploaded the sketch to my AT. It's empty, but no errors were reported.

Next step is to try the blink sketch. I will report back.

Thank you very much.

WOO_HOO!!!

I have two alternating blinking LEDs on PB0 and PB1 running on my Atmel classic AT90S8515!!!

For those interested, here is my addition to boards.txt, courtesy of DrAzzy:

s8515.name=AT90S8515-8

s8515.upload.tool=avrdude s8515.upload.maximum_data_size=8192

s8515.build.mcu=at90s8515 s8515.build.f_cpu=8000000L s8515.build.core=arduino s8515.build.variant=standard

The pin mapping just sets which pin is known by what number, so when you do, say, digitalRead(4), it knows that you want to look at, say, PD2, so it should look at bit 2 of the PIND register and return that value.

the digital_pin_to_port/bitmask/etc and so on are what actually control that pin mapping. If the 8515 has similar pin layout to the 328, obviously, you want to use the same pin mapping. Otherwise, you need to pick a pin mapping that makes sense. Whenever I can, I try to avoid having the progmem arrays, and instead use very short expressions - the ternary operator is great for this.

Thanks again, doc.

The pin mapping is different - 40 pin dip, so I will need to figure out the file.

Once I have it, I will document my project on this forum.

DrAzzy: I think the build.board is wrong. I don't have that option in any of the boards.txt entries I've written, and I don't even know what that option does. Maybe that's where the USB error is coming from?

From Arduino IDE 1.5 3rd party Hardware specification

The uno.build.board property is used to set a compile-time variable ARDUINO_{build.board} to allow use of conditional code between #ifdefs. The Arduino IDE automatically generate a build.board value if not defined. In this case the variable defined at compile time will be ARDUINO_AVR_UNO.

So basically it's just a way for your code to identify which board model is being used. In this case you could use anything you want for the value of build.board or just leave it off and the IDE will automatically assign a value. The only problem with leaving it off is if you open boards manager you will see the warning message in the console: "Board s8515:avr:s8515 doesn't define a 'build.board' preference. Auto-set to: AVR_S8515"

Oh neat. That actually solves a problem I had with one of my cores...

For those more advanced that can make sense of it, I found this link: http://code.google.com/p/arduino/issues/detail?id=1055 This highlights details on pins_arduino.h for custom setups. I think I have to contend with using just the digital pins that map to the standard Arduino, as I don't have enough know-how to create my own mapping for the 8515. I will try, as the data sheet for the 8515 does describe the ports in detail.

If I do, I will post it here.

Another bit of progress.

I am now able to compile a sketch written in Arduino IDE, pick up the hex file it generates and upload it with PonyProg using a serial programmer that I built.

I guess that for the amount of times I will be programming this AVR there is no need to take it any further.

I still have to sort out the pins file and I will try to set siprog as the programmer in the IDE just because it would be nice to have a complete solution. Once I have it, I will create a new post with the tutorial.

Anyone interested in details please ask questions here.

I don't have enough know-how to create my own mapping for the 8515.

The pin mapping translates from the "pin numbers" used in sketches to numbered pins on a "standard board." If you're using an unusual chip, of course a "standard board" doesn't exist, so this is a bit problematic. There are three common strategies: 1) Make up a board design that routes chip pins to io pins and use those pin assignments. Like the Modern Devices Really Bare Bones Board or a Sanguino. In the simplest case, I've always thought you should just use the chip's pin numbers, even if that means that some of the middle-numbered pins are not actually usable (because they have fixed functions like "power.") 2) Pick a "similar" standard board and copy their pin definitions. So a Nano or an Arduino Pro Mini copies the Uno pin mapping, even though the pins are in entirely different places on the actual board. Just put the pin names as prominent labels on the silkscreen... 3) Pay attention to common secondary pin functionality on a standard board, and try to duplicate that given your significantly different chip. For example, maps pins so that Serial RX/TX shows up on D0/D1, SPI on D10..13, etc. Even if that means scrambling the layout or logicality of mapping.

(conflicts between these are the reason that there are so many different pin mappings on 1284-based boards. Sanguino (which was first) picked a convenient PCB layout. Subsequent layouts (eg Crossroads) paid more attention to Uno-compatibility.)

(Sanguino is probably a good example for you to follow...)

Thank you westfw.

For now, since I only have 8k of flash and I can't add a lot of stuff to my AVR, I mapped the 8515's pins to the Uno/Nano and I use the Arduino pin numbers in my sketches. That gives me enough to continue and seems to work well, except my 8515 has more pins.

I also have some "Bender related news" - I just managed to get the Arduino IDE to work with my serial programmer.

For the benefit of others, here is what I added to my programmers.txt file:

ponyser.name=Custom Ponyser ponyser.communication=serial ponyser.protocol=ponyser ponyser.program.protocol=ponyser ponyser.program.tool=avrdude ponyser.program.extra_params=-P{serial.port}

And the current iteration of my entry in boards.txt:

s8515.name=AT90S8515-8PC

s8515.upload.tool=avrdude s8515.upload.maximum_data_size=8192 s8515.upload.protocol=ponyser s8515.upload.speed=9600

s8515.build.mcu=at90s8515 s8515.build.f_cpu=8000000L s8515.build.board=AVR_8515 s8515.build.core=arduino s8515.build.variant=standard

This is the guy I built for a few bucks: http://electronics-diy.com/avr_programmer.php Instead of the connector they show on that page, I used a female 6 pin ICSP connector like those that Arduino boards use, so now I have full compatibility in case I decide to use the full flash on my Arduinos.

I also stumbled on a pins file here: http://www.avrfreaks.net/forum/calculating-avr-fuse-bits so I might try that to see if I can get it to work with my 8515.

Thank you all for keeping this thread interesting.