10. FUNCTION $34: FLASH MEMORY MANAGEMENT
10.4. Flash programming procedures
These are the suggested procedures for common flash functions. To fully reflash the UI image and configuration, the operations in sections 10.4.2 through 10.4.5 must complete successfully.
10.4.1. Bootloader mode and ATTN
An RMI device may be unable to respond to physical layer communication while executing bootloader commands. Because of this, an RMI device will assert the ATTN signal to indicate that a command has completed, and that the physical layer interface is active again.
Once the host observes ATTN after a command completes, the interrupt should be cleared in the normal fashion by reading the Interrupt Status register before proceeding with the next bootloader operation.
Some RMI devices may not implement an ATTN signal. In addition, there may be hosts that do not have the ability to read the state of ATTN, even if the RMI device supports it. In those cases, there are two options to determine when the command has completed.
The first option is to poll the device, knowing that the physical layer may be inactive while the device is busy. In the case of devices that implement an I2C or SMBus physical layer, the device will NAK any transfers sent to it during the period where the command is being executed. As soon as the command completes, the device will respond normally. In the case of devices implementing an SPI interface, the device will respond with the default state of the data bus until such time as the command completes. In either case, the host driver needs to recognize those situations as representing a ‘command in progress’, as opposed to being a physical layer error.
The second option is to insert host-generated time delays after issuing a bootloader command. While simple, this approach is not time efficient, so the reflashing operation takes much longer than it would if the ATTN handshake was used. The time delay after issuing a flash command is module-specific.
10.4.2. Enable flash programming
Before any actual erase or program operations can be performed, the Flash Programming mode must be enabled. Follow this procedure to enable flash programming:
1. Read the Bootloader ID registers (F34_Flash_Query0 and 1) to obtain the key.
2. Write the Bootloader ID key data back to the first two Block Data registers (F34_Flash_Data2.0 and F34_Flash_Data2.1).
3. Issue a Flash Program Enable ($0F) command to the Flash Command (F34_Flash_Data3, bits 3:0) field.
Copyright © 2007–2011 Synaptics Incorporated. All Rights Reserved. 109
4. Wait for ATTN. The Flash interrupt request bit will be ‘1’.
5. Read the Flash Command field in the F34_Flash_Data3 register. The result should be
$80: Flash Command = Idle ($0), Flash Status = Success ($0), Program Enabled = Enabled (1).
Any other value indicates an error.
6. Rescan the Page Description table.
Important: The nature of the changes in the new image may result in the device registers
“moving around” in the RMI register map. Rescanning the Page Description table ensures that it reflects any relocations that have occurred due to the change from Bootloader mode to Flash Programming mode.
10.4.3. Program the firmware image
After the device is in Flash Programming mode, program the firmware image by following this procedure:
1. Read the Bootloader ID registers (F34_Flash_Query0 and F34_Flash_Query1) to obtain the key.
2. Write the Bootloader ID key data back to the first two Block Data registers (F34_Flash_Data2.0 and F34_Flash_Data2.1).
3. Issue the Firmware and Configuration Erase ($03) command to the Flash Command (F34_Flash_Data3, bits 3:0) field.
4. Wait for ATTN. The Flash interrupt request bit will be ‘1’.
5. Read the Flash Command field in the F34_Flash_Data3 register. The result should be $80: Flash Command = Idle ($0), Flash Status = Success ($0), Program Enabled = Enabled (1). Any other value indicates an error.
6. For each block in the firmware image, starting at Block 0 and proceeding consecutively:
a) Write the Block Number (F34_Flash_Data0 and 1) register.
Note: Because the Block Number register auto-increments after each Write Firmware Block operation, this step is only required before writing Firmware Block 0.
b) Write the Block Data starting at F34_Flash_Data2. Fill the next n registers with the data to be programmed.
c) Issue the Write Firmware Block ($02) command to the Flash Command (F34_Flash_Data3, bits 3:0) field.
Note: Steps a, b, and c can be performed in a single write transaction because of the way registers in an RMI register map are organized.
d) Wait for ATTN. The Flash interrupt request bit will be ‘1’.
7. Program the configuration image.
110 Copyright © 2007–2011 Synaptics Incorporated. All Rights Reserved.
10.4.4. Program the configuration image
After the device is in Flash Programming mode and the configuration area has been erased by either an Erase Firmware and Configuration Areas command or an Erase Configuration Area command, program the configuration image by following this procedure:
1. For each block in the configuration image, starting at Block 0 and proceeding consecutively:
a) Write the Block Number (F34_Flash_Data0 and 1) register.
Note: Because the Block Number register auto-increments after each Write Configuration Block operation, this step is only required before writing Configuration Block 0.
b) Write the Block Data starting at F34_Flash_Data2. Fill the next n registers with the data to be programmed.
c) Issue a Write Configuration Block ($06) command to the Flash Command (F34_Flash_Data3, bits 3:0) field.
Note: Steps a, b, and c can be performed in a single write transaction because of the way registers in an RMI register map are organized.
d) Wait for ATTN. The Flash interrupt request bit will be ‘1’.
e) Read the Flash Command field in the F34_Flash_Data3 register. The result should be $80:
Flash Command = Idle ($0), Flash Status = Success ($0), Program Enabled = Enabled (1).
Any other value indicates an error.
2. Disable Flash Programming mode to put the new configuration into effect.
10.4.5. Disable Flash Programming mode
After all flash programming operations are complete, resume normal operation by resetting the device:
1. Issue a Reset ($01) command to the RMI Command (F01_RMI_Cmd0, bit 0) field. This tests the firmware image and executes it if it is valid.
2. Wait for ATTN to assert.
3. At this point, the Bootloader will perform a CRC on the UI Firmware and the Configuration space, and the Program Enabled bit (bit 6 of F01_RMI_Data0) will be set to ‘1’ to reflect this.
4. Eventually, if there is no CRC failure, ATTN is de-asserted and then asserted again as the firmware enters UI mode.
5. The Program Enabled bit is cleared to ‘0’ to indicate that the new firmware is valid and is executing in UI mode.
6. A host driver should re-scan the Product Description table after restarting the new UI image.
Important: Changes in the new image may cause the device registers to move to new locations in the RMI register map. Rescanning the Product Description table ensures that the host driver properly tracks any relocations.
Important: The device has not been successfully reprogrammed until step 6 is reached. A CRC failure in the UI Firmware or Configuration space will cause the device to remain in Bootloader mode with the Program Enabled bit set to ‘1’ and an error code in the Status Code field (bits 3:0 of F01_RMI_Data0).
Copyright © 2007–2011 Synaptics Incorporated. All Rights Reserved. 111
For more information about the suggested rules and procedures for bootloader use, see the RMI4 Bootloader Procedures (PN: 506-000221-01) application note.