Bering-uClibc 5.x - Developer Guide - Appendices - Hardware-Specific Guides

From bering-uClibc
Revision as of 17:41, 7 March 2015 by Kapeka (Talk | contribs) (Boot Disk Layout change names of initrd and linux to current)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Hardware-Specific Guides
Prev Bering-uClibc 5.x - Developer Guide Next

Introduction

This page provides guidelines for Bering-uClibc 5.x developers targeting specific hardware devices.

See also the equivalent page in the User Guide for hardware-specific information relevant to Users as well as Developers.


ARM CPU Architecture

Raspberry Pi Model B

Please note: The following instructions works only for Bering-uClibc 5.2 and above!

Overview

The Raspberry Pi Model B has a Broadcom BCM2835 "system on a chip" integrated circuit containing an ARM1176JZF-S CPU which implements the ARMv6 CPU architecture standard.

  • As described here, the ARM1176JZF-S is an ARM1176JZ-S with the addition of a Vector Floating-Point (VFP) coprocessor. This means it can execute floating-point arithmetic in hardware rather than (only) in software.

A PDF data sheet for the BCM2835 can be downloaded from here. The BCM2835 contains a variety of devices and many of these seem to be identified with the string BCM2708 rather than BCM2835, judging by the example boot log from an Alpha board here

There is no Real-Time Clock so it is necessary to use an NTP or similar time source for accurate time keeping.

There is a USB interface (with 2 Type-A sockets) and also a 10/100 Ethernet interface, connected internally via the USB bus.

While there is no standard physical connector for an RS-232 serial interface, the GPIO header does support serial communications using 3.3V TTL signals. Something like a PL2303 adaptor can be used to convert these to USB for connection to a host computer running a terminal emulator.

Linux Kernel Source

Many of the device drivers for the on-board peripherals are currently (February 2015) not included in the mainstream Linux source tree.

Developers of Alpine Linux provides one big patch with all changes for Raspberry Pi, based on the work of the Raspberry Pi foundation, for the Linux Kernel 3.14.x. See root/main/linux-rpi.

Linux Kernel Configuration

SD Card Driver

Relevant device drivers and settings for the SD card interface as of linux kernel 3.14.x are:

CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_IO_ACCESSORS=y
CONFIG_MMC_SDHCI_PLTFM=y
# CONFIG_MMC_SDHCI_PXAV3 is not set
# CONFIG_MMC_SDHCI_PXAV2 is not set
CONFIG_MMC_SDHCI_BCM2708=y
CONFIG_MMC_SDHCI_BCM2708_DMA=y

Note: More kernel options have to be set, to boot from SD Card, esp enabling USB storage (see below for a link to a complete kernel configuration).

USB Driver

The USB interface driver is the DWC OTG Controller:

CONFIG_USB_DWCOTG=y

Ethernet Driver

The Ethernet interface chip is an SMC 91X-compatible device:

CONFIG_NET_VENDOR_SMSC=y

The Linux kernel 3.14.x configuration file for LEAF Bering-uClibc, which is known to boot, can be found in our git repository - at the time of writing Bering-3.14.33.config-bcmrpi.

Considerations about initrd

We use two files during boot, initrd.lrp, providing the basic stuff to boot, and initmod-bcmrpi.lrp with architecture specific modules.

While the bootloader of Raspberry Pi supports loading an initramfs (initrd) file to boot, it fails to load more than one file (initrd.lrp and initmod-bcmrpi.lrp), as other hardware does.

So we first have to concatenate the two files into one. This is done with the following commands:

mv initrd.lrp initrd.gz
mv initmod-bcmrpi.lrp initmod-bcmrpi.gz
cat initrd.gz initmod-bcmrpi.gz > initrd-rpi.gz
mv initrd-rpi.gz initrd-rpi.lrp

A shorter version of the command above works also:

cat initrd.lrp initmod-bcmrpi.lrp > initrd-rpi.lrp

The file initrd-rpi.lrp then needs to declared in config.txt as described at the eLinux Wiki.

initramfs initrd-rpi.lrp 0x00a00000

Boot Disk Layout

The Raspberry Pi must boot from its SD card and some vital files must be present in the root directory of the boot partition.

The latest versions of these files can be downloaded from the raspberrypi/firmware page on GitHub.

The first disk partition on the SD card must be formatted as a VFAT filesystem. It works OK if the partition type is 0xb (W95 FAT32). This partition does not have to to be marked as "bootable".

The boot sequence is as follows (based on content here):

  1. The first-stage bootloader, built into the very small on-chip ROM runs, and loads...
  2. A file called bootcode.bin which contains the second-stage bootloader. This runs, and loads...
  3. A file called start.elf which contains the GPU binary driver code. If the optional configuration file config.txt is present this is read and processed.
    • The syntax for config.txt is comprehensively documented at the eLinux Wiki.
    • By default start.elf loads a file called kernel.img, passing it the command line specified in file cmdline.txt
    • The default name kernel.img can be overriden by an entry like the following in config.txt
      kernel=linux
      where linux is the (renamed) kernel build with the Bering-uClibc toolchain. The file kernel.img is typically a standard uncompressed Linux kernel Image file. The kernel linux-[version]-bcmrpi, as it has been build within the Bering-uClibc toolchain, is an uncompressed Linux kernel and shall be renamed to linux while copying to your Raspberry Pi.
    • The initrd file initrd.lrp has to be added to config.txt
      initramfs initrd.lrp 0x00a00000
    • The kernel command line is declared in cmdline.txt
      dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline LEAFCFG=/dev/mmcblk0p1:vfat init=/linuxrc root=/dev/ram0 rw rootwait reboot=bios
      The most important entry is LEAFCFG=/dev/mmcblk0p1:vfat which points to the file leaf.cfg, that loads the remaining files to be loaded during the boot process.

Note that the Raspberry Pi references the first disk partition as /dev/mmcblk0p1 and the second disk partition as /dev/mmcblk0p2.

Install LEAF Bering-uClibc on a SD card side-by-side with raspbian

This section explains how to install LEAF Bering-uClibc side-by-side with raspbian, a debian based image for Raspberry Pi. You will be able to start either raspbian or LEAF-Bering-uClibc, so it is considered as a testbed for LEAF-Bering-uClibc for Raspberry Pi, while you still can double check your hardware with a setup known to work (raspbian).

  • Flash a SD card with raspbian as described here. The SD card will afterwards have a boot partition and second partition containing the data files.
  • Download the latest LEAF Bering-uClibc tarball for Raspbian Pi from the File Release System of leaf.sourceforge.net. The tarball is named Bering-uClibc_[version-nn]_bcmrpi.tar.gz (at the time of writing Bering-uClibc_5.1-alpha1_bcmrpi.tar.gz). And extract the tarball into a temporary directory.
  • Mount the boot directory of your SD card. Copy the files linux.img, initrd-rpi.lrp, config.txt and cmdline.txt from the extracted tarball to the boot partition of your SD card.
  • Create a file leaf.cfg with the content:
# Uncomment for more verbose execution.
# VERBOSE=1
LRP="root local iptables dropbear shorwall shorwall6 keyboard dnsmasq bbntpd libz dhcpcd ulogd nano"
PKGPATH=/dev/mmcblk0p2:ext4
syst_size=42M
log_size=16M
zswap_size=50M
  • Umount the boot partition and mount the second partition with the data.
  • Copy the remaining Packages files onto the second partition. The minimum of Packages is:
root.lrp
etc.lrp
nano.lrp
ncurses.lrp
ulogd.lrp
shorwall.lrp
shorewall6.lrp
iptables.lrp
libnetfilter_log.lrp
libnetfilter_cttimeout.lrp
libnetfilter_conntrack.lrp
libnetfilter_acct.lrp
modules.lrp
libnfnetlink.lrp
liblzo.lrp
dhcpcd.lrp
dnsmasq.lrp
keyboard.lrp
dropbear.lrp
perl.lrp
libdigest-sha1-perl.lrp
config.lrp
local.lrp
bbntpd.lrp
  • Finally copy moddb-bcmrpi.lrp from the extracted tarball to moddb.lrp on your SD card.
  • Umount the data partition, insert the SD card into your Raspberry Pi and reboot it.

Additional reading


Prev Up Next