Giter Club home page Giter Club logo

rust_armv8's Introduction

rust_armv8_hello

This is a bare metal system for arm with print module, it's built on Ubuntu 16.04. I mainly followed these tutorials:

https://os.phil-opp.com/first-edition/
https://balau82.wordpress.com/2010/02/28/hello-world-for-bare-metal-arm-using-qemu/
https://balau82.wordpress.com/2010/11/30/emulating-arm-pl011-serial-ports/

Setup Rust

You can go this page or just type on your command:

curl https://sh.rustup.rs -sSf | sh

First install with default options (you can also directly install the nightly version), this allows you to start with normal rust programming (remember to add $HOME/.cargo/bin to your $PATH). Then, type:

rustup toolchain install nightly

to install the nightly version of rust. The nightly version of rust allows us to use some features which are essential to write the system. Then switch your default rust toolchain to the nightly version:

rustup default nightly-x86_64-unknown-linux-gnu

Install the xargo and add rust-src for building the core:

cargo install xargo
rustup component add rust-src

GCC Toolchain

I use the aarch64-none-elf-gcc toolchain for cross compiling. You can download here or just clone my whole project (they are in bin and libexec). Then change the path in the Makefile:

CROSS_COMPILE ?= path_to_the_toolchain/bin/aarch64-none-elf-

QEMU

Install the qemu:

sudo apt-get install qemu

Run the Bare Metal System

make qemu

You should see the output:

Press Ctrl-A and then X to exit QEMU

qemu-system-aarch64	-M virt -cpu cortex-a57	\
					-smp 1 -m 128 \
					-nographic \
					-kernel hello.elf
Hello world!
0x123456

Using GDB

If you want to debug the system, you can use the aarch64-none-elf-gdb in the toolchain. Qemu implements a gdb connector using a TCP connection. To do so, you can run the qemu with options -s and -S.

 -s: shorthand for -gdb tcp::1234  
 -S: freeze the CPU at startup, you can connect your gdb at this time  

For convenience, you can just type:

make dqemu

Now you are running the qemu without output, the command freezes the system before executing any code and waits for a connection on the TCP port 1234. Open another terminal and run aarch64-none-elf-gdb and enter:

target remote localhost:1234
file hello.elf

or just:

make gdb

rust_armv8's People

Contributors

leonana69 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.