Giter Site home page Giter Site logo

c2prog's Introduction

c2prog

Use an Arduino to flash the Ardupilot bootloader to SiK radios via the C2 interface.

The Ardiuno sketch containts the SiK bootloader for HM-TRP based radios. Once the bootloader is flashed to the radio, the latest firmware can be installed via the USB or serial port in the usual way.

Based on the AVR code within https://github.com/x893/C2.Flash. Which in turn is based on the code examples provided in the orginal Si Labs application note, AN127 Rev. 1.1.

Connections

  Arduino        HM-TRP
 ~~-------+    +-----------~~
          |    | O #:#:
          |    | O = +------+
          |    | O = |      |
          |    | O   |      |
      D12 | -----> o +------+  <- C2CK
      D11 | -----> o     +-+   <- C2D
     +3V3 | -----> o # # | |   <- VDD_MCU
      GND | -----> o     +-+   <- GND
 ~~-------+    +---^-------~~
                   |
                 C2 interface
                 This row of 4 holes.

Hook up the Sik radio board (such as the HM-TRP board) as per the connection diagram. On some boards there is a row of 4 holes for the C2 interface through which breadboard hookup wire can be insterted.

Be careful: The Si1000 VDD_MCU is not 5V tolerant so only connect to the Arduino 3.3V output. However, all other I/O including C2D and C2CK pins are 5V tolerant, and can be connected directly to the Ardiuno 5V I/O pins.

Ardiuno Hookup

Building

Build the c2prog.ino sketch with an Ardiuno IDE and flash to the Arduino. The low level pin mappings should work with the Uno, Mega, Nano or Pro Mini, but other boards may need to be remapped. The code is tested for 16 Mhz boards, but for other boards the timming may need to be adjusted. See Porting.

Keys

From a serial console:

  • D Get Device ID

  • E Erase Flash

  • B Burn bootloader

  • V Verify bootloader

  • W Write Flash: WAAAALLbb..bb

  • R Read Flash: RAAAALL

    where:

    AAAA = 16 bit start address in hex

    LL = length in hex, 0-256 bytes

    bb..bb = LL hex bytes to read or write

Instructions

  1. Connect a serial console to the Arduino at 115200 baud.
  2. Press D to check Device ID: e.g. 1600 = Si100x, rev. A, 0000 = not connected.
  3. Press E to erase flash.
  4. Press B to burn the bootloader.
  5. Press V to verify bootloader. The lock byte is not flashed to allow for verification, so ignor the failure at address 0xFBFF.

Once the bootloader is installed, connect to the radio via its serial interface and install the Ardupilot Sik firmware in the usual way.

For example, using the SiK tools:

    python uploader.py --baudrate 115200 --port /dev/ttyUSB0 radio_hm_trp.ihx

Or using a ground station such as Mission planner, see the Ardupilot docs: upgrading-radio-firmware.

The latest firmware can be downloaded from: https://firmware.ardupilot.org/SiK/

Porting

The timming for the C2CK pluse is the most critical. The code is tested for 16 Mhz boards, but for other frequencies the timing of Pulse_C2CLK() may need to be padded with additional NOP's.


     C2CK line pulse timing

     C2CK ---+--------\          /-------------\         /
             |        |\        /|             |\       /
             |        | \------/ |             | \-----/
      driver |        |          |             |
        on ->+<------>+<- t_CL ->+<-- t_CH --->+
               >40ns   80ns - 5us    >120ns

To generate C2CK clock strobes with a microcontroller-based programmer:

  1. Turn the C2CK driver on.
  2. Wait at least 40 ns. This helps ensure C2D data setup time.
  3. Force C2CK low. Ensure interrupts are disabled at this point.
  4. Wait between 80 and 5000 ns.
  5. Force C2CK high.
  6. Wait at least 120 ns. This helps ensure C2D data valid time.
void Pulse_C2CLK(void)
{
  C2CK_PORT &= ~C2CK_BIT;
  asm volatile("nop\n\t");
  asm volatile("nop\n\t");
  C2CK_PORT |= C2CK_BIT;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.