Digilent Arty board and Linux - Part 3 - Linux Kernel Image

 We created a basic FPGA system capable to run Linux in the Part 1 and generated the Device Tree file in the Part 2. At this time we will compile the Linux Kernel obtaining an image ready to be launched on our hardware synthesized into the Arty board.

 First thing we need is a computer running Linux, I always have some virtual machines to run with each OS depending on the task to perform. 

  • Install all needed dependencies for the compilation.
     
    sudo apt-get install build-essential bison flex gettext libncurses5-dev texinfo autoconf automake libtool
  • We need to include our device tree information so we create the board/arty folder and copy our artylinux.dts file into it.
     
    mkdir board/arty
    cp ../../artylinux.dts board/arty/
  • The next step is to define the kernel properties. This procedure can be done through different ways but the most graphical is to use the menuconfig option from the makefile. You can learn and play a lot searching on the internet. Here you can include packages, binaries or even package managers. Take into account that our Flash space is not too high (about 7MB), rememeber that we are into embedded world, not a general application computer ;)
    Here I present the selected properties to generate the _defconfig file. The _defconfig file is merely the text file with the output of the make menuconfig. 
     
            Target options
                    Target Architecture: Microblaze AXI (little endian)
                    Target Binary Format: ELF
            Build options
                    Commands
                            (wget --passive-ftp -nd -t 3) Wget command
                            (svn) Subversion (svn) command
                            (bzr) Bazaar (bzr) command
                            (git) Git command
                            (cvs) CVS command (NEW)
                            (tcp) Local files retrieval command (NEW)
                            (scp) Secure copy (scp) command (NEW)
                            (ssh) Secure shell (ssh) command (NEW)
                            (hg) Mercurial (hg) command (NEW)
                            (gzip -d -c) zcat command (NEW)
                            (bzcat) bzcat command (NEW)
                            (xzcat) xzcat command (NEW)
                            ()  Tar options (NEW)
                    ($(CONFIG_DIR)/defconfig) Location to save buildroot config
                    ($(TOPDIR)/dl) Download dir (NEW)
                    ($(BASE_DIR)/host) Host dir (NEW)
                    Mirrors and Download locations
                            (http://sources.buildroot.net) Backup download site (NEW)
                            (https://www.kernel.org/pub) Kernel.org mirror (NEW)
                            (http://ftp.gnu.org/pub/gnu) GNU Software mirror (NEW)
                            (http://rocks.moonscript.org) LuaRocks mirror (NEW)
                            (http://cpan.metacpan.org) CPAN mirror (Perl packages) (NEW)
                    (0) Number of jobs to run simultaneously (0 for auto) (NEW)
                    NO Enable compiler cache
                    NO Show options and packages that are deprecated
                    NO build packages with debugging symbols
                    strip command for binaries on target (strip)
                    () executables that should not be strupped
                    ()  directories that should be skipped when stripping (NEW)
                    gcc optimization level (optimize for size)
                    NO build code with Stack Smashing Protection (NEW)
                    libraries (shared only)
                    ($(CONFIG_DIR)/local.mk) location of a package override file (NEW)
                    ()  global patch directories
                    Advanced
                            None
            Toolchain[*] Linux Kernel
                            Kernel version (4.3)
                            () Custom kernel patches (NEW)
                            Kernel configuration /Using a custom (def) config file)
                            (board/arty/artyLinux_defconfig) Configuration file path
                            () Additional configuration fragment files (NEW)
                            Kernel binary format (simpleImage)
                            -*- Build a Device Tree Blob (DTB)
                                    Device tree source (Use a custom device tree file)
                            (board/arty/artylinux.dts) Device Tree Source file paths
                            Linux Kernel Extensions
                                    None
                            Linux Kernel Tools
                                    None
            Target Packages
                    -*- BusyBox
                    (package/busybox/busybox.config) BusyBox configuration file to use? (NE$
                    ()    Additional BusyBox configuration fragment files (NEW)
                    [ ]   Show packages that are also provided by busybox (NEW)
                    [ ]   Enable SELinux support (NEW)
                    [ ]   Install the watchdog daemon startup script (NEW)
                    Audio and video applications  --->
    
                    Compressors and decompressors  --->
                    Debugging, profiling and benchmark  --->
                    Development tools  --->
                    Filesystem and flash utilities  --->
                    Fonts, icons, sounds and themes  --->
                    Games  --->
                    Graphic libraries and applications (graphic/text)  --->
                    Hardware handling  --->
                    Interpreter languages and scripting  --->
                    Libraries  --->
                    Mail  --->
                    Miscellaneous  --->
                    Networking applications  --->
                    Package managers  --->
                    Real-Time  ----
                    Security  --->
                    ...
            Filesystem images
                    [ ] axfs root filesystem (NEW)
                    [ ] cloop root filesystem for the target device (NEW)
                    [ ] cpio the root filesystem (for use as an initial RAM filesystem) (NE$
                    [ ] cramfs root filesystem (NEW)
                    [ ] ext2/3/4 root filesystem (NEW)
                    *** initramfs needs a Linux kernel to be built ***
                    *** iso image needs a Linux kernel and one of grub, grub2 or isolinux t
                    [ ] jffs2 root filesystem (NEW)
                    [ ] romfs root filesystem (NEW)
                    [ ] squashfs root filesystem (NEW)
                    [*] tar the root filesystem (NEW)
                    Compression method (no compression)  --->
                    ()    other random options to pass to tar (NEW)
                    [ ] ubifs root filesystem (NEW)
                    [ ] yaffs2 root filesystem (NEW)
            Bootloaders
                    NO Bootloader
            Host Utilities
                    NO Host utilites
            Legacy config options
                    NO Legacy config options

 If you want to try my _defconfig file with my configuration, here are the generated files [first] [second].

  •  Locate each file in the following folders:
    • buildroot-2015.11/board/arty/artylinux_defconfig
    • buildroot-2015.11/configs/arty/artylinux_defconfig
       
  • From the buildroot-2015.11 root directory, type: 
     
    make arty_artylinux_defconfig
    make

At this moment buildroot will do its magic. To download all dependencies, binutils, patches, gcc, etc, compile the crosstool, libs and compile the linux kernel.

The output binary file can be found at buildroot-2015.11/output/images/simpleImage.artylinux

The next step will be to load the image into the Arty board and to launch it, see it in the Part 4

 

 

AttachmentSize
buildroot-2015.11.tar.gz5.21 MB
artylinux_defconfig1.77 KB
arty_artylinux_defconfig891 bytes

Comments

Thank you! It works! VERY

Thank you! It works! VERY COOL!

Could you explain couple of things for the future use?
For example how to add other software to linux image?

I tried to add Midnight Commander (MC) via "menuconfig" options.
So in .config file this string was added:
BR2_PACKAGE_MC=y
Also automatically these strings were added too:
BR2_PACKAGE_ZLIB=y
BR2_PACKAGE_LIBFFI=y
BR2_PACKAGE_LIBGLIB2=y
BR2_PACKAGE_SLANG=y

After that I rebuilded linux image via "make" command.
Image became bigger (12 MB instead of 6 MB).
I loaded it via xmd console. Linux booted up normally.
Now it knows "mc" command, but after execution nothing happens.
Just carriage return and nothing more.
Ctrl+C be able to break execution and go back to console.

May be Midnight Commander has any hardware requirements (may be video adapter or so on) ? Should I try another package? Or my original way was wrong, isn't it ?

Thanks again!

Hi again!! Nice to know that

Hi again!!

Nice to know that you now have your Linux running!

The way to add software is a little different than the common way. Of course you cannot get the compiler running into the system so the way is to cross-compile the software in your computer an then move compiled program to the system.

As you said, 12MB are slightly bigger, enought to be hard to save it into the Flash memory (only 16 MB) if you want the fpga config, bootloader and non-volatile user files to be storaged too, but should be no problem if you upload the image and launch the execution directly into the RAM memory as you have 256 MB.

I do not know why your file manager is not running, try to check the log if any. It runs over the terminal with no GUI so should be no problem to run it on your system. Give me the details if you finally manage to run it ;)

Best Regards

Hi! I'm trying to repeat all

Hi!

I'm trying to repeat all yours steps.

Could you explain a little more about config files?

Second config file - arty_artylinux_defconfig
>BR2_microblaze=y
>BR2_microblazeel=y
>BR2_TARGET_GENERIC_GETTY_PORT="ttyUL0"
>BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
>...
- is a result of "make menuconfig" isn't it ? This is clear.

How to create first config file (artylinux_defconfig)?
>CONFIG_EXPERIMENTAL=y
>CONFIG_SYSVIPC=y
>CONFIG_IKCONFIG=y
>...
>CONFIG_KERNEL_BASE_ADDR=0x80000000
>CONFIG_FLAT_NODE_MEM_MAP=y
>CONFIG_XILINX_MICROBLAZE0_FAMILY="artix7"
>CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR=1
>...

Is there any template or guide how to create config file with microblaze parameters included?

Thanks!

Kernel configuration

 Hello Ululuk22,
you are right, one is generated with make menuconfig and the second one is the running "make linux-menuconfig". There you can select all kernel options, like the processor settings or kernel packages. You will need to get the config from output/build/linux folder.
Check the Buildroot guide for more details:
https://buildroot.org/downloads/manual/manual.html
Best regards and good luck!

Link is wrong

Hi!

Link for arty_artylinux_defconfig
should be http://rdepablos.merlitec.com/sites/default/files/arty_artylinux_defconfig

You are totally

You are totally right!
Thanks! Now it is fixed :)