TeensyTransfer

Frank B

Senior Member
Hi,

TeensyTransfer grows, and i open this thread for further discussion and as a reference or "howto". I'll edit this inital post when changes or updates are made.

TeensyTransfer is a utility which runs on Linux, Windows, and MAC. There is no graphical user interface, and it works on the commandline.
Currently, it is able to access the Teensy-internal EEPROM, a serial connected SPI-FLASH, or a parallel connected SPI-Flash.

https://github.com/FrankBoesing/TeensyTransfer

Please switch to "Raw Hid" usb Mode (Arduino Menu) and run the example-code on the Teensy.

The "extras" folder contains executables for Windows, Linux and MAC.

- Version for Windows is inside *.zip
- Version for Linux is inside *.gz
- Version for MAC is inside *.mac.zip

1. Teensy

Print some info:
Code:
teensytransfer -i teensy

Example:

Model : Teensy 3.1/3.2 (MK20DX256)
Serial: 156351
MAC : 04:E9:E5:02:62:BF
EEPROM: 2048 Bytes
F_CPU : 96000000 Hz
F_PLL : 96000000 Hz
F_BUS : 48000000 Hz
F_MEM : 24000000 Hz


2. Teensy internal EEPROM
There are two available commands:

Write file to internal eeprom:
Code:
teensytransfer -w eeprom filename
The contents of the file with the name "filename" are stored to the Teensy eeprom

Read file from internal eeprom :
Code:
teensytransfer -r eeprom > file
The contents of the eeprom are stroed to the file "file"


3. SPI Flash (Prop Shield, Audio Shield,....)
List files of serial flash:
Code:
teensytransfer -l

Write file to serial flash :
Code:
teensytransfer -w filename

Read file from serial flash :
Code:
teensytransfer -r filename > file

Delete file from serial flash :
Code:
teensytransfer -d filename

Erase chip :
Code:
teensytransfer -e

Info:
Code:
teensytransfer -i

Example:
ID : EF 40 17
Serial: D1 65 38 25 47 2C 19 2F
Size : 8388608 Bytes


4. Parallel connected SPI-Flash (Winbond only)

This requires a special connection to the Teensy.

Furthermore, you need the additional ParallelFlash library:
https://github.com/FrankBoesing/ParallelFlash
The connections are shown in the readme.

Then, enable this line in TeensyTransfer.h:
//#define _HAVE_PARFLASH //Parallel Flash

List files:
Code:
teensytransfer -l parflash

Write file to parallel connected spi-flash :
Code:
teensytransfer -w parflash filename

Read file from parallel connected spi-flash :
Code:
teensytransfer -r parflash filename > file

Delete file from parallel connected spi-flash :
Code:
teensytransfer -d parflash filename

Erase chip :
Code:
teensytransfer -e parflash

Info:
Code:
teensytransfer -i parflash


5. ... ? SD? (not implemented, todo)

 
Last edited:
FAQ:

Question:
- I don't know if i have all needed updates of teensyduino (1.28b), and TeensyTransfer shows "Communication Error"s
Answer:
Here are compiled Hex-Files for the different teensy-models:
https://github.com/FrankBoesing/TeensyTransfer/tree/master/extras


The files marked with "AUDIO" are special variants with :

SPI.setSCK(14);
SPI.setMOSI(7);

(They work with the Audio-Shield or my FlexiBoard)


Question:
- How can i sort the output of -l ?
Answer:
Windows: To sort filesize: teensytransfer -l | sort . To sort filenames: teensytransfer -l | sort /+10



 
Last edited:
As I use it, I think that teensytransfer should allow "-e" without a file name to erase the whole flash/EEPROM/etc.

Perhaps moving "-e file" to "-d file" for delete, and allow "-e" just to erase all of the memory.

It would be handy if teensytransfer could report the amount of space used and the amount of space available on the Teensy.

In case of hangs, etc. it would be useful if teensytransfer could indicate packets being transfered (perhaps by emitting a '.' for each packet).

I could imagine wanting to link the library with my application, so that I wouldn't have to reflash the Teensy to load new sounds, but instead I could have a pin that if held HIGH would put me into teensytransfer mode during program startup, otherwise continuing with my program.
 
i wrote a bat script to auto upload all files in a folder, might be handy for doing alot of files in once.
View attachment teensytransfer.zip

note: this is my first bat script i ever made, so it might a little messy :p
note2: windows only
 
Last edited:
Perhaps moving "-e file" to "-d file" for delete, and allow "-e" just to erase all of the memory.
Good point. It'll be in the next release

It would be handy if teensytransfer could report the amount of space used and the amount of space available on the Teensy.
Yes, you're right. Unfortunately te SerialFlash library does not provied such functions (or i hav'nt seen them?)

In case of hangs, etc. it would be useful if teensytransfer could indicate packets being transfered (perhaps by emitting a '.' for each packet).
In theory, it should'nt ever hang. It uses timeouts (max 500ms) in all functions. But you're right, the "." are a good idea anyway. But it is not possible for reading files.

I could imagine wanting to link the library with my application, so that I wouldn't have to reflash the Teensy to load new sounds, but instead I could have a pin that if held HIGH would put me into teensytransfer mode during program startup, otherwise continuing with my program.
You can do that. Just call transfer() when the pin is held HIGH only.
The PC utility will print a "Communication error" on STDERR if transfer() doesnt answer after ~100ms.
 
Posted by MichaelMeissner:
It would be handy if teensytransfer could report the amount of space used and the amount of space available on the Teensy.
Yes, you're right. Unfortunately te SerialFlash library does not provied such functions (or i hav'nt seen them?)

it would be usefull to have a check if the file is too large for the free space on the flash ic. :)
 
i wrote a bat script to auto upload all files in a folder, might be handy for doing alot of files in once.
Thanks :) But the .exe in your attached zip file will soon be old.. :)

it would be usefull to have a check if the file is too large for the free space on the flash ic.
smile.png
Yes.
Now, it returns an error during upload (well, in theory..did'nt test it)
 
Last edited:
The change to -d makes sense, I would say to erase "-e ERASE" would help prevent parameter confusion from wiping the whole of the flash/eeprom - while you had 19 long seconds to see the typo.
Also given the EEPROM is fully addressable - erasing or dumping parts - even halves - could increase the utility. Also perhaps a 'copy EEPROM file_xyz' feature could write the 2K contents to a file on the flash? And maybe the reverse as well - this could facilitate Automated testing or a state machine - and perhaps not need Raw_HID with public functions as it is internal.
 
If you need a Mac developer - here I am ... :cool:
Will we use the tool together with the TCD-Editor?
 
@fms1961, RE Mac -that would we cool. not sure if I will get to it this weekend...

i think, i have the new features tomorrow evening (German time) done..

I add an "-i" switch for information about the devices, too... (perhaps not so much for serFlash - depends on a pullrequest...:) )

a leak:
Code:
C:\teensytransfertool>teensytransfer teensy -i
Model : Teensy 3.1/3.2 (MK20DX256)
Serial: 64102
MAC   : 04:E9:E5:00:FA:66
EEPROM: 2048 Bytes
F_CPU : 144000000 Hz
F_PLL : 144000000 Hz
F_BUS : 48000000 Hz
F_MEM : 28800000 Hz

The only thing to be done is a compile on mac.
Last time blackketter was so kind to do it - any volunteers ?

The sourcecode is on github.
A minor edit to the makefile is needed.

Can someone explain how i can do this myself on ubuntu ? Is that possible ?
 
Last edited:
The only thing to be done is a compile on mac.
Last time blackketter was so kind to do it - any volunteers ?
I thought I offered my support with my last post ... Xcode is up to date ... so tell me what to do ... (perhaps via e-mail in German, this will be way faster ...)

Can someone explain how i can do this myself on ubuntu ? Is that possible ?

I quote an exerpt from stackoverflow:

For Linux, there is a prebuilt GCC cross-compiler (from publicly available Apple's modified GCC sources).
Update for 2015
...
For all these options you still need a real mac/i-device to test the application.
 
Last edited:
I've merged a new compiled version for MAC, from FMS (THANK YOU!)

There was a Warning:
hid_MACOSX.c:197:3: warning: "Send timeout not implemented on MACOSX" [-W#warnings]

this can lead to problems, if the teensy is not reachable. But normaly, it should work.

 
Last edited:
The new update is available

Important:
- Please update your version of SerialFlash: https://github.com/PaulStoffregen/SerialFlash
- Please use the new example code. The lib does not initialize the devices!

New:
- -i gives some info (see first post)
- To delete a file, use -d
- To erase the whole flash, use -e

On the Teensy, erasing flash is a not-blocking operation, so your sketch can run while the flash is erasing.
You can use the SerialFlash.ready() function to check wether the flash is busy or not.

The PC prints a row of "." during that time.

For writing files, "." are printed every 4096 written bytes (+one at start). (@Michael, printing for every packet was a bit tooo much :))
 
Last edited:
AFAIK I just pulled the latest properly and got this:
C:\tCode\libraries\TeensyTransfer\TeensyTransfer.cpp:328:2: error: 'ParallelFlash' was not declared in this scope

ParallelFlash.readID(id);

The sample might commnet RAW_HID needed :: To make a USB RawHID device, use the Tools > USB Type menu
 
AFAIK I just pulled the latest properly and got this:


The sample might commnet RAW_HID needed :: To make a USB RawHID device, use the Tools > USB Type menu

Thank you Tim, it was a copy&paste error.. :) Its fixed.

Tim, it prints a message, if RawHid is not selected.
Code:
C:\Users\Frank\Documents\Arduino\libraries\TeensyTransfer/TeensyTransfer.h:46:2: error: #error To make a USB RawHID device, use the Tools > USB Type menu

 #error To make a USB RawHID device, use the Tools > USB Type menu
But you're right, i add the comment.
 
Frank: not sure where I can get your fix? Yeah in my post that text is the 'message' from the compiler - thought a comment in the code might save a re-compile.
 
Frank,

This is a great tool, Thanks
I was able to try each transfertool option successfully to the Prop Shield serial flash from my Windows 10 PC.
I noticed though that when I wrote a file then read it back I had the following issue.
  • A .wav file was nearly twice as large and corrupted.
  • A .txt file was also much larger, but readable.

I haven't tried to use the files on the Prop Shield yet.

Here are the original files and the files copied back: View attachment TeensyTransferTestFiles.zip
I'm using the Serial Flash from yesterday, Arduino 1.6.8 and Teensyduino 1.28b1
 
Last edited:
Thanks Frank - I wanted to get a fresh build to confirm - this is all I get running the sketch on my T_3.2 w/Prop shield against the teensytransfer.exe I have::

C:\tCode\libraries\TeensyTransfer\extras>teensytransfer.exe -l
teensytransfer: Communication error

I pulled the copy from the github too.
 
Frank,

This is a great tool, Thanks
I was able to try each transfertool option successfully to the Prop Shield serial flash from my Windows 10 PC.
I noticed though that when I wrote a file then read it back I had the following issue.
  • A .wav file was nearly twice as large and corrupted.
  • A .txt file was also much larger, but readable.

I haven't tried to use the files on the from the Prop Shield yet.

Here are the original files and the files copied back: View attachment 6898
I'm using the Serial Flash from yesterday, Arduino 1.6.8 and Teensyduino 1.28b1

Hmm..
Can anyone confirm this ?

Can you try the latest version please and delete the chip first ?

I had no corrupted files, but perhaps it helps to update. There were updates for SerialFlash, too.
 
I had done that earlier - on your post I did:: RawHardwareTest {failed as it was not erased}, ERASE, RawHardwareTest, ERASE and all worked - then I get the same with "teensytransfer.exe -l" again? And power cycle - then the same failure.

Are the default build flags all set right for T_3.2 w/Prop shield?

Code:
Raw SerialFlash Hardware Test

Read Chip Identification:
  JEDEC ID:     EF 40 17
  Part Nummber: W25Q64FV
  Memory Size:  8388608 bytes
  Block Size:   65536 bytes

Reading Chip...
  Previous data found at address 0
  You must fully erase the chip before this test
  found this: 4C 55 96 FA 58 02 F6 18 
     correct: 00 00 00 00 15 F5 95 4B 

Tests Failed  :{

The flash chip may be left in an improper state.
You might need to power cycle to return to normal.
Flash Memory has 8388608 bytes.
Erasing ALL Flash Memory:
  estimated wait: 20 seconds.
  Yes, full chip erase is SLOW!
..................
Erase completed
  actual wait: 19 seconds.

Double Checking All Signatures:
  all 4096 signatures read ok

Checking Signature Pairs
  all 2047 signature pairs read ok

Checking Read-While-Write (Program Suspend)
  write 256 bytes at 256
  write time was 442 microseconds.
  read-while-writing: 00 00 00 00 15 F5 95 4B 
  test passed, good read while writing

Checking Read-While-Erase (Erase Suspend)
  erase time was 159478 microseconds.
  erase correctly erased 65536 bytes
  read-while-erasing: 00 00 00 00 15 F5 95 4B 
  test passed, good read while erasing

All Tests Passed  :-)

Test data was written to your chip.  You must run
EraseEverything before using this chip for files.
Flash Memory has 8388608 bytes.
Erasing ALL Flash Memory:
  estimated wait: 20 seconds.
  Yes, full chip erase is SLOW!
..................
Erase completed
  actual wait: 19 seconds.
 
Back
Top