Problem with custom AVR8 toolchain


ben

Recommended Posts

Hi all,

I wanted to try that AVR8 soft processor, but I couldn't get it to work with basic tools.

I downloaded the AVR8 code, opened the Papilio_AVR8_500k project (I am the happy owner of a Papilio One 500) in Xilinx ISE, and generated the bit file. No problems there.

Then I wanted to put some AVR code into the memory. So I dug up my old Makefile for compiling C to AVR, and created a simple .hex file for a program blinking all output ports, using avr-gcc and avr-obj-copy.

Then I updated the bit file with the data, using data2mem:

data2mem -bm custom_bd.bmm -bd avr_prog.mem -bt custom.bit -o b avr.bit

(custom_bd.bmm and csutom.bit are copies of the Papilio_AVR8_bd.bmm and Papilio_AVR8.bit, as the shell script in the Papilio Arduino IDE does)

Then I uploaded the bit file, using butterflyprog as usual... and no blinking at all. On any port.

Did I do something wrong ?

All the tutorials are about ArduinoIDE, which is probably great but 1) I use linux so the provided Papilio ArduinoIDE won't work and I'll have to reconfigure the Linux stock version to add the Papilio output and 2) I'd like to use C for my project. I'll try it too, but  any insight on why my "no IDE" toolchain did not work would be great.

Thanks,

Ben

Link to comment
Share on other sites

Hey Ben,

 

  There are a couple of things that could have gone wrong here. The best  bet is to download the latest version of the Arduino IDE and grab the  Makefile out of the hardware/tools/butterfly_platform directory. The  Arduino IDE just calls this Makefile and calls the correct targets  anyway. I set it up that way so the Makefile could be used independently  of the Arduino IDE, just haven't had a chance to document and test that  usage. Oh, and there might need to be some tweeks for tool locations  under Linux.

 

  Ok, so for what might have gone wrong:

 

  1) Make sure you are using the *_bd.bmm file that gets generated at the  same time as the bit file. They generated *_bd.bmm file describes how  the block memory is laid out so using the wrong file could be placing  your code in the wrong memory block.

  2) The step to convert the hex file to a mem file has a potential  gotcha, the data2mem tool seems to have a bug in it and requires a  specific format that I use gawk in the Makefile to ensure is correct.  There is a post in this forum about another method to fix this without  using gawk.

  http://www.gadgetfactory.net/gadgetforum/index.php?topic=134.msg275#msg275

 

 

  Hope this clears it up, it is a good feeling to finally get code running  on the AVR8. It took me several months of work to get my first LED  blinking with the AVR8 and I remember how exciting it was to finally get  it working. :)

 

  BTW, I attached the Makefile to this message too.

  Jack.

 

 

 

 

Makefile.zip

Link to comment
Share on other sites

Thanks. I'll try the Makefile tomorrow -- hoping I can indeed fix the tool paths ;-)

1) should be ok, but I'll double check. I'll also check 2), but I used the same command for Z80 roms without any problems. I remember having to limit the line length in the mem file (using a weird option of srec_cat) I can't have made that up myself, so I must have picked it from somewhere on the forum -- I think it was the "how to load data into BRAM" tutorial.

Your post confirm I had the theory right, but that I must have made a silly mistake somewhere. I guess I'll be banging my head on the walls when I find it...

Link to comment
Share on other sites

Ok, it does work.  Thanks a lot.

I'll try to clean up the Makefile a bit, though, as it seems a bit overkill. That could also tell me why *my* Makefile wouldn't work.

BTW, I see you compile for atmega103 and my experience shows that it doesn't work if you compile for atmega128. How can you address all ports A-F, then ? (I only need only, so that doesn't bother me, but I'm curious)

Link to comment
Share on other sites

I'll try to clean up the Makefile.

Here it is, a minimal  demo with a minimal Makefile. Correct the paths to the tools and to the custom .bit and _bd.bmm files, and you should see blinking on all bits of port A.

Nota: of course, this Makefile has less features than the one you provided -- in particular, it doesn't compute dependencies. But I understand every bit of it, and it might help other people debug their own toolchain.

Oh, and the problem was indeed the conversion to .mem. I can't see what went wrong with my conversion (it did work for Z80 roms), apart from the byteswap option -- perhaps I was lucky that the output from my Z80 assembler had the right endianness ? Anyway, your srec_cat+gawk combination work, and that's all we need  ;)

Again: thank you, and congrats for the great papilio tools and support.

Off to real AVR programming, now !

avr8_test.zip

Link to comment
Share on other sites

Ben,

Thank you for the simplified and cleaned up Makefile, I will post to the playground.

The data2mem error took a long time to figure out because if your program is short enough to fit on a single line then everything works fine. Its not until you start making larger hex files that every 80th byte, or something like that, that 1 byte gets reversed. So usually what happens is your program kind of works and just leaves you scratching your head.

The AVR8 is an atmega103 compatible core, the way I managed to get more Ports then what the atmega103 has was by hijacking some of the analog registers.

Ruslan, the AVR8 creator, did release a new atmega128 design to me to clean up and release. Unfortunately I have never had the time to work on it. So if someone wants to put some work into it it is available.

Jack.

Link to comment
Share on other sites

  • 3 years later...

Hi,

 

I know this is an old post, but i need to do the same. But im sorry, i can't get the avr8_test.zip (empty) or the makefile (some strange characters after download)

 

Please let me know where i can get a make file or an simple blink example.

 

=> First i must say thank you, for your grate project (based on avr_core). Actualy i used an old version from avr_core and it works. but in this version there are now interrupts and timers includes... So I m happy about your version. Hopefuly i get it work.

 

At the moment i use a other small hardware with an xilinx 500K Q100 on it. So i changed the ucf for only port A. uncommend A also in top (other false...)

 

After make my project , i use the command: data2mem -bm Papilio_AVR8_bd.bmm -bd main.elf -o h progMemInit.vhd ,=> to get the Progmem File. After that, i copied (only Constants) into project. (I can't use your IDE because i use Suse)

 

blinky is realy simple:

 

-----------------------------------------
DDRA = 0xFF;  
 
while(1)
{
 
      PORTA =  0x00;
      _delay_ms(500);
      PORTA =  0xFF;
     _delay_ms(500);
     
}

 

Have You an Idea, what is wrong ?

 

 

Thanks,

 

Manni

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.