SWD programming using a RaspberryPi

I previously write this post on how to use a BeagleBoneBlack as a JTAG (SWD) programmer. It was fun but really slow. I port my code on RaspberryPI and now what was taken 5-8 hours is a couple of minutes.

To connect the SWD connector to the PI use the following schema

Connect SWD to RaspberryPi

Connect SWD to RaspberryPi

I use this peace of code to reflash my TD1204 and TD1208 based both on EFM32 when bricked after unsuccessful update…

Here is the python file to interact with SWD : https://github.com/disk91/PySWD/blob/master/RpiGPIO.py

I hop it will be soon integrated in the main PySWD project as the previous one.

You should check or modify flashEFM32.py file

import array

from PirateSWD import *
from RpiGPIO import *
from SWDCommon import *

[...]

def main():
    busPirate = RpiSWD("", vreg = True)
    debugPort = DebugPort(busPirate)
    efm32     = EFM32(debugPort)

To run the Flash program, just launch

# ./flashEFM32.py ../myProgram.bin

 

Manage sigfox device for consumer deployment

sigfoxWhen you plan to deploy / sell sigfox based solution to consumer, you have to manage you device park. The sigfox network have a restricted radio medium to ensure you will not emit more than what you payed for you will be charged by them if a device you own is emitting, even if it is emitting out of your control. There is no network subscription like in 3G before being able to emit so anyone can emit.  That is why, to ensure every one is clear, you have an extra cost if you emit more than you are allowed or if you emit from a non registered device.

When you are designing end-user system you have no control on the device and if you propose a monthly fee to use your solution you will never sure the end user will unplug it once he stop to pay for your service. It means you could have a consumer stopping to pay for your service but a device continuing to emit and sigfox request you to pay for it.

Since the network allow you to have downlink message, now you have the capability to send order to your device and as a consequence allowing you to kill the device remotely. This is a good solution !

Next you have a new scenario where your end user finally decide to reuse your service and want to reactivate the device. At this step you won’t be able to communicate with it and you will have to find another way to reset its state to normal. You can eventually add a “factory reset” button or request to reflash it. There is another funny when : playing with the reboot time.

This post will describe how to lock a device to stop emit on network and how to play with the startup sequence to reset it. Read more !

Continue reading

Telecom Design sdk – track your stack usage

When trying to see what is happening with your code, you could try to follow stack size and current running time. Here is a simple function for doing the work :

void dsk_printDebug() {
#ifdef DEBUG
    uint64_t time;
    uint32_t msec, t;
    uint16_t hour, min, sec;
    time = TD_SCHEDULER_GetTime();


    msec = time & 0x3FFF;
    time >>= 15;
    t = time;

    sec = t % 60;
    t = t / 60;
    min = t % 60;
    t = t / 60;
    hour = t % 24;
    t = t / 24;


    #ifndef __ICCARM__
        extern char __cs3_stack[];
        char *limit=__cs3_stack;
    #else
        extern char CSTACK$$Limit[];
        char *limit = CSTACK$$Limit;
    #endif
        uint32_t *sp = (uint32_t *) __get_MSP();

    tfp_printf("[debug] Time:%d.%02d:%02d:%02d.%3d || Stack size : %d / %d \r\n",
        (uint32_t) t, hour, min, sec, (msec * 1000) >> 15,
        ((uint32_t)limit - (uint32_t)sp), CONFIG_STACK_SIZE
    );
#endif
}

Telecom Design SDK – TD_USER_Loop working way

After some discussions this afternoon with TD support and get a good advice from them, this post details some notice about TD_USER_Loop working way and power saving.

For those like experienced with Arduino, Telecom Design loop is not working like

while(1) {
   loop();
}

But it is called on Interrupt ; I don’t know why but I was expecting it to be called every tick (32KHz) which was a wrong assumption. In fact, this procedure is called on wake up from any interrupt. The frequency of call can’t be determined, it can be not called in a minute if no events occurs. That is why schedulers helps you to have a predictable call.

SigFox Down-Link is now available for TD chips

I was waiting for it since a long time, now it is ready ! The down-link code is available on the Telecom Design SDK version 5.0.0.

Thank to this upgrade we are now ready to receive 4 messages a day on a device and ready for device actions !

I recommend to reinstall the SDK or at least to clean all the previous build as in my case, updating from github created a lot of build issues.

Stay tuned, I’ll try and give some feedback soon !

SigFox arduino Raspberry PI hacking board

sigfox hack board

sigfox hack board

I assume you know a little bit who I am and what I’m doing, I’m not the one to by > 100€ to buy a one shot development board kit to test & hack a device like the Telecom Design chip. So basically I built my own with the objective to work with multiple configuration.

My “cahier des charges” was to make a board able to be installed as a dauther board on a raspberry PI,  able to support an arduino, able to run autonomously and being able to own a TD1204 as a TD1208.

It was a huge work to route it and I must recognize that it do not have all the GPIO connected as I expected but it exists, it works and it help me to build my first SigFox prototypes with success.

So, now, I propose to distribute this board to those of you looking for a such swiss knife.

Continue reading

TD1204 – How to use GPS device for geolocalization with Sigfox

The TD1204 is the GPS & Accelerometer version of the sigfox Telecom Design chip. After a previous post about the use of the accelerometers (here) I’m describing how to use the GPS module.

The embedded GPS is based on a UBX G7020 chip. This chip will give you the date, time, longitude, latitude, altitude, speed and direction of the device when activated.

Read more for programming details

Continue reading