Data Block (D) command


(see command description format info here)

Function:Supplies one 128-byte block of firmware file to the NetLoader
Command format:Dnndd...d, where

        nn - block number (binary format, two bytes, high byte first);

        dd...d - 128 bytes of file data.

Possible replies:Ann, Cnn, Snn, Onn, Inn, Fnn, where nn is the number of the next expected data block (binary format, two bytes, high byte first)
See also:Firmware upload procedure


Data Block command carries a 128-byte block of application firmware file. Entire application firmware file is to be uploaded using multiple Data Block commands and the NetLoader expects that the firmware file size will consist of an integer number of 128-byte blocks.

The data blocks must be sent in consecutive order i.e. the first block (block 0) must carry first 128 bytes of the firmware file, block 1 should supply next 128 bytes, etc. Because NetLoader communications is based on UDP commands and UDP packets can get lost each data block is sent with its own block number. This way the NetLoader can make sure that all data blocks received are in sequence.

The nn field in the command body carries the block number. The block number is supplied in a binary form. Since block numbers can exceed 255 two bytes are needed for the block number. High byte goes first so, for example, to denote block #300 the first two bytes should be 01H 2CH. Block numbers start from 0.

Following two block number bytes are 128 bytes of firmware file data. Again, the data is supplied in a binary form, that is, a part of the firmware file is "cut out" and attached to the command.

Like all other commands, the Data Block command returns an appropriate reply status code. The difference is that all reply status codes are followed by the number of the next expected data block. Next data block is present even in replies indicating that the command was not processed successfully. In this case the next expected data block simply remains the same (is not incremented). If the command was completed successfully the nn field in the reply will "point at" the next data block to be sent. For example, if the nn field in the command was 300 (01H 2CH) and the command was completed successfully the reply will have the nn field of 301 (01H 2DH). If command failed the nn field in the reply will still be at 300 (01H 2DH).

OK (A) reply status code is returned if the data block was programmed successfully or if the Data Block command has carried a data block that has already been programmed. That is, if the NetLoader expects the block number to be 10 and the network host supplies block 5 the NetLoader will reply with A code and discard this data block.

Error (C) reply status code is returned if the total length of nn and dd...d fields in the command is not 130 bytes.

Sequence Error (S) reply code is returned if the NetLoader receives the data block with nn field greater than the one expected (for example, block 7 when block 6 was expected).

Out-of-range (O) reply code is returned if the total size of the firmware file received by the NetLoader exceeds the size detected in the beginning of the file upload. Total file size information is contained in the firmware file itself (in block 1). For example, if the file size was expected to be 40064 bytes then the total number of data blocks had to be 40064/128=313. Therefore, the range of expected data block numbers is 0...312. The NetLoader will return the O code if any data block with the number greater than 312 is received.

Invalid Data (I) reply code is retuned if the NetLoader detects that the file data sent by the network host is invalid. This can only be generated for data blocks 0 and 1. These blocks contain certain "service" information (such as the total file size- see above) that the NetLoader checks to make sure that the firmware file being uploaded is acceptable.

Failed (F) reply code is returned if the NetLoader fails to program the data block into the FLASH memory of the DS.

We recommend that the network host sends the Start Over (Q) command before beginning file upload with the Data Block commands