GainSpan Programming Module Using UART or SPI Protocol Rev 1.3
GainSpan Programming Module Using UART or SPI Protocol Rev 1.3
1
CONFIDENTIAL PAGE 2 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Table of Contents
1 INTRODUCTION ............................................................................................................................... 6
1.1 POWER ON ...................................................................................................................................... 6
2 HOST INTERFACE............................................................................................................................ 8
2.1 HI OVERVIEW ................................................................................................................................. 9
2.2 HI FRAME FORMAT ...................................................................................................................... 10
2.2.1 Transmission and reception .................................................................................................. 11
2.3 HI FRAME MAPPING OVER PHYSICAL INTERFACES ...................................................................... 12
2.3.1 HI Frame over UART ............................................................................................................ 12
2.3.2 HI Frame over Slave SPI ...................................................................................................... 13
2.4 DOWNLOAD PROTOCOL ................................................................................................................ 13
2.4.1 Message Flow........................................................................................................................ 13
2.4.2 Message Format .................................................................................................................... 15
2.4.3 Checksum Verification .......................................................................................................... 18
2.4.4 Download Error Management .............................................................................................. 18
2.4.5 Firmware Signature .............................................................................................................. 18
2.4.6 WLAN Software operation .................................................................................................... 18
2.5 MEMORY MAP : FLASH MEMORY AND CONTROL REGISTER ....................................................... 20
2.6 MAC ADDRESS OVERVIEW (IN FACTORY DEFAULT AREA) ........................................................ 21
3 GAINSPAN PROGRAMMING UTILITIES: ................................................................................ 22
3.1 PRE-REQUISITE FOR SPI BASED PROGRAMMING WITH GS_FLASHPROGRAM. ............................. 22
1
CONFIDENTIAL PAGE 3 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Figures
1
CONFIDENTIAL PAGE 4 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Tables
Table 1: Supported Service Classes for UART and Slave SPI Interfaces ...................................... 11
Table 2: GS1011M Flash Memory Map ................................................................................................ 20
1
CONFIDENTIAL PAGE 5 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
1 Introduction
The GS1011M module uses the GainSpan GS1011 system-on-chip device. On the GS1011, there are two
CPU: WLAN CPU and APP CPU. The WLAN is the main CPU that first runs after power up and boots
from its internal boot ROM. The code in the boot ROM first checks if a firmware download is requested.
This is achieved by reading the state of GPIO27 (pin 36 of the GS1011M). At power-on or reset, if the
GPIO27 is high, then the module is in program mode. Once in program mode, either UART0 or Slave SPI
(SSPI) interface can be used to program the module flash.
The UART0 interface would run with the following setting:
Baud rate: 115200 kbps
Data: 8 bits
Parity: None
Stop: 1 bit
Flow control: None
1.1 Power On
The WLAN CPU always boots from its internal boot ROM. The code in boot ROM performs the
following operations:
1. After reset or power-on, the boot code first checks if a firmware download is requested. This is
achieved by reading the state of GPIO27. If GPIO27 is high, the boot code proceeds to step 3.
Otherwise, it goes to step 2.
2. If GPIO27 is low, the boot code checks the validity of the firmware present in flash memory, by
reading the firmware signature in the information section of the memory bank. If a valid signature is
detected, then the program proceeds to step 4. Otherwise it goes to step 3.
3. If GPIO27 is high, or no valid signature is found, the boot code waits for code to be received on the
UART or SSPI interfaces, according to the Firmware Update procedure. When the firmware update
procedure is complete, the boot code proceeds to step 4.
4. Boot code jumps to the start of WLAN Firmware (WFW) in WLAN flash memory.
1
CONFIDENTIAL PAGE 6 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Programing the device over the host interface (UART0 or SSPI) uses the following protocol format for
transferring data.
1
CONFIDENTIAL PAGE 7 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
2 Host Interface
WFW provides the Host Interface, which allows the on-chip APP CPU or an external CPU to
control WLAN operation through a message-based protocol.
The GS1011M SoC provides a Host Interface, which allows the on-Chip APP CPU or an external CPU to
do programming operations through a message based protocol on either the Slave SPI or UART0 physical
interface..
Messages are organized into service classes, according to the general function they support. Each class
has a slightly different message format and a different usage model. The classes are:
► Kernel message service: messages controlling WFW operation and configuration
► Data service (and Data Confirmation service): messages whose contents are intended to be
sent or received over the wireless link (not described here)
► Download service: messages used to write new firmware (or other data) to the WLAN and APP
Flash memory banks
► Debug service, Trace service: (not described here)
► ROM Debug service: messages that allow direct read and write to/from memory locations and
memory-mapped registers (not described here).
Messages can be sent and received over differing physical-layer transport mechanisms – Mailbox,
UART0, Slave SPI, and WLAN – although not all service classes can be used with all PHY layers (see
Table 1). Messages consist of a PHY-independent Host Interface header and data section, with additional
data specialized for the relevant PHY layer. The focus here is going to be the UART and Slave SPI
interface for programming of the GS1011 SoC flash.
An example of how an abstract message is reduced by the protocol stack to a byte sequence is depicted in
Figure 2. An internal module (the Scan module) needs to tell the host processor that it has found four
stations in response to a request to scan for WLAN access points. This message is of the service class
kernel messages. The sending module, the Scan module, is the source of the information. Since the
message is destined for an external processor, its formal destination is the WFW Host Interface module
(which is responsible for forwarding the message over the appropriate physical layer). The kernel
message, consisting of a message identifier, destination and source modules, a length field, and parameter
values appropriate to the particular type of message, is formed according a class-specific format to create
an HI Parameters field. This parameter field is passed to the Host Interface, which adds a physical-layer-
independent header describing the class and length of the HI Parameters field. (Some classes also make
use of the Additional Info field of the header.) The resulting HI frame then receives any necessary
additions specific to a given physical layer; for the UART PHY, a start-of-frame (SOF) delimiter and
header checksum packet are used.
1
CONFIDENTIAL PAGE 8 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
The HI interface and specializations to various PHY layers are described in detail in the remainder of this
chapter.
2.1 HI Overview
The Host Interface (HI) is the software layer that enables access to the WLAN services that are provided
to an external CPU by the WLAN CPU.
These services are offered over the various external interfaces of the WLAN CPU: the Mailbox interface
(or more specifically the Mailbox Frame Exchange mechanism), the SPI slave interface, the UART
interfaces and the WLAN interface (for the firmware update procedure).
The Mailbox Frame Exchange was specifically designed to carry HI frames unmodified; messages must
be encapsulated in larger frames to be sent over the other interfaces. The required encapsulation will be
defined in this chapter.
The Mailbox Frame Exchange is the default interface for the HI frames. The use of other PHY layers is
approached differently depending on whether the frames in question are sent by the Host, or sent by the
WLAN CPU to the Host.
The WLAN CPU is always waiting for incoming frames on all the interfaces that it has control of, so an
incoming HI frame will always be handled, regardless of the interface used.
1
CONFIDENTIAL PAGE 9 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
The format of the HI Parameters field is determined by the service class. The service class of each frame
is signaled by the value of the first field; available service class identifiers are:
► 0x00 : Data (and Data Confirmation) service.
► 0x01 : Kernel message service.
► 0x02 : Download service.
► 0x03 : Debug service.
► 0x04 : reserved
► 0x05 : reserved
► 0x06 : Trace service.
► 0x07 : ROM Debug service.
The Additional Info field is a general-purpose field whose contents depend on the service class of the
message.
The length field is 2 bytes long even though only 11 bits will be used, since the length cannot exceed
1514. The length value does not include the 6 bytes of the HI header. Depending on the PHY used to
carry the HI frame, it is possible that only the 11 significant bits will be transmitted.
1
CONFIDENTIAL PAGE 10 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
All the service classes are not intended to be carried over all the interfaces. The service classes supported
by each interface are listed in Table 1.
Table 1: Supported Service Classes for UART and Slave SPI Interfaces
Figure 5: HI FIFOs
1
CONFIDENTIAL PAGE 11 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
The Start-of-frame delimiter is the single-byte value 0xA5 (Error! Reference source not found.), used
to ensure synchronization at the frame level. The driver starts the reception process when it recognizes the
delimiter.
The length of the delimiter has been reduced to 1 byte to avoid alignment problems when waiting for the
start element. However, no provisions are made to ensure that the subsequent data stream does not
contain a byte with value 0xA5, so it is possible for the driver to mistake a data byte for a delimiter.
Therefore, a header checksum has been added to ensure correct synchronization. The checksum definition
is shown in Error! Reference source not found.. A single checksum byte is used, computed as the 1’s
complement of the 8-bit long (modulo-256) sum of all the bytes of the HI HEADER (not including the
Start delimiter). Note that each byte is independently added to the sum, as an integer between 0 and 255,
without regard for its significance within its own data field.
1
CONFIDENTIAL PAGE 12 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
The Start-of-frame delimiter is the single-byte value 0xA5 (Error! Reference source not found.), used
to ensure synchronization at the frame level. The driver starts the reception process when it recognizes the
delimiter.
The length of the delimiter has been reduced to 1 byte to avoid alignment problems when waiting for the
start element. However, no provisions are made to ensure that the subsequent data stream does not
contain a byte with value 0xA5, so it is possible for the driver to mistake a data byte for a delimiter.
Therefore, a header checksum has been added to ensure correct synchronization. The checksum definition
is shown in Error! Reference source not found.. A single checksum byte is used, computed as the 1’s
complement of the 8-bit long (modulo-256) sum of all the bytes of the HI HEADER (not including the
Start delimiter). Note that each byte is independently added to the sum, as an integer between 0 and 255,
without regard for its significance within its own data field.
1
CONFIDENTIAL PAGE 13 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Figure 12 depicts the sequence of messages exchanged between the host and the WLAN CPU (the
Download/Copy sequence). If both the WLAN and APP CPU firmware are to be updated, or if the RAM
size is not sufficient to perform the update in one sequence, the sequence below is repeated for the
required number of times, as described below. The on-chip flash memory is organized in 2kB sectors, so
the firmware fragment downloaded in one Download/Copy sequence must be aligned on a 2kB boundary,
and has a length that is a multiple of 2kB, except for the last fragment.
Note: The DownloadAck frame indicates the proper reception of the Download frame, not the proper
execution of the associated command. This mechanism is used for both flow control and reliability
purposes.
1
CONFIDENTIAL PAGE 14 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Note: For Download class, Additional Info field is not used and can be 0000
2.4.2.1 DownloadReq
The Download request is composed of six fields (Figure 14):
► Opcode, 7 bits: 0x01. The least-significant bit is bit 0 in the diagram. Bit 7 is reserved.
► SeqNbr, 1 byte: Sequence number of the current request
► FileLength, 4 bytes: Total length of the downloaded firmware.
► BundleLength, 2 bytes: Length (in bytes) of the Data field
► RamAddr, 4 bytes: Address where the current code bundle must be stored in shared SRAM
► Data, <BundleLength> bytes: Data to be written to SRAM
1
CONFIDENTIAL PAGE 15 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
2.4.2.3 ErrorInd
The Error indication is composed of three fields (Figure 16):
► Opcode, 7 bits: 0x04
► SeqNbr, 1 byte: Sequence number of the current indication
► ErrorCode, 2 bytes: Failure code:
o 0x01: ModuleBusy. The Firmware Update module was not ready to receive a command.
The Host can retry the command.
o 0x02: ParamError. The CopyReq contains inconsistent parameters.
1
CONFIDENTIAL PAGE 16 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
2.4.2.4 Ack
The Ack message is composed of two fields (Figure 17):
► Opcode, 7 bits: 0x05
► SeqNbr, 1 byte: Sequence number of the request being acknowledged.
1
CONFIDENTIAL PAGE 17 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
1
CONFIDENTIAL PAGE 18 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
1
CONFIDENTIAL PAGE 19 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
1
CONFIDENTIAL PAGE 20 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
Checksum : Simple byte wise xor of both length and MAC address
Length: The length in bytes of MAC address and length (here it is 7)
MAC Address: MAC ID (6 byte hex value) that is on the module label
For details see the Serial-to-Wi-Fi Adapter Guide Document.
When using firmware version 2.3.x or 3.3.x the firmware uses the MAC ID from location
0x0801E800 only.
When using firmware version 2.4.x or 3.4.x the firmware uses the MAC ID from location
0x0801F800 only.
Follow the process or steps are described by the GainSpan module programming guidelines to
ensure MAC ID is written or preserved at the correct location as per the firmware version being
programmed/used.
1
CONFIDENTIAL PAGE 21 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
GainSpan has developed a programming utility, called gs_flashprogram, that provides both a GUI
interface and a DOS command line interface for programming the module. The DOS utility is
configurable to use either UART or SPI to program the module and the GUI uses the UART interface. If
using SPI mode, then see section below for additional HW, drivers and software items needed.
Install the latest gs_flashprogram provided by GainSpan and follow the GainSpan module programming
guidelines.
The following steps need to be followed to copy the necessary SW to enable SPI based
programming of the module. This is assuming that the customer has already installed the
gs_flashprogram installation package. The installation package includes some additional pieces
of software such as the WildServer that provides an abstraction layer for SPI and converts the
data to the SPI HI format.
1. Please install Total Phase Aardvark driver. You may download the latest software
release from Total Phase at: http://www.totalphase.com/products/aardvark_i2cspi/
2. To install the Aardvark driver, first plug in the Aardvark then point the installer to the
.\GSFLASHPROGRAM\Total Phase_2008 location. Click “Continue Anyway” if you
see Figure 1 while installing Aardvark driver. For details see the “Detailed Aardvark
Installation” doc.
1
CONFIDENTIAL PAGE 22 OF 23 PRELIMINARY
PROGRAMMING MODULE PROTOCOL
1
CONFIDENTIAL PAGE 23 OF 23 PRELIMINARY