EEPROM Programmer W/ Rapsberry Pi and Flashrom

At the office, they’ve been using a SHARQ DSP chip in one of the products and for years they have been using the SHARQ dev board in conjunction with the SHARQ software to program the product.  Turns out the software costs the company $1000 per year for the license.  GROSS.  $1000/year to program an EEPROM chip.  I was tasked with fixing this issue and as it turns out, the Pi is the perfect candidate.  Simply install Flashrom and some dependencies and viola, EEPROM programmer for under $50.  I’m going to outline the steps for you to create your own.  You can flash dozens of EEPROM and ROM chips with this, potentially saving bricked motherboards from the trash bin.

First:  Get a Pi

Install Raspbian via NOOBS on SD card

If you are new to RPi, then you will need to have a monitor, mouse, and keyboard.  There are ways to enable SSH and configure WiFi and boot headless using PuTTY to access the terminal but I won’t dive into that now.

You need to click on the “START” button at the top left (has the raspberry logo).  Scroll down to Preferences, then click Raspberry Pi Configuration.

Click the Interfaces tab and enable SPI for Flashrom to operate correctly.  I also enable SSH and VNC so that I can access the Pi over the network but those are optional.  You will need to connect to WiFi also.

Next, click the icon at the top that looks like a black square with a >_ on it.  This is the terminal program.  We will be installing Flashrom and dependencies via the command line, don’t be scared.

It’s usually a good idea to update the operating system but not required.  To do this type:

sudo apt-get update

Then hit Enter.  Allow the update to download and install then type:

sudo apt-get dist-upgrade

Then hit Enter and allow the upgrade to happen. You will need to type “Y” when it asks you if you want to continue with the upgrade.

If you’ve never used Linux before, the sudo command means “superuser do” which translates to “run with administrator privileges.” The apt-get command is the installer app, essentially.

Now that the OS is updated, let’s install the dependencies that Flashrom needs.

Type:

sudo apt-get install pciutils libpci-dev libusb-1.0 libusb-dev git

This installs a bunch of things, including git, which we will use to clone the Flashrom files.

Next, type:

git clone https://github.com/flashrom/flashrom.git

This clones the latest version of Flashrom to your Pi from the GitHub repository.

Next, type:

cd flashrom

This moves us into the Flashrom directory that git just created.

Next, type:

make && make install

This configures and installs Flashrom into our system.

That’s it.  Flashrom should be properly installed on your system.  You should be able to run Flashrom commands and program chips once you get the hardware wired up properly.  The command I use is:

sudo flashrom -p linux_spi:dev=/dev/spidev0.0 -w erasethisandputyourfilenamehere.hex

The -p tells Flashrom which programmer to use and the -w command means write to the chip whatever filename that comes next.  It doesn’t have to be a .hex file.  The file extension shouldn’t matter as long as the file is in the correct format.  If you want to read your chip, use -r instead of -w and type in a filename to save the read as.

The pinout is as follows:

RPi pin SPI flash
25 GND
24 CS
23 SCK
21 DO
19 DI
17 VCC 3.3V

Be sure to use short wires or you may run into problems.

Here is a picture of my setup, these wires are actually far too long but it worked for me.

Bluetooth Express

Had an idea for a product so I did a little research (almost not enough because I initially ordered something that would not have worked) and picked out a Bluetooth module that should suit my needs.  Well after soldering it to the breakout board and hooking everything up on the breadboard, I got a blinky light and I could see it on my phone’s pairing screen but could not get it to pair.  I knew there was a utility to talk to the module via the UART interface and I had also purchased the Sparkfun FTDI Basic to take advantage of this.  Actually, I bought it to talk to the Arduino Pro Mini that I thought I needed to talk with the original Bluetooth module I almost ordered initially and then didn’t because it would not have done what I needed.  Unfortunately, the FTDI Basic changes the !RTS pin to a DTR pin in order to automatically reset the Arduino when loading sketches.  Not a big deal though because I happen to have a USB to FTDI cable that is used for talking with PIC microcontrollers.  Disaster averted.

So I hook up the Rx, Tx, !CTS, !RTS, and ground pins.  I initially had the Rx and Tx reversed because I assumed that the label on the cable meant Rx and Tx of the computer so Rx of computer goes to Tx of Bluetooth module and vice versa but alas, it was labeled for the TTL side so Rx goes to Rx and Tx to Tx.  I’ve made this mistake in the past but in reverse order.  So much for learning from the past.

I installed the KC Terminal app that is used to talk to the module and got it to recognize the TTL cable and open a virtual com port without any driver issues.  It should work with Windows out of the box (I’m using Windows 10).  Now I’m ready to see what’s going on inside the sleek little metal box.  Nothing… Can’t get anything output when the unit boots even though it should be giving me the version, status, and other info.  Nothing.  I try to throw some commands at it (AT Version, AT Status, …) and still nothing.  Obviously something is not right.  I check all the solder connections on the board, check the connections on the bread board, check power.  Nothing.

Luckily I have a handy dandy oscilloscope that I can slap on the Rx and Tx lines and see if there’s anything happening.  This should at least tell me if the module is attempting to talk and maybe I have a bad cable.  I get some noisy BS that doesn’t make much sense but definitely no TTL signals that I can readily see.  Maybe I have a bad cable.  Still, I should see SOMETHING coming out of the module that looks like TTL unless I have something wrong with the module or the wiring between the module and the TTL cable.  If the problem is the module then I should see SOMETHING coming from the computer that looks like TTL.  I see neither of those things so I feel like I have a fundamental problem with my setup.  I go ahead and reread the manuals but don’t find any clues so I go back over the whole circuit, wire by wire.  The only thing I see that might seem out of place is I don’t have the TTL cable’s power wire hooked up.  I’m powering the circuit externally so I don’t know why I would need 5V from the computer’s USB port but I figure it can’t hurt.  OF COURSE THAT’S THE PROBLEM… and I immediately see TTL signals on the Oscope and KC Terminal lights up and talks to me.  I’m disgusted but happy that the problem is behind me!  Now I can send and receive AT commands to my heart’s delight.

I still can’t get it to pair to anything though and there isn’t a word in the documentation about the pairing process or troubleshooting problems.  I’m going to get in touch with the company and see if they have anything for me.

Update: Got everything working. Didn’t change anything, just started working.  I’m not sure whether to be ecstatic or pull out my hair.  Whatever, it works.

Clipping Reverb

I’ve been working on a guitar pedal.  It’s a reverb and I’m attempting to add an overdrive stage into the reverb signal but it’s proving to be much more difficult than expected.  For some reason when the drive potentiometer gets to a certain spot it seems to bring out a pre-delay before the reverb starts and the reverb drowns out the dry signal as well.  Changing the diodes has improved the problem but more improvement is necessary.  I’ve had to reduce the drive gain so much that the diodes are clipping fully due to the voltage not getting high enough.  If I increase the gain any more, the pre-delay becomes very pronounced and too loud.  I’m hoping that I can find another diode that has a lower forward voltage so that it begins clipping earlier and gives the desired overdrive without the delay.  I haven’t been able to find a list of diodes and their corresponding forward voltages so I guess I’ll have to make one.  I’ve noticed the Germanium diodes bias much lower and they also have a softer clipping which guitar tone aficionados prefer.  I like the softer clipping because I’m not looking for hard distortion, just some edginess for the reverb.

Update:
Moving the clipping stage in front of the reverb unit and increasing the gain in front of the clipping stage seems to have given enough edge and gain for a satisfactory overdrive though the problem still arises when the drive pot is larger than about 15k Ohms.

Update:
Removed R6.  I don’t see that it is necessary if R12 is there, although every other Belton brick circuit I’ve seen leaves it in there.  Added R17 to keep the bypassed input from being sucked by the always-on output.  I didn’t have the problem with the early iterations so I considered it solved and quit using the footswitch  Now that I’ve put the switching back into the circuit there’s a massive drain.  I’ve added another capacitor from the output to ground to cut high-frequency noise that was seeping through the wet signal.  There’s still a trace of noise when I crank the gain on my amp but I’ve compared it to other reverbs (even a digital one) and I’m getting no more noise than those so I consider that solid.  Another problem has arisen, and I think it has been there but not as prominently as now.  I’m getting footswitch pop at the input.  I know it’s at the input because it echoes in the wet signal.  When I measure the input pin of the circuit while the input is bypassed, I’m getting over 2V.  On the other side of my capacitor I get just over 4V, which is approximately the expected reference voltage being fed from Vref but the cap should be blocking all DC from coming back across.  Turns out the cap was bad. Now all the DC is being blocked but still getting some switch pop that can be heard when the amp is cranked pretty hard.  Hearing it pop when switching into and out of the circuit but it’s more noticeable when switching it on because I get an echo of the noise.

 

Update:
Made more changes.  Added output buffer and removed R17.

 

Footswitch POP

I’m getting some footswitch pop on my reverb now that I have most of the other problems licked.  I’m using a “half” true-bypass to allow the reverb to trail off naturally instead of cutting off abruptly with the footswitch.  I’ve not seen much on the Google about achieving “trails” (or “tails”) with reverb or echo units.  I see where people are attempting to implement it, claim it works, then take it out because it’s not working.  Of all the schematics I’ve found, none are too clear about the switching circuit itself.  Most schematics leave the switching out completely so it’s hard to know exactly what’s happening.  But I’ll leave that to another post.  What follows is a (mostly) comprehensive discussion of why switch pop happens and how to prevent it.

First and easiest thing to do, add a 1MΩ.  Tie the resistor across the input and output of the pedal  The theory is that any DC bias that tries to feed the input will be leaked to ground through this resistor.  There is also a capacitor in series with the input buffer that blocks DC.  Leaky capacitors can cause switch pop sense all of the DC is not blocked.  Electrolytic caps tend to be leaky so always use film caps at the input and output of your circuits.

Another cause of pop can be the LED that tells the user the effects circuit is on.  This happens because of the rapid current inrush.  A wire (or PCB trace) with a large change in current causes a magnetic field that induces a change in surrounding wires (traces) which can result in popping.  Be sure to use an appropriate resistor in line with the LED to limit current.

Leaky capacitors can also cause a voltage potential difference that gives pop.

Power supply noise and ground noise is what the “LED tick” is doing. The LED current is suddenly changing either the power supply or ground voltage at the amplifier’s sensitive points by suddenly changing. It’s usually a wiring or wire routing problem.

Any sudden change in current in a current loop also broadcasts itself as either a magnetic pulse to be picked up by another current loop, or a radio pulse.

In the image below, you can see R1 is the input resistor to ground that drains any C1 capacitor voltage that leaks across.

input buffer

Input Impedance of Op Amp Buffers

I learned a few things about input impedances of op amp input buffers.  Different op amp arrangements are measured differently so I’ll walk you through the different types.

 

Image result for non inverting buffer op amp

Image result for non inverting op amp

Non-inverting buffers are the quintessential setup for a buffer.  Bring the signal in on the non-inverting (+) input and tie the output to the inverting (-) input.  This will give a unity gain buffer that provides high input impedance  is typically 1 MΩ to 10 TΩ.  An ideal op amp has infinite resistance.  The output of this buffer is very low, typically much less than 1Ω.  In the guitar FX world we would add a resistor to Vb (Vb is half of the input voltage) in order to allow the guitar signal to pass through since we typically use a single sided 9V power supply.  This resistor will negate the high input impedance of the op amp though since you are essentially putting it in parallel.  This resistor will determine your input impedance so always keep it above ~470kΩ.  1MΩ is generally the go-to resistor here.

 

Image result for inverting op amp

Inverting op amp circuits change the game completely so be aware of which op amp you are using.  Rin alone will determine your input impedance here.  Generally, this circuit is preceded by a transistor buffer or a non-inverting op amp buffer so that lower resistor values can be used.  Higher resistor values in series with your signal translate to higher noise levels.

 

Getting WordPress Started With SmarterASP.net Server

SmarterASP.net is a great hosting provider and super cheap, I highly recommend them.

 

When I did the one-click WordPress install from the Control Panel, I got “Error Establishing Database Connection.”  I had no idea what I was doing so I tried accessing the wp_config file directly and no luck.  I found out there were two problems.

  1.  I had not created a database in the SmarterASP Control Panel.  I assumed it did this automatically.  Go create one by clicking on the database button in the Control Panel.  Choose the “Databases” tab then click the “+MySQL” button.
  2. I had to manually put the database info into the wp_config.php file.  Get the file using the download button on the Control Panel or use FTP.  The FTP server is: ftp.smarterasp.net.  You’ll find this info on the same screen that you add the database.  After creating the database, there will be two connection string examples.  I wan’t sure how to use them directly but the info you need is contained in here.  It’s also located above in the Database Info section.  Look through this line and find your server name and user name the input these and the password you specified into the wp_config.php file.

 

Database Creation

 

Here is the snippet that I edited:

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘db_a1068b_thisismydatabasename’);

/** MySQL database username */
define(‘DB_USER’, ‘a1068b_thisismyusername’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘thisismypassword’);

/** MySQL hostname */
define(‘DB_HOST’, ‘MYSQL5018.SmarterASP.NET’);

 

After you put that info in, go to “yoursite.com/wp_admin/install.php” and follow the instructions!