Application to generate firmware for USB Host Mass Storage Bootloader.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <string.h>
#include "conf_usb_host.h"
#include "conf_bootloader.h"
#include "main.h"
#include "aesa.h"
Macros | |
#define | MSC_DELAY_SOF_COUNT 100 |
Functions | |
static void | aes_encrypt (uint32_t *decrypted_data, uint32_t size) |
AES Decryption routine. More... | |
static void | console_init (void) |
Initializes the console output. More... | |
static void | firmware_gen_system_init () |
Initializes the device for the bootloader. More... | |
static void | generate_crc (void) |
Generate the CRC value for the firmware. More... | |
static bool | generate_firmware (void) |
Function to generate the final firmware. More... | |
static void | init_aes () |
AES Initialization routine. More... | |
int | main (void) |
Main function. More... | |
void | main_usb_connection_event (uhc_device_t *dev, bool b_present) |
Notify that a USB device has been connected or disconnected. More... | |
void | main_usb_sof_event (void) |
Notify that a SOF has been sent (each 1 ms) More... | |
Variables | |
COMPILER_WORD_ALIGNED volatile uint32_t | aes_output [FLASH_BUFFER_SIZE/4] |
COMPILER_WORD_ALIGNED volatile uint8_t | buffer [FLASH_BUFFER_SIZE] |
static crccu_dscr_type_t | crc_dscr |
static DIR | file_dir |
static FIL | file_object1 |
static FIL | file_object2 |
static uint32_t | firmware_crc = 0 |
static FATFS | fs |
struct aes_config | g_aes_cfg |
struct aes_dev_inst | g_aes_inst |
static char | input_file_name [] |
static volatile bool | lun_connected = false |
static char | output_file_name [] |
static volatile uint32_t | sof_count = 0 |
#define MSC_DELAY_SOF_COUNT 100 |
Referenced by main().
|
static |
AES Decryption routine.
References aes_read_output_data(), aes_read_status(), aes_write_input_data(), and g_aes_inst.
Referenced by generate_firmware().
|
static |
Initializes the console output.
References sam_usart_opt_t::baudrate, sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), usart_enable_tx(), and usart_init_rs232().
Referenced by firmware_gen_system_init().
|
static |
Initializes the device for the bootloader.
References board_init(), console_init(), cpu_irq_enable, sleepmgr_init(), sysclk_init(), and uhc_start().
Referenced by main().
|
static |
Generate the CRC value for the firmware.
References APP_CRC_POLYNOMIAL_TYPE, buffer, crccu_configure_descriptor(), crccu_configure_mode(), crccu_enable_dma(), crccu_get_dma_status(), crccu_read_crc_value(), crccu_reset(), CRCCU_TR_CTRL_IEN_DISABLE, CRCCU_TR_CTRL_TRWIDTH_BYTE, f_close(), f_open(), f_read(), FA_OPEN_EXISTING, FA_READ, firmware_crc, input_file_name, sysclk_disable_peripheral_clock(), and sysclk_enable_peripheral_clock().
Referenced by main().
|
static |
Function to generate the final firmware.
References aes_encrypt(), APP_BINARY_OFFSET, APP_CRC_SIZE, APP_SIGNATURE, APP_SIGNATURE_SIZE, buffer, f_close(), f_lseek(), f_open(), f_read(), f_sync(), f_write(), FA_CREATE_ALWAYS, FA_OPEN_EXISTING, FA_READ, FA_WRITE, firmware_crc, FR_OK, init_aes(), input_file_name, and output_file_name.
Referenced by main().
|
static |
AES Initialization routine.
References AES_CBC_MODE, AES_CFB_SIZE_128, aes_dev_inst::aes_cfg, AES_COUNTERMEASURE_TYPE_ALL, aes_enable(), AES_ENCRYPTION, aes_get_config_defaults(), aes_init(), AES_KEY_SIZE_128, AES_MANUAL_MODE, aes_set_config(), aes_set_new_message(), aes_write_initvector(), aes_write_key(), aes_config::cfb_size, aes_config::countermeasure_mask, aes_config::dma_mode, aes_config::encrypt_mode, g_aes_cfg, g_aes_inst, aes_config::key_size, and aes_config::opmode.
Referenced by generate_firmware().
int main | ( | void | ) |
Main function.
Execution starts here.
References APP_BINARY_OFFSET, APP_MAX_SIZE, buffer, cpu_irq_disable, f_close(), f_lseek(), f_mount(), f_open(), f_opendir(), f_sync(), f_write(), FA_OPEN_EXISTING, FA_READ, FA_WRITE, firmware_gen_system_init(), FR_OK, FIL::fsize, generate_crc(), generate_firmware(), input_file_name, lun_connected, MSC_DELAY_SOF_COUNT, output_file_name, sof_count, uhc_stop(), and uhi_msc_mem_get_lun().
void main_usb_connection_event | ( | uhc_device_t * | dev, |
bool | b_present | ||
) |
Notify that a USB device has been connected or disconnected.
dev | Pointer on USB device information |
b_present | true, if the device has been connected |
References lun_connected, sof_count, and UNUSED.
void main_usb_sof_event | ( | void | ) |
Notify that a SOF has been sent (each 1 ms)
References sof_count.
COMPILER_WORD_ALIGNED volatile uint32_t aes_output[FLASH_BUFFER_SIZE/4] |
COMPILER_WORD_ALIGNED volatile uint8_t buffer[FLASH_BUFFER_SIZE] |
Referenced by generate_crc(), generate_firmware(), and main().
|
static |
|
static |
|
static |
|
static |
|
static |
Referenced by generate_crc(), and generate_firmware().
|
static |
Referenced by chk_mounted(), and f_mount().
struct aes_config g_aes_cfg |
Referenced by init_aes().
struct aes_dev_inst g_aes_inst |
Referenced by aes_encrypt(), and init_aes().
|
static |
Referenced by generate_crc(), generate_firmware(), and main().
Referenced by main(), and main_usb_connection_event().
|
static |
Referenced by generate_firmware(), and main().
|
static |
Referenced by main(), main_usb_connection_event(), and main_usb_sof_event().