FV1_EEProg - programming your EEPROMS directly from the SpinAsm

Started by free electron, October 23, 2015, 03:47:09 PM

Previous topic - Next topic

free electron

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

#1
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
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

slacker

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

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

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
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

slacker

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.

free electron

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

Quote from: slacker 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.

That's not a bad suggestion at all.  Thx!
Digital Larry
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

slacker

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

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

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
Want to quickly design your own effects patches for the Spin FV-1 DSP chip?
https://github.com/HolyCityAudio/SpinCAD-Designer

Ice-9

Quote from: Digital Larry 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?

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
www.stanleyfx.co.uk

Sanity: doing the same thing over and over again and expecting the same result. Mick Taylor

Please at least have 1 forum post before sending me a PM demanding something.


dathey

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

#14
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

tuckster

Hi everyone,

is there a slight change that I killed my FX2LP board by connecting 6V to TRG_PWR?
I connected it to a 3,3 converter which was turned by 180°.
VID/PID was reconfigured, the board was recognized correctly by Windows as a SPIN Dev device.
Then I soldered the daughter board on top and connected everything. Then notice that the LED doesn't light up and checked everything.
I noticed the reversed regulator and turned it.
The status LED of the daughter board never lights up and the device is recognized an unknown device after about 10 seconds.
  • SUPPORTER

tuckster

It turns out that it is not damaged. The 3,3V connection to the programmer was not connected properly.

Did anyone try to set the VID&PID descriptors via the cyconsole?

I can write them with Vendor request 0xA2 Value&Index 0x0000 Length 8 Direction Out to the small EEPROM
I can also write them with Vendor Request 0xA9 to the large EEPROM.
But no matter what I do I can not programm the FV-1 EEPROM afterwards without fiddling around with the jumper.
When the jumper is attached the Board gets recognized as Cypress FX2LP.
Without the jumper it gets recognized as Spin Dev Board but then I can not programm via Spincad without attaching the jumper again but then I reprogramm the internal EEPROM, right?
  • SUPPORTER

tuckster

I did it again and it works now.
On some boards the jumper connects the A0 of the EEPROM to 3,3V and some boards to GND.
Measuring the voltage on A0 gives the answer.
I used Cyconsole again and was able to write the VID/PID/DID without an issue
And I tried it as well with AsProgrammer and a CH341 adapter directly connected to the EEPROM.
One thing bothered me with Cyconsole, I alsowas have to fake a firmwareupload with a non existing file to be able to change the IDs else it wont work.
  • SUPPORTER