GitHub on Fuchsia project related articles translation-Getting Started (FUCHSIA-MIRROR/MAGENTA/GETTING_STARTED.MD)

Source: Internet
Author: User
Tags require system log git clone automake

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. Quick Start Recipes- QuickStart

For the purpose of this document, we'll assume that Magenta was checked out in $SRC/magenta and that we'll build Toolch Ains, QEMU, etc alongside that. Various make invocations is presented with a '-j32 ' option for parallel make. If that's excessive for the machine you ' re building on, Try-j16 or-j8.

This article will introduce the compilation process of magenta and related tools: First download magenta source code, and put in $src/magenta directory, and then compile toolchains,qemu and magenta source code.
During compilation, adding the-J32 option after the Make command allows the machine to speed up in parallel compilation, and if the machine you are using does not support the-J32 option, try-j16 or-j8. Preparing The build environment-ready to build the environment

On Ubuntu This should obtain the necessary pre-reqs:
The Ubuntu environment runs the following command:

sudo apt-get install texinfo libglib2.0-dev autoconf libtool libsdl-dev build-essential

On Mac with homebrew:
Run the following command in a Mac system with homebrew:

Brew Install wget pkg-config glib autoconf automake libtool

On Mac with MacPorts:
Run the following command in a Mac system with MacPorts:

Port install autoconf automake libtool libpixman pkgconfig glib2
Install Toolchains-installation Toolchains

If you ' re developing on Linux or OSX, there is prebuilt toolchain binaries avaiable. Just run this script from your Magenta working directory:
If you are developing on a Linux or OSX system, the operating system typically comes with precompiled toochain, just run the following command in the Magenta directory:

./scripts/download-toolchain
build Toolchains (Optional)-compile toolchain (optional)

If the prebuilt toolchain binaries does not work for you, there is a set of scripts which would download and build suitable GCC toolchains for building Magenta for ARM32, ARM64, and x86-64 rchitectures:
If the above command is not valid, download the applicable GCC toolchain tool and the command is as follows:

CD $SRC
git clone https://fuchsia.googlesource.com/third_party/gcc_none_toolchains
cd Toolchains
. Doit-a ' arm aarch64 x86_64 '-f-j32
build qemu-Compile Qemu

You can skip this if you ' re only testing on actual hardware, but the emulator are handy for quick local tests and generally Worth has around.

You can skip this step if you only want to test on a real-world hardware environment. However, when doing some local testing, the simulator will be more convenient and faster, it is worth the installation.

If you don ' t want to install in/usr/local (the default), which'll require you to be root, add–prefix=/path/to/install (perhaps $HOME/qemu) and then your ' ll need to add/path/to/install/bin to your path.

If you want to install QEMU to the default/usr/local directory, then you need root privileges and run the following command directly, if you want to specify the installation path, simply add the parameter –prefix=/path/to/install after the./configure Command ( Where path represents the path you want to install, possibly $HOME/qemu), remember to modify the PATH environment variable when the installation is complete and add the installation path to path.

CD $SRC
git clone https://fuchsia.googlesource.com/third_party/qemu
cd qemu
git checkout fuchsia
. Configure--target-list=arm-softmmu,aarch64-softmmu,x86_64-softmmu
make-j32
sudo make install
Configure path– Configuring the PATH environment variable

If you ' re using the prebuilt toolchains, you can skip this step, since the build would find them automatically.

If your operating system comes with precompiled Toochain (see "Install Toolchains-Install Toolchains") You can skip this step because path is configured automatically. Otherwise, you will need to run the following command.

# on Linux
export path= $PATH: $SRC/toolchains/aarch64-elf-5.3.0-linux-x86_64/bin
export path= $PATH: $SRC/ Toolchains/x86_64-elf-5.3.0-linux-x86_64/bin

# on Mac
export path= $PATH: $SRC/toolchains/ Aarch64-elf-5.3.0-darwin-x86_64/bin
export path= $PATH: $SRC/toolchains/x86_64-elf-5.3.0-darwin-x86_64/bin
build magenta– Compile Magenta

Build results'll is in $SRC/magenta/build-{qemu-arm64,pc-x86-64}

The variable $BUILDDIR in examples below refers to the build output directory for the particular build in question.

After you execute the following command, the compilation results are saved at the src/magenta/build-{qemu-arm64,pc-x86-64} location. The $src/magenta in the command refers to the compiled output directory.

CD $SRC/magenta

# for aarch64
make-j32 magenta-qemu-arm64

# for x86-64
make-j32 magenta-pc-x86-64
run Magenta under Qemu–qemu Magenta
# for Aarch64
./scripts/run-magenta-arm64

# for i686
./scripts/run-magenta-x86-64

The-h flag would list a number of options, including things like-b to rebuild first if necessary and-g to run with a GRA Phical framebuffer.

To exit QEMU, enter Ctrl-a x. Use ctrl-a h to see other commands.

When you run the command with the-h parameter, the system displays an optional list of parameters for the command, such as the-B parameter to recompile the project as needed before running, and the-G parameter to run under the graphical interface.
If you want to exit QEMU, you can type Ctrl-a x. If you want to view additional commands, type ctrl-a H. Building Magenta for all targets– compile all targets

# THE-R enables release builds as well
./scripts/buildall-r

Please build the targets before submitting to ensure builds.
To allow magenta to compile in all architectures, you need to run the above command to compile all the targets. enabling Networking under Qemu (x86-64 only) –qemu activating the network module

The run-magenta-x86-64 script, when given the-n argument would attempt to create a network interface using the Linux tun/t AP Network device named "Qemu". Qemu does not need to being run with any special privileges for this, but you need to create a persistent Tun/tap device Ahea D of time (which does require you is root):

When you run the run-magenta-x86-64 script (see "Build magenta– Compile Magenta") and add the-n parameter after the command, the system creates an interface for the TUN/TAP virtual network device called "QEMU". QEMU does not require special permissions to run it, but you need to create a TUN/TAP virtual network device for the interface in advance of root.
The first line of the following command installs the toolkit used by Tunctl, and the second line is used to create a TUN/TAP virtual network device called QEMU, which is owned by $user and the third row is enabled for the device.

sudo apt-get install uml-utilities
sudo tunctl-u $USER-t qemu
sudo ifconfig qemu up

This was sufficient to enable link local IPv6 (as the Loglistener tool uses).
This command is valid for the IPV6 protocol. including Additional userspace files– contains user space files

The Magenta build creates a bootfs image containing necessary userspace the system to boot (the device mana GER, some device drivers, etc). The kernel is capable of including a second BOOTFS image which are provided by Qemu or the bootloader as a ramdisk image.

Compiling magenta creates a bootfs image file that contains the user space components necessary for system startup, such as Device Manager, device driver, and so on (what is Bootfs and Rootfs Baidu). In addition, the kernel can contain another memory image of Bootfs created by QEMU or bootloader.

To create such a bootfs image with the Mkbootfs tool that's generated as part of the build. It can assemble a bootfs image for either source directories (in which case every file in the specified directory and its Subdirectories is included) or via a manifest file which specifies on a file-by-file basis which files to include.

The tool used to create the BOOTFS image is the MKBOOTFS generated after magenta compilation. Mkbootfs can complete the creation of a BOOTFS image file by specifying the source folder directory or specifying a manifest file. Whichever method you use, make sure that all the files you need to create the image are included.
See the following command, the first and fourth lines are the creation process for the specified directory and manifest, respectively.

$BUILDDIR/tools/mkbootfs-o extra.bootfs @/path/to/directory

echo "issue.txt=/etc/issue" > Manifest
echo " Etc/hosts=/etc/hosts ">> manifest
$BUILDDIR/tools/mkbootfs-o extra.bootfs Manifest

On the booted Magenta system, the files in the Bootfs would appear under/boot, so in the above manifest example, the "host S "file would appear at/boot/etc/hosts.

After the magenta is started, the Bootfs file is saved in the/boot directory. For example, the Hosts file in the above command, in the boot system, its directory location should be/boot/etc/hosts.
  
For Qemu, use the-x option to specify an extra bootfs image.

In the case of QEMU, add the-x parameter to the command to specify a second BOOTFS memory image. Network booting

The gigaboot20x6 Bootloader speaks a Simple Network boot protocol (over IPV6 UDP) which does no require any special host Configuration or privileged access to use.

In this article, the bootloader we use is gigaboot20x6, which enables a network boot protocol based on IPV6 UDP and does not require special configuration and permissions to use this protocol.

It does the taking advantage of IPV6 Link Local addressing and multicast, allowing the device being booted to Advertis e its bootability and the host to find it and send a system image to it.

The purpose of this is to use the local link address and multicast address of the IPV6 to allow the host to automatically know and locate the bootloader device (which may be a mini computer host) and transfer the system image to it.

If you had a device (for example a Broadwell or Skylake the Intel NUC) running gigaboot20x6, you can boot Magenta on it like So

If you have a device running gigaboot20x6 (such as a Broadwell or Skylake Intel NUC, a mini PC host that doesn't know what Baidu is), run the following command to enable magenta on that device.

$BUILDDIR/tools/bootserver $BUILDDIR/magenta.bin

# If you have a extra bootfs image (see above):
$BUILDDIR/ Tools/bootserver $BUILDDIR/magenta.bin/path/to/extra.bootfs

By default Bootserver would continue to run and every time it obsveres a netboot beacon it would send the kernel (and Bootfs If provided) to that device. If you pass the-1 option, Bootserver would exit after a successful boot instead.

The bootserver in the above command is a tool that is generated after magenta is compiled, and it is useful to find the device to be started (how to find it). The first two paragraphs of this section are described) and copy the magenta image file to it. Bootserver is a program that runs continuously, and whenever it discovers a network boot request, it sends the kernel image file to the device to be started. After the command is added with the-1 parameter, the Bootserver will automatically exit after the send completes the mirror. Network Log Viewing

The default build of Magenta includes a network log service that multicasts the system log over the link local IPv6 UDP. Please note that this is a quick hack and the protocol would certainly change at some point.

When Magenta is compiled, it comes with a network log service, which is multicast system logs via the IPV6 UDP local link.

For now, if you ' re running Magenta on Qemu with The-n flag or running on hardware with a supported Ethernet interface (AS IX USB Dongle or Intel Ethernet on NUC), the Loglistener tool would observe logs broadcast over the local link:

Whether you are on QEMU (running the command to the-n parameter) or running the magenta system on a networked hardware device, the Loglistener tool can monitor the broadcast behavior of the system log.
The command is as follows:

$BUILDDIR/tools/loglistener

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.