How to program the Atmel IC on the Shruthi_XT?

Hi there,
i now finished my set of shruthi_XT together with 2 different filter boards.
Sadly i did never use Atmel nor open source gnu toolchain before, so I am running into trouble or stuff is simply not working.

I am used to Texas Instruments toolchain, know exactly what to do there, so I figured before i simply get an programmer, i got the olimex ISP which can be directly connected to the 6pole thing on the board, until then no problem.

Then I thought i get the Atmel Studio, since its freeware, import the github project and simply compile and flash it to the atmel IC, then the problems begin :slight_smile:

There is no project file on github, at least nothing that i could use simply for import or copy into a new project in the Atmel Studio. So I began using the noramel was explained under firmware:
http://mutable-instruments.net/wiki/Setting_up_a_development_environment_on_Windows_machines

this did seem pretty straightforward too, of course I simply followed all thesteps and nothing else, now first error I am runnning into:

step:6. Go into the ./avrlib directory and edit the “makefile.mk” file with an editor of your choice.

Look for the following entries:

AVRLIB_TOOLS_PATH
AVRLIB_ETC_PATH<----------------------------- this line does not exist in my makefile.mk

I guess it has simply something to do with version, but its a bit sad, so I thought i just ask around, maybe someone got the same problems.

THEN NEXT STEPS.
7. Go back into the shruthi-1 directory and start the WinAVR shell by running “sh”.

Then run the following command (the -d option is for showing detailed information only; you can leave it out later):

make -f shruthi/makefile

8. If everything goes well a new directory “build” with a subdirectory “shruthi” will be created. Here you will find a file called “shruthi.hex” which contains the new firmware.

It works i got no error codes but also when i type make nothing at all happens, i just get a new line in the cmd window, i get no status text nor nothing, I do not know if that is normal behaviour, would appreciate some tips there too.

And of course i do not get an build folder :frowning: so i cannot flash my atmel chips.

I would also appreciate someone sending me some files i can directly flash into the atmel via the 6pole connector, I dont know if it needs hex file or elf file, I am used to elf on the Texas instruments chips, but i got no clue how to get them and how to flash them onto the atmel.

So thanks a lot i will keep this up to date, enough stupid computer work for now, i wanna make some music :slight_smile:

I’ll save you some time

Which Olimex ISP is it exactly? If it’s the AVR ISP mk2 the it’s actually the 10pin connector that should be used (via an adapter). It can also provide power to the target, so be careful with the settings…

Thanks for your help already:
I use this one
http://www.watterott.com/de/AVR-ISP500-USB-STK500v2
So I think it is not the Mk2
The thing witht he 6pin header or 10pin: I am used witht he Texas Debugger, and MSP430 you can actually choose wheather to provide Vcc to the board or to get Vcc from the board, is that the same with atmel???

I did try both things, supply external 5V and without external 5V, I had an example running, but I think atmelstudio tricked me with using a simulator, although i am pretty sure i did tell the damn thing not to.

So right now I am thinking, I need external 5V, after that I would like to see an test program up and running on the Atmel , like toggle GPIO-pins, so I see that I am in control, after that I maybe try to make an own project and try to simply copy and paste allt he Shruthi code in there.

Next question: The AVR-ISP500-USB-STK500v2 is only a programmer? or can I also debug my code, using breakpoint single tepping through my code???

And final question: maybe i should get an older winavr and try the firmware procedure again? I am conspicuous about the open source market, I can imagine 5 years ago everything worked just right, but now, after all the stupid windows updates etc things arent that simple anymore :slight_smile:

oh and altitude:
I think i should be able to simply flash an *.hex file into the Atmel, right?
Is there a really simple way of doing it , if there is, could you or someone post it?

I am using windows 7, got now the latest winavr, i am able to use command lines :slight_smile: ( good old dos was my teacher ).

Appreciate every help, still only worked like 2 hours with the atmel toolchain and until now nothing workes, but i am used to worse :slight_smile:

OK, no it’s not the mk2. Good! :slight_smile:
As far as I can see your programmer can’t power the target board - but I haven’t read all of the manual…

If your winavr includes the avrdude utility you should be able to flash the AVR with that, but I’m not sure if it works exactly the same as on Mac or Linux, which is what I’m used to…

thanks for your thoughts.
I am at work now, check tonight to flash the damn chip via winavr. I got the fear my make is not working, but im going to read some atmel app notes and stuff, to make sure tonight im wiser, and maybe it will simply work.

I wonder , is noone working with atmel studio or avr studio as it was named before? Are the open source compilers more popular? I am wondering since i read some posts, where people said, if i compile the ocde in AtmelStudio it will probably not fit into the Atmega.

I use command line tools because they run on linux and OS X (the two OSes I use), because I’m free to use whatever text editor I want, because I can integrate in my makefile other tasks like building data files in python, generating update files, and more generally because I can accomplish significant work quickly with a keyboard, without touching a mouse and clicking on stuff.

AtmelStudio is based on the same open-source compiler as I use (gcc).

Because the Shruthi codebase is so close to filling the entire MCU (in terms of flash size and CPU use), minor differences in compiler versions can cause the code not to work. It is recommended to use the same version as i do.

thought so. Thanks for reply pinchenettes.

Will try to get it to work tonight or until next week, then update this post here. if nothing works i will give the arduino toolchain a shot, just to get it to work somehow, but im pretty confident that i will get the winavr and avrdude to shoot a hex image onto my atmel.

Gladly i got a lot of Shruthi_XTs, so i may as well use one just for programming with direct 5V supply.

#1 update: it turned out i did not have a make.exe file :slight_smile: funny story, since i simply downloades an make.exe.html renamed it without giving nothing, i thought of that yetserday, so now i think im able to at least make something happen, i be back, also starting another pc in parallel, i wanna hear some music in the next hour :slight_smile:

#2 update: i am able to make my own hex files and midi, but how the hell do i simply transfer the code into my atmel chip.

I think i use the avrdude cmd lines, this seems pretty straight forward, i think i even saw the code line in the forum before, or if someone wanna help me out, sadly my winavr just doesnt seem to work with the make.exe i did point it to, it does only give error messages:
> “C:\\WinAVR-20100110\\utils\\bin\\make.exe” program
make: ***** No rule to make target ‘program’. Stop.

> Process Exit Code: 2
> Time Taken: 00:00

#3 : do i have to tell the avr dude commandline to use usb???

D:\\Musikarbeit\\firmware_shruthi\\Make\\shruthi-1>avrdude -B 1 -V -p m
p2 -P usb -U flash:w:shruthi1_0.97.hex:i -U flash:w:muboot.hex:i -U
m
avrdude: usbdev_open(): did not find any USB device “usb”
^^ this is what i get, oh and another point that is pretty strange:

I got an external 5V power supply attached to my board, the atmel chip sits on it and well not a lot more besides the crystal oscilator and the 6 pin header, when i put the olimex ISP500 into the header, and i am 99,9% sure where pin 1 is, then the voltage drops to under 1V, that seems very strange to me, normally that screams shortage, but i dont know yet, maybe some awkward programming behaviiour?

ok, im getting closer here, i can feel it, have 20minutes left then i have to go, probably last commen enjoy it :slight_smile:

5V now stable, maybe the olimex programer was in a strange mood, i disconnected it and restarted and probed, all fine now, but still the avrdude command does not work, i did delete the -P usb and then did write another hex file, now i am back with the missing usb error:
avrdude: ser_open(): can’t open device -U The system…

so any news?

does anyone know how the winavr is supposed to work?
and there is a mfile.exe, i can make makefiles, with the programmer etc, what do i do with such a file, could i doubleclick it and it programs? or do i have to use it with something else?

Damn this atmel toolchain feels like monkey island all over again: use this with this, speak to them use compass on monkey :slight_smile:
loving it

I might be wrong, but I think avrstudio install drivers that take control of the USB port, so you can’t use avrdude on the same machine without having to disable the drivers installed by atmel.

ok, ich hab mit dem AtmelStudio programmieren können bzw flashen, jetzt weiss ich allerdings noch nicht ob der auch tut was ich will,muss ihn erstmal ins andere board stecken, man darf gespannt sein.

sry damn i am tired, got my real board with attached filter tobe programmed, but unfortunatyl display doesnot show anything, but to defend it it is not yet soldered in i just press it to it, so maybe there is a chance, but id say it is still not working… but we are getting closer, hear you tomorrow

>I might be wrong, but I think avrstudio install drivers that take control of the USB port, so you can’t use avrdude on the same machine without having to disable the drivers installed by atmel.

This. You MUST switch the driver from the Mungo to the libusb-win one included with winavr.

Simply go to the device manage, update driver and select the one included with winavr

ok maybe i try that, for now i am confused, since i did see with my analog oscilloscope some bits getting sent via the ISP prorgammer, so i am pretty sure it did work, but i do not get any text on the display, how else can i probe ? i think the OSC PWM output should also be seeable, and maybe some others things too, i need to have proof for the aliveness of the µC.

Then i am confused with Atmels architecture, is it different from Texas Instrumnets? like Harvard vs. Neumann architecture, cause i can choose between eeprom and flash program space? And is this important for me?

And ok important question, once programmed the Shruthi should show something in the display right?

I am close to getting sounds i can sense it :slight_smile:

Flash fuses, flash bootloader, flash main. Adjust contrast trimmer to see something on the display (if its flashed correctly)

It works even without the LCD. If the Shruthi boots correctly then a few of the LEDs by the buttons should lit up and it should react to key presses. It can also be played via MIDI (on channel 1 I guess).

Yeah i did play around with the trimmer, i dont have the fitted trimmer yet, and as i said did not solder the LCD yet, i will do later, i did probe some signals on the PCB and the OSC seems to work, and I assume the Atmel also sends signals to the LCD, my best guess is the LCD due to not beeing soldered misses the initial code and so its hard for it to work correctly :slight_smile:

So right now i am convinced i will get it to work later.

Next question or what i was hoping to do, is look into the code and write maybe some one snippets, once i do know or have the urge of playing around with the osc pwm for example.
So before i started to build, I did hope i could read the softwarecode in a project kind of setting, single stepping through it with a debugger or something, so i can directly see and maybe hear my changes.
But as i am aware right now, i am flashing hex files, do not even find a main.c file :slight_smile: so i do not know how the code is doing his whole routines, i guess the main is missing due to c++? I am used to c, and i am electric engineer not hardcore coder, although would say i am fluent in c.
So feel free to point me to the right things, if there is a project code kind of structure for winavr or something i would like to work on it, rather than looking at a hexfile .

Thanks and cheers.

> i guess the main is missing due to c++?

Neither C nor C++ require you to have a file named “main.c” in your project.

Maybe it’s a convention you’ve seen so far in the software projects you’ve contributed to, but it’s not necessary.

What you need to have is a main function and it’s here