Instructions for running uCLinux on the Arm MPS2 platform

Introduction

uClinux

Is Linux built for microcontroller platforms without an MMU. It relies on a specific version of libc not available in the standard Linaro toolchain binary releases. These instructions use Buildroot to automate compiling the toolchain and creating a simple busybox filesystem.

MPS2

Is an Arm supplied FPGA based hardware development platform that can be configured to use a variety of Arm Cortex-M family cores. The platform is also available as a FVP (Fixed Virtual Platform) software model - included with Arm's DS-5 toolchain.

The instructions and configuration files supplied describe how to build and run uClinux on

  • MPS2 hardware with Cortex-M7 (AN500) or CM3DS (Cortex-M3 Design Start) FPGA images
  • MPS2 Cortex-M7 FVP

It should be possible to port the example to other Cortex-M variants. However changes may be required to the following configuration files:

  • The buildroot defconfig will need modifying, to reflect the processor variant and relevant dts file
  • The device tree configuration (The kernel sources include a device tree for Cortex-M3/an385)
  • The boot wrapper makefile (which has specific assumptions about where RAM is located)

MPS2 specific configuration files

  1. Download and extract the MPS2_config.zip archive associated with this document

Build the kernel and busybox with buildroot

  1. Download and extract Buildroot. These instructions were tested with 2017.05, but should work with any recent version of Buildroot.
  2. Copy the contents of MPS2_config/configs to <buildroot>/configs.
  3. In <buildroot>/board/arm create the folder mps2
  4. Copy the contents of MPS2_config/mps2 into <buildroot>/board/arm/mps2
  5. Apply the defconfig and build buildroot:

    $ make arm_mps2_<platform>_defconfig

    $ make -j16

This may take a while, it is rebuilding gcc + linux + busybox and will produce 3 things:

Linux kernel Image + busybox in initramfs in output/build/linux-4.11.3/arch/arm/boot/Image Device tree in output/images/<platform>.dtb Toolchain in output/host/usr/bin/

Note: The FVP target uses a non-upstreamed variant of mps2-an399.dts, because the FVP requires a different ethernet device node than used by the in-tree dts.

Build the bootwrapper

This bootwrapper is a simple Linux bootloader intended for use with Cortex-M devices on Arm's MPS development platform.

  1. Download the boot wrapper

    git clone https://github.com/ARM-software/bootwrapper.git -b cortex-m-linux

  2. Copy the kernel Image and dtb produced by Buildroot into the root of the bootwrapper folder.
  3. Edit the bootwrapper Makefile to use the correct PHYS OFFSET & .dtb for your platform
     #For MPS2 CM7  PHYS_OFFSET = 0x60000000
     #For CM3DS  PHYS_OFFSET = 0x21000000
     
     #For MPS2 CM7  DTB = ./mps2-an399.dtb
     #For FVP CM7  DTB = ./mps2-an399-fvp.dtb
     #For CM3DS  DTB = ./cm3ds.dtb

  4. For CM3DS only edit boot.S to change the address of the UART to 0x40005000 (this will allow you to see early kernel boot messages)
  5. Start the build

    export CROSS_COMPILE=<workspace>/buildroot-2017.05.01/output/host/usr/bin/arm-buildroot-uclinux-uclibcgnueabi-
    cd ./bootwrapper
    make

This will produce boot.axf (A small assembler shim which jumps from flash to RAM. Loads at 0x0, jumps to PHYS_OFFSET). linux.axf (Includes the bootwrapper + Image at PHYS_OFFSET)

Run on MPS2 FVP model

  1. Launch the FVP from the command line using: $ FVP_MPS2_Cortex-M7 -a linux.axf

Run on MPS2 Development Board

The MPS2 board allows images to be programmed into flash via configuration files on the board's MMC card.

  1. Ensure the boards MMC card is mounted on your host PC.
  2. Copy boot.axf and linux.axf into the SOFTWARE/ folder
  3. Edit MB/HBI0xyz/ANxyz/images.txt (The exact path/file to modify is dictated by the FPGA image you have selected in MB/board.txt) to contain:

    [IMAGES]
    TOTALIMAGES: 2
    IMAGE0ADDRESS: 0x00000000
    IMAGE0FILE: \SOFTWARE\boot.axf
    IMAGE1ADDRESS: PHYS_OFFSET**
    IMAGE1FILE: \SOFTWARE\linux.axf


    **PHYS_OFFSET is the appropriate RAM address for your platform, detailed above

  4. Set baudrate to 9600bps on the UART console
  5. Reset and boot

An example Linux boot log is included in the supplied MPS2_config.zip archive

MPS2_config.zip