Compatibility of firmware upgrade with any Teensy board #144
Replies: 6 comments 6 replies
-
Further info:
|
Beta Was this translation helpful? Give feedback.
-
Current working plan:
Currently I am stuck on 1) because the USB logging code doesn't compile to a working hex using my avr-gcc 11.1. I am working on creating a virtual platform which supports a lower version of avr-gcc. M12x proved that it works for avr-gcc 9.3. |
Beta Was this translation helpful? Give feedback.
-
Hi. I don't have experience with GitHub so apologies if I do this wrong. The following is probably well known, but I wanted to understand the .SYX file format currently in use. It appears to be a variation on the Mutable Instruments format. This is a good choice. MI have a great repository of work that is well regarded in the community. Regarding the current Teensy2pp PJRC HalfKay USB bootloader (that's a mouthful), I suspect that he (Paul/PJRC) is ignoring the CRC (in the interest of making a very small bootloader). Considering the connection is hardwired during upload I think this is an acceptable choice. Do we need to increase the size of the bootloader? Hard to say so far, and there may be limited boundaries that can be assigned to bootloader space as defined by Atmel. Clearly I don't know much about AVR at this point either. One thing I noticed when comparing the .HEX versus the .SYX is that the .HEX carries content in the second 64K of the Atmel MCU. Am I mistaken? What are the elements that the .HEX firmware transfer that the .SYX does not? Here are further Mutable Instruments links regarding their AVR MIDI bootloader (MI has since moved on to STM32 parts as far as I know). I think the MI AVR toolchain is similar to what you guys are using for the P600. https://github.com/pichenettes/avr-midi-bootloader/blob/master/bootloader/bootloader.c https://github.com/pichenettes/shruthi-1/blob/master/bootloader/bootloader.cc I have been looking at solutions for physically replacing the Teensy2pp HalfKay USB Bootloader (using an ICSP/ICE) and have pondered whether or not we could write an interim application that can be downloaded using HalfKay (USB) or MIDI (SYX) and this interim application would rewrite the bootloader with the new one. |
Beta Was this translation helpful? Give feedback.
-
Yeah, the P600 bootloader would have to use the same 6850 UART code as the P600 keyboard fw. It's only a few lines of code though. I assume there some kind of UART/MIDI buffer or queue in the existing p600fw code as well. The code would be smaller than the USB "stack". A MIDI UART bootloader only really needs to deal with Sys Ex too, so I don't know that it would merit that whole xnormidi thing. It's just a small state machine. So theoretically one could delete the USB stack and xnormidi. Or not, depending on the comfort level. :-) Compared to what you have been doing I don't think this is more difficult. Just different. The advantage of the existing PJRC method is that the software (protocol) has some built-in considerations for speed/connection and the PC host side software is supplied by the board vendor so Paul knows what the best behaviour for the Teensy Loader should be. The flash update process is something like: send a block of data, erase that block, burn that block. I think the AT90USB flash blocks are 256 bytes, but that's from memory. It may be better to do one bulk erase rather than several, but this affects MCU busy time (one long erase wait versus many shorter ones). It takes a fairly long time to erase or burn a block so the protocol either calls out "Delay after F7" and/or must wait for an ACK/NAK sys ex response from the P600 after each block. The former is implemented by MIDI-OX as seen here: Delay after F7 example: http://www.moogmusic.de/midiox.jpg An ACK sys ex response could just be something like: If people are just doing blind dumps with existing software then specifying "Delay after F7" is important and pretty common. If someone is writing a PC application from scratch then it would be better to wait for the ACK. Bidirectional communication means you know if the device is attached and you know when each transaction is done. Another thing that would be a great idea is to brick-proof the bootloader. The easiest way to do this is, assuming the hardware can support it, "if a-certain-p600-panel-button is pressed at startup, then run the bootloader". You guys have had excitement with the membranes, so that might need to be considered. I think a "ping" command/response should be added to the current P600fw as soon as possible. Some kind of version info can be returned if the P600 receives a MIDI Universal Device Inquiry request (for example). It doesn't have to be that, but some incoming MIDI command triggers a MIDI response (preferably with version info). Finally, a nice feature would be to have a sys ex or other command that can launch the bootloader. That way a new PC application can request the bootloader, check to see if it's active, send the firmware update and reboot without the user touching the P600. This requires the bootloader also respond to the MIDI Universal Device Inquiry. Hopefully the AT90USB supports this (launch bootloader from app), but I don't know. Now having said all that, there's nothing stopping us from doing the same basic thing over USB HID or whatever. Once the existing bootloader is replaced then also the Teensy Loader needs to be replaced. I've done raw USB HID stuff on Ubuntu linux using libusb and it's my understanding that one can do the same thing on Windows. My Windows code came first so I just used Win32 for that. I was not aware of libusb until years later. Does Mac have libusb? I'm guessing it must. Anyway, Paul shows some techniques for USB HID here: https://github.com/PaulStoffregen/teensy_loader_cli/blob/master/teensy_loader_cli.c |
Beta Was this translation helpful? Give feedback.
-
Instant Gratification: Well here is one path that seems easy, at the beginning at least:
There are a LOT of example projects included with LUFA so it will take some digging to see if there is anything suitable. This thing covers just about every possible angle though (MIDI, USB, UART, bootloaders, devices, ...). It's not a small bootloader though. I think 4k is the best one could hope for. Documentation: I have used the CLI "dfu-programmer" on Windows before so I can see if anything is usable for the AT90USB162 I have at the moment. I'm not sure that part is supported. The API seems decent enough, but there will be a learning curve: Example:
|
Beta Was this translation helpful? Give feedback.
-
Update on minor tests. This is all stuff that AVR fans have been doing for 10 years I imagine, but it's all Greek to me. I was able to use the Waveshare ICE that I got on Amazon (and I'm very impressed with the whole kit) to wipe the fake Teensy loader off of the Teensy Clone I got and instead install the Atmel factory "DFU" (at90usb1287-dfu-1_0_1.hex). I used Atmel Studio 7 to do the procedure, but probably AVRDude might be more interesting to you guys. I put DFU in quotes because from what I read, Atmel kind of bastardized the industry standard DFU protocol, but that's not terribly important to us. This loader would also accept the files "blink_fast_Teensy2pp.hex" and "blink_slow_Teensy2pp.hex". For this I used the command line Windows DFU application dfu-programmer.exe. (https://github.com/dfu-programmer/dfu-programmer) As an aside, there is also a command line Teensy Loader from PJRC if anyone wants to play with that. It's on the PJRC site. I'm not sure how the Atmel DFU got it's driver associated on Windows. I've installed a lot of AVR things in the last few days and for me it was plug-n-play. Next steps will be to evaluate if I can build a LUFA HID and/or DFU bootloader in the Atmel Studio 7 environment and see if it boots. Then to figure out if there is already some software for the actual application loading. Recall that LUFA already has a documented method for a running application to program flash. Then of course, what are the effects of that on P600fw. Curiously, LUFA has some MIDI support but I'm guessing that's for over USB. |
Beta Was this translation helpful? Give feedback.
-
The firmware upgrade currently only works for original PJRC Teensy boards. There are copycat versions of the Teensy++ 2.0 board on the market but the firmware code is not compatible. This discussion is about putting the knowledge together to understand the incompatibility and ideally to make changes / variants of the firmware or to develop changes to Teensy++ 2.0 boards so the firmware can be used with any board.
Some basic information from the firmware code and the Teensy++ 2.0 features:
Beta Was this translation helpful? Give feedback.
All reactions