Project

General

Profile

Download (7.31 KB) Statistics
| Branch: | Tag: | Revision:
1
<?xml version="1.0" encoding="UTF-8"?>
2
<chapter id="chapter_firmware">
3
    <title>Getting and Building the Firmware</title>
4
    <section id="building_fw_intro">
5
        <title>Introduction</title>
6
        <para>The Firmware is the Software that is running on the
7
        Microcontroller of the SIMtrace hardware. The Firmware itself
8
        consists out of a couple of components for different parts of
9
        the system. Besides the source code for the firmware you will
10
        also need to have an ARM Cross-Compile Toolchain, a copy of the
11
        SAM7 utilities to initially program the device or recover from
12
        a fatal error and dfu-util to update the main part of the firmware
13
        using the Device Firmware Update (DFU) mode.</para>
14
    </section>
15

    
16
    <section id="getting_a_toolchain">
17
        <title>Getting a Toolchain</title>
18
        <para>The toolchain needs to include a GCC newer than 3.4
19
        and it may not be an EABI toolchain. EABI toolchains fail to properly
20
        link the SIMtrace binary. You can easily build a toolchain yourself
21
        or use one of the known working pre-built ones. Please see the
22
        <ulink url="http://bb.osmocom.org/trac/wiki/toolchain">SIMtrace wiki</ulink>
23
        for more information about getting a toolchain.
24
        </para>
25
    </section>
26

    
27
    <section id="getting_the_firmware">
28
        <title>Getting and Building the Firmware</title>
29

    
30
        <para>The SIMtrace firmware is based on the OpenPCD RFID Reader Firmware and the
31
        SIMtrace firmware code is located in the OpenPCD repository. You can use the
32
        <command>git</command> to clone the repository.
33
        <screen>
34
$ git clone https://gitea.osmocom.org/sim-card/openpcd
35
        </screen>
36
        </para>
37
    
38
        <para>The firmware consists out of two separate binaries that will be concatted
39
        and flashed into the NOR flash of the microcontroller. The main part is the dfu
40
        program that will handle basic USB functionality and respond to Device Firmware
41
        Update (DFU) requests to allow to update the firmware in the NOR or execute
42
        software in RAM.
43
        <screen>
44
$ cd openpcd/firmware
45
$ make -f Makefile.dfu BOARD=SIMTRACE
46
$ make BOARD=SIMTRACE DEBUG=1 TARGET=main_simtrace
47
$ cat dfu.bin main_simtrace.bin > main_simtrace.samba
48
$ cd ../..
49
        </screen></para>
50
    </section>
51
    <section id="firmware_details">
52
        <title>Firmware Details</title>
53
        <para>
54
        The handling for the DFU part can be found in the <filename>src/dfu</filename>
55
        directory, it also provides low-level USB routines to work with USB Device
56
        Port (UDP). These functions will be called from the main payload.
57
        </para>
58
        <para>The operating system part is in <filename>src/os</filename> it provides
59
        basic hardware control and services to be used by the main application, this
60
        includes USB enumeration, Watchdog programming, running the mainloop, interrupt
61
        dispatching. The main application for SIMtrace can be found in
62
        <filename>src/simtrace</filename> and this includes programming the two USART,
63
        configuring the bus switch according to the mode.
64
        </para>
65
    </section>
66

    
67
    <section id="firmware_programming_sam_ba">
68
        <title>Initial Firmware Programming</title>
69
        <para>In case the NOR Flash of the SAM7 Microcontroller is either blank or has
70
        become corrupted the Microcontrollers support entering a mode called SAM-BA which
71
        then allows flashing the device using the <filename>sam</filename> application. The
72
        SAM-BA mode can be easily entered by following the below procedure.</para>
73

    
74
        <procedure>
75
            <title>Entering SAM-BA Mode</title>
76
            <step><para>Unplug the SIMtrace Hardware from USB.</para></step>
77
            <step><para>Short TEST to VCC (3.3V) pin by using the Jumper. Leave PA0, PA1, PA2 unconnected.</para></step>
78
            <step><para>Power up the SIMtrace Hardware from USB.</para></step>
79
            <step><para>Wait for 20 seconds.</para></step>
80
            <step><para>Unplug the SIMtrace Hardware from USB.</para></step>
81
            <step><para>Open/Remove the Jumper.</para></step>
82
        </procedure>
83

    
84
        <figure>
85
            <title>TEST Jumper</title>
86
            <mediaobject><imageobject>
87
                <imagedata fileref="images/shortTEST.jpg" width="12cm"/>
88
            </imageobject></mediaobject>
89
        </figure>
90

    
91
        <note><title>v1.0p/v1.1p Hardware Owners</title>
92
            <para>Sometimes the SAM-BA mode is not entered. This is the case when the
93
            two LEDs are on when powering up the SIMtrace Hardware with the Jumper set.
94
            The reason for this is unknown but there are several workarounds:
95
            <itemizedlist>
96
                <listitem><para>Press the RESET button while powering up.</para></listitem>
97
                <listitem><para>In addition, remove the jumper and put it back.</para></listitem>
98
            </itemizedlist>
99

    
100
            As soon as the two LEDs go off, the SAM-BA mode is properly entered.
101
            </para>
102
        </note>
103
        <para>The <command>sam</command> application can be compiled to either use libusb or
104
        normal files to program the device, depending on the drivers used you will
105
        need to configure the application one way or another. The programming can then
106
        be done using the below command.
107
        <screen>
108
$ ./sam7 --exec set_clock --exec unlock_regions --exec "flash ../openpcd/firmware/main_simtrace.samba"
109
        </screen>
110
        <note><title>Silent failures</title>
111
        <para>The <command>sam</command> can silently fail when not finding or being
112
        able to configure the device properly. It is best to enter the interactive mode
113
        by not providing any <command>--exec</command> commands.</para>
114
        </note>
115
        </para>
116
    </section>
117

    
118
    <section id="firmware_programming_dfu">
119
        <title>Device Firmware Update</title>
120
        <para>The Device Firmware Update (DFU) part of the firmware will be
121
        booted first, it is checking if a button is active or if the software
122
        reset reason was for DFU and then activates the DFU part or jumps to
123
        the main application. DFU can be activated at any time using
124
        <command>dfu-util</command> on the USB Host.</para>
125
        <para>The <command>dfu-util</command> application might be already
126
        packaged for your distribution, the source code can be found on the
127
        <ulink url="http://dfu-util.gnumonks.org/">dfu-util.gnumonks.org</ulink>
128
        website. To update the main part of the firmware simply do:
129
        <screen>
130
$ dfu-util -d 16c0:0762 -a0 -D ./main_simtrace.bin -R
131
        </screen></para>
132
    </section>
133

    
134
    <section id="firmware_programming_upgrade">
135
        <title>Upgrading to v0.4 Firmware</title>
136
        <para>Upgrading to v0.4 requires flashing both the Bootloader and the
137
        SIMtrace application. The procedure is first to flash the bootloader,
138
        then the SIMtrace application and finally reset the device.
139
        </para>
140

    
141
        <screen>
142
$ dfu-util -d 16c0:0762 -a 1  -D ./dfu.bin
143
$ dfu-util -d 16c0:0762 -a 0  -D ./main_simtrace.bin
144
... reset the device
145
        </screen>
146
    </section>
147

    
148
    <section id="firmware_serial_console">
149
	<title>Serial Console for debugging</title>
150
	<para>The serial console operates at 115200 bauds with 8n1 and no flow control.</para>
151
    </section>
152
</chapter>
(3-3/7)
Add picture from clipboard (Maximum size: 48.8 MB)