TT Zephyr Platforms 18.11.99
Tenstorrent Firmware
|
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <tenstorrent/fwupdate.h>
#include <tenstorrent/tt_boot_fs.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/dfu/mcuboot.h>
#include <zephyr/drivers/flash.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/storage/flash_map.h>
#include <zephyr/sys/reboot.h>
#include <zephyr/sys/util.h>
#include <tenstorrent/bh_chip.h>
Macros | |
#define | IMAGE_MAGIC 0x96f3b83d |
#define | AS_U32(a, b, c, d) |
#define | FLASH0_NODE DT_NODELABEL(flash) /* "flash" (NOT "flash0") is internal flash */ |
#define | ERASE_BLOCK_SIZE DT_PROP(DT_NODELABEL(flash0), erase_block_size) |
#define | WRITE_BLOCK_SIZE DT_PROP(DT_NODELABEL(flash0), write_block_size) |
#define | TT_BOOT_FS_OFFSET 0 |
Functions | |
LOG_MODULE_REGISTER (tt_fwupdate, CONFIG_TT_FWUPDATE_LOG_LEVEL) | |
int | tt_fwupdate_init (const struct device *dev, struct gpio_dt_spec mux) |
Set the external flash device and set the passed spi mux (if not null) to allow communication with the spi. | |
int | tt_fwupdate_complete (void) |
Called on the completion of the fwupdate operation, disables the spi mux if initialized in tt_fwupdate_init | |
static int | z_tt_boot_fs_read (uint32_t addr, uint32_t size, uint8_t *dst) |
static int | z_tt_boot_fs_write (uint32_t addr, uint32_t size, const uint8_t *src) |
static int | z_tt_boot_fs_erase (uint32_t addr, uint32_t size) |
static void | tt_fwupdate_dump_fd (const char *msg, const tt_boot_fs_fd *fd, bool verified) |
int | tt_fwupdate (const char *tag, bool dry_run, bool reboot) |
Search for, verify, and apply firmware updates. | |
int | tt_fwupdate_confirm (void) |
Confirm that the current firmware has booted successfully. | |
int | tt_fwupdate_flash_image (const tt_boot_fs_fd *fd) |
Flash the image described by the provided boot filesystem file descriptor. | |
int | tt_fwupdate_is_confirmed (void) |
Check if the currently running firmware has been confirmed. | |
int | tt_fwupdate_validate_fd (const tt_boot_fs_fd *fd) |
Validate the provided boot filesystem file descriptor. | |
int | tt_fwupdate_validate_image (const tt_boot_fs_fd *fd) |
Validate the image described by the provided boot filesystem file descriptor. |
Variables | |
static tt_boot_fs | boot_fs |
static const struct device * | flash1_dev |
static struct gpio_dt_spec | spi_mux |
static const struct device *const | flash0_dev = DEVICE_DT_GET( DT_NODELABEL(flash) ) |
#define AS_U32 | ( | a, | |
b, | |||
c, | |||
d ) |
#define ERASE_BLOCK_SIZE DT_PROP(DT_NODELABEL(flash0), erase_block_size) |
#define FLASH0_NODE DT_NODELABEL(flash) /* "flash" (NOT "flash0") is internal flash */ |
#define IMAGE_MAGIC 0x96f3b83d |
#define TT_BOOT_FS_OFFSET 0 |
#define WRITE_BLOCK_SIZE DT_PROP(DT_NODELABEL(flash0), write_block_size) |
LOG_MODULE_REGISTER | ( | tt_fwupdate | , |
CONFIG_TT_FWUPDATE_LOG_LEVEL | ) |
Search for, verify, and apply firmware updates.
reboot
is true, then this function does not return.tag | The tag (name) of the update image in the flash filesystem. |
dry_run | Only verify data and operations. Do not write to flash or reboot. |
reboot | If true, reboot after the update has been successfully written. |
0 | on success, if no firmware update is needed. |
1 | on success, if a firmware update was applied and a reboot is required. |
-EINVAL | if an argument is invalid. |
-EIO | if an I/O error occurs. |
-ENOENT | if the image is invalid an image named tag cannot be found. |
-ENODEV | if the current slot cannot be determined or a device is not ready. |
int tt_fwupdate_complete | ( | void | ) |
Called on the completion of the fwupdate operation, disables the spi mux if initialized in tt_fwupdate_init
0 | on success, if the spi mux was able to be set |
int tt_fwupdate_confirm | ( | void | ) |
Confirm that the current firmware has booted successfully.
0 | on success. |
-EIO | if an I/O erorr occurs. |
|
static |
int tt_fwupdate_flash_image | ( | const tt_boot_fs_fd * | fd | ) |
Flash the image described by the provided boot filesystem file descriptor.
fd | A pointer to the file descriptor for the desired image. |
-EINVAL | if fd is NULL. |
-ENOENT | if the image is invalid. |
-EIO | if an I/O error occurs. |
-EFBIG | if the image is too large to fit in the slot. |
int tt_fwupdate_init | ( | const struct device * | dev, |
struct gpio_dt_spec | mux ) |
Set the external flash device and set the passed spi mux (if not null) to allow communication with the spi.
dev | The pointer to the external flash device to use. |
mux | The spi mux to set and disable on start and completion of the fw update operations. |
0 | on success, if the spi mux was able to be set |
int tt_fwupdate_is_confirmed | ( | void | ) |
Check if the currently running firmware has been confirmed.
0 | if the currently running firmware has not been confirmed. |
1 | if the currently running firmware has been confirmed. |
-EIO | if an I/O erorr occurs. |
int tt_fwupdate_validate_fd | ( | const tt_boot_fs_fd * | fd | ) |
Validate the provided boot filesystem file descriptor.
fd | A pointer to the file descriptor to validate. |
0 | if fd is valid. |
-EINVAL | if fd is NULL. |
-ENOENT | if fd is invalid. |
-EIO | if an I/O error occurs. |
int tt_fwupdate_validate_image | ( | const tt_boot_fs_fd * | fd | ) |
Validate the image described by the provided boot filesystem file descriptor.
fd | A pointer to the file descriptor for the desired image. |
-EINVAL | if fd is NULL. |
-ENOENT | if the image is invalid. |
-EIO | if an I/O error occurs. |
|
static |
|
static |
|
static |
|
static |