main_ubi_sdk v 0.1.3
This is UBI4 documentation
update_fw.h File Reference
#include "UBI_SDK.h"
#include "TransportLevel/main_receiver.h"
#include "stdint.h"
#include "string.h"
#include "stdbool.h"
#include "Data/data_table.h"
#include "Data/device_info_structs.h"
#include "Data/base_parameter.h"
#include "Devices/enum_discription.h"
#include "Drivers/base_memory_driver.h"
#include "TransportLevel/a_protocol_struct.h"
#include "Data/base_device_info.h"
#include "Data/data_table_structs.h"
#include "Data/data_verification.h"
#include "TransportLevel/p2p_protocol.h"
Include dependency graph for update_fw.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FW_info_struct
 
struct  FW_up_load_atribute
 

Macros

#define IN_MAIN_APP_STATUS   0x01
 
#define IN_BOOTLOADER_STATUS   0x02
 
#define BAD_CRC_FIRMWARE   0x1E
 
#define GOOD_CRC_FIRMWARE   0x2E
 
#define BAD_COMPARE   0x00
 
#define GOOD_COMPARE   0x01
 
#define SIZE_BUFF_FOR_BOOT   1024
 
#define SIZE_FW_INFO_STRUCT   10
 
#define BEGIN_CALCULATE_CRC   0x01
 
#define END_CALCULATE_CRC   0x00
 

Enumerations

enum  update_fw_state_enum {
  GET_RUN_PROGRAM_TYPE = 1 , JUMP_TO_BOOTLOADER , CHECK_NEW_FW , PRELOAD_INFO ,
  LOAD_NEW_FW , GET_BOOTLOADER_STATUS , CALCULATE_CRC , COMPLITE_CRC ,
  GET_BOOTLOADER_INFO , CHECK_NEW_BOOTLOADER , LOAD_NEW_BOOTLOADER , GET_UP_LOAD_ATRIBUTE ,
  START_SYSTEM_UPDATE , FINISH_SYSTEM_UPDATE
}
 
enum  state_process_bootloader {
  BOOTLOADER_IDLE =1 , PROCESSING_CLER , DONE_CLEAR , BOOTLOADER_PRELOAD_STATE ,
  BOOTLOADER_CONTINUE_WRITE_FW , BOOTLOADER_CHECK_INFO_FW , PROCESSING_CULCULATE_CRC , DONE_CALCULATE_CRC
}
 
enum  update_fw_program_type_enum { BOOTLOADER = 1 , MAIN_PROGRAM }
 

Functions

void Update_FW_Receive (base_device_information_struct *deviceInfo, ubi4_bus_protocol_obj_struct *protocol_str, protocol_receive_struct receive_str)
 A function that determines which command has arrived and which state needs to be switched to.
 
void JumpToProgramCommand (uint32_t address_to_jump)
 The function goes to the received address.
 
void Init_Need_Struct_For_FW (base_BootloaderInfo_struct *base_boot, base_FWInfo_struct *base_fw, base_BoardInfo_struct *base_board)
 A function for initializing "Bootloader_struct", "FW_struct" and "Board_struct" from flash.
 
uint8_t Compare_Data (void)
 A function for verifying the firmware.
 

Macro Definition Documentation

◆ BAD_COMPARE

#define BAD_COMPARE   0x00

◆ BAD_CRC_FIRMWARE

#define BAD_CRC_FIRMWARE   0x1E

◆ BEGIN_CALCULATE_CRC

#define BEGIN_CALCULATE_CRC   0x01

◆ END_CALCULATE_CRC

#define END_CALCULATE_CRC   0x00

◆ GOOD_COMPARE

#define GOOD_COMPARE   0x01

◆ GOOD_CRC_FIRMWARE

#define GOOD_CRC_FIRMWARE   0x2E

◆ IN_BOOTLOADER_STATUS

#define IN_BOOTLOADER_STATUS   0x02

◆ IN_MAIN_APP_STATUS

#define IN_MAIN_APP_STATUS   0x01

◆ SIZE_BUFF_FOR_BOOT

#define SIZE_BUFF_FOR_BOOT   1024

◆ SIZE_FW_INFO_STRUCT

#define SIZE_FW_INFO_STRUCT   10

Enumeration Type Documentation

◆ state_process_bootloader

Enumerator
BOOTLOADER_IDLE 
PROCESSING_CLER 
DONE_CLEAR 
BOOTLOADER_PRELOAD_STATE 
BOOTLOADER_CONTINUE_WRITE_FW 
BOOTLOADER_CHECK_INFO_FW 
PROCESSING_CULCULATE_CRC 
DONE_CALCULATE_CRC 

◆ update_fw_program_type_enum

Enumerator
BOOTLOADER 
MAIN_PROGRAM 

◆ update_fw_state_enum

Enumerator
GET_RUN_PROGRAM_TYPE 
JUMP_TO_BOOTLOADER 
CHECK_NEW_FW 
PRELOAD_INFO 
LOAD_NEW_FW 
GET_BOOTLOADER_STATUS 
CALCULATE_CRC 
COMPLITE_CRC 
GET_BOOTLOADER_INFO 
CHECK_NEW_BOOTLOADER 
LOAD_NEW_BOOTLOADER 
GET_UP_LOAD_ATRIBUTE 
START_SYSTEM_UPDATE 
FINISH_SYSTEM_UPDATE 

Function Documentation

◆ Compare_Data()

uint8_t Compare_Data ( void )

A function for verifying the firmware.

Parameters
Nothing.
Returns
1 - if the firmware is correct. 0 - in case of a firmware mismatch.

Available to call in any module.

Here is the caller graph for this function:

◆ Init_Need_Struct_For_FW()

void Init_Need_Struct_For_FW ( base_BootloaderInfo_struct * base_boot,
base_FWInfo_struct * base_fw,
base_BoardInfo_struct * base_board )

A function for initializing "Bootloader_struct", "FW_struct" and "Board_struct" from flash.

Parameters
base_boot- a pointer to a structure containing information about the loader program itself. base_fw - a pointer to a structure containing information about the firmware received from the master device. base_board - a pointer to a structure containing information about the board itself, which is necessary for firmware verification.
Returns
Nothing.

Available to call in any module.

◆ JumpToProgramCommand()

void JumpToProgramCommand ( uint32_t address_to_jump)

The function goes to the received address.

Parameters
address_to_jump- The program's transition address.
Returns
Nothing.

◆ Update_FW_Receive()

void Update_FW_Receive ( base_device_information_struct * deviceInfo,
ubi4_bus_protocol_obj_struct * protocol_str,
protocol_receive_struct receive_str )

A function that determines which command has arrived and which state needs to be switched to.

Parameters
deviceInfo- a pointer to a structure containing information about the device. protocol_str - a pointer to a structure for communication. receive_str - a structure containing information about the received data.
Returns
Nothing.

The first byte of the received buffer is the status. Takes the value from "update_fw_state_enum". Available for calling in other libraries.

Here is the call graph for this function:
Here is the caller graph for this function: