REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
|
#include <Arduino.h>
#include <malloc.h>
#include <stdint.h>
#include <string.h>
#include "ota/flasher.h"
#include "utils/etl_base64.h"
#include "utils/logging.h"

Go to the source code of this file.
Macros | |
#define | FLASH_ID "fw_teensy41" |
#define | FLASH_ID_LEN (11) |
#define | FLASH_SIZE (0x800000) |
#define | FLASH_SECTOR_SIZE (0x1000) |
#define | FLASH_WRITE_SIZE (4) |
#define | FLASH_RESERVE (80 * FLASH_SECTOR_SIZE) |
#define | FLASH_BASE_ADDR (0x60000000) |
#define | IN_FLASH(a) |
#define | CPU_RESTART_ADDR ((uint32_t *)0xE000ED0C) |
#define | CPU_RESTART_VAL (0x5FA0004) |
#define | REBOOT (*CPU_RESTART_ADDR = CPU_RESTART_VAL) |
#define | RAMFUNC __attribute__((section(".fastrun"), noinline, noclone, optimize("Os"))) |
#define | return_err(code, msg) |
#define | return_errf(code, msg, ...) |
#define | RETURN_IF_FLASHING_NOT_ENABLED return_err(0, "OTA Flashing is disabled in this firmware build") |
Functions | |
__attribute__ ((section(".fastrun"), noinline, noclone, optimize("Os"))) int flash_sector_not_erased(uint32_t address) | |
void | eepromemu_flash_write (void *addr, const void *data, uint32_t len) |
void | eepromemu_flash_erase_sector (void *addr) |
void | eepromemu_flash_erase_32K_block (void *addr) |
void | eepromemu_flash_erase_64K_block (void *addr) |
void | firmware_buffer_free (uint32_t buffer_addr, uint32_t buffer_size) |
int | flash_write_block (uint32_t addr, char *data, uint32_t count) |
int | flash_erase_block (uint32_t address, uint32_t size) |
void | firmware_buffer_init (uint32_t *buffer_addr, uint32_t *buffer_size) |
while (offset< size &&error==0) | |
if (((src) >=(0x60000000) &&(src)<(0x60000000)+(0x800000))) | |
for (;;) | |
FLASHMEM int | flash_write_block (uint32_t addr, uint8_t *data, uint32_t count) |
Variables | |
uint32_t | src |
uint32_t uint32_t | size |
static int | leave_interrupts_disabled = 0 |
uint32_t = (0x5FA0004) ) | |
static constexpr int | success = 0 |
constexpr static size_t | json_overhead = 0xff |
constexpr static size_t | base64_chunk_size = 4096 / 2 |
constexpr static size_t | bin_chunk_size = base64_chunk_size * 3 / 4 |
Macro Definition Documentation
◆ CPU_RESTART_ADDR
#define CPU_RESTART_ADDR ((uint32_t *)0xE000ED0C) |
Definition at line 44 of file flasher.cpp.
◆ CPU_RESTART_VAL
#define CPU_RESTART_VAL (0x5FA0004) |
Definition at line 45 of file flasher.cpp.
◆ FLASH_BASE_ADDR
#define FLASH_BASE_ADDR (0x60000000) |
Definition at line 39 of file flasher.cpp.
Referenced by loader::FirmwareFlasher::complete(), and firmware_buffer_init().
◆ FLASH_ID
#define FLASH_ID "fw_teensy41" |
Definition at line 31 of file flasher.cpp.
◆ FLASH_ID_LEN
#define FLASH_ID_LEN (11) |
Definition at line 32 of file flasher.cpp.
◆ FLASH_RESERVE
#define FLASH_RESERVE (80 * FLASH_SECTOR_SIZE) |
Definition at line 38 of file flasher.cpp.
Referenced by firmware_buffer_init(), and if().
◆ FLASH_SECTOR_SIZE
#define FLASH_SECTOR_SIZE (0x1000) |
Definition at line 34 of file flasher.cpp.
Referenced by __attribute__(), firmware_buffer_init(), flash_erase_block(), if(), and while().
◆ FLASH_SIZE
#define FLASH_SIZE (0x800000) |
Definition at line 33 of file flasher.cpp.
Referenced by firmware_buffer_init(), and if().
◆ FLASH_WRITE_SIZE
#define FLASH_WRITE_SIZE (4) |
Definition at line 35 of file flasher.cpp.
Referenced by flash_write_block(), if(), and while().
◆ IN_FLASH
#define IN_FLASH | ( | a | ) |
◆ RAMFUNC
#define RAMFUNC __attribute__((section(".fastrun"), noinline, noclone, optimize("Os"))) |
Definition at line 50 of file flasher.cpp.
◆ REBOOT
#define REBOOT (*CPU_RESTART_ADDR = CPU_RESTART_VAL) |
Definition at line 46 of file flasher.cpp.
Referenced by loader::reboot().
◆ return_err
#define return_err | ( | code, | |
msg ) |
Definition at line 276 of file flasher.cpp.
Referenced by loader::FirmwareFlasher::abort(), loader::FirmwareFlasher::complete(), loader::FirmwareFlasher::init(), loader::SinglePluginLoader::load_and_execute(), loader::FirmwareFlasher::stream(), and loader::SinglePluginLoader::unload().
◆ return_errf
#define return_errf | ( | code, | |
msg, | |||
... ) |
Definition at line 281 of file flasher.cpp.
Referenced by loader::FirmwareFlasher::init(), and loader::FirmwareFlasher::stream().
◆ RETURN_IF_FLASHING_NOT_ENABLED
#define RETURN_IF_FLASHING_NOT_ENABLED return_err(0, "OTA Flashing is disabled in this firmware build") |
Definition at line 304 of file flasher.cpp.
Referenced by loader::FirmwareFlasher::abort(), loader::FirmwareFlasher::complete(), loader::FirmwareFlasher::init(), and loader::FirmwareFlasher::stream().
Function Documentation
◆ __attribute__()
__attribute__ | ( | (section(".fastrun"), noinline, noclone, optimize("Os")) | ) |
Definition at line 114 of file flasher.cpp.
References FLASH_SECTOR_SIZE, and uint32_t.
Referenced by flash_write_block(), and loader::FirmwareFlasher::stream().
◆ eepromemu_flash_erase_32K_block()
void eepromemu_flash_erase_32K_block | ( | void * | addr | ) |
◆ eepromemu_flash_erase_64K_block()
void eepromemu_flash_erase_64K_block | ( | void * | addr | ) |
◆ eepromemu_flash_erase_sector()
void eepromemu_flash_erase_sector | ( | void * | addr | ) |
Referenced by flash_erase_block(), if(), and while().
◆ eepromemu_flash_write()
void eepromemu_flash_write | ( | void * | addr, |
const void * | data, | ||
uint32_t | len ) |
Referenced by flash_write_block(), and while().
◆ firmware_buffer_free()
Definition at line 107 of file flasher.cpp.
References flash_erase_block().
Referenced by loader::FirmwareBuffer::~FirmwareBuffer().
◆ firmware_buffer_init()
Definition at line 75 of file flasher.cpp.
References FLASH_BASE_ADDR, FLASH_RESERVE, FLASH_SECTOR_SIZE, FLASH_SIZE, LOGMEV, and uint32_t.
Referenced by loader::FirmwareBuffer::FirmwareBuffer(), and loader::FirmwareFlasher::status().
◆ flash_erase_block()
Definition at line 204 of file flasher.cpp.
References eepromemu_flash_erase_sector(), FLASH_SECTOR_SIZE, size, and uint32_t.
Referenced by firmware_buffer_free().
◆ flash_write_block() [1/2]
Referenced by loader::FirmwareFlasher::stream().
◆ flash_write_block() [2/2]
Definition at line 225 of file flasher.cpp.
References __attribute__(), eepromemu_flash_write(), FLASH_WRITE_SIZE, IN_FLASH, and uint32_t.
◆ for()
for | ( | ;; | ) |
Definition at line 197 of file flasher.cpp.
◆ if()
Definition at line 177 of file flasher.cpp.
References eepromemu_flash_erase_sector(), FLASH_RESERVE, FLASH_SECTOR_SIZE, FLASH_SIZE, and FLASH_WRITE_SIZE.
◆ while()
while | ( | ) |
Definition at line 135 of file flasher.cpp.
References eepromemu_flash_erase_sector(), eepromemu_flash_write(), FLASH_SECTOR_SIZE, FLASH_WRITE_SIZE, src, and uint32_t.
Variable Documentation
◆ base64_chunk_size
|
staticconstexpr |
Definition at line 294 of file flasher.cpp.
◆ bin_chunk_size
|
staticconstexpr |
Definition at line 295 of file flasher.cpp.
Referenced by loader::FirmwareFlasher::init(), and loader::FirmwareFlasher::stream().
◆ json_overhead
|
staticconstexpr |
Definition at line 293 of file flasher.cpp.
◆ leave_interrupts_disabled
|
static |
Definition at line 70 of file flasher.cpp.
◆ size
Definition at line 63 of file flasher.cpp.
Referenced by utils::dcp_hash_update(), utils::dcp_hash_update_non_blocking(), flash_erase_block(), run::Run::from_json(), awot::Request::read(), and utils::shift_5_left().
◆ src
uint32_t src |
Definition at line 63 of file flasher.cpp.
Referenced by loader::convertFromJson(), utils::convertFromJson(), loader::convertToJson(), loader::convertToJson(), utils::dcp_reverse_and_copy(), ArduinoJson::Converter< entities::EntityClassifier >::fromJson(), net::auth::Gatekeeper::fromJson(), net::StartupConfig::fromJson(), nvmconfig::PermanentUserDefinedStuff::fromJson(), nvmconfig::VendorOTP::fromJson(), utils::UUID::fromJson(), utils::UUID::fromJson(), ArduinoJson::Converter< entities::EntityClassifier >::toJson(), and while().
◆ success
|
staticconstexpr |
Definition at line 275 of file flasher.cpp.
Referenced by blocks::MIntBlock_V_1_1_X::_gain_calibration(), blocks::MIntBlock_V_1_1_X::calibrate(), blocks::MMulBlock::calibrate(), blocks::MMulBlock_FullAutoCalibration::calibrate(), carrier::Carrier::calibrate_m_blocks(), carrier::Carrier::calibrate_mblock(), platform::Cluster::calibrate_routes(), loader::FirmwareFlasher::complete(), loader::FirmwareFlasher::init(), loader::FirmwareFlasher::stream(), utils::PrintMultiplexer::write(), utils::PrintMultiplexer::write(), and blocks::TBlockHAL_V_1_0_X::write_muxes().
◆ uint32_t
uint32_t = (0x5FA0004) ) |
Definition at line 177 of file flasher.cpp.
Referenced by __attribute__(), daq::average(), loader::convertToJson(), utils::dcp_clear_channel_status(), utils::dcp_clear_status(), utils::dcp_get_channel_status(), utils::dcp_hash_process_message_data(), utils::dcp_hash_update(), utils::dcp_hash_update_non_blocking(), utils::dcp_schedule_work(), utils::DCP_WaitForChannelComplete(), utils::demo_crc32(), utils::demo_sha256(), firmware_buffer_init(), flash_erase_block(), flash_write_block(), client::RunDataNotificationHandler::handle(), client::StreamingRunDataNotificationHandler::handle(), blocks::IBlockHAL::INPUT_BITMASK(), loader::flashimage::len(), daq::stream::process(), websockets::internals::readData(), websockets::internals::readUntilSuccessfullOrError(), run::RunManager::run_next_traditional(), serve_static(), loader::FirmwareFlasher::status(), daq::stream::stop(), websockets::internals::swapEndianess(), websockets::internals::swapEndianess(), while(), functions::EEPROM25AA02::write32(), functions::AD9834::write_frequency(), and blocks::IBlockHAL_V_1_2_X::write_outputs().