[RTEMS BSP] graphic support for raspberry pi

Hi,

After three months development under the guide of other RTEMS developers, the graphic support for raspberry pi bsp is about to complete. Here is a resume of all features added and some remarks for users and developpers.

Mailbox:

As introduced in the previous blog, mailbox is the main way for arm cpu to communicate with videocore gpu. The interface contains two functions for read and write data.

for more information, please checkout this blog.

 

VC:

In order to setup the hardware related properties, the mailbox channel arm->vc is used and many interfaces are available. We offer an entry structure for holding data of request or responce with a function to call gpu. With this support we can retrieve most of hardware status (version, power, temperature …..) and also have access to graphic features (framebuffer allocation, color palette etc…).

for more information, please checkout this blog.

 

CMDLINE:

At the first stage of boot, gpu will read the text file config.txt for a BIOS-like configuration, it will also read the single-line text file cmdline.txt and append the content to the kernel command line which will be passed by ATAG structure to kernel later.

As documented in arm cpu documentation, when the kernel started, register r2 will contain the address of  ATAG structures or the devicetree. For the moment, I’ve used the VC interface to get cmdline instead of parsing ATAG and devicetree. As the boot of VC is the early stage, if we use a bootloader linke UBOOT and append more kernel arguments in cmdline, this may cause problems. So for a long term solution, we will implement a more generic way for arm bsps.

The cmdline is initialization by calling rpi_init_cmdline() at the early boot. The we can get the full cmdline by rpi_cmdline() or a substring started with a given string rpi_cmdline_arg(const char* arg). These functions are decalred in header file <bsp.h>.

 

Framebuffer:

As the cmdline is supported , we are allowed to pass arguments to choose the resolution of framebuffer for display. The command line argument format is

–video=<resX>x<resY>[-<bpp>]

where  numbers <resX>, <resY> and <bpp> are decadic. For the moment I’ve only implemented for bpp=32, (32BIT_X888RGB pixel format) which is the most commonly used, so the <bpp> will be ignored. –video=auto can be used for an auto-detection and auto-configuration.

In order to make use of the full memory on board, we have to configure the physic memory size in file /c/src/lib/libbsp/arm/raspberrypi/startup/linkcmds.

MEMORY {
VECTOR_RAM (AIW) : ORIGIN = 0x0 , LENGTH = 0x8000
GPU_RAM (AIW) : ORIGIN = 256M – 64M, LENGTH = 64M
RAM (AIW) : ORIGIN = 0x00008000, LENGTH = 256M – 64M – 48K
RAM_MMU (AIW) : ORIGIN = 256M – 64M – 16k, LENGTH = 16k
}

Here is a setup for a rip with maximum 256M memory and 64M will be used for GPU (by default). If you are using 512M board, please replace all ”’256M”’ by ”’512M”’ so that the memory can be fully used.

Video character output:

With the support of framebuffer, we can draw anything we want and of course, the characters.

At the early stage of boot, _RPI_initVideo() will be called for the initialization of framebuffer and prepare for drawing ASCII characters on the screen. After the init is done, we can have the access to maxCol and maxRow, which stand for the number of characters in a row and the number of rows in the display.

_RPI_outch(char) can be used to output a character on the screen. The scroll of the screen and the ESC sequences are handled automatically by a state machine.

FB console:

Instead of using serial port, we are now able to redirect all to a framebuffer console (fbcons) and use a graphic text console. To choose the fb console, use cmdline argument –console=fbcons.

Graphic libraries:

Previously, we can build the graphic libraries with the script of project rtems-graphic-tool-kits. In order to make it easier to build add-on graphic packages, I’ve ported them all into rtems-source-builder.

To list all available bsets, you can use a command like:

cd rtems-source-builder/rtems;
../source-builder/sb-set-builder –list-bsets

To build a bset, you can use a command like

cd rtems-source-builder/rtems;
../source-builder/sb-set-builder \
–log=graphic-build-log.txt \
–prefix=$HOME/development/rtems/bsps/4.11 \
–with-rtems-bsp=raspberrypi \
–host=arm-rtems4.11   4.11/graphics/t1lib.bset’

If you are using cross-compiling, no installation will be performed. You
may need –pkg-tar-files to creat tar packages and install them manually.
Since microwindows and nxlib depend on previous libraries, they should be
installed afterward.

More usage please checkout RTEMS wiki.

 

codes are available on my github:

*  [https://github.com/yangqiao/rtems rtems Git Repo]
*  [https://github.com/yangqiao/rtems-source-builder rtems-source-builder Git Repo]
*  [https://github.com/yangqiao/rtems-tools rtems-tools Git Repo]

More details of implementations are documented in RTEMS dev wiki

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s