setBoot.c File Reference

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "libusb.h"
#include "commands.h"

Defines

#define OSBDM_VID   (0x15A2)
 OSBDM Vendor ID.
#define OSBDM_PID   (0x0021)
 OSBDM Product ID.
#define TBDML_VID   (0x0425)
 TBDML Vendor ID.
#define TBDML_PID   (0x1000)
 TBDML Product ID.
#define EP_OUT   (0x02)
#define EP_IN   (0x82)
#define TIMEOUT   (500)
 Timeouts for BDM communications.
#define BUF_SIZE   (5)

Typedefs

typedef unsigned char U8
typedef unsigned short U16
typedef unsigned int U32

Functions

usb_dev_handleopen_dev (void)
unsigned char bdm_usb_recv_ep0 (usb_dev_handle *usb_devh, U8 *data)
unsigned char bdm_usb_send_ep0 (usb_dev_handle *usb_devh, U8 *data)
usb_dev_handleOSBDMConnect (void)
int OSBDMReportVersion (usb_dev_handle *usb_devh)
int OSBDMSetBoot (usb_dev_handle *usb_devh)
int main (void)

Variables

usb_dev_handledev
 USB device handle.

Define Documentation

#define BUF_SIZE   (5)

#define EP_IN   (0x82)

#define EP_OUT   (0x02)

#define OSBDM_PID   (0x0021)

OSBDM Product ID.

#define OSBDM_VID   (0x15A2)

OSBDM Vendor ID.

#define TBDML_PID   (0x1000)

TBDML Product ID.

#define TBDML_VID   (0x0425)

TBDML Vendor ID.

#define TIMEOUT   (500)

Timeouts for BDM communications.


Typedef Documentation

typedef unsigned short U16

typedef unsigned int U32

typedef unsigned char U8


Function Documentation

unsigned char bdm_usb_recv_ep0 ( usb_dev_handle usb_devh,
U8 data 
)

Sends a message of up to 5 bytes to the TBDML/OSBDM device over EP0. An immediate response is expected

Parameters:
usb_devh - device handle previous obtained from open_dev()
data - in/out buffer for transfer
Entry:
  • data[0] = N, the number of bytes to receive from the device
  • data[1] = OSBDM command byte
  • data[2..5] = parameter(s) for OSBDM command

Exit:

  • data[0] = cmd response from OSBDM
  • data[1..] = data response from the device

Returns:
>0 => USB transfer OK, valid response from device
0 => USB transfer Failed, or unexpected response from device

unsigned char bdm_usb_send_ep0 ( usb_dev_handle usb_devh,
U8 data 
)

Sends a message of up to 5 bytes to the TBDML/OSBDM device over EP0. An immediate response is expected

Parameters:
usb_devh - device handle previous obtained from open_dev()
data - buffer for transfer
Entry:
  • data[0] = N, the number of bytes to send to the device
  • data[1] = OSBDM command byte
  • data[2..N-1] = parameter(s) for OSBDM command

Returns:
>0 => USB transfer OK, valid response from device
0 => USB transfer Failed, or unexpected response from device

int main ( void   ) 

usb_dev_handle* open_dev ( void   ) 

Opens a BDM device

Returns:
device handle for opened device or NULL on failure.

usb_dev_handle* OSBDMConnect ( void   ) 

Connect to the BDM device

Returns:
device handle for opened BDM device or NULL on failure.

int OSBDMReportVersion ( usb_dev_handle usb_devh  ) 

Check & Report Firmware/Hardware version numbers

Returns:

<= 0 => Error or ICP not supported
== 1 => Old version of ICP (re-program flash version)
== 2 => New version of ICP (temporary reboot to ICP)
== 3 => Newest! version of ICP (temporary reboot to ICP)
This has to handle several different version of the ICP code. These are indicated by different responses to the CMD_GET_VER command
1. Initial release (JB16 only)
Version response [8 bytes]
  • [0] status = 0C
  • [1] BDM sw version = 01 (v0.1)
  • [2] BDM hw version = 01 (v0.1)
  • [3..7] ?,?,?,?,? = garbage (due to bug in original USB code?)
    This uses a hard ICP mode where the flash is re-programmed to permanently force ICP on all further resets.
    The user is advised to update the entire Flash as the change in the ICP code is significant.

2. August 08 release (JB16 only)
Version response [6 bytes]

  • [0] status = 0C
  • [1] BDM sw version = 10 (v1.0)
  • [2] BDM hw version = 13 (v1.3)
  • [3] ICP sw version = 10 (v1.0)
  • [4] ICP hw version = 00 => JB16, 80 => JMxx
  • [5] Hardware identifier = 01 to 06 indicates hardware type
    This uses a soft ICP mode where the flash is unchanged but the BDM is immediately reset into ICP mode. This is temporary.
    The user is advised to only update the BDM flash area as the changes are not significant for the JB16 and this version doesn't exist for the JMxx.

3. September 08 release (JB16 & JMxx)
Version response [5 bytes]

  • [0] status = 0C
  • [1] BDM sw version = 10 (v1.0)
  • [2] Hardware identifier = 01 to 08 indicates hardware type (in BDM code)
    +80 for JMxx versions
  • [3] ICP sw version = 11 (v1.1)
  • [4] Hardware identifier = 01 to 08 indicates hardware type (in ICP code)
    +80 for JMxx versions
    As for version 3 but the hardware identification is kept in the ICP code and the BDM code. These should always match! This allows the JMxx driver to automatically update the BDM flash with the correct version of the Firmware even if the BDM flash area is corrupted.
    The user is advised to only update the BDM flash area as the ICP is current.

int OSBDMSetBoot ( usb_dev_handle usb_devh  ) 

Set for flash load on next reboot


Variable Documentation

USB device handle.


Generated on Wed Aug 13 18:26:55 2008 for SetBoot by  doxygen 1.5.6