Synopsis

struct              NtdIsp;
struct              NtdIspClass;
void                ntd_isp_clear_status                (NtdIsp *isp);
void                ntd_isp_connect                     (NtdIsp *isp);
void                ntd_isp_disconnect                  (NtdIsp *isp);
gboolean            ntd_isp_download                    (NtdIsp *isp,
                                                         const gchar *address,
                                                         gconstpointer buffer,
                                                         gsize nbytes);
gboolean            ntd_isp_download_file               (NtdIsp *isp,
                                                         const gchar *address,
                                                         const gchar *file,
                                                         GError **error);
gboolean            ntd_isp_dump                        (NtdIsp *isp,
                                                         const gchar *address,
                                                         gpointer *buffer,
                                                         gsize *nbytes);
gboolean            ntd_isp_dump_file                   (NtdIsp *isp,
                                                         const gchar *address,
                                                         gsize nbytes,
                                                         const gchar *file,
                                                         GError **error);
const gchar *       ntd_isp_get_message                 (NtdIsp *isp);
NtdSerial *         ntd_isp_get_serial                  (NtdIsp *isp);
gint                ntd_isp_get_status                  (NtdIsp *isp);
gboolean            ntd_isp_is_connected                (NtdIsp *isp);
gboolean            ntd_isp_probe                       (NtdIsp *isp);
void                ntd_isp_progress_notify             (NtdIsp *isp,
                                                         gdouble fraction);
gboolean            ntd_isp_run                         (NtdIsp *isp,
                                                         const gchar *address);
void                ntd_isp_set_connected               (NtdIsp *isp,
                                                         gboolean connected);
void                ntd_isp_set_device                  (NtdIsp *isp,
                                                         const gchar *file);
void                ntd_isp_set_serial                  (NtdIsp *isp,
                                                         NtdSerial *serial);
void                ntd_isp_set_status                  (NtdIsp *isp,
                                                         gint status);
void                ntd_isp_status_changed              (NtdIsp *isp);
gboolean            ntd_isp_verify                      (NtdIsp *isp,
                                                         const gchar *address,
                                                         gconstpointer buffer,
                                                         gsize nbytes);
gboolean            ntd_isp_verify_file                 (NtdIsp *isp,
                                                         const gchar *address,
                                                         const gchar *file,
                                                         GError **error);
gboolean            ntd_isp_wipe                        (NtdIsp *isp,
                                                         const gchar *address,
                                                         gsize nbytes);

Object Hierarchy

  GObject
   +----NtdIsp
         +----NtdLpc
         +----NtdStm

Properties

  "serial"                   NtdSerial*            : Read / Write
  "status"                   gint                  : Read / Write

Signals

  "progress-notify"                                : Run First
  "status-changed"                                 : Run First

Description

Details

struct NtdIsp

struct NtdIsp;

All fields are private and should not be used directly. Use its public methods instead.


struct NtdIspClass

struct NtdIspClass {
};

ntd_isp_clear_status ()

void                ntd_isp_clear_status                (NtdIsp *isp);

Clears the internal status of isp, that is set the "status" property to 0.

isp :

a NtdIsp instance

ntd_isp_connect ()

void                ntd_isp_connect                     (NtdIsp *isp);

Connects the host to isp, performing any initialization procedure requested by the underline protocol.

On success, the NtdIsp:status property must be set to 0.

isp :

a NtdIsp instance

ntd_isp_disconnect ()

void                ntd_isp_disconnect                  (NtdIsp *isp);

Disconnects the host from isp, performing any finalization procedures requested by the protocol.

isp :

a NtdIsp instance

ntd_isp_download ()

gboolean            ntd_isp_download                    (NtdIsp *isp,
                                                         const gchar *address,
                                                         gconstpointer buffer,
                                                         gsize nbytes);

Downloads, that is move from the host (PC) to the target isp (the embedded device), the provided binary data, starting from address (an ISP dependent value). When address is NULL, this will be the start of the flash memory.

isp :

a NtdIsp instance

address :

the address where starting the download

buffer :

the binary data to download

nbytes :

how many bytes to download

Returns :

TRUE on success, FALSE on error

ntd_isp_download_file ()

gboolean            ntd_isp_download_file               (NtdIsp *isp,
                                                         const gchar *address,
                                                         const gchar *file,
                                                         GError **error);

A convenient wrapper around ntd_isp_download() that downloads the content of file into the isp chip, starting from address. The eventual I/O error will be reported in error.

address can be NULL, in which case the starting address of the flash memory will be used.

file can be NULL, in which case the standard input will be used.

isp :

a NtdIsp instance

address :

the address where starting the download

file :

the binary file to download

error :

return location for a GError, or NULL

Returns :

TRUE on success, FALSE on error

ntd_isp_dump ()

gboolean            ntd_isp_dump                        (NtdIsp *isp,
                                                         const gchar *address,
                                                         gpointer *buffer,
                                                         gsize *nbytes);

Dumps, that is move from the target isp (the embedded device) to the host (PC), the specified portion of memory.

address can be NULL, in which case the starting address of the flash memory will be used.

nbytes specifies the size of the memory to dump. If initialized to 0 or if nbytes is NULL the flash memory size will be used.

The effective size of the memory dumped will be stored in nbytes, if not NULL.

isp :

a NtdIsp instance

address :

the address where starting to get

buffer :

location to store the data got, use g_free() to free the returned buffer

nbytes :

either specify how many bytes to get and the location to store the returned buffer size

Returns :

TRUE on success, FALSE on error

ntd_isp_dump_file ()

gboolean            ntd_isp_dump_file                   (NtdIsp *isp,
                                                         const gchar *address,
                                                         gsize nbytes,
                                                         const gchar *file,
                                                         GError **error);

A convenient wrapper around ntd_isp_dump() that dumps nbytes bytes of memory starting at address on the target isp directly to file, providing optional error checking through error.

address can be NULL, in which case the starting address of the flash memory will be used.

If nbytes is 0, the portion of memory starting at address up to the end of the flash will be dumped.

file can be NULL, in which case the standard output will be used.

isp :

a NtdIsp instance

address :

the address where starting the dump

nbytes :

size of the portion to dump, in bytes

file :

where to store the binary data

error :

return location for a GError, or NULL

Returns :

TRUE on success, FALSE on error

ntd_isp_get_message ()

const gchar *       ntd_isp_get_message                 (NtdIsp *isp);

Gets a descriptive string of the current status of isp. The returned value is owned by isp and should not be changed or freed.

isp :

a NtdIsp instance

Returns :

the status message or NULL on errors

ntd_isp_get_serial ()

NtdSerial *         ntd_isp_get_serial                  (NtdIsp *isp);

ntd_isp_get_status ()

gint                ntd_isp_get_status                  (NtdIsp *isp);

Gets the internal status of isp. The internal status is used to hold the result of the last operation executed on isp.

isp :

a NtdIsp instance

Returns :

the current status of isp

ntd_isp_is_connected ()

gboolean            ntd_isp_is_connected                (NtdIsp *isp);

Checks for the connection status of isp.

isp :

a NtdIsp instance

Returns :

TRUE if isp is connected, FALSE otherwise

ntd_isp_probe ()

gboolean            ntd_isp_probe                       (NtdIsp *isp);

Probes isp trying to guess the optimal values directly from the target.

isp :

a NtdIsp instance

Returns :

TRUE on success, FALSE on error

ntd_isp_progress_notify ()

void                ntd_isp_progress_notify             (NtdIsp *isp,
                                                         gdouble fraction);

Emits the "progress-notify" signal on isp.

isp :

a NtdIsp

fraction :

the new fraction value

ntd_isp_run ()

gboolean            ntd_isp_run                         (NtdIsp *isp,
                                                         const gchar *address);

Puts the isp in run mode, if possible, running the code at a specific address. address can be NULL, in which case the starting address of the flash memory will be used.

isp :

a NtdIsp instance

address :

from where the program must be run

Returns :

TRUE on success, FALSE on error

ntd_isp_set_connected ()

void                ntd_isp_set_connected               (NtdIsp *isp,
                                                         gboolean connected);

Forcibly sets the connection flag of isp to connected. This function is reserved for guru use because of its dangerouseness. It is used to skip some initialization steps performed during the connection phase.

isp :

a NtdIsp instance

connected :

the new flag value

ntd_isp_set_device ()

void                ntd_isp_set_device                  (NtdIsp *isp,
                                                         const gchar *file);

Convenient function to create a new NtdSerial instance and bind it to isp (if not yet present) and to initialize it to the default serial values tipically used by this kind of protocol.

isp :

a NtdIsp instance

file :

path to the device file

ntd_isp_set_serial ()

void                ntd_isp_set_serial                  (NtdIsp *isp,
                                                         NtdSerial *serial);

Sets the "serial" property of isp to serial.

isp :

a NtdIsp instance

serial :

a valid NtdSerial instance

ntd_isp_set_status ()

void                ntd_isp_set_status                  (NtdIsp *isp,
                                                         gint status);

Sets the internal status of isp to status.

isp :

a NtdIsp instance

status :

the new status

ntd_isp_status_changed ()

void                ntd_isp_status_changed              (NtdIsp *isp);

Emits the "status-changed" signal on isp. This function is only useful in NtdIsp implementation.

isp :

a NtdIsp

ntd_isp_verify ()

gboolean            ntd_isp_verify                      (NtdIsp *isp,
                                                         const gchar *address,
                                                         gconstpointer buffer,
                                                         gsize nbytes);

Verifies that nbytes bytes at address address of the device bound to isp are the same as nbytes bytes at buffer.

This is conceptually equivalent to the following code:

ntd_isp_dump(isp, address, &real_buffer, &nbytes);
return memcmp(real_buffer, buffer, nbytes) == 0;

isp :

an NtdIsp instance

address :

the address where starting to verify

buffer :

location containing the original data

nbytes :

size of buffer

Returns :

TRUE on success, FALSE on error

ntd_isp_verify_file ()

gboolean            ntd_isp_verify_file                 (NtdIsp *isp,
                                                         const gchar *address,
                                                         const gchar *file,
                                                         GError **error);

A convenient wrapper around ntd_isp_verify() that verifies that the content of file will match the bytes starting at address on the target isp, providing optional error checking.

address can be NULL, in which case the starting address of the flash memory will be used.

isp :

an NtdIsp instance

address :

the address where starting the dump

file :

where to store the binary data

error :

return location for a GError, or NULL

Returns :

TRUE on success, FALSE on error

ntd_isp_wipe ()

gboolean            ntd_isp_wipe                        (NtdIsp *isp,
                                                         const gchar *address,
                                                         gsize nbytes);

Wipes isp, that is clear the flash on target starting from address for nbytes bytes.

address can be NULL, in which case the starting address of the flash memory will be used.

If nbytes is set to 0, all the flash memory starting from address will be cleared.

isp :

a NtdIsp instance

address :

the address where starting to wipe

nbytes :

how many bytes must be cleared

Returns :

TRUE on success, FALSE on error

Property Details

The "serial" property

  "serial"                   NtdSerial*            : Read / Write

The serial device used by this ISP instance.


The "status" property

  "status"                   gint                  : Read / Write

Status of the last operation.

Allowed values: >= -2147483647

Default value: 0

Signal Details

The "progress-notify" signal

void                user_function                      (NtdIsp  *isp,
                                                        gdouble  fraction,
                                                        gpointer user_data)      : Run First

Emitted during the download to notify current progress state.

isp :

a NtdIsp

fraction :

the new fraction value

user_data :

user data set when the signal handler was connected.

The "status-changed" signal

void                user_function                      (NtdIsp  *isp,
                                                        gpointer user_data)      : Run First

Emitted when "status" property has changed.

isp :

a NtdIsp

user_data :

user data set when the signal handler was connected.