8Bitdo NES30 Pro Gamepad Teardown

A while ago I bought two NES30 Pro Retro Gamepads. They are really nice and good quality, and support different modes, plain Gampad mode, or they can emulate keyboards which is handy for games which do not come with support for gamepads out of the box. And with the latest firmware update the OSX support was improved, so that the analog sticks become usable.

But you don’t own a product until you opened it up (at least if you are an engineer). So here some shots of the inside of the NES30 Pro with some comments:


Start by popping of the bottom plate, e.g. by sliding your fingernail in the gap under one of the L1/R1 Buttons, then slide it towards the side until the bottom plate starts to pop off.


After the screws have been removed the top side can be removed and we see the main PCB. Before it can be removed make sure to open the flat-flex cable connector. Try to not touch the carbon contacts for the buttons too much. Removing the PCB is a bit tricky because it sits tight in the housing. Wiggle it around a bit, but don’t pull to hard because otherwise flat-flex cable can be destroyed it gets stuck somewhere.


The analog sticks are on a second PCB. For safety I pulled the battery connector.


Nice PCB artwork 🙂 (8bitdo Logo in the lower left corner)


The battery. Next to the battery a mystery unpopulated header?


The bluetooth chip. The chip label says RDA 5876. Manufacturer is RDA Micro


The main processor is a chinese clone of a STM32F103


The main processor is a chinese clone of a STM32F103


Overview of the parts with my trusty swiss knife.

Veröffentlicht unter Allgemein | 12 Kommentare

SSH Tunnel serial ports over the internet

For the project I am working on we have a (expensive) development board sitting in the lab, so that everyone in the Team can access it, without the need to have a board for every developer. The board can be accessed by logging in over ssh to the server.

But I thought: Wouldn’t it be nice to be able to access the board like a normal serial adapter on your local computer? I searched a bit and it is doable with pretty much standard software on any Linux/Unix (OSX) system:

The setup looks like this:


netcat is kind of a Swiss Army Knife regarding networks. On the our Server netcat listens for a connection on a TCP port on the loopback interface, so that the port is not visible from the outside (which otherwise might invite unintended guests ;). The inputs and outputs of netcat are redirected to the Serial Port where the Dev Board is connected to.

Socat is similar to netcat, as it can connect to servers over the network, but has a couple of extra features, for example creating a pseudo terminal device: All the data that is written to the Pseudo Terminal device is sent out over the network. And everything that is received from the network is written to the Pseudo Terminal. Again Socat is set up to only connect to the loopback interface, so that the Port is not visible from the internet.

Finally a SSH tunnel connects the two computers and tunnels the data to the ports on the loopback interfaces.

All this can be initiated from the client like so:

ssh -fCo "ExitOnForwardFailure yes" -L 54333:localhost:54321 USER@SERVER "nc -l localhost 54321 </dev/ttyDEVBOARD >/dev/ttyDEVBOARD" && socat pty,link=$HOME/vmodem0,wait-slave tcp:localhost:54333 &
screen ./vmodem0 BAUDRATE

Here 54321 is the Port on the Server side (on which netcat listens), and 54333 is the port on which socat on the Client side listens. SSH is told to start netcat on the client side and to fork into the background when it is done. Also the Tunnel is set up to use compression. When the SSH Tunnel was set up successfully, socat connects to the tunnel, where on the other side netcat is already listening and creates a pseudo terminal device in my /home directory. Every terminal client can connect to this device as if it was a physical device locally attached to the Client. In my case I am using GNU screen as a terminal client.

The only problems that I had is that sometimes the start up of the connection fails. But other than that, once the connection is established, it is as stable as a normal ssh connection.

Veröffentlicht unter Allgemein | Kommentar hinterlassen

Using Serial Adapters with Baudrates >230400 on OSX

The Problem

For the project I am currently working I have a development board with a FTDI 2232 serial to USB adapter to connect to it. The Baudrate is set to Baudrate of 460800. This is not a problem on Linux and Windows. But if you are using OSX and open the serial device with a baudrate over 230400, it falls back to 9600 baud. (Up to 230400 all baudrates work fine)

I investigated already a bit into this, and the problem occurs independently of the program that you use to open the terminal. I tried GNU screen, and a couple of others.

I even tried to use other drivers, in my case the drivers provided by FTDI (stock OSX provides its own drivers for most serial converters). But this still didn’t help.

All combinations of serial terminal clients and drivers „pretend“ to open the device at 460800 baud, but if you look at the signals with an oscilloscope or logic analyzer you see that in reality it is only 9600.

The solution I found involves the commandline program stty, which can be used to set (among other options) the Baudrate of TTYs on Unix systems. stty opens the serial port device, and sets the new baudrate. However there is one tricky part left: OSX resets the baudrate after stty exits!! But I found a solution here

TL;DR: The Solution

stty -f /dev/cu.usbserial-141A 460800 & screen /dev/cu.usbserial-141A 460800

Explanation: The first part (before the &) sets the baudrate for the terminal. The & sends the stty process to the background. The second part opens the serial terminal, while stty is still in the background. There is a small time frame after stty exits where OSX did not reset the baudrate yet, and this is used to connect to it with the correct baudrate.

Veröffentlicht unter Allgemein | 2 Kommentare

Using the Xilinx Unisim and XilinxCoreLib with GHDL (on Mac OSX)

For my project I partly work on my Mac, on which I cannot use the Xilinx ISE, and the only option to simulate VHDL code is to use GHDL. I was looking for a possibility to still use the IP Cores that I generate with the Xilinx Coregen tool, e.g. FIFOs. I found an article which described how the unisim library can be used  with GHDL. I adapted and improved the method described in the article a little bit. So here is what I did:

First you have to have a computer with the Xilinx ISE installed. From there obtain the Unisim and XilinxCoreLib source files from /opt/Xilinx/14.7/ISE_DS/ISE/vhdl/src/

I copied them to my GHDL directory on my Mac under /usr/local/lib/ghdl/src/xilinx. If you use a different directory this has to be changed in the following scripts.

Compiling the libraries is a bit tricky, because there are interdependencies between the files. But luckily Xilinx provides a file (vhdl_analyze_order in the source folders) that gives us the order in which the files have to be compiled.

To compile the files in the right order, I wrote two little scripts. Here is the script for the unisim library:

# adapt this to your needs:

mkdir -p $output_dir

# First analyze the files in the base directory
ghdl -a --work=$library_name --ieee=synopsys --std=$vhdl_standard --workdir=$output_dir -P$output_dir -fexplicit ${src_dir}/*.vhd

# Then analyze the files in the 'primitive/' sub-directory
# Strip lines that do not start with a alphabetic character
f=$(grep --no-filename -R '^[a-zA-Z]' ${src_dir}/primitive/vhdl_analyze_order)

# compile each file
while read line
        ghdl -a --work=$library_name --ieee=synopsys --std=$vhdl_standard --workdir=$output_dir -P$output_dir -fexplicit ${src_dir}/primitive/$line
done <<< "$f"

And here is a similar script for the XilinxCoreLib:

# adapt this to your needs:
mkdir -p $output_dir
#Strip lines that do not start with a alphabetic character
f=$(grep --no-filename -R '^[a-zA-Z]' ${src_dir}/vhdl_analyze_order)
# compile each file
while read line
        ghdl -a --work=$library_name --ieee=synopsys --std=$vhdl_standard --workdir=$output_dir -P$output_dir -fexplicit ${src_dir}/$line
done <<< "$f"

Save this to a file, e.g. build_XilinxCoreLib, make it executable, then the XilinxCoreLib can be analyzed and added to the library with:


Most of the files are analyzed without problems. Only the following files could not be analyzed, and hence will be missing from the library:

  • xbip_dsp48_macro_v2_1 .vhd
  • xbip_dsp48_macro_v2_0.vhd
  • fir_compiler_v5_1_sim_pkg.vhd
  • fir_compiler_v5_0_sim_pkg.vhd

To use the library use the „-P“ option of ghdl to specify the location of the additional libraries. And because Xilinx uses some non IEEE standard libraries you also have to add the „–ieee=synopsys -fexplicit“ options for example:

ghdl -a -P/usr/local/lib/ghdl/v93/unisim/ -P/usr/local/lib/ghdl/v93/xilinxcorelib/ --ieee=synopsys -fexplicit FIFO.vhd
Veröffentlicht unter Allgemein | Kommentar hinterlassen

Install Xilinx / Digilent Cable drivers on Linux Mint for LX9 Microboard

I have a Avnet / Digilent Spartan-6 LX9 microboard. During installation of the Xilinx ISE I did not select to install the cable drivers. So I had to install them before I could program the FPGA Board. I am using Linux Mint 17.3 (Cinnamon), but the instructions should be similar to other Ubuntu based Linux distributions.

I roughly followed the description on this site:

First open a terminal and change directory to the Xilinx ISE installation, to be specific to the directory that contains the drivers for my board:

 cd /opt/Xilinx/14.7/ISE_DS/common/bin/lin64/digilent/

Then execute the install script as root. I accepted all of the defaults:

sudo ./install_digilent.sh

Finally udev has to be restarted to load the driver correctly

sudo udev restart

Now Impact (the FPGA programmer) can be started:

source /opt/Xilinx/14.7/ISE_DS/settings64.sh

(Before all that I installed:

sudo apt-get install git build-essential libusb-dev fxload

But I think this is not necessary (it was from a different instruction))

Veröffentlicht unter Allgemein | Kommentar hinterlassen

Setting up PostgreSQL & PostGIS

I wanted to make a custom printed map to give it as a present. I quickly found that Mapbox Studio Classic is an good tool for that which is easy to learn.

For some reasons I was not completely satisfied with the map data that Mapbox provides. This is why I wanted to work with my own map data, hosted in a PostgreSQL/PostGIS database (PostGIS is an extension to PostgreSQL. In the following is how I set up my DB

I installed PostgreSQL and the PostGIS extension via homebrew (I am using a Mac. On Linux you could youse your packet manager).:

brew install postgresql postgis

Here I found out how to start the PostgreSQL server:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Then I could set up the database user and the database itself:

createuser --superuser gisuser
createdb -E UTF8 -O gisuser gis
psql --username=gisuser --dbname=gis -c "CREATE EXTENSION postgis;"
psql --username=gisuser --dbname=gis -c "CREATE EXTENSION postgis_topology;"

To test whether everything worked as expected one can connect to the db:

psql --username=gisuser --dbname=gis

and inside the db prompt one can list the extensions:

gis-# \dx
                                         List of installed extensions
       Name       | Version |   Schema   |                             Description                             
 plpgsql          | 1.0     | pg_catalog | PL/pgSQL procedural language
 postgis          | 2.1.7   | public     | PostGIS geometry, geography, and raster spatial types and functions
 postgis_topology | 2.1.7   | topology   | PostGIS topology spatial types and functions
(3 rows)

And finally the OSM data can be imported:

osm2pgsql -s -U gisuser -d gis ~/Downloads/rotterdam_netherlands.osm.pbf

This can take a while, and at this point I was glad that I only downloaded the map data of Rotterdam, and not of whole Netherlands, or the Planet.

Veröffentlicht unter Allgemein | Kommentar hinterlassen