|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The firmware update on this board. More...
#include "update_hw.h"#include <stddef.h>#include <string.h>#include "pico/stdlib.h"#include "boot/bootrom_constants.h"#include "boot/picobin.h"#include "boot/picoboot_constants.h"#include "hardware/flash.h"#include "pico/bootrom.h"#include "link_update_dev.h"#include "out_store.h"Functions | |
| static bool | io_erase (void *ctx, uint32_t off) |
| Erases a sector of the slot being written. | |
| static bool | io_program (void *ctx, uint32_t off, const uint8_t *data) |
| Programs one sector of the slot being written. | |
| static bool | io_gate (void *ctx) |
| Tells whether a flash write may run now. | |
| static void | buy_in_window (void *arg) |
| Inside a flash window: the boot ROM clears the TBYB (try before you buy) flag in flash, and for a version downgrade erases the other slot's first sector. link_update_dev erases that sector after every BUY, and owes the erase until it holds. | |
| static bool | io_buy (void *ctx) |
| Runs the boot ROM's BUY inside a flash window. | |
| static void | io_restart (void *ctx) |
| Restarts into the slot just written, as a flash update boot. This function does not return. | |
| static bool | partition_at (unsigned n, uint32_t *start, uint32_t *bytes) |
Where partition n of the table the boot ROM holds starts and how many bytes it spans; false without one. | |
| void | update_hw_init (bool(*busy)(void)) |
| Read the boot ROM's word on this boot – which slot runs, whether it is on trial – and check the partition table against the layout this build has. | |
| void | update_hw_ctl_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out) |
| The two pages' handlers, for the link_page_t table. | |
| uint8_t | update_hw_ctl_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in) |
| Writes the UPDATE_CTL page, for the link_page_t table. | |
| void | update_hw_data_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out) |
| Reads the UPDATE_DATA page, for the link_page_t table. | |
| uint8_t | update_hw_data_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in) |
| Writes the UPDATE_DATA page, for the link_page_t table. | |
| void | update_hw_poll (uint32_t now_ms) |
| Once per pass: a slice of a hash, the restart after ACTIVATE, an owed erase of the other slot's first sector, the end of a session that has had no update request for 5s. | |
| bool | update_hw_holds_arm (void) |
| True while ARM is refused: an update session or an image on trial. | |
| bool | update_hw_refuses_arm (uint8_t off, uint8_t n, const uint16_t *in) |
| Whether a CONTROL write is refused for the update (link_update_dev.h). | |
| int | update_hw_slot (void) |
| For the console: the slot running, 0 or 1, or -1 without a table. | |
| bool | update_hw_on_trial (void) |
| For the console: whether the running image waits for its BUY. | |
Variables | |
| static link_update_dev_t | s_upd |
| static link_update_io_t | s_io |
| static bool(*) | s_busy (void) |
| static uint32_t | s_target_off |
| static uint32_t | s_running_off |
| Offset of the running image's slot from the start of flash. | |
| static int | s_slot = -1 |
| static uint32_t | s_buy_work [FLASH_SECTOR_SIZE/sizeof(uint32_t)] |
| The boot ROM's BUY needs 4KiB to rewrite the sector holding the flag. | |
| static int | s_buy_rc |
The firmware update on this board.
See update_hw.h and the update section of link_pages.h.
SPDX-License-Identifier: MIT
|
static |
Inside a flash window: the boot ROM clears the TBYB (try before you buy) flag in flash, and for a version downgrade erases the other slot's first sector. link_update_dev erases that sector after every BUY, and owes the erase until it holds.
| arg | Unused. |
|
static |
Runs the boot ROM's BUY inside a flash window.
| ctx | Unused. |
|
static |
Erases a sector of the slot being written.
| ctx | Unused. |
| off | Offset within the slot, in bytes. An offset of IOMCU_SLOT_BYTES or more is refused. |
|
static |
Tells whether a flash write may run now.
| ctx | Unused. |
|
static |
Programs one sector of the slot being written.
| ctx | Unused. |
| off | Offset within the slot, in bytes. An offset of IOMCU_SLOT_BYTES or more is refused. |
| data | The sector contents. |
|
static |
Restarts into the slot just written, as a flash update boot. This function does not return.
| ctx | Unused. |
|
static |
Where partition n of the table the boot ROM holds starts and how many bytes it spans; false without one.
| n | Partition number, 0 or 1. |
| start | Receives the start offset in bytes from flash 0. |
| bytes | Receives the length of the partition, in bytes. |
| void update_hw_ctl_read | ( | void * | ctx, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| uint16_t * | out ) |
The two pages' handlers, for the link_page_t table.
| ctx | Unused. |
| off | First register to read. |
| n | Number of registers to read. |
| out | Receives the register values. |
| uint8_t update_hw_ctl_write | ( | void * | ctx, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| const uint16_t * | in ) |
Writes the UPDATE_CTL page, for the link_page_t table.
| ctx | Unused. |
| off | First register to write. |
| n | Number of registers to write. |
| in | The register values to write. |
| void update_hw_data_read | ( | void * | ctx, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| uint16_t * | out ) |
Reads the UPDATE_DATA page, for the link_page_t table.
| ctx | Unused. |
| off | First register to read. |
| n | Number of registers to read. |
| out | Receives the register values. |
| uint8_t update_hw_data_write | ( | void * | ctx, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| const uint16_t * | in ) |
Writes the UPDATE_DATA page, for the link_page_t table.
| ctx | Unused. |
| off | First register to write. |
| n | Number of registers to write. |
| in | The register values to write. |
| bool update_hw_holds_arm | ( | void | ) |
True while ARM is refused: an update session or an image on trial.
| void update_hw_init | ( | bool(* | busy )(void) | ) |
Read the boot ROM's word on this boot – which slot runs, whether it is on trial – and check the partition table against the layout this build has.
busy says whether flash may not be written now: the bank driving, the supply on, a servo programming session.
| busy | Returns true while flash may not be written now. |
| bool update_hw_on_trial | ( | void | ) |
For the console: whether the running image waits for its BUY.
| void update_hw_poll | ( | uint32_t | now_ms | ) |
Once per pass: a slice of a hash, the restart after ACTIVATE, an owed erase of the other slot's first sector, the end of a session that has had no update request for 5s.
| now_ms | The pass's clock in ms. |
| bool update_hw_refuses_arm | ( | uint8_t | off, |
| uint8_t | n, | ||
| const uint16_t * | in ) |
Whether a CONTROL write is refused for the update (link_update_dev.h).
| off | First register of the write. |
| n | Number of registers in the write. |
| in | The register values of the write. |
| int update_hw_slot | ( | void | ) |
For the console: the slot running, 0 or 1, or -1 without a table.