Build the Linux Kernel, BusyBox, glibc and Dropbear for ARM and run them on QEMU



This post is an combination of Mitchel Humphery's post @ link and Beyond Logic's post @ link. It gives step-by-step instructions for building a minimal custom Linux kernel, creating a userland with BusyBox and Dropbear, linking both to glibc and booting everything on an emulated (QEMU) versatile-pb ARM.


Environment

  • T460

  • Oracle VM VirtualBox Version 5.1.30 r118389 (Qt5.6.2) running on Windows 7 SP1

  • VM's configured with 4 GB of RAM and a 64 GB disk running Ubuntu 16.04.2.

If you need help setting up this environment click here (just install 16.04.02 instead of 16.04.01).



Steps


1. Open a terminal


2. Retrieve new lists of packages

You'll see something like:


3. Get the required packages:

You'll see something like:

...or:


4. Create a workspace:


5. Download and extract the Linux kernel, BusyBox glibc and Dropbear

You'll see something like:


6. Create a minimal userland with Busybox

You'll see something like:


Note: you can enable options in Busybox using this command (these instructions do not require and options to be turned on or off).


7. Build and Install Busybox

You should see something like:


8. Configure glibc

You should see something like:


9. Build glibc

You should see something like this (some of the logs beginning has been chopped):



10. Configure Dropbear

You should see something like:


11. Build Dropbear

You should see something like:


12. Build the directory structure of the initramfs

You should see something like (end of output shown):



13. Create init and make it executable


13.1 Type:

13.2 Paste this in (press i)

13.3 Type :w to save, then :q to quit



14. Make init executable:


15. Add /usr/lib to ldconfig's search path


16. Create the initramfs:


17. Config the Linux kernel with the minimal config

You'll see something like:


18. Turn options on for QEMU:


19. Turn these options on:

This writes .config to $TOP/obj/linux-arm-versatile_defconfig


Use ls -a $TOP/obj/linux-arm-versatile_defconfig to check



20. Make the kernel:

You should see something like:


21. Launch the Linux kernel binary & initrd in QEMU:

You should see something like:


22. To check that busybox finds glibc, type:

You should see something like


23. Check if Dropbear runs by typing:

You should see something like:



24. Type Control-a x to quit QEMU



References

  • Building a minimal RootFS with Busybox, GLIBC and DropBear @ [link]

  • Configuring and compiling the GNU C Library @ [link]

  • BusyBox @ [link]

  • The LD_DEBUG environment variable @ [link]

  • Installing the C Library @ [link]

  • Documentation/Platforms/ARM @ [link]

  • Versatile Express support in QEMU @ [link]

  • Automatically answer defaults when doing 'make oldconfig' on a kernel tree @ [link]

  • this architecture does not have kernel memory protection @ [link]

  • Build the Linux Kernel and Busybox and run them on QEMU @ [link]

  • Build Your ARM Image for QEMU @ [link]

0 views

©2018 by Centennial Software Solutions LLC. Proudly created with Wix.com