OpenSky on D4R-ii – pinout, flashing, and usage

Disclosure: This post may contain affiliate links, meaning I get a commission if you decide to make a purchase through my links, at no cost to you.

By | September 7, 2016

In this post i am going to explain how to use my opensource firmware on a FrSky D4R-ii receiver. Please refer to the main page about my opensource project OpenSky for general information. Addition information on the board layout, used components, and the pinout can be found in this blog post.

Pinout

The default configuration of my code uses the following pinout. If the board is in front of you with the LEDs on the lower left corner, the channel and connector layout is like this:

,-------------------------------.
|                        CH1 CH2|
|  ANT1                   +   + |
|                         -   - |
|                         -   - |
|                         +   + |
|  ANT2                  CH3 CH4|
|      LEDS                     |
|      [] []             [1234] |
`-------------------------------´

Opensky uses the following pin mapping on the main port:

CH1: PPM out (if SBUS is disabled)
CH2: APA102 DATA
CH3: APA102 CLK
CH4: non-inverted SBUS or debug UART (115200baud, 8N1)

And for the extension port:

[1]: GND
[2]: ADC1 input (max 3.3V!)
[3]: inverted SBUS or debug UART (115200, 8N1)
[4]: inverted hub telemetry input (9600baud, 8N1)

The different options can be configured in the main.h file: use the defines to select CPPM or SBUS or to redefine the pin mappings. Please note that not all pins can be freely remapped, e.g. the uart port used for SBUS is fixed to this special pin.

Flashing

This target can be flashed using either a ST-Link V2 or by using the STM32 serial bootloader.

ST-Link

Please connect the ST-Link to the following pins:

GND    = GND
SWDIO  = R12 (the side connected to STM32 pin 34)
SWDCLK = RP2, pin4 (connected to to STM32 pin 37)

Connect the ST-Link first, power the target and run “make flash” to program the device.

Serial bootloader

In addition to the ST-Link interfacae the STM32 series of chips has a ROM based un-brickable bootloader. In order to enter the bootloader, temporarily short circuit the jumper pad R19 to enter the boot loader.

Please note that the D4R-ii has a signal inverter in between the serial header and the CPU, thus the serial lines are inverted!
USB to serial convertes based on FTDI chips can be configured to invert rx and tx by software! Windows users can use MPROG for that.

Connect an inverted serial cable to the 4pin expansionport connector:

[1] = GND
[2] =  not connected
[3] = inverted TX ---> connect to RX 
[4] = inverted RX ---> connect to TX

Debugging

When you connect a serial to usb connector (RX) to the debug output pin and set up your terminal to 115200 baud 8N1 you will see the following debug messages:

TODO: ADD EXAMPLE DEBUG OUT

This is quite useful for debugging or initial set up, however, please disable it by uncommenting the DEBUG entry in main.h for real use.

Usage

The usage is straightforward, connect the SBUS or PPM output to your flightcontroller and set it up properly. Optionally connect the hub telemetry input and configure your flight controller to output FrSky hub telemetry at 9600 baud (8N1).

Disclaimer

Please see the disclaimer on the OpenSky main page. DO NOT use this code on dangerous equipment! I am not responsible for any damage/injuries caused by using this code!

Leave a Reply

Your email address will not be published. Required fields are marked *