Bootloader and FW update made easy

Discussions related to MegaDrum Hardware

Bootloader and FW update made easy

Postby shaman » Sat Jul 19, 2008 6:13 pm

This topic gathers step by step information needed to install a bootloader and install firmware using SySex.


[!] This instruction manual is for ATmega32 [!]
therefore it may need some minor changes on other MCUs.

  • The newest version of the bootloader can be found in "Bootloader Test" topic.

    dimitri wrote:Fuses must be set so that Bootblock size is 1024 words and Atmega32 jumps to Bootblock on reset.


    By using avrdude and stk200 compatible programmer you can do it as follows (commandline):
    Code: Select all
    avrdude -p m32 -c stk200 -e -U hfuse:w:0x12:m -U lfuse:w:0xef:m -U flash:w:bootloader32.hex


    If you are using PonyProg, you have to program bootloader32.hex using the following fusebits settings:
    Image

    On WinPic800 fusebits looks like this:
    Image

    Remember to disconnect the programmer after programming - otherwise you may have keyboard input problems.

  • To initiate the firmware update folow these steps:
    dimitri wrote:This bootloader version is "multiclock" capable.
    To enter the bootloader - hold key LEFT pressed while powering up.
    While in the bootloader:
    To select MCU clock - press key UP. The selection is between 12/16/20/24MHz (16MHz by default). The selected clock will be displayed on an LCD.
    To cancel the firmware update - power cycle without pressing any other key.
    To start the firmware update - press key DOWN. It will erase an old firmware and wait for Sysex with a new firmware.

  • To update the firmware using MIDI-OX SySex:
    dimitri wrote:A MegaDrum firmware file must be modified slightly:
    three bytes, 0xF0 0x7F 0x40, must be prepended
    and one byte, 0xF7, must be appended
    and rename the *.hex file to *.syx.



    To easily generate *.syx files from *.hex files you can use my python script (makesyx.py) in the following way:
    Code: Select all
    makesyx.py file1.hex file2.hex file3.hex ...
      this will generate *.syx files from specified *.hex files.
    or
    Code: Select all
    makesyx.py
      this will generate *.syx files from all *.hex files in current directory.
    makesyx.zip

    To use this script you will need a recent version of Python interpreter installed on your operating system.

  • Finally you can send the firmware by using MIDI-OX:
    dimitri wrote:Before doing this you MUST set 'Low Level Output Buffers' to at least 40000
    (in MIDI-OX menu go Options->Configure Buffers and set Output, NOT Input, Buffers to 40000).

    dimitri wrote:Now in MIDI-OX go to Actions->Send->SysEx File... and choose the firmware *.syx file you've prepared beforehand. The update will take around 5 seconds and after it's finished MegaDrum will reset itself and boot the new firmware.


    When I have done it, it took about 20-30 seconds.
    After that you should close MIDI-OX and power cycle the Megadrum.

Good Luck,
shaman

PS. If you find a bug in the script or something is unclear in the description please send me a PM.
You do not have the required permissions to view the files attached to this post.
shaman
 
Posts: 8
Joined: Mon Mar 24, 2008 3:40 pm

Re: Bootloader and FW update made easy

Postby dmitri » Sat Jul 19, 2008 7:01 pm

Very nice done!
dmitri
Site Admin
 
Posts: 8706
Joined: Fri Aug 03, 2007 8:05 pm

Re: Bootloader and FW update made easy

Postby elrules » Mon Jul 21, 2008 11:32 am

If the script must add 4 bytes (3 prepended and 1 appended), why after executing it I get a file 6 bytes bigger?

How do I have to program the bootloader in avrdude for the atmega644?

I saw this line on the Documentation page:
"avrdude.exe -q -u -C avrdude.conf -p m324 -P lpt1 -c stk200 -U efuse:w:0xff:m -U hfuse:w:0x9f:m -U lfuse:w:0xef:m flash:w:megadrum324_20_20071211.hex:i"

But it is for atmega324 and to program a firmware, not a bootloader..
elrules
 
Posts: 629
Joined: Thu Nov 29, 2007 4:51 pm
Location: Murcia, Spain, Europe, The World

Re: Bootloader and FW update made easy

Postby shaman » Mon Jul 21, 2008 1:03 pm

elrules wrote:If the script must add 4 bytes (3 prepended and 1 appended), why after executing it I get a file 6 bytes bigger?

Finally someone has tested the script. It adds 6 bytes cause I have added dos/windows like line end (CR + LF) after prepending first 3 bytes. When I analysed dimitris file I found that it was done this way. I have tested it and can assure you that it works just fine. MIDI-OX is not line end sensitive.

elrules wrote:How do I have to program the bootloader in avrdude for the atmega644?

I saw this line on the Documentation page:
"avrdude.exe -q -u -C avrdude.conf -p m324 -P lpt1 -c stk200 -U efuse:w:0xff:m -U hfuse:w:0x9f:m -U lfuse:w:0xef:m flash:w:megadrum324_20_20071211.hex:i"

But it is for atmega324 and to program a firmware, not a bootloader..

After looking into the Atmega164/324/644 datasheet it looks like the same fuse bit settings as on Atmega32 should work. Some fuse bits are different but they are not programmed on Atmega32. You can try the following at your own risk:

Programming the bootloader on atmega324:
Code: Select all
avrdude -p m324 -c stk200 -e -U hfuse:w:0x12:m -U lfuse:w:0xef:m -U flash:w:bootloader324.hex:i


Programming the bootloader on atmega644:
Code: Select all
avrdude -p m644 -c stk200 -e -U hfuse:w:0x12:m -U lfuse:w:0xef:m -U flash:w:bootloader644.hex:i


Good luck,
and please report back after testing this settings so I can put this into the first post.
shaman
 
Posts: 8
Joined: Mon Mar 24, 2008 3:40 pm

Re: Bootloader and FW update made easy

Postby elrules » Mon Jul 21, 2008 2:23 pm

Ok, it works, at least for atmega32.

Now I will have to try with atmega644.

Could you also do a script utility to rename inputs? ;)
elrules
 
Posts: 629
Joined: Thu Nov 29, 2007 4:51 pm
Location: Murcia, Spain, Europe, The World

Re: Bootloader and FW update made easy

Postby slayer666 » Tue Jul 22, 2008 12:53 pm

I have installed the Python app but I'm kinda clueless on what the next step is.
Can someone please explain exactly how to use the makesyx script.

or, maybe Dmitri could start releasing new firmwares in syx format ;)
slayer666
 
Posts: 178
Joined: Thu Oct 11, 2007 8:07 pm
Location: Sweden

Re: Bootloader and FW update made easy

Postby dmitri » Tue Jul 22, 2008 1:09 pm

slayer666 wrote:or, maybe Dmitri could start releasing new firmwares in syx format ;)

I might do it but it may turn out to be unnecessary. Seems like MegaDrum is not doing what I claimed it to be able to do. See viewtopic.php?f=3&t=231&start=40
As an amature drummer I could not find a difference in performance between Roland and MegaDrum so I can forgive myself:)
dmitri
Site Admin
 
Posts: 8706
Joined: Fri Aug 03, 2007 8:05 pm

Re: Bootloader and FW update made easy

Postby dmitri » Tue Jul 22, 2008 8:06 pm

On the other hand how hard could it be? You don't update firmware in your MegaDrum every day, do you?:) Once you created the first .syx firmware file you can use any text editor to cut and paste first and last line from this file to any new file.
dmitri
Site Admin
 
Posts: 8706
Joined: Fri Aug 03, 2007 8:05 pm

Re: Bootloader and FW update made easy

Postby shaman » Wed Jul 23, 2008 3:56 am

slayer666 wrote:I have installed the Python app but I'm kinda clueless on what the next step is.
Can someone please explain exactly how to use the makesyx script.

Assuming that you have Python installed, the easiest script usage should be:

1) Unpack the script from mksyx.zip into the directory where you have *.hex file(s)

2a) On Linux
Run the following commands on some kind of terminal:
Code: Select all
$ cd directory_where_you_have_the_script_and_hex
$ chmod +x makesyx.py
$ ./makesyx.py


2b) On Windows (not tested, but if does not work I can borrow a windows machine in the evening and find an easy way).
- Right click on the script
- Choose "Run" (if not possible, "Run with..." and select Python)

Those commands will generate *.syx files from all the *.hex files. It will not affect any other files.
Maybe it is a good idea to put it in the first post...

slayer666 wrote:or, maybe Dmitri could start releasing new firmwares in syx format ;)

I think that might be an idea to release two firmware packs, one with *.hex files, and the other with *.syx files (hopefully my script will help). If the one with *.syx is not popular enough I would just stop releasing it.
But the decision is up to Dimitri.

elrules wrote:Now I will have to try with atmega644.
Does it work?
shaman
 
Posts: 8
Joined: Mon Mar 24, 2008 3:40 pm

Re: Bootloader and FW update made easy

Postby dmitri » Wed Jul 23, 2008 11:27 am

I will probably use it in my build script.
dmitri
Site Admin
 
Posts: 8706
Joined: Fri Aug 03, 2007 8:05 pm

Next

Return to MegaDrum Hardware

Who is online

Users browsing this forum: Google [Bot] and 114 guests