Logo
Link Labs Interface Library
External host library for using Link Lab's modules.
top
Data Structures | Typedefs | Functions
XModem File Transfer Protocol

Detailed Description

XModem File Transfer Protocol. An implementation of the XMODEM File Transfer Protocol using the Hardware Abstraction Layer.

We use XModem a lot of times to communicate with the bootloaders of our modules and other embedded devices to bootload the device with new firmware.

The entire xmodem transfer utilizes the Hardware Abstraction Layer (HAL) which means that as long as the user has properly defined the HAL, this protocol should work on any platform.

Data Structures

struct  ll_xmodem_callbacks
 

Typedefs

typedef struct ll_xmodem_callbacks ll_xmodem_callbacks_t
 
typedef int32_t(* ll_xmodem_progress_update_t) (uint32_t sent, uint32_t total)
 

Functions

int32_t ll_xmodem_prepare_module (bool is_host_ifc_active)
 
int32_t ll_xmodem_send (ll_xmodem_callbacks_t *cb, uint8_t *payload, size_t len)
 

Typedef Documentation

typedef int32_t(* ll_xmodem_progress_update_t) (uint32_t sent, uint32_t total)

Gets called every time a packet gets sent.

Parameters
[in]sentThe amount of bytes sent.
[in]totalThe amount of bytes to send.
Returns
0 - on success, negative otherwise.

Function Documentation

int32_t ll_xmodem_prepare_module ( bool  is_host_ifc_active)

Prepares the module to recieve firmware via XModem.

  • Puts the module in bootloader mode.
  • Waits 2 seconds.
  • Sends the bootloader the Upload Request.
  • Returns when the Module starts waiting for an XModem Request.
Parameters
[in]is_host_ifc_activeTrue if the host interface is active. False otherwise, indicating that the module is already running the bootloader.
Returns
0 - success, negative otherwise.
int32_t ll_xmodem_send ( ll_xmodem_callbacks_t cb,
uint8_t *  payload,
size_t  len 
)

Sends data through the Hardware Abstraction Layer (HAL) utilizing the XMODEM File Transfer Protocol.

Make sure you have already implemented the HAL functions like transport_read, transport_write, and gettime for your target platform. This function will do a complete XModem Transfer and Verification. After the firmware is verified and activated the protocol will reboot the module.

Parameters
[in]cbThe XModem callbacks (should be initialized).
[in]payloadPointer to the buffer where the bytes will be stored.
[in]lenNumber of bytes to read.
Returns
  • 0 - success, negative otherwise.
  • -2 : Timeout.
  • -3 : Canceled.
  • -4 : Maxed out Attempts.
  • -5 : Callbacks aren't initialized.
  • -6 : Firmware did not download
  • -7 : Firmware did not verify
  • -8 : Firmware did not activate Other negative values are ifc errors.