5.3.1.3.2.1. cli.cmd_bootloader.bootloader.Bootloader

class cli.cmd_bootloader.bootloader.Bootloader(interface: BootloaderInterface, app: Path = WindowsPath('D:/_github/foxbms-2/build/app_ti_arm_cgt/src/app/main/foxbms.bin'), crc_table: Path = WindowsPath('D:/_github/foxbms-2/build/app_ti_arm_cgt/src/app/main/foxbms.crc64.csv'), program_info: Path = WindowsPath('D:/_github/foxbms-2/build/app_ti_arm_cgt/src/app/main/foxbms.crc64.json'))

Bases: object

Implementation of the communication between host-implementation of the bootloader and the embedded bootloader.

check_target() → tuple[int, BootloaderStatus]

Check if the bootloader can be reached and print its current status.

Returns:

0 if everything is successful. 1 if only partial information can be received from bootloader. 2 if the foxBMS application is running. 3 if the foxBMS master board can not be reached at all.

reset_bootloader() → bool

Reset bootloader

Returns:

True if the bootloader has been successfully reset, False otherwise.

run_app() → bool

Run application on bootloader

Returns:

True if bootloader has been successfully informed to run application, False otherwise.

send_and_validate_vector_table() → bool

Send vector table to the bootloader

Returns:

True if vector table has been successfully sent, False otherwise

send_app_binary(bl_info: BootloaderStatus, show_progressbar: bool = True, times_of_repeat: int = 2) → bool

Transfer the app binary to the embedded bootloader

Parameters:
  • bl_info – Instance of a database type BootloaderStatus, which attributes are can_fsm_state, boot_fsm_state and current_num_of_loops.

  • show_progressbar – True, show the progress progressbar while uploading the binary.

  • times_of_repeat – Times to repeat sending the application binary if it fails, e.g., if the value is 2, there will be 3 attempts in total to send the application.

Returns:

True if the app binary has been successfully sent.

send_app_data(i_loop: int, progressbar: ProgressBar[TypeAliasForwardRef('typing.Any')] | None = None) → bool

Send the application binary file as data in 8 bytes (and calculated crc in 8 bytes) to the embedded bootloader.

Parameters:
  • i_loop – the start data loop number (must be 1 or greater).

  • progressbar – optional progress bar to update during transfer.

send_data_as_a_sector(i_loop: int, total_num_of_loops: int, size_of_sector_in_loops: int, times_of_repeat: int = 3, progressbar: ProgressBar[TypeAliasForwardRef('typing.Any')] | None = None, progressbar_sector_steps: int = 0) → bool

Send data of one sector to the embedded bootloader.

Parameters:
  • i_loop – start loop number

  • total_num_of_loops – total loop number

  • size_of_sector_in_loops – number of loops contained in this sector.

  • times_of_repeat – time to repeat if a subsector cannot be successfully sent

  • progressbar – optional progress bar to update while sending data.

  • progressbar_sector_steps – number of progress bar steps assigned to this sector.

Returns:

True if this sector data has been successfully sent, False otherwise

send_data_as_a_sub_sector(i_loop_start: int, i_loop_end: int, is_first_sub_sector: bool = True) → bool

Send one sub-sector of data to bootloader.

Parameters:
  • i_loop_start – start index of data loops to send (min. 1)

  • i_loop_end – end index of data loops to send

  • is_first_sub_sector – True if this is the first subsector in the current sector transfer.

Returns:

True if the data has been successfully sent, False otherwise

send_pre_info() → bool

Send CAN message to the embedded bootloader to let the embedded bootloader prepare for receiving the application data.

Returns:

True if the pre-info has been successfully sent to the bootloader, False otherwise.