SOMANET Flash Service

The SOMANET Flash Service offers an abstraction layer to access internal flash of SOMANET devices. The usage of this module is currently not recommended for end-users.

Warning

The usage of this module can erase all contents from flash and render your SoC unusable.

API

Service

void flash_service(fl_SPIPorts &SPI, interface FlashBootInterface server ?i_boot, interface FlashDataInterface server(& ?i_data)[n_data], unsigned n_data)

Service to access the data partition of the internal flash of Synapticon SoCs.

Parameters:
  • SPI – SPI port definition struct
  • i_boot – Interface for boot partition manipulation
  • i_data – Interface for data partition manipulation
  • n_data – Number of end-points in i_data array Module Flash Service provides a server, which managed the flash content and is responsible for the flash access (writing/reading).
  • SPI – SPI ports and clock blocks
  • i_boot – Server class for boot service
  • i_data – Server interfaces for data service
  • n_data – Pattern variable for data services

Interface

interface FlashBootInterface

Interface to access boot partition of SOMANET SoCs.

[[guarded]] int read(char data[], unsigned nbytes, unsigned char image_num)

NOT YET IMPLEMENTED.

[[guarded]] int write(char data[], unsigned nbytes)

Writes chunk of data to boot partition of flash.

Parameters:
  • data[] – Char array holding data to be written to flash
  • nbytes – Number of bytes to be written (max 1024)
Returns:

0 - success

[[guarded]] int prepare_boot_partition()

Prepares the boot partition for a new boot image to be written.

Returns:0 - success
[[guarded]] void erase_boot_partition(void)

Deletes the boot partition of the SoC.

Note: This will remove the running program from flash, after this function is called, the device will not boot after a power cycle.

Returns:0 - success
[[guarded]] int validate_flashing(void)

Checks if the boot partition of flash contains a valid factory and upgrade image.

Returns:0 - if valid images exist
[[guarded]] int upgrade_image_installed(void)

Checks if the boot partition of flash contains a valid upgrade image.

Returns:0 - if valid image exists
[[notification]] slave void notification()
[[clears_notification]] int get_notification()
interface FlashDataInterface

Interface to communicate with the Position Feedback Service.

[[guarded]] int getDataPartitionSize()

Returns the data partition size of the flash memory.

Returns:Data partition size
[[guarded]] int read(unsigned addr, unsigned size, unsigned char data[])

Read data (whole page) from SPI flash.

Parameters:
  • addr – Start address of data block
  • size – Data size for reading
  • data – Pointer to data buffer
Returns:

Size of readed data or 0 in case of error

[[guarded]] int write(unsigned addr, unsigned size, unsigned char data[])

Write data to SPI flash.

Parameters:
  • addr – Start address for writing
  • size – Data size for writing
  • data – Pointer to data buffer
Returns:

Size of writed data or 0 in case of error

[[guarded]] int erase(unsigned addr, unsigned size)

Erase data block in SPI flash.

Parameters:
  • addr – Start address for writing
  • size – Data size for writing
  • data – Pointer to data buffer
Returns:

Size of writed data or 0 in case of error

[[guarded]] int get_configurations(int type, unsigned char buffer[], unsigned &n_bytes)
[[guarded]] int set_configurations(int type, unsigned char data[n_bytes], unsigned n_bytes)

Writes configuration to the data partition of flash.

Parameters:
  • type – Type of configuration data to read
  • data – Array of chars containing the configuration data to be written
  • n_bytes – Amount of bytes to write
Returns:

0 - if writing of data was successful

[[notification]] slave void service_ready(void)

Types

configuration_type

Enum Values:

MOTCTRL_CONFIG