Git Product home page Git Product logo

cc2530prog's Introduction

cc2530prog - Texas Instruments CC2530 Micro controller programming utility

1. General informations

This utility uses the CC2530 Debug Port to program the micro-controller. The specific details of this interface are described in the following documents:

The hardware is programmed with the means of 3 GPIOs:

  • reset (RST) (whose polarity can be software configured)
  • data (DATA)
  • clock (CLK)

The principle is the following:

  • pulse the reset line to enter debug mode
  • configure the hardware with DMA descriptors for transfering data from the DEBUG port directly to Flash
  • clock out data to the debug port using the GPIOs

2. Software integration and modifications

The current version is provided using the Linux GPIO sysfs interface. Linux can expose GPIOs to the user-space under /sys/class/gpio when the config symbol CONFIG_GPIO_SYSFS=y is enabled.

3 GPIOs must be exposed by your hardware in order to use cc2530prog. In case your system does not use GPIOs exposed through sysfs, you are supposed to implement the following functions (also declared in gpio.h):

gpio_export: exports a GPIO pin for an user-space/consumer/producer application

gpio_unexport: unexports a GPIO pin

gpio_set_direction: set the direction (IN, OUT, HIGHZ) of the given pin

gpio_get_value: sets the output value of a given pin (pin must be output first)

gpio_set_value: returns the current gpio value

You are then supposed to set the Makefile environment GPIO_BACKEND to point to the file implementing these GPIO routines for your specific platform.

3. Recommandations

The CC2530 firmware size matches the available hardware flash sizes (64KB up to 256KB) but since programming using the debug port is very slow, it is recommended to bootstrap using the debug port and then use another mechanism to transfer the bigger software image.

TI provides such a mechanism using an UART/SPI bootloader.

4. Future developments

At the moment nothing else is planned for this utility, however it should be possible to use the routines exposed by this utility for doing interactive debugging using the debug interface (which is what the CC2530 Debug dongles basically do).

-- Florian Fainelli

cc2530prog's People

Contributors

ffainelli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cc2530prog's Issues

what kind of binary cc2530-prog could burn ?

Hello, ffainelli.

I am trying to burn cc2530 firmware with cc2530-prog. but I have no idea what kind of firmware should be used for burning? I only have hex binary built with iar workbench.

Regards!

The code is not working on the Raspberry Pi.

Hey,
First of all thank you for this piece of code, this made my work much easier.
I compiled the code on the Raspberry Pi and connected all the pins but it didn't work.
I took some time but I find out the problem, I based my research on the working cclil project and cc_flahser:
https://github.com/tobyjaffey/cctl/tree/master/ccpil
http://sourceforge.net/projects/ccflasher/
From this project you can get several things:

  1. You need to put delays in some areas of the code because the Pi is too fast fot the CC2530.
    For example here is your code with my added delays:
static void delay_ns(unsigned int ns)
{
    struct timespec sleeper, dummy;
    sleeper.tv_sec  = 0;
    sleeper.tv_nsec = ns ;
    nanosleep (&sleeper, &dummy) ;
}

void delay (unsigned int millis)
{
  struct timespec sleeper, dummy ;

  sleeper.tv_sec  = (time_t)(millis / 1000) ;
  sleeper.tv_nsec = (long)(millis % 1000) * 1000000 ;
  nanosleep (&sleeper, &dummy) ;
}


/*
 * Hold reset low while raising clock twice
 */

static int cc2530_leave_debug(void)
{
    gpio_set_value(RST_GPIO, 0);
    delay(100);
    gpio_set_value(RST_GPIO, 1);
    return 0;
}

static int cc2530_enter_debug(void)
{

    cc2530_leave_debug();
    gpio_set_value(CCLK_GPIO, 0);
    gpio_set_value(DATA_GPIO, 0);


    gpio_set_value(RST_GPIO, 0);
    delay(10);
    gpio_set_value(CCLK_GPIO, 0);
    delay(1);
    gpio_set_value(CCLK_GPIO, 1);
    delay(1);
    gpio_set_value(CCLK_GPIO, 0);
    delay(1);
    gpio_set_value(CCLK_GPIO, 1);
    delay(1);
    gpio_set_value(CCLK_GPIO, 0);
    delay(1);
    gpio_set_value(RST_GPIO, 1);
    delay(10);

    debug_enabled = 1;

    return 0;
}


/*
 * Bit-bang a byte on the GPIO data line
 */
static inline void send_byte(unsigned char byte)
{
    int i;

    /* Data setup on rising clock edge */
    for (i = 7; i >= 0; i--) {
        //
        if (byte & (1 << i))
            gpio_set_value(DATA_GPIO, 1);
        else
            gpio_set_value(DATA_GPIO, 0);


        gpio_set_value(CCLK_GPIO, 1);
        delay_ns(1);

        gpio_set_value(CCLK_GPIO, 0);
        delay_ns(1);
    }
}

/*
 * Clock in a byte from the GPIO line
 */
static inline void read_byte(unsigned char *byte)
{
    int i;
    bool val;
    *byte = 0;

    /* data read on falling clock edge */
    for (i = 7; i >= 0; i--) {

        gpio_set_value(CCLK_GPIO, 1);
        delay_ns(1);

        gpio_get_value(DATA_GPIO, &val);

        if (val)
            *byte |= (1 << i);

        gpio_set_value(CCLK_GPIO, 0);

    }
  1. Delays alone won't make this code work, I find out that you need to reset the debug port before you init it. I don't know how to explain this but its working that way.

After this changes I was able to get this code program the chip and verify it, but still the code doesn't appear to be running. I halted the cpu and checked the pc register and it point to zero. I suspect it has to do with the output format of the IAR compiler. which format should be used with this programmer? raw-binary? simple-code? intel-extened?
hope you can help me and many thanks for this work!!

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.