OpenBSL  v.0.1.0
Classes | Macros | Enumerations | Functions | Variables
OpenBSL_Int.h File Reference

OpenBSL internal header file. More...

#include "OpenBSL_Device.h"

Go to the source code of this file.

Classes

struct  OpenBSL_MemSect_t
 

Macros

#define OPEN_BSL_FUNC_PROC_ERASE_IMAGE   OpenBSL_ProcEraseImg
 
#define OPEN_BSL_FUNC_PROC_DOWNLOAD_IMAGE   OpenBSL_ProcDnldImg
 
#define OPEN_BSL_FUNC_PROC_UPLOAD_IMAGE   OpenBSL_ProcUpldImg
 
#define OPEN_BSL_FUNC_PROC_CALCULATE_CHECKSUM   OpenBSL_ProcCalcChksm
 
#define OPEN_BSL_FUNC_PROC_ERASE_SEGMENT   OpenBSL_ProcEraseSegment
 
#define OPEN_BSL_FUNC_PROC_CMD_DOWNLOAD_SEGMENT   OpenBSL_ProcDnldSegment
 
#define OPEN_BSL_FUNC_PROC_UPLOAD_SEGMENT   OpenBSL_ProcUpldSegment
 
#define OPEN_BSL_FUNC_PROC_PASSWORD   OpenBSL_ProcPwdCmd
 
#define OPEN_BSL_FUNC_PROC_JUMP_TO_ADDR   OpenBSL_ProcJumpToAddr
 
#define OPEN_BSL_CMD_FUNC_TABLE
 
#define ENTRY(cmd, func)   cmd,
 
#define OPEN_BSL_RESP_BIT_MASK   (0x80)
 
#define OPEN_BSL_ASSERT(x)   if(!(x)) OpenBSL_AssertHdl();
 
#define BV(x)   (1 << x)
 
#define OPEN_BSL_ADDR_DATA_SIZE   (sizeof(uint32_t))
 
#define OPEN_BSL_MAX_SEGMENT_READ_WRITE_DATA_SIZE   (32)
 
#define OPEN_BSL_PASSWORD_LENGTH   (8)
 
#define OPEN_BSL_CHKSUM_LEN   (2)
 

Enumerations

enum  OpenBSL_Cmd_t { OPEN_BSL_CMD_SYNC = 0x80 }
 
enum  OpenBSL_Resp_t {
  OPEN_BSL_RESP_OK = 0x00, OPEN_BSL_RESP_ERR_UNKNOWN_CMD = 0xE1, OPEN_BSL_RESP_ERR_UNSUPPORTED_CMD = 0xE2, OPEN_BSL_RESP_ERR_PASSWORD_PROTECTED = 0xE3,
  OPEN_BSL_RESP_ERR_INVALID_PARAM = 0xE4, OPEN_BSL_RESP_ERR_INVALID_FORMAT = 0xE5, OPEN_BSL_RESP_ERR_INVALID_CHECKSUM = 0xE6
}
 

Functions

void OpenBSL_CalcChksum (uint8_t byte, uint16_t *checksum)
 OpenBSL checksum calcuation routine - based on the simple BSD checksum algorithm. More...
 
void OpenBSL_DevInit (void)
 device/HW initialization function for OpenBSL More...
 
bool OpenBSL_EntryCheck (void)
 check whether it is necessary to run BSL or application More...
 
void OpenBSL_AssertHdl (void)
 assert handle function More...
 
void OpenBSL_Jump (memAddr_t addr)
 run application, leave BSL mode More...
 
void OpenBSL_ProcGetMemInfo (void)
 send memory info regarding on-chip non-volatile memory More...
 
void OpenBSL_ProcEraseImg (void)
 erase application image/memory area More...
 
void OpenBSL_ProcDnldImg (void)
 download/write incoming byte streams to application image/memory area, ended with 2 checksum bytes More...
 
void OpenBSL_ProcUpldImg (void)
 upload/read application image/memory area as byte streams, ended with 2 checksum bytes More...
 
void OpenBSL_ProcCalcChksm (void)
 calculate 2 checksum bytes of given memory area More...
 
void OpenBSL_ProcEraseSegment (void)
 erase certain part of application image/memory area More...
 
void OpenBSL_ProcDnldSegment (void)
 download/write input bytes to certain part of application image/memory area More...
 
void OpenBSL_ProcUpldSegment (void)
 upload/read bytes from certain part of application image/memory area More...
 
void OpenBSL_ProcPwdCmd (void)
 process incoming password to unlock other commands More...
 
void OpenBSL_ProcJumpToAddr (void)
 process command to jump to certain given address More...
 
void OpenBSL_ProcRunApp (void)
 process command to run application (jump to application reset vector at address APP_MEM_RESET_VECT_ADDR More...
 
void OpenBSL_CommInit (void)
 device/HW initialization communication module function for OpenBSL More...
 
uint8_t OpenBSL_CommRcvByte (void)
 receive a single byte from communication line - blocking function More...
 
uint8_t OpenBSL_CommRcvByteChksum (void)
 receive a single byte from communication line and update the OpenBSL_InChecksum checksum variable - blocking function More...
 
uint16_t OpenBSL_CommRcvShort (void)
 receive a two bytes data (16 bit) from communication line - blocking function More...
 
uint16_t OpenBSL_CommRcvShortChksum (void)
 receive a two bytes data (16 bit) from communication line and calculate/update the OpenBSL_InChecksum checksum variable - blocking function More...
 
uint32_t OpenBSL_CommRcvLong (void)
 receive a four bytes data (32 bit) from communication line - blocking function More...
 
uint32_t OpenBSL_CommRcvLongChksum (void)
 receive a four bytes data (32 bit) from communication line and calculate/update the OpenBSL_InChecksum checksum variable - blocking function More...
 
void OpenBSL_CommSendByte (uint8_t byte)
 send a single byte to communication line - blocking function More...
 
void OpenBSL_CommSendByteChksum (uint8_t byte)
 send a single byte to communication line and update the OpenBSL_OutChecksum checksum variable - blocking function More...
 
void OpenBSL_CommSendShort (uint16_t val)
 send a two bytes (16 bit) value to communication line in little endian byte order (LSB first) - blocking function More...
 
void OpenBSL_CommSendShortChksum (uint16_t val)
 send a two bytes (16 bit) to communication line and update the OpenBSL_OutChecksum checksum variable - blocking function More...
 
void OpenBSL_CommSendLong (uint32_t val)
 send a four bytes (32 bit) value to communication line in little endian byte order (LSB first) - blocking function More...
 
void OpenBSL_CommSendLongChksum (uint32_t val)
 send a four bytes (32 bit) to communication line and update the OpenBSL_OutChecksum checksum variable - blocking function More...
 
void OpenBSL_MemInit (void)
 device/HW initialization memory module function for OpenBSL More...
 
uint8_t OpenBSL_MemReadByte (memAddr_t address)
 read byte from device memory More...
 
void OpenBSL_MemOpenForErase (uint8_t section)
 open memory for erase operation More...
 
void OpenBSL_MemErase (memAddr_t address)
 erase an address/segment from device memory More...
 
void OpenBSL_MemCloseForErase (uint8_t section)
 close memory for erase operation More...
 
void OpenBSL_MemOpenForWrite (uint8_t section)
 open memory for write operation More...
 
void OpenBSL_MemWrite (uint8_t byte, memAddr_t address)
 write byte to device memory More...
 
void OpenBSL_MemCloseForWrite (uint8_t section)
 close memory for write operation More...
 
uint8_t OpenBSL_MemChkSection (memAddr_t address, memAddr_t end)
 check for validity of a given memory section parameter More...
 
uint32_t OpenBSL_MemSgmntGetSize (uint8_t section)
 get device memory segment size More...
 

Variables

uint16_t OpenBSL_InChecksum
 
uint16_t OpenBSL_OutChecksum
 

Detailed Description

OpenBSL internal header file.

Version
0.1
Remarks

Macro Definition Documentation

#define OPEN_BSL_CMD_FUNC_TABLE
Value:
ENTRY(OPEN_BSL_CMD_GET_MEM_INFO = 0x00, OpenBSL_ProcGetMemInfo) \
ENTRY(OPEN_BSL_CMD_ERASE_IMAGE = 0x01, OPEN_BSL_FUNC_PROC_ERASE_IMAGE) \
ENTRY(OPEN_BSL_CMD_DOWNLOAD_IMAGE = 0x02, OPEN_BSL_FUNC_PROC_DOWNLOAD_IMAGE) \
ENTRY(OPEN_BSL_CMD_UPLOAD_IMAGE = 0x03, OPEN_BSL_FUNC_PROC_UPLOAD_IMAGE) \
ENTRY(OPEN_BSL_CMD_RUN_APP = 0x04, OpenBSL_ProcRunApp) \
ENTRY(OPEN_BSL_CMD_CALCULATE_CHECKSUM = 0x05, OPEN_BSL_FUNC_PROC_CALCULATE_CHECKSUM) \
ENTRY(OPEN_BSL_CMD_ERASE_SEGMENT = 0x06, OPEN_BSL_FUNC_PROC_ERASE_SEGMENT) \
ENTRY(OPEN_BSL_CMD_DOWNLOAD_SEGMENT = 0x07, OPEN_BSL_FUNC_PROC_CMD_DOWNLOAD_SEGMENT) \
ENTRY(OPEN_BSL_CMD_UPLOAD_SEGMENT = 0x08, OPEN_BSL_FUNC_PROC_UPLOAD_SEGMENT) \
ENTRY(OPEN_BSL_CMD_PASSWD = 0x09, OPEN_BSL_FUNC_PROC_PASSWORD) \
ENTRY(OPEN_BSL_CMD_JUMP_TO_ADDR = 0x0A, OPEN_BSL_FUNC_PROC_JUMP_TO_ADDR)
void OpenBSL_ProcGetMemInfo(void)
send memory info regarding on-chip non-volatile memory
Definition: OpenBSL_Core.c:309
void OpenBSL_ProcRunApp(void)
process command to run application (jump to application reset vector at address APP_MEM_RESET_VECT_AD...
Definition: OpenBSL_Core.c:1575

OPEN_BSL_CMD_FUNC_TABLE X Macro for OpenBSL commands - processing functions table

#define OPEN_BSL_RESP_BIT_MASK   (0x80)

OPEN_BSL_RESP_BIT_MASK response bit mask for positive response of incoming command

Enumeration Type Documentation

OpenBSL_Cmd_t OpenBSL supported list of commands

OpenBSL_Resp_t OpenBSL supported list of response

Function Documentation

void OpenBSL_AssertHdl ( void  )

assert handle function

OpenBSL_AssertHdl

Parameters
-
Returns
-
void OpenBSL_CalcChksum ( uint8_t  byte,
uint16_t *  checksum 
)

OpenBSL checksum calcuation routine - based on the simple BSD checksum algorithm.

OpenBSL_CalcChksum()

Parameters
[in]byteinput byte
[out]checksumpointer to the checksum buffer
Returns
-
void OpenBSL_CommInit ( void  )

device/HW initialization communication module function for OpenBSL

OpenBSL_CommInit

Parameters
-
Returns
-
uint8_t OpenBSL_CommRcvByte ( void  )

receive a single byte from communication line - blocking function

OpenBSL_CommRcvByte

Parameters
-
Returns
received single byte from communication line
uint8_t OpenBSL_CommRcvByteChksum ( void  )

receive a single byte from communication line and update the OpenBSL_InChecksum checksum variable - blocking function

OpenBSL_CommRcvByteChksum

Parameters
[in]checksumpointer to the checksum buffer to be updated
Returns
received single byte from communication line
uint32_t OpenBSL_CommRcvLong ( void  )

receive a four bytes data (32 bit) from communication line - blocking function

OpenBSL_CommRcvLong

Parameters
-
Returns
received four bytes data from communication line
uint32_t OpenBSL_CommRcvLongChksum ( void  )

receive a four bytes data (32 bit) from communication line and calculate/update the OpenBSL_InChecksum checksum variable - blocking function

OpenBSL_CommRcvLongChksum

Parameters
-
Returns
received four bytes from communication line
uint16_t OpenBSL_CommRcvShort ( void  )

receive a two bytes data (16 bit) from communication line - blocking function

OpenBSL_CommRcvShort

Parameters
-
Returns
received two bytes data from communication line
uint16_t OpenBSL_CommRcvShortChksum ( void  )

receive a two bytes data (16 bit) from communication line and calculate/update the OpenBSL_InChecksum checksum variable - blocking function

OpenBSL_CommRcvShortChksum

Parameters
-
Returns
received two bytes data from communication line
void OpenBSL_CommSendByte ( uint8_t  byte)

send a single byte to communication line - blocking function

OpenBSL_CommSendByte

Parameters
singlebyte to be sent out to communication line
Returns
-
void OpenBSL_CommSendByteChksum ( uint8_t  byte)

send a single byte to communication line and update the OpenBSL_OutChecksum checksum variable - blocking function

OpenBSL_CommSendByteChksum

Parameters
[in]byteinput byte to be sent out
Returns
-
void OpenBSL_CommSendLong ( uint32_t  val)

send a four bytes (32 bit) value to communication line in little endian byte order (LSB first) - blocking function

OpenBSL_CommSendLong

Parameters
[in]val32 bit data to be sent out to communication line
Returns
-
void OpenBSL_CommSendLongChksum ( uint32_t  val)

send a four bytes (32 bit) to communication line and update the OpenBSL_OutChecksum checksum variable - blocking function

OpenBSL_CommSendLongChksum

Parameters
[in]valinput word (32 bit) to be sent out
Returns
-
void OpenBSL_CommSendShort ( uint16_t  val)

send a two bytes (16 bit) value to communication line in little endian byte order (LSB first) - blocking function

OpenBSL_CommSendShort

Parameters
[in]val16 bit data to be sent out to communication line
Returns
-
void OpenBSL_CommSendShortChksum ( uint16_t  val)

send a two bytes (16 bit) to communication line and update the OpenBSL_OutChecksum checksum variable - blocking function

OpenBSL_CommSendShortChksum

Parameters
[in]valinput word (16 bit) to be sent out
Returns
-
void OpenBSL_DevInit ( void  )

device/HW initialization function for OpenBSL

OpenBSL_DevInit

Parameters
-
Returns
-
bool OpenBSL_EntryCheck ( void  )

check whether it is necessary to run BSL or application

OpenBSL_EntryCheck

Parameters
-
Returns
true - run BSL, false - run application
void OpenBSL_Jump ( memAddr_t  addr)

run application, leave BSL mode

OpenBSL_Jump

Parameters
-
Returns
-
uint8_t OpenBSL_MemChkSection ( memAddr_t  start,
memAddr_t  end 
)

check for validity of a given memory section parameter

OpenBSL_MemChkSection

Parameters
[in]startstart address
[in]endend address
Returns
0xFF if not a valid memory area, otherwise index of memory area section
void OpenBSL_MemCloseForErase ( uint8_t  section)

close memory for erase operation

OpenBSL_MemCloseForErase

Parameters
[in]sectionmemory section number to be erased
Returns
-
void OpenBSL_MemCloseForWrite ( uint8_t  section)

close memory for write operation

OpenBSL_MemCloseForWrite

Parameters
[in]sectionmemory section number to be written
Returns
-
void OpenBSL_MemErase ( memAddr_t  address)

erase an address/segment from device memory

OpenBSL_MemErase

Parameters
[in]addressmemory address to be erased
Returns
-
void OpenBSL_MemInit ( void  )

device/HW initialization memory module function for OpenBSL

OpenBSL_MemInit

Parameters
-
Returns
-
void OpenBSL_MemOpenForErase ( uint8_t  section)

open memory for erase operation

OpenBSL_MemOpenForErase

Parameters
[in]sectionmemory section number to be erased
Returns
-
void OpenBSL_MemOpenForWrite ( uint8_t  section)

open memory for write operation

OpenBSL_MemOpenForWrite

Parameters
[in]sectionmemory section number to be written
Returns
-
uint8_t OpenBSL_MemReadByte ( memAddr_t  address)

read byte from device memory

OpenBSL_MemReadByte

Parameters
addressaddress/pointer to the memory address to be read
Returns
-
uint32_t OpenBSL_MemSgmntGetSize ( uint8_t  section)

get device memory segment size

OpenBSL_MemSgmntGetSize

Parameters
[in]sectionmemory section number
Returns
size of the device memory segment size
void OpenBSL_MemWrite ( uint8_t  byte,
memAddr_t  address 
)

write byte to device memory

OpenBSL_MemWrite

Parameters
[in]bytedata byte to be written
[in]addressmemory address to be written
Returns
-
void OpenBSL_ProcCalcChksm ( void  )

calculate 2 checksum bytes of given memory area

OpenBSL_ProcCalcChksm

Parameters
-
Returns
-
void OpenBSL_ProcDnldImg ( void  )

download/write incoming byte streams to application image/memory area, ended with 2 checksum bytes

OpenBSL_ProcDnldImg

Parameters
-
Returns
-
void OpenBSL_ProcDnldSegment ( void  )

download/write input bytes to certain part of application image/memory area

OpenBSL_ProcDnldSegment

Parameters
-
Returns
-
void OpenBSL_ProcEraseImg ( void  )

erase application image/memory area

OpenBSL_ProcEraseImg

Parameters
-
Returns
-
void OpenBSL_ProcEraseSegment ( void  )

erase certain part of application image/memory area

OpenBSL_ProcEraseSegment

Parameters
-
Returns
-
void OpenBSL_ProcGetMemInfo ( void  )

send memory info regarding on-chip non-volatile memory

OpenBSL_ProcGetMemInfo

Parameters
-
Returns
-
void OpenBSL_ProcJumpToAddr ( void  )

process command to jump to certain given address

OpenBSL_ProcJumpToAddr

Parameters
-
Returns
-
Remarks

CMD packet format:

CMD (1 byte) = OPEN_BSL_CMD_JUMP_TO_ADDR ADDR (4 bytes) =

positive RESPONSE packet format:


| RESP |

RESP (1 byte) = OPEN_BSL_CMD_JUMP_TO_ADDR | OPEN_BSL_RESP_BIT_MASK

void OpenBSL_ProcPwdCmd ( void  )

process incoming password to unlock other commands

OpenBSL_ProcPwdCmd

Parameters
-
Returns
-
void OpenBSL_ProcRunApp ( void  )

process command to run application (jump to application reset vector at address APP_MEM_RESET_VECT_ADDR

OpenBSL_ProcRun

Parameters
-
Returns
-
Remarks

CMD packet format:


| CMD | ADDR |

CMD (1 byte) = OPEN_BSL_CMD_RUN_APP

positive RESPONSE packet format:


| RESP |

RESP (1 byte) = OPEN_BSL_CMD_RUN_APP | OPEN_BSL_RESP_BIT_MASK

void OpenBSL_ProcUpldImg ( void  )

upload/read application image/memory area as byte streams, ended with 2 checksum bytes

OpenBSL_ProcUpldImg

Parameters
-
Returns
-
void OpenBSL_ProcUpldSegment ( void  )

upload/read bytes from certain part of application image/memory area

OpenBSL_ProcUpldSegment

Parameters
-
Returns
-