Author Topic: FV1_EEProg - programming your EEPROMS directly from the SpinAsm  (Read 10596 times)

free electron

FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« on: October 23, 2015, 03:47:09 PM »
Here is a little project which might be interesting for those playing with the FV-1 chip:

EEPROM burner that works directly within the SpinAsm software, just as the original SpinDev Board does.

Background:
It's a result of one of those "what if" moments i had during developing my own FV1 dev board (LINK). Sure, you could use the original Spin FV1 dev board with an adapter cable, but the target would have to be disconnected every time the new program is uploaded. Having two FV1s/two masters on the I2C bus, in my case often clocked differently (= different I2C frequency) is a no go. My new board already has an USB connection and at first i was thinking about implementing the eeprom burner into it. However, having something comfortable to use, so i can just hit the "build" button, the new firmware will be burned into the EEPROM, DSP resetted and ready to work, now that was very tempting!
I saw two hints telling that might be possible, without reverse engineering the whole usb stream between the SpinAsm and the original DevBoard or more important: without copying the original Spin dev board firmware (there is no need for that as it turns out):

1. The Spinsemi dev board uses Cypress CY7C68013A microcontroller as an USB<->I2C bridge. A pretty common technique used by manufacturers is to upload the firmware via USB into RAM right after the chip is enumerated and detected by the software.
2. This told me i'm right on the track: there is a spindev.hex file in the main directory of the SpinASM IDE. I bet it is the one uploaded into the chip after boot up.

Next step was to make a piece of hardware that will introduce itself to the system as the SpinDev board to see if it'd work.
I got one of these cheap (~6EUR) mini dev boards with the CY7C68013A MCU, they are clones of the EZ-USB FX2LP board (widely available on 'bay, i used one marked as "LCSOFT").
The onboard EEPROM (24LC128) had to be written with the VID&PID descriptors of the SpinDev board (sequence: C0 79 18 01 10 00 00 00 starting at address 0x00) and the jumper J1 installed to set the 24LC128's address at 0xA2 instead of 0xA0 to avoid overwriting it during the programming of the DSP EEPROM.
I used the Pickit2 to write to the EEPROM. There is another way to do that without any additional hardware (it is an USB MCU in the end) by installing the Cypress USB Suite 3.4.7 software and using the CyConsole program. This method is slightly more convoluted, personally i found that hooking up Pickit2 onto the bus and doing the write was much easier and quicker.

And... it worked! The board was detected as SpinDev ONLINE within the SpinASM and i could program the target DSP EEPROM directly.
That means there is actually no firmware stored inside the IC1 (24LC64ST - schematic), only the USB descriptors.
Hence, this hack does not require any copying of the original Spin Semi FV-1 dev board firmware.

Two things more had to be done to make it a comfortable tool:
  • isolate the I2C bus from the target during the boot up.
    FV1's EEPROM is at 0xA0 address, the Cypress chip looks first if there is anything at the 0xA0 on the I2C bus and if it finds an EEPROM, it reads the USB descriptors from it. Obviously the enumeration would fail, as it would read the first bytes of the DSP program. Of course it happens only if you leave the target DSP board connected to the programmer all the time. I do that quite often when i'm working on the project for a longer time. And frankly, the whole idea for this project is to have a one click solution to program/reprogram your own FV-1 based circuit.
    If there is nothing at 0xA0 the chip looks at 0xA2 and finds the onboard 24LC128 EPPROM with the VID&PID stored in it.
    In a very similar way as the SpinDev board, i designed an small add on pcb with a 4066 switch which is OFF at boot up and is turned ON after the programmer goes online (LED goes on). 4066 is powered from the target, don't forget to connect the VDD line. This way if there is nothing connected to the programmer, the MCUs pins are isolated from the outside world.
  • enable automatic resetting the DSP after loading the new set of programs. This is done by pulling down the FV1's T0 line (internal/external programs) causing the chip to reload the actual program.
    CAUTION! use pull up resistor (~10k is ok) on the T0 line instead of tying up it directly to the 3.3V

Here is the schematic of the daughter board:


And this is how you interface the programmer with your own circuit:


The 4066 daughter board is very easy to build (only TH components) and the PCB costed me around $9 at OSHpark. Here is the link to the project:
FV1_EEProg PCB OSHPark Project
Deisgn files are here:
FV1_EEProg github repo

3D render of the board made with KiCAD:


and the real (verified, tested and working) thing:


This is my current modular FV1 development system (analog IO, dev board, programmer):

Here is a video of the dev board (SVF filter program) if you'd like to see/hear it in action.

So, here it is, a relatively cheap (total cost shouldn't exceed 30 bucks) way to make a programmer that works directly within the SpinASM compiler.
I should add, i'd be totally happy to buy such a thing from Spin Semi if they would offer it. As far as i know, there is no such device and looking at the page (last update in 2009, FV-1 still marked as NEW!), it seems there is not much going on.
With the constantly growing interest in FV-1, i'm sure they'd sell tons of these...

Happy coding!

--
Piotr

Digital Larry

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #1 on: October 23, 2015, 11:40:59 PM »
That's pretty cool.  I'm slowly getting support for "Bank Mode" going in SpinCAD, where you can load up 8 patches and switch between them quickly.  Also it will generate hex code for the bank of 8 patches.  It would be cool if I could make this work with the Spin Dev board.  I haven't done any USB programming, but from the sounds of it, I'd:

1) Enumerate attached USB devices
2) See if any matched VID and PID for Spin board (or your programmer)
3) Offer that in a menu for "hex destination"
4) When person clicks on "Program", write the bank to... "A0" I guess?  Then it would write the bank and read it back to verify.  Does that sound about right?

Thanks,

DL
« Last Edit: October 24, 2015, 04:59:18 PM by Digital Larry »
Digital Larry
DSP tinkerer and former transistor twister

slacker

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #2 on: October 24, 2015, 08:20:32 AM »
Very nice bit of detective work, thanks for sharing.

I don't think it helps you much DL, if I understand Piotr correctly when spinASM or possibly the dev board device driver detects that it's been connected it uploads firmware to the CY7C68013A, it's this firmware that turns it from an unprogrammed IC into something that can program the FV-1's eeprom. In order to use it without spinASM you would need to reverse engineer how spinASM communicates with the dev board, bearing in mind that until the firmware is uploaded it's useless.

free electron

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #3 on: October 24, 2015, 09:04:05 AM »
It's exactly what Slacker said. One step is missing in the list: software has to upload the spindev.hex file into the CY7...yy whatever chip first to make a programmer out of it.
Whether it is the SpinDev USB driver or the SpinAsm that does that, i don't know (i'd have to sniff the usb communication), but i tend to think it is the latter.
The LED i added to the programmer goes on when the I2C channel is open. It happens only when i start the SpinASM, not right after plugging the device into USB.
Even if you reverse engineer the comm protocol, command parser etc, you'd have to provide the spindev.hex with the SpinCAD, which i'm afraid would violate the copyright.

For a SpinCAD dedicated EEPROM burner i'd look for something inexpensive, widely available and open source. Thinking about Arduino:
- relatively cheap,
- has an usb port,
- detected as generic serial port, no special drivers required,
- already existing solutions, like ie this one:
http://thegaragelab.com/a-simple-serial-i2c-spi-eeprom-programmer/
  probably worth porting to ATMEGA32U4 (Leonardo/MicroPro? No idea, not a fanboy myself), which already has USB onboard, no need for that FTDI chip.
 

Digital Larry

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #4 on: October 24, 2015, 10:13:59 AM »
Ah I see what you mean.  Well, I don't think I have to supply the Spin Hex file.  Presumably somebody has that if they were already using Spin ASM and they could copy that over.  If it's not there then it doesn't work.

My original thought was to get it directly integrated with a PICKit2 since I have a couple of those around here somewhere and lots of people use that already and I think its code is open source (though doubtful it is Java).  But when I saw the post I thought wouldn't it be cool if it could work directly with the Spin Dev board.  Of course if I brought out i2c pins on THAT, then I could probably just hook a PICKit2 to it and away you go.  But I'm becoming less and less fond of soldering.

Whatever happens, it's unlikely I'd integrate it soon.
Digital Larry
DSP tinkerer and former transistor twister

slacker

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #5 on: October 25, 2015, 07:24:59 AM »
I don't know anything about java but I assume you can make it call external programs or scripts so you could add support for the PIckit2 using it's command line tool pk2cmd which is available on Windows, Linux and Mac OS.

Just ordered one of the EZ-USB boards to give this a try, I'll report back once it arrives.
« Last Edit: October 25, 2015, 07:34:40 AM by slacker »

free electron

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #6 on: October 25, 2015, 11:10:40 AM »
You don't actually need that 4066 daughter board to test the operation, just make sure the 24LC128 is written with the VID&PID, it's address is 0xA2 and do not connect the target until the board goes online. The PA0 line goes high when it happens. After that just hook up the SCL, SDA and GND lines to your target and you're ready to go.

Digital Larry

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #7 on: October 26, 2015, 10:27:35 AM »
I don't know anything about java but I assume you can make it call external programs or scripts so you could add support for the PIckit2 using it's command line tool pk2cmd which is available on Windows, Linux and Mac OS.

That's not a bad suggestion at all.  Thx!
Digital Larry
DSP tinkerer and former transistor twister

slacker

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #8 on: November 12, 2015, 02:07:56 PM »
Well the slow boat from China finally arrived and I'm happy to say it works like a charm. I haven't made the daughter board circuit yet but just hooking up SCL, SDA and ground works perfectly.

adbloch

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #9 on: March 14, 2016, 01:38:26 PM »
I don't get it.  I have SpinCad running but would like to audition other people's patches alongside my own.  Where is the community of developers sharing their SpinCad files?

Digital Larry

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #10 on: March 15, 2016, 10:02:39 AM »
My site's been down for a few days while I pursue installing a Malware removal service to deal with site hacks that have been going wild since the beginning of the year.  That said, for whatever reason I found that people using SpinCAD did not generally share their patches.  I guess everyone's starting their own pedal company?
Digital Larry
DSP tinkerer and former transistor twister

Ice-9

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #11 on: March 15, 2016, 05:31:21 PM »
My site's been down for a few days while I pursue installing a Malware removal service to deal with site hacks that have been going wild since the beginning of the year.  That said, for whatever reason I found that people using SpinCAD did not generally share their patches.  I guess everyone's starting their own pedal company?

Sorry to hear you have had some Malware probs with the SpinCad site Gary, and I hope you are able to sort that without too much trouble.
Regarding people sharing code or not sharing as it may be,  I am not sure why this is,  but maybe as SpinCad is so easy to use to generate code then perhaps most think it not necessary to share their compilations. If you look at the Spinsemi forum as I know you do. more code and help with ideas is shared in the assembly format more readily.

It would be nice to see more spincad shared files as I think you have done a great job with its development.

Mick
It's fairly straight forward, if you want to start it , press start. You can work out the rest of the controls for yourself !
Do me a lemon, that a poor IQ for a glass of water.


dathey

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #13 on: September 25, 2019, 08:13:57 PM »
On the EZ-USB FX2LP board I purchased ( https://www.ebay.com/itm/CY7C68013A-56-EZ-USB-FX2LP-USB2-0-Develope-Board-Module-Logic-Analyzer-EEPROM/302749503335), pin 10 is actually tied to 'Vcc'.

However, the FV1 EEProg board I ordered from Oshpark ( https://oshpark.com/shared_projects/okfY0ITb ), has pin 10 tied to 'Gnd'...




Once I finally realized and I removed the Vcc-to-Gnd short, the completed EZ-USB/FV1 EEProg assembly was then recognized successfully, within the SpinASM software (assuming also the successful completion of the onboard eeprom overwrite, with the 'magic hex' sequence...!)




Pic of final build:



free electron

Re: FV1_EEProg - programming your EEPROMS directly from the SpinAsm
« Reply #14 on: October 18, 2019, 06:48:58 AM »
I can confirm, the newer FX2LP boards have different layout from the one i used originally:



There are more pin changes, actually, but they have no impact here, since these pins are not used and left open.
I'm going to change the project and leave the pin10 unconnected.

--- Edit ---
Here is the link to the corrected OshPark project:
https://oshpark.com/shared_projects/5Jfe9GrT
« Last Edit: October 18, 2019, 08:14:13 AM by free electron »