Boot Thread (BLACKSheep OS)

Aus BECOM Systems Support
Version vom 22. August 2023, 20:35 Uhr von en>Peter (1 Version importiert)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Introduction

The file boot_thread.c contains the source of the boot thread of BLACKSheep® OS and it's the first thread that is executed by the VDK. The boot thread is quasi the main function of the application were you can configure the processor, the peripherals, the connected devices and so on. BLACKSheep® OS provides an extended boot thread that helps you configuring your processor and your environment as simple as possible.

The boot thread is subdivided in several sections that can be enabled or disabled by configuring the file Environment.h . The The boot thread starts configuring the processor then proceeds with the initialization of peripherals (i.e. terminal UART), services (i.e. MSD manager, Device manager, MDMA manager) and external devices (i.e. Ethernet PHY, SD Card, USB).

The following section describes the structure of the boot thread and how the sections can be configured by the user.

Boot Thread structure

Order of execution

Processor configuration

The first operation executed by the boot thread is the configuration of the processor. The processor configuration can be found in the section Processor Definitions in Environment.h .

BLACKSheep OS terminal UART

BLACKSheep® OS uses the UART interface for the OS terminal and to print informations about the boot process. BLACKSheep® OS supports two kinds of UART interface for the terminal:

  • BS UART: based on threads and DMA transfers
  • UART: no threads and no DMA transfers

We recommend to use the BS UART as it is works more efficient. The BLACKSheep® OS UART con be configured in the section BS UART in Environment.h .

Asynchronous memory interface

The asynchronous memory interface is configured based on the settings of section Asynchronous Memory in Environment.h .

Flash memory

The Flash memory interface is configured based on the settings of section FLASH Memory in Environment.h .

IO manager

The IO manager is initialized.

Thread descriptor service

The service for the thread descriptors is started.

MSD Manager

The Mass Storage Device manager is initialized.

File Systems

The file systems that should be supported by BLACKSheep® OS are registered to the MSD manager to allow for mounting a MSD partition in the specified file system. The supported file systems are listen in the section File system in Environment.h .

STDIO Support

As the MSD manager can also deal with streaming systems the BS UART is registered for supporting the stdin, stdout and stderr. The UART device is mounted as streaming device and allow to use the standard IO functions such as printf to control the BS UART device.

Boot Loader

The boot thread checks if there is an application stored in the flash. The boot thread stops at this point and starts the user application if an application was found. The boot thread has 3 possibilities to continue without starting the user application:

  • No user application was found
  • Press c within a defined time to abort the application loader
  • The command fwupdate was executed before the boot thread starts. The command fwupdate can be executed by the user application to perform a firmware update on the module. The command writes a special key in the flash memory and then executes a software reset. If the boot thread can find the special key, the key will be erased and the application loader is disabled.

The boot loader behavior can be set in the section Bootloader Behavior in Environment.h .

Environment Table

The environment table that is used to save information on the flash memory to be available at next startup is opened and the information is restored. If no environment table was found, a table is created and the data are set to the default values configured in the section Environment Table, FLASH Memory and Ethernet in Environment.h

MDMA Manager

The MDMA Manager is initialized. The MDMA Manager provides a simple interface to the user to execute Memory-DMA transfers.

SPI interface

The SPI interface is initialized at this point. You can specify which SPI bus should be initialized for future use. Please refer to the processor documentation to check how many SPI interfaces are supported by your processor. You can enable the individual SPI interface in the section SPI interface in Environment.h .

I2C interface

The I2C interface is configured. Since not all processors supports TWI (Two Wire Interface) there are 2 possibilities to initialize the I2C interface:

From user point of view there are no differences between the internal and the emulated I2C interface. If you use the emulated TWI interface, you have to set the GPIOs and the timer used to emulate the TWI interface.

If you want to execute a scan on the I2C bus after initialization to show the devices, the macro I2C_ENABLE_SCANBUS must be declared.

Further settings can set in section I2C interface in Environment.h .

CAN interface

The CAN bus interface supported by some processor is initialized. You can configure the CAN interface in section CAN Interface in Environment.h .

Real Time Clock

The RTC is initialized even if not supported by the processor.

Mass Storage Devices

The supported MSDs can be initialized at this point. By default you can initialize the RAM drive and the SD Card (over SPI and SDH). Refer to Mass Storage Devices for further informations.

User management

The user management is used for login purposes and can be configured in section User Management in Environment.h .

Alive LED

If enabled, a thread controlling a connected LED is started to show that the processor is running. The thread can be configured in section Alive LED in Environment.h .

USB support

The following section can only be executed by processors or core modules supporting USB such as the CM-BF537U or the BF548. BLACKSheep® OS supports the USB OTG of a Blackfin® processor as well as the device [1]. BLACKSheep® OS supports 2 operation modes for the USB interface:

  • Bulk transfer: for data transfer
  • USB Mass Storage Device: the partitions from BLACKSheep® OS can be mounted as USB MSD

The USB interface can be configured in section USB in Environment.h .

Ethernet

BLACKSheep® OS supports following Ethernet PHYs dependent from Blackfin® processor or core module:

  • KSZ8041
  • KSZ8721
  • LAN83C185
  • LAN9218

You can choose your settings in section Ethernet in Environment.h . Here you can set the IP addresses and the MAC address of your platform. Further you can change the hardware interface to the selected PHY device.

Web server

BLACKSheep® OS implements a web server based on the free | GoAhead WebServer. The GoAhead WebServer is a fast and efficient standards-based Web server designed for cross-platform support. The web server allow to install a dynamic web site on your platform and to communicate with your PC in a simple way.

BLACKSheep® OS provides a demo web site that is installed on a partition of your choice and shows a short description of the core module.

There is a HTTP daemon thread started at this point that handles the requirements at the selected port number.

The web server can be configured in section Web Server in Environment.h .

Telnet

A Telnet daemon can be started to provide bidirectional interactive text-oriented communications facility via a virtual terminal connection to BLACKSheep® OK. If enabled, a thread is started in the background that handles the requirements on the selected port number.

The Telnet daemon can be configured in section Telnet in Environment.h .

Shell Commands

The shell commands supported by BLACKSheep® OS are added at this point. You can add or remove commands by uncomment or comment the defined macros in section BLACKSheep Commands in Environment.h .

Syslog Service

The Syslog Service is started. It implements a message queue that is printed when the thread is running. This service allows to print messages during the execution of an ISR (interrupt service routine). Common printf-function cannot be used while executing an ISR.

User Code

If you want to execute a user code at the end of the BLACKSheep® OS boot process, the macro BS_ENABLE_EXECUTE_USER_CODE located in section BLACKSheep in Environment.h must be set to 1. This enables the execution of executeUserCode-function in user_code.c located in the project root directory.

Terminal

At the end of the boot process, the BLACKSheep® OS terminal is executed if the macro _USE_TERMINAL_ is declared. The terminal allows to execute shell commands on BLACKSheep® OS.

You can configure the terminal in section Terminal of Environment.h .