Ultibo-- Raspberry Pi embedded system development tools

    Ultibo The system contains all the basic components of a written entirely in Object Pascal kernel, and required the construction of modern embedded systems. All functions from the USB stack to the network are all written using Object Pascal.

Ultibo core is a full-featured environment for raspberry pie (all models) or on embedded bare metal (no operating system) development. It is not the operating system itself, but provides many of the same operating system services such as memory management, thread, and network file systems. Ultibo core mainly aims to provide common features and services, and to eliminate the need to start from scratch, so the development of embedded application development similar to other platforms as possible, so you can use in many different ways.

You may want to use it only to develop the use of a large number of API to create applications connected devices, or to support general-purpose hardware (such as USB and standard protocols (such as IP, TCP and UDP) or application control calculated by the physical GPIO Alternatively, you You can use it to test embedded operating system design and development, to avoid all content created from scratch, and allows you to have adopted basic knowledge of the environment focused on ideas and concepts to try to take care of.

More advanced users can choose to use Ultibo core as the foundation to explore specific ARM technology (such as TrustZone and hypervisor mode), since you have complete and unrestricted access to the hardware, you can "take over" one or more CPU, The need to use, for example, still allows Ultibo kernel provides basic services such as internet access and logging.

Although Ultibo kernel is not designed for real-time operating system (RTOS), but it offers unlimited access to the hardware, including real-time and allows you to select the components without the need to bypass the operating system functions.

No matter which way you choose, the possibilities are only limited by your imagination.

 

Installation Ultibo kernel


Start embedded programming sometimes takes a few hours of work, then what can write lines of code, Ultibo Windows kernel through simple packaging can download all the pain required to install the program to reduce began.

Setup includes a free Pascal compiler, Lazarus IDE and Ultibo core source, all configured and ready to create the application. From the download get Ultibo core Setup page and save it to a temporary location on your computer.

Ultibo Windows kernel is installed on any computer are quite safe, in addition to the items above, there is no other content installed, and all the contents are contained in a single folder (usually C: [Ultibo] Core). Or even if you have a Lazarus Free Pascal installed, they will not be affected, because Ultibo Core installation to a different folder, and set the official FPC and Lazarus installed separately reserved. If you later decide it's not for you, then you can simply uninstall, all content will be deleted.

You should only download Ultibo core using the official download links on the page, our goal is to provide you with high quality development tool, but there are other people have different intentions.

When you are ready to start double-click Ultibo core Setup file you downloaded, and select the language installed when prompted.

The installer will ask you where to install Ultibo kernel, by default, this will be C: [Ultibo] Core, but if you are fit, you can select a different folder.

Note: Due to limitations in the compiler, you can not choose the path has spaces, such as C: \ Ultibo.

 

There are several other issues after the installation program will continue to copy all the necessary files to a folder of your choice and configure the installation when it is completed, you will see the dialog box shown below. If everything is successful, you can choose to complete and continue creating your first application.

 

Lazarus Introduction


Lazarus is an IDE or integrated development environment that provides the first thing is having syntax highlighting, automatic indentation, and auto-complete source code editor. But it also provides many more advanced features such as code completion, parameter preview, touch navigation and compilation process of integration errors highlighted. You can learn more about Lazarus, as well as through access to documents or via the built-coded to help the many ways to achieve faster encoding.

Lazarus IDE to open the Start menu by selecting the icon.

 

At the top of the screen, you'll find Lazarus main bar, which contains all the menu options for opening, saving and closing projects and files, and allows you to access a range of options to customize what you see on the screen. Main bar also contains a toolbar, which contains some commonly used items, you can add other items by right-clicking and select options.

 

Below the main bar is the source editor, which is edit the code to create an application location. Source editor can have multiple tabs, each tab to open different files, so you can quickly navigate between units of the program.

 

 

Starting a new project


With the introduction, let's do something! The first step is by selecting the item, a new project to launch a new project in Lazarus ... menu.

 


We define some basic project templates, so you can easily start a new project, in addition to the option chosen, there is not much difference between them. Choose one kind of type of raspberry pie available to you.

Tip: To find Raspberry Pi Raspberry Pi projects and 2 distinguish between projects, please see the " Project " , " Project Options ..." , Config and Target  menu.

 

 

Hello World example


Create a new project may leave you in the source editor window of Lazarus (called project1.lpr) and some text. Let's make a new application to become a project work.

请注意,在源编辑器页面的顶部有一行,说,这告诉编译器,这是一个程序,它应该使一个可执行,当我们编译它。如果行以关键字开头,那么这将是一个单元,我们可以在程序中使用,但它不会自行编译为完整的程序。program Project1 unit

Units 是一种非常有用的方式将项目分解为多个部分,以便相关代码可以分组在一起并在多个位置重用。我们现在需要包括几个Ultibo单位,开始创建hello world 的例子。在编辑器中查找从开头的部分,并将其更改为如下所示:uses

uses

 RaspberryPi,

 GlobalConfig,

 GlobalConst,

 GlobalTypes,

 Platform,

 Threads,

 SysUtils,

 Classes,

 Ultibo,

 Console,

 Framebuffer

 { Add additional units here };

请注意,我们将控制台和 Framebuffer 单元添加到列表中,这告诉编译器将它们作为项目的一部分,以便我们可以在代码中使用它们的函数。

在使用部分的正下方和关键字添加新部分之前,我们将稍后解释它的作用:begin

var

 WindowHandle:TWindowHandle;

我们的代码在 和 关键字之间,因为这是一个 hello world 示例,您可能会认为这只是一行,但我们需要一些额外的处理在 Ultibo 的一些内务。我们应用程序的第一行如下所示:begin

end

WindowHandle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);

这将调用控制台单元中的函数,所需的第一个参数是控制台设备,因此我们还会调用获取第一个可用的控制台设备(应只有一个)并将其传递给函数。下一个参数是我们窗口的位置,所以我们传递常量,最终参数告诉函数,如果可以使这个默认窗口,所以我们传递的值。ConsoleWindowCreateConsoleDeviceGetDefaultCONSOLE_POSITION_FULLTrue

函数的结果存储在我们在上面的节中创建的变量中。变量只是存储值的位置,因此您可以反复使用它。ConsoleWindowCreateWindowHandlevar

现在,我们可以在我们刚刚创建的控制台窗口中打印 hello 世界消息。如下所示:

ConsoleWindowWriteLn(WindowHandle,'Hello Ultibo!');

在这里,我们调用函数并传递变量,以便知道文本的写入位置,当然第二个参数是我们想要显示的文本。ConsoleWindowWriteLnWindowHandle

最后,我们需要告诉 Ultibo 核心停止为我们执行此工作的线程。Ultibo 内核始终是多线程的,因此绝不应让启动程序的线程(主线程)退出程序的部分。我们可以通过这样调用来停止线程:begin..endThreadHalt

ThreadHalt(0);

我们你好的世界程序应该看起来像这样现在:

begin

 WindowHandle:=ConsoleWindowCreate(ConsoleDeviceGetDefault,CONSOLE_POSITION_FULL,True);

 ConsoleWindowWriteLn(WindowHandle,'Hello Ultibo!');

 ThreadHalt(0);

end.

编译项目


我们最好先保存我们的示例,以便以后找到它,选择项目,保存项目...并选择一个文件夹保存到,可能最好在某处创建新文件夹,并记住该文件夹的名称中不应有任何空格。如果您愿意,可以将项目文件的名称更改为 project1.lpr 以外的内容。

要编译我们的示例,我们需要创建一个链接器脚本和一个makefile,并下载一个工具链...,不,我们不需要这样做!

只需选择"运行",在菜单中编译,Lazarus 将传递到 Free Pascal 所需的所有信息,这将创建可执行文件。

 

如果消息窗口中的顶行(源编辑器下方)变为绿色,则编译成功,应用程序可以进行测试。

制作可引导的 SD


要测试应用程序,您需要 SD 卡,几乎任何大小都会执行,因为应用程序将小于 2MB。SD 卡需要使用 FAT 文件系统进行格式化(大多数是在获取它们时格式化),并且需要将这些文件复制到根目录:

bootcode.bin

start.elf

fixup.dat

kernel.img OR kernel7.img

前三个是树莓派固件的一部分,您可以在 Ultibo 核心安装下的固件文件夹中找到(通常为C:\Ultibo\Core\firmware),或者您可以在树莓派固件GitHub 页面下载最新版本,第四个固件将在您将示例项目保存到的文件夹中找到。如果你的项目是树莓A,B,A+,B+或零,那么文件将是kernel.img,如果你选择了树莓派2B或3B,当你开始该项目,那么文件将是kernel7.img代替。

测试项目


关闭并拔下您的树莓派,如果它已经在做其他事情,删除任何SD卡当前在插槽中,并插入一个你复制的文件到上面。

插上电源,在大约 2 到 3 秒内,您应该会看到显示"Hello Ultibo!" 消息的屏幕。

如果没有,请检查电源是否已连接,SD 卡是否正确插入,请检查监视器是否连接到树莓派上的 HDMI 端口,并且显示器已通电,然后重试。

接下来呢?


Ultibo 核心安装中包括许多示例,可用于探索 Ultibo core 和pascal 编程。这些示例从 hello world 开始,以便您可以跳过该功能并完成各种不同的功能,最后以功能齐全的 Web 服务器作为最后一个示例。

要尝试示例,只需选择"Tools",Example Projects

 

官网地址:
https://ultibo.org/

Ultibo Core下载:
https://github.com/ultibohub/Core/releases/download/2.0.029/Ultibo-Core-2.0.029-Beetroot.exe

Ultibo Sources下载:
https://github.com/ultibohub/

Guess you like

Origin www.cnblogs.com/qiufeng2014/p/12434736.html