Saturday, 29 November 2014

Setting up CSS Uniflash to program the CC2538DK in Contiki

When I first started trying-out setting Uniflash to work with the CC2538DK and Contiki, I stumbled upon this warning:

I first tried Uniflash v3.1.0.00026 with no luck, so I downgraded to version v2.2.00016, you might want to skip the next section as it mostly describes the pain and futility of my first attempts with the latest Uniflash version, mostly kept as a warning of the severed-head-on-a-pike type for others encountering the same errors, and maybe lurking a kind soul who has fought this monster and prevailed, willing to share the solution.

At the end the solution was to find the right combinations of magic ingredients:

The right CCXML recipe:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<configurations XML_version="1.2" id="configurations_0">
    <configuration XML_version="1.2" id="configuration_0">
        <instance XML_version="1.2" desc="Texas Instruments XDS100v3 USB Emulator" href="connections/TIXDS100v3_Dot7_Connection.xml" id="Texas Instruments XDS100v3 USB Emulator" xml="TIXDS100v3_Dot7_Connection.xml" xmlpath="connections"/>
        <connection XML_version="1.2" id="Texas Instruments XDS100v3 USB Emulator">
            <instance XML_version="1.2" href="drivers/tixds100v2icepick_c.xml" id="drivers" xml="tixds100v2icepick_c.xml" xmlpath="drivers"/>
            <instance XML_version="1.2" href="drivers/tixds100v2cs_dap.xml" id="drivers" xml="tixds100v2cs_dap.xml" xmlpath="drivers"/>
            <instance XML_version="1.2" href="drivers/tixds100v2cortexM.xml" id="drivers" xml="tixds100v2cortexM.xml" xmlpath="drivers"/>
            <property Type="choicelist" Value="4" id="The JTAG nTRST Boot-Mode"/>
            <property Type="choicelist" Value="4" id="The Power-On-Reset Boot-Mode"/>
            <property Type="choicelist" Value="2" id="The Converter Usage"/>
            <platform XML_version="1.2" id="platform_0">
                <instance XML_version="1.2" desc="CC2538SF53" href="devices/cc2538sf53.xml" id="CC2538SF53" xml="cc2538sf53.xml" xmlpath="devices"/>

The right CSS Uniflash version (mine was

And finally the right flashing command:

contiki/examples/cc2538dk$ sudo /opt/ti/ -ccxml /opt/ti/CC2538SF53.ccxml -operation Erase -program cc2538-demo.elf

Then the magic starts:

***** Texas Instruments Universal Flash Programmer *****
<START: 19:19:29 GMT+0100 (CET)>
> Configuring the Flash Programmer with the given configuration ...
> Flash Manager is configured for the following part: CC2538SF53
> Connecting to the target for Flash operations ... 
> Connected.
> Performing operation: Erase
> Completed current operation.
> Loading Program: cc2538-demo.elf
> Finish Loading.
> Disconnecting from target. 
Cortex_M3_0: GEL Output: CPU Reset.
<END: 19:19:56 GMT+0100 (CET)>
<Operation Time: 19.341s>
<Total Time: 27.662s>

This is not my preferred way to flash the CC2538DK, as now with the bootloader backdoor unlocked it is possible to program the devices over UART using the built-in bootloader BSL script, but there may be cases in which you accidentaly flash an image with the backdoor unlocked, and need to enable this again.

No comments: