FreeBSD on latest ARM Processors

Similar documents
Freescale Semiconductor gcc linaro toolchain, Rev

How to cross compile with LLVM based tools. Peter Smith, Linaro

Cortex-R5 Software Development

Embedded Systems Programming

Porting uclinux to MIPS

ECE 471 Embedded Systems Lecture 8

GBA Dev In Linux - GCC for GBA for Linux

Connecting the EDG front-end to LLVM. Renato Golin, Evzen Muller, Jim MacArthur, Al Grant ARM Ltd.

Arm cross development tools

Sourcery CodeBench Lite. ARM GNU/Linux Sourcery CodeBench Lite Getting Started

Cortex-A9 MPCore Software Development

GCC Configuration and Building

Poky Linux & OpenEmbedded based environment

ARM Powered SoCs OpenEmbedded: a framework for toolcha. generation and rootfs management

NDK OVERVIEW OF THE ANDROID NATIVE DEVELOPMENT KIT

Yocto Project components

Cross Compiling. Real Time Operating Systems and Middleware. Luca Abeni

The build2 Toolchain Installation and Upgrade

Porting FreeBSD to AArch64

WM_W60X_SDK_GCC Compiling Guide V1.1

Familiar Linux for the ipaq H3975 (XScale Processor) CSC 714 Real Time Computing Systems Term Project

QPSI. Qualcomm Technologies Countermeasures Update

Cucumber Linux Distribution

Cortex-A15 MPCore Software Development

ECE 571 Advanced Microprocessor-Based Design Lecture 3

NetBSD Work-in-Progress

ECE 598 Advanced Operating Systems Lecture 4

Computer Science 322 Operating Systems Mount Holyoke College Spring Topic Notes: C and Unix Overview

Compilers and Code Optimization EDOARDO FUSELLA

Supporting the new IBM z13 mainframe and its SIMD vector unit

KVM/ARM. Marc Zyngier LPC 12

RELEASE NOTES. GNU Toolchain for Atmel ARM Embedded Processors. Introduction

C6000 Compiler Roadmap

Raspberry Pi Kernel Install. By: Daniel Rizko

Building U-Boot in CodeWarrior ARMv8

Mingw-w64 and Win-builds.org - Building for Windows

Rethinking the core OS in 2015

ECE 598 Advanced Operating Systems Lecture 11

Gcc Get Current Instruction Pointer

Apple Llvm 5.1 Error Exit Code 1.0

HKG18-TR08: Upstreaming SVE in QEMU. Alex Bennée and Richard Henderson

Multicore Programming Handout 1: Installing GCC Cilk Plus

OSELAS.Support OSELAS.Training OSELAS.Development OSELAS.Services

ARMv8-A Software Development

GNU-AVR Building the GNU AVR Toolchain for Mac OS X and Linux

ARM Linux & GNU. Philippe Robin. Beijing June 2004

ECE 471 Embedded Systems Lecture 4

5. ARM 기반모니터프로그램사용. Embedded Processors. DE1-SoC 보드 (IntelFPGA) Application Processors. Development of the ARM Architecture.

Cross build in the FreeBSD ports tree

ECE 471 Embedded Systems Lecture 4

Modern Processor Architectures. L25: Modern Compiler Design

Cortex-A5 MPCore Software Development

GCC and LLVM collaboration

Job Posting (Aug. 19) ECE 425. ARM7 Block Diagram. ARM Programming. Assembly Language Programming. ARM Architecture 9/7/2017. Microprocessor Systems

CODE TIME TECHNOLOGIES. mabassi RTOS. Porting Document. SMP / ARM Cortex-A9 Xilinx SDK (GCC)

Agenda. ARM Core Data Flow Model Registers Program Status Register Pipeline Exceptions Core Extensions ARM Architecture Revision

LPC17 - Supporting newer toolchains in the kernel. Bernhard Bero Rosenkränzer

Development Environment of Embedded System

Aurelien Jarno 26/02/2006 FOSDEM. Debian GNU/kFreeBSD. Aurelien Jarno. What? Why? Status. The future. How to help?

Porting Linux to x86-64

Yocto Project & Embedded Linux

Universität Dortmund. ARM Architecture

RISC-V. Palmer Dabbelt, SiFive COPYRIGHT 2018 SIFIVE. ALL RIGHTS RESERVED.

CODE TIME TECHNOLOGIES. mabassi RTOS. Porting Document. SMP / ARM Cortex-A9 DS5 (GCC)

LINUX KERNEL UPDATES FOR AUTOMOTIVE: LESSONS LEARNED

LLVM, Clang and Embedded Linux Systems. Bruno Cardoso Lopes University of Campinas

Git Workbook. Self-Study Guide to Git. Lorna Mitchell. This book is for sale at

IoT and Security: ARM v8-m Architecture. Robert Boys Product Marketing DSG, ARM. Spring 2017: V 3.1

Khem Raj Embedded Linux Conference 2014, San Jose, CA

IRIX is moving in the n32 direction, and n32 is now the default, but the toolchain still supports o32. When we started supporting native mode o32 was

valgrind overview: runtime memory checker and a bit more What can we do with it?

Saint Louis University. Intro to Linux and C. CSCI 2400/ ECE 3217: Computer Architecture. Instructors: David Ferry

Cortex-M3/M4 Software Development

Implementing Secure Software Systems on ARMv8-M Microcontrollers

Thwarting unknown bugs: hardening features in the mainline Linux kernel

ECE 498 Linux Assembly Language Lecture 1

BUD Navigating the ABI for the ARM Architecture. Peter Smith

ECE 471 Embedded Systems Lecture 5

ECE 471 Embedded Systems Lecture 6

Adding GNU/Hurd support to GNU Guix Porting GNU Guix to a new platform

Rethinking the core OS in 2015

Operating systems. Lecture 7

Crosstoolchains in Debian

The C standard library

Arm TrustZone Armv8-M Primer

Creating a system call in Linux. Tushar B. Kute,

Android. Separated Kernel build might break the Android build process. Toolchain

The challenge of SVE in QEMU. Alex Bennée Senior Virtualization Engineer

ARM Processors for Embedded Applications

Scratchbox Remote Shell

Chapter 5. Introduction ARM Cortex series

Setting up an SDK for Secondo

The Next Steps in the Evolution of ARM Cortex-M

Faculty of Computer Science Institute for System Architecture, Operating Systems Group. Complex Lab Operating Systems 2016 Winter Term.

Porting Linux to a New Architecture

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Digi Embedded Yocto 1.6. First Steps Guide

Android on Everything! Smooth Development of Cross-platform Native Android Games

Efficient JIT to 32-bit Arches

Ideas to improve glibc and Kernel interaction. Adhemerval Zanella

Transcription:

FreeBSD on latest ARM Processors EABI, Toolchain ARM Ltd. vasileios.laganakos@arm.com 9th of October, 2010

1 Outline 2 Background Why? Few things about ARM... ARM EABI The Project 3 Part of the Procedure What we need Binutils GCC - C lang GCC - C Library 4 Future work Schedule LLVM Kernel 5 References 6 The End!

1 Outline 2 Background Why? Few things about ARM... ARM EABI The Project 3 Part of the Procedure What we need Binutils GCC - C lang GCC - C Library 4 Future work Schedule LLVM Kernel 5 References 6 The End!

Why? Why all this fuss? Well it is a combination of reasons: Been using FreeBSD for a long time and love its stability and robustness :o) <- Need to contribute! Want to learn more about the FreeBSD structure (in order to contribute :o) ) Found the ARM architecture unique, and wanted to get BSD on it ;o) Embedded systems are cool - why not enhance them with BSD ;o)

Why? Why all this fuss? Well it is a combination of reasons: Been using FreeBSD for a long time and love its stability and robustness :o) <- Need to contribute! Want to learn more about the FreeBSD structure (in order to contribute :o) ) Found the ARM architecture unique, and wanted to get BSD on it ;o) Embedded systems are cool - why not enhance them with BSD ;o)

Why? Why all this fuss? Well it is a combination of reasons: Been using FreeBSD for a long time and love its stability and robustness :o) <- Need to contribute! Want to learn more about the FreeBSD structure (in order to contribute :o) ) Found the ARM architecture unique, and wanted to get BSD on it ;o) Embedded systems are cool - why not enhance them with BSD ;o)

Why? Why all this fuss? Well it is a combination of reasons: Been using FreeBSD for a long time and love its stability and robustness :o) <- Need to contribute! Want to learn more about the FreeBSD structure (in order to contribute :o) ) Found the ARM architecture unique, and wanted to get BSD on it ;o) Embedded systems are cool - why not enhance them with BSD ;o)

Why? OABI Noticed that the ARM ports in buildtree are using OABI. And also that the toolchain version (GCC 4.2.1) does not support ARMv6 and ARMv7. Ports Couldn t find any recent board ports in there (e.g. BeagleBoard, imx/51, Tegra-2). Interesting... There are currently some very interesting ARM-based platforms. So let s do something about this!

Why? OABI Noticed that the ARM ports in buildtree are using OABI. And also that the toolchain version (GCC 4.2.1) does not support ARMv6 and ARMv7. Ports Couldn t find any recent board ports in there (e.g. BeagleBoard, imx/51, Tegra-2). Interesting... There are currently some very interesting ARM-based platforms. So let s do something about this!

Few things about ARM... ARM info pt.1 ARM is a 32bit load/store architecture 32bit ARM Instruction Set - instructions conditionally executed 16bit Thumb Instruction Set - simple branches conditionally executed Thumb-2 Instruction Set : extension to Thumb, does not depend on ARM - A mixture of 16 and 32 bit instructions. Small as Thumb and fast as ARM code. :o) Has different modes of operation: User unprivileged mode SVC, FIQ, IRQ, Abort, Undef and System privileged modes The Core is configurable by the vendor

Few things about ARM... ARM info pt.2 Support for Floating Point operations - requires the FP coprocessor NEON : wide SIMD extension for the latest ARMv7-A cores - requires the Vector NEON Unit Multiple-stage pipeline - size variable depending on implementation

Few things about ARM... ARMv4T ARMv5TE ARMv6 ARMv7 Thumb Instruction Set Improved ARM-Thumb interworking DSP multiplyaccumulate instr. SIMD Instructions Unaligned data support v6 Memory Architecture H/W Options: Thumb-2, Multicore, TrustZone Thumb-2 NEON Architecture profiles: Hardware Divide, Thumb-2 only

ARM EABI ARM EABI is the way forward Some of the benefits A more efficient syscall convention (used in GNU EABI) Put syscall number to r7 & use svc 0 calling the kernel More compatibility with various tools Structure packing is not as painful as it used to be No minimum size - packing determined by types size ARM-Thumb interworking is mandatory - function-level granularity Better Floating point performance with or without an FPU is much faster makes mixing soft and hardfloat code possible Compatible with all ARM architectures greater than ARMv4T GNU EABI for Linux is a sub-variant of ARM EABI

ARM EABI Parts of the standard - Pt.1 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15 Register Conventions argument/result/scratch register argument/result/scratch register argument/scratch register argument/scratch register variable register variable register variable register variable register variable register platform register variable register variable register IP call register the stack pointer the link register the program counter

ARM EABI Parts of the standard - Pt.2 Some more Conventions... If you are passing more arguments that can fit in the first 4 registers, they will be placed on the stack Need to have 64-bit alignment. I.e. for a 64-bit value, r0-r1 or r2-r3 must be used, but not r1-r2 enums can have variable size type Conventions Similar things hold for the VFP and Advanced SIMD Standard Variants of the EABI. Won t go into this now :o)

The Project A project? Yes! - It is project "Prometheus": Note! Trying to learn more for FreeBSD internals by getting first an EABI, ARMv7 supporting toolchain, which will then be imported to the build system (that s the learn internals part of the story :o) ), and then used to set-up a kernel for an ARMv7 arch platform. And then going to see if we can boot the platform, in order to test whether the application we built is actually working. :o) Iterate as appropriate! Oh! Also chose to work on FreeBSD-Current. (9.0 at the time) This is as most of the times, work-in-progress :o)

1 Outline 2 Background Why? Few things about ARM... ARM EABI The Project 3 Part of the Procedure What we need Binutils GCC - C lang GCC - C Library 4 Future work Schedule LLVM Kernel 5 References 6 The End!

Please note Not using the FreeBSD build system, yet! The cross-building toolchain is built on its own, outside the build system.

What we need Getting the goodies! get binutils 2.20.1 wget http://ftp.gnu.org/gnu/binutils/binutils-2.20.1.tar.gz get GCC 4.4 branch svn co svn://gcc.gnu.org/svn/gcc/branches/gcc-4_4-branch/ gcc Picked 4.4 branch because I want to have Thumb-2 and ARMv7 Arch support.

Binutils Building binutils - Pt.1 Configure:./configure --prefix=$home/work/out --target=arm-unknown-freebsd9.0 Build: gmake Install: gmake install

Binutils Building binutils - Pt.2 And this will deploy things in a layout, like things would look in a live embedded system. The result will look like: [vassilis@prometheus ~/work/out]$ ls arm-unknown-freebsd9.0 include lib man bin info libexec share

Binutils Errors in building Need to use gmake, or you get errors like the following: flat_bl.m:2: error: expected identifier or ( before % token *** Error code 1 Stop in /prometheus/work/arm/binutils-2.20.1/gprof. *** Error code 1 Stop in /prometheus/work/arm/binutils-2.20.1/gprof. *** Error code 1 Stop in /prometheus/work/arm/binutils-2.20.1/gprof. *** Error code 1 Stop in /prometheus/work/arm/binutils-2.20.1. *** Error code 1 Stop in /prometheus/work/arm/binutils-2.20.1.

GCC - C lang GCC Pre-requisites Get GMP and MPFR as you need them for the compilation of the Cross-Toolchain. The stuff you get from the respective ports seem to be just fine. Or if you prefer building them from source for some reason, grab them from: http://www.mpfr.org/mpfr-current/mpfr-3.0.0.tar.bz2 ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2 No obvious reason why you should do this though... :o)

GCC - C lang Important Make sure......you use gmake for building GCC...you build it out of its source tree...before config and gmake, add the path to the built and installed binutils early at your PATH env var Or else you will get quite a few weird warnings and artefacts!

GCC - C lang Prepare the required headers Need to copy some header files where the GCC building system expects them to be: in sysroot related path mkdir -p $HOME/work/out/sysroot/usr/include/sys cp /usr/src/sys/arm/include/_types.h $HOME/work/out/sysroot/usr/include/sys/ cp /usr/src/sys/sys/cdefs.h $HOME/work/out/sysroot/usr/include/sys/... Some duplicates...(?) cd $HOME/work/out/sysroot/usr/include ln -s /prometheus/work/out/sysroot/usr/include/sys/errno.h ln -s /prometheus/work/out/sysroot/usr/include/sys/sched.h... And some more not included above cp /usr/src/include/pthread.h $HOME/work/out/sysroot/usr/include/...

GCC - C lang Or else... You will get errors such as: GCC: "...I can t find the headers man..." In file included from../../../gcc/libgcc/../gcc/tsystem.h:44, from../../../gcc/libgcc/../gcc/libgcc2.c:29: /prometheus/work/arm/objdir/./gcc/include/stddef.h:59:24: error: sys/_types.h: No such file or directory In file included from../../../gcc/libgcc/../gcc/libgcc2.c:29:../../../gcc/libgcc/../gcc/tsystem.h:87:19: error: stdio.h: No such file or directory../../../gcc/libgcc/../gcc/tsystem.h:90:23: error: sys/types.h: No such file or directory../../../gcc/libgcc/../gcc/tsystem.h:93:19: error: errno.h: No such file or directory../../../gcc/libgcc/../gcc/tsystem.h:100:20: error: string.h: No such file or directory../../../gcc/libgcc/../gcc/tsystem.h:101:20: error: stdlib.h: No such file or directory../../../gcc/libgcc/../gcc/tsystem.h:102:20: error: unistd.h: No such file or directory../../../gcc/libgcc/../gcc/tsystem.h:108:18: error: time.h: No such file or directory

GCC - C lang Build Cross-GCC Need to perform 3 passes: 1st pass - Just C Language support Don t build C library 2nd pass - Build C library 3rd pass - Build the rest of the toolchain

GCC - C lang Configure GCC for cross-building So, configure GCC accordingly:../gcc/configure \ --target=arm-unknown-freebsd9.0 --host=i386-unknown-freebsd9.0 \ --build=i386-unknown-freebsd9.0 --prefix=$home/work/out/ \ --with-sysroot=$home/work/out/sysroot --enable-languages=c \ --disable-multilib --disable-libmudflap --disable-threads \ --disable-libgomp --disable-libssp Notice that only C is enabled, since this will suffice for now. Disabled are multilib and libmudflap, as well as threads. For more details, see http://www.linuxfromscratch.org/lfs/view/6.6/chapter05/gccpass1.html

GCC - C lang Configure GCC for cross-building Also... Edited the freebsd.h file to build for another, more recent architecture. #define SUBTARGET_CPU_DEFAULT TARGET_CPU_arm926ejs #undef TARGET_VERSION #define TARGET_VERSION fprintf (stderr, " (FreeBSD/ARM926EJ-S ELF)"); Once......this gets in a reasonable state, will try moving to ARMv7

GCC - C lang And build... gmake

GCC - C lang Wotchas! What s that!? In file included from tm.h:16, from insn-recog.c:7:../.././gcc/config/arm/arm.h:606:1: warning: "WCHAR_TYPE_SIZE" redefined In file included from tm.h:15, from insn-recog.c:7:../.././gcc/config/arm/freebsd.h:61:1: warning: this is the location of the previous definition In file included from tm.h:16, from insn-recog.c:7:../.././gcc/config/arm/arm.h:2249:1: warning: "HANDLE_PRAGMA_PACK_PUSH_POP" redefined In file included from tm.h:12, from insn-recog.c:7:../.././gcc/config/freebsd.h:59:1: warning: this is the location of the previous definition Well... WCHAR_TYPE_SIZE - should be 32bits HANDLE_PRAGMA_PACK_PUSH_POP - Source code says: /* Define this so we can compile MS code for use with WINE. */

GCC - C lang Done!...and install it gmake install So... We now have a toolchain that can compile and link programs that do not use C library... Not that useful!

GCC - C Library All we need now is the C Library! More specifically: crt1.o part of csu code libc.so and as source code reveals: "csu must be built before all shared libraries for ELF" and "libc must be built before all other shared libraries"

GCC - C Library csu Built it from the main build tree -> got crt1.o which was missing from what we got from GCC so far.

GCC - C Library However... Unfortunately building csu and libc is a hack for now Moving stuff out of the build tree... :o( Objective: Need to familiarize more with the build system!

GCC - C Library And this is the current stage in the project: In the process of building libc...

1 Outline 2 Background Why? Few things about ARM... ARM EABI The Project 3 Part of the Procedure What we need Binutils GCC - C lang GCC - C Library 4 Future work Schedule LLVM Kernel 5 References 6 The End!

Schedule Milestones; a Schedule or something... 1 Build libc and finalize the GCC cross toolchain 2 Find a better way of doing it and create a port 3 Work on getting support for a recent platform 4 List the changes required in the current kernel to support EABI (kind of critical ;o) ) 5 Userspace compilation... Update the Wiki: http://prometheus.wikidot.com Gradually push something in the project page as things are created: launchpad.net/prometheus Feedback would be most helpful! :o)

Schedule However: So: Not sure if dropping-in a later version of binutils in the buildtree is going to be accepted Same for the 4.4 GCC - as everything after version 4.2.1 is GPLv3 Perhaps this is destined to be a standalone port? Can t be sure yet...

Schedule However: So: Not sure if dropping-in a later version of binutils in the buildtree is going to be accepted Same for the 4.4 GCC - as everything after version 4.2.1 is GPLv3 Perhaps this is destined to be a standalone port? Can t be sure yet...

Schedule Thoughts... Maybe switch to llvm entirely and forget the above work :o)

LLVM ARM have contributed some patches, regarding the EABI compatibility in the LLVM-backend http://llvm.org/viewvc/llvm-project?view=rev&revision=93884 Optimise ~(~X >>s Y) --> (X >>s Y) http://llvm.org/viewvc/llvm-project?view=rev&revision=97656 Add framework for ARM builtins http://llvm.org/viewvc/llvm-project?view=rev&revision=103181 Bug fix in ARMISelDAGToDAG.cpp http://llvm.org/viewvc/llvm-project?view=rev&revision=103876 powf/modf fixes for Solaris build http://llvm.org/viewvc/llvm-project?view=rev&revision=103877 round() fixes for Solaris build http://llvm.org/viewvc/llvm-project?view=rev&revision=109854 Bug fix in SelectionDAG/TargetLowering.cpp http://llvm.org/viewvc/llvm-project?view=rev&revision=110072 C-tor polymorphism in lib/analysis/debuginfo.cpp http://llvm.org/viewvc/llvm-project?view=rev&revision=114991 Support for ARM Run-Time ABI (FP and Integerhelper functions) EABI support is something ARM cares about - Answering EABI/ARM specific questions in the mailing list :o) Note: llvm 2.8 - ARM NEON support was added to Clang.

Kernel Currently Investigating the existing infrastructure, and going through the instructions at: wiki.freebsd.org/freebsd/arm for the ports that are already there, and wiki.freebsd.org/freebsdarmboards for adding new ports. The fact that the ARM cores are customizable, and the unique way that they are embedded in each different SoC, would make it useful to have a more generic way of "expressing" an ARM platform in the build system Had some experience adding support for ARM968 to FreeRTOS, so I hope that this is going to be helpful :o)

Kernel Currently Adding a new platform is of higher priority Need to check the existing syscalls and see if there are any changes required - I meant how many are required :o)

References ARM EABI Debian ARM EABI LLVM FreeBSD ARM wiki EABI on FPU speed Linux from Scratch glibc -EABI syscall interface ARM Tech Blogs ABI for the ARM Architecture http://wiki.debian.org/armeabiport http://llvm.org/docs/releasenotes.html http://wiki.freebsd.org/freebsd/arm Why-ARMs-EABI-matters Constructing a temporary system - GCC pass1 http://sourceware.org/ml/libc-ports/2005-11/msg00028.html http://blogs.arm.com/software-enablement/ Acknowledgement: The ever cute little Daemon is a registered trademark of Marshall Kirk McKusick :o)

Hoping that real-life / work-life is not going to interfere as much as it did last year with the project... :o)

Thank you for your time! Any... Questions? Contact Details email: Prometheus Wiki Prometheus Project vasileios.laganakos@arm.com http://prometheus.wikidot.com https://launchpad.net/prometheus More than happy for any kind of feedback/information!