Chia sẻ kiến thức trong lĩnh vực embedded system

Thứ Ba, 16 tháng 7, 2013

Cơ bản về barebox



Barebox là gì?


Barebox là một bộ nạp khởi động mà ở đấy ta dùng để kích khởi phần cứng và khởi tạo linux, và cũng có lẽ dùng với các hệ điều hành khác hoặc các các code khởi tạo với các vi xử lí khác. Nó khởi tạo bắt nguồn từ nguồn gốc của U-Boot và bảo tồn nhiều tính năng của uboot, do đấy nếu người dùng đã quen với U-Boot thì sẽ làm quen nhanh với barebox.



Tuy nhiên, những người phát triển barebox đánh giá rất cao về nhân linux, nó có coding style sạch và chất lượng code rất cao, những người phát triển barebox cũng đang rất cố gắng để làm gần giống như cách linux đã làm. Ngoài ra, họ rất mạnh về POSIX, do đấy, chúng ta có thể tìm nhiều điểm rất hay của hệ thống UNIX cũ trong hệ thống này.






Tại sao có barebox?


Để nguyên văn, vì không biết nên dịch thế nào cho đúng:


"Most embedded Linux developers are familiar with busybox, the Swiss army knife of embedded Linux. barebox aims to be the same Swiss army knife for bare metal; hence, we call it 'barebox'."


Các điểm cần chú ý:
POSIX File API


barebox uses the the well known open/close/read/write/lseek access functions, together with a model of representing devices by files. This makes the APIs familiar to everyone who has experience with Unix systems.
Shell


We have the standard shell commands like ls/cd/mkdir/echo/cat,…
Environment Filesystem


In contrast to U-Boot, barebox doesn't misuse the environment for scripting. If you start the bootloader, it gives you a shell and something that looks like a filesystem. In fact, it isn't: it is a very simple ar archive being extracted from flash into a ramdisk with 'loadenv' and stored back with 'saveenv'.
Filesystem Support


When starting up, the environment is mounted to /, followed by a device filesytem being mounted to /dev in order to make it possible to access devices. Other filesystems can be mounted on demand.
Driver Model (borrowed from Linux)


barebox follows the Linux driver model: devices can be specified in a hardware specific file, and drivers feel responsible for these devices if they have the same name.
Clocksource


We use the clocksource API known from Linux.
Kconfig/Kbuild


This gives us parallel builds and removes the need for lots of ifdefs.
Sandbox


If you develop features for barebox, you can use the 'sandbox' target which compiles barebox as a POSIX application in the Linux userspace: it can be started like a normal command and even has network access (tun/tap). Files from the local filesystem can be used to simulate devices.
Device Parameters


There is a parameter model in barebox: each device can specify its own parameters, which do exist for every instance. Parameters can be changed on the command line with \<devid\>.\<param\>=”…”. For example, if you want to access the IPv4 address for eth0, this is done with 'eth0.ip=192.168.0.7' and 'echo $eth0.ip'.
Getopt


barebox has a lightweight getopt() implementation. This makes it unnecessary to use positional parameters, which can be hard to read.
Integrated Editor


Scripts can be edited with a small integrated fullscreen editor. This editor has no features except the ones really needed: moving the cursor around, typing characters, exiting and saving.




Không có nhận xét nào:

Đăng nhận xét