Home Teaching Research Publications

Advanced Operating Systems (LV 7680)

M0 - Familiarisation

This is a simple exercise designed to get you started on seL4 and set up your hardware kit. It contains very detailed instructions, together with the existing source code and the seL4 manual you should have no problem doing it.

Your Environment

If you haven't already you may want to take a look at Odroid C2 Lab or the wiki for details on the contents of your kit. Log into the lab machine before you plug in the hardware, as this triggers the machine to run specific scripts for your project to work, on your account. If you have permission/tftp issues down the line, try unplugging/replugging the usb/serial adapter and ethernet adapter while logged in.

Get the source

Clone your copy of the milestone 0 starting code.

We use git for revision control for this project, and it will be simplest if you do also. You will be submitting via a provided git repository for each milestone in the project. You will need to support yourself if you use any other tools.

You can find some pointers on using git on our git page.

    git clone https://gitlab.cs.hs-rm.de/advanced-operating-systems/2021_aos/aos-2021.git aos2021-m0

You will need to provide your username and password when cloning. If you set up your ssh-keys on our gitlab server you can use the following command instead:

    git clone git@gitlab.cs.hs-rm.de:advanced-operating-systems/2021_aos/aos-2021.git aos2021-m0

Note: you will only be using this repository for milestone 0. Once you have selected your group members for the remainder of semester you will be using a different group respository to submit.

Building SOS

Dependencies

The lab machines have already been configured with all dependencies. To set up a Linux machine, please see the Linux instructions. Alternatively, you can use a virtual machine appliance

Build the project

We use Cmake and ninja as our build system, which you can read more about on the resources menu on the left. Importantly, this build system does not build in the source tree: you create another directory (in this case build to build code in, and develop in the source directories.

Follow these instructions to build SOS:

    cd aos2021-m0      # change to the project directory
    ln -s projects/aos/settings.cmake settings.cmake # symlink to config file
    mkdir build         # create a build directory
    cd build            # change to the build directory
    ../init-build.sh    # initialise the build directory
    ninja               # init-build

There may be some ELFCLASS_32 errors on the lab machines. These can safely be ignored

By default ninja builds in parallel. If you have a lot of build errors, this can cause confusing output. use ninja -j1 to build with only one thread, which will make the build slower but also serialise the output.

Getting it Going

Booting your Odroid-c2 for the first time is easy:

Plug in the Odroid-c2. Use dmesg to observe the USB port name (usually /dev/ttyUSB0).
In a terminal, launch picocom, $ picocom -b 115200 /dev/ttyUSB0.

Reset the Odroid-C2 by disconnecting the power supply and reconnecting. Then, quickly enter input into the keyboard to stop U-Boot from immediately booting Linux. You should see the following output in picocom (Note: be prepared to hit Return twice quickly.):

    GXBB:BL1:08dafd:0a8993;FEAT:EDFC318C;POC:3;RCY:0;EMMC:0;READ:0;CHK:0;
    TE: 97752
    no sdio debug board detected 

    BL2 Built : 11:44:26, Nov 25 2015. 
    gxb gfb13a3b-c2 - jcao@wonton

    Board ID = 8
    set vcck to 1100 mv
    set vddee to 1050 mv
    CPU clk: 1536MHz
    DDR channel setting: DDR0 Rank0+1 same
    DDR0: 2048MB(auto) @ 912MHz(2T)-13
    DataBus test pass!
    AddrBus test pass!
    Load fip header from eMMC, src: 0x0000c200, des: 0x01400000, size: 0x000000b0
    Load bl30 from eMMC, src: 0x00010200, des: 0x01000000, size: 0x00009ef0
    Sending bl30........................................OK. 
    Run bl30...
    Load bl301 from eMMC, src: 0x0001c200, des: 0x01000000, size: 0x000018c0
    Wait bl30...Done
    Sending bl301.......OK. 
    Run bl301...
    31 from eMMC, src: 0x00020200, des: 0x10100000, size: 0x00011130


    --- UART initialized after reboot ---
    [Reset cause: unknown]
    [Image: unknown, amlogic_v1.1.3046-00db630-dirty 2016-08-31 09:24:14 tao.zeng@droid04]
    bl30: check_permit, count is 1
    bl30: check_permit: ok!
    chipidLoad bl33 from eMMC, src: 0x00034200, des: 0x01000000, size: 0x000769f0
    : ef be ad de d f0 ad ba ef be ad de not ES chip
    [0.212760 Inits done]
    secure task start!
    high task start!
    low task start!
    NOTICE:  BL3-1: v1.0(debug):4d2e34d
    NOTICE:  BL3-1: Built : 17:08:35, Oct 29 2015
    INFO:    BL3-1: Initializing runtime services
    INFO:    BL3-1: Preparing for EL3 exit to normal world
    INFO:    BL3-1: Next image address = 0x1000000
    INFO:    BL3-1: Next image spsr = 0x3c9


    U-Boot 2015.01-00014-g2e4380b-dirty (Jan 16 2018 - 02:09:02)

    DRAM:  2 GiB
    Relocation Offset is: 76f2f000
    -------------------------------------------------
    * Welcome to Hardkernel's ODROID-C2
    -------------------------------------------------
    CPU : AMLogic S905
    S/N : HKC213254E00DD5C
    MAC : 00:1e:06:37:29:dc
    BID : HKC2211910
    -------------------------------------------------
    register usb cfg[1][0] = 0000000077f95010
    register usb cfg[0][1] = 0000000077f95030
    vpu detect type: 5
    vpu clk_level = 7
    set vpu clk: 666667000Hz, readback: 666660000Hz(0x300)
    MMC:   aml_priv->desc_buf = 0x0000000073f27d30
    aml_priv->desc_buf = 0x0000000073f29ec0
    SDIO Port C: 0, SDIO Port B: 1
    [mmc_init] mmc init success
    In:    serial
    Out:   serial
    Err:   serial
    ----------------------------------
    MMC Size : 16 GB
    ----------------------------------
    reading boot-logo.bmp.gz
    ** Unable to read file boot-logo.bmp.gz **
    reading boot-logo.bmp
    ** Unable to read file boot-logo.bmp **
    movi: the partiton 'logo' is reading...

    MMC read: dev # 0, block # 61024, count 2048 ... 2048 blocks read: OK
    hpd_state=1
    [CANVAS]addr=0x3f800000 width=3840, height=1440

    set hdmitx VIC = 16
    hdmitx phy setting done
    set hdmitx VIC = 16
    hdmitx phy setting done
    Error: Bad gzipped data
    There is no valid bmp file at the given address
    Net:   Meson_Ethernet
    Hit [Enter] key twice to stop autoboot:  0 
    odroidc2#

If you missed hitting [Enter] quick enough, the board will autoboot into Linux. If this happens to you, wait until it completes booting, log in (username/password: odroid/odroid), then sudo reboot.

Now set U-boot to autoboot SOS instead of Linux, and set the expected ip addresses:

    setenv ipaddr 192.168.168.2
    setenv serverip 192.168.168.1
    setenv bootcmd 'tftpboot 0x10000000 sos-image-arm-odroidc2 && go 0x10000000'
    saveenv # write the new settings to the eMMC

Development cycle

We have developed a few tools to speed the development cycle along. The Makefile can copy the sos operating system, known as a bootimage to your tftp directory and reset the OdroidC2. Below is a typical development cycle, assuming the path changes to your login script:

  1. Plug in the Odroid-C2, including serial and ethernet.
  2. In a terminal, launch picocom, picocom -b 115200 /dev/ttyUSB0.
  3. Make your changes in the source directory, (hint: learn cscope).
  4. Build with ninja, in the build directory.
  5. Test your changes (from the build dir ../reset.sh) and launch netcat (nc -up 26721 192.168.168.2 26721).
  6. Repeat from step 3 above until satisfied, or you fall over for lack of sleep.

The Milestone

The example skeleton operating system includes an application tty_test which starts up, prints out its name, and then blocks itself forever.

The example includes a printf() implementation that outputs data to seL4's debug console. In fact it uses the seL4 debug API seL4_DebugPutChar(). This function should only be used for internal SOS debugging, not as a console for applications, so, your task is to modify the sos_write() function to send data through the operating system and across the network to your netcat(nc) console.

The second part of milestone zero is to find a partner for the rest of the project. The project is to be completed, in pairs, unless prior permission has been obtained from the supervisor.

Before you complete this milestone, be sure to spend time becoming familiar with the seL4 Debugging Guide. It will save you a lot of debugging effort throughout the project.

Recommended procedure

  1. Read (and understand) the code in projects/aos/sos/src/main.c and the code in the projects/aos/apps/tty_test application directory.
  2. Read the documentation on libserial.
  3. Initialise libserial during SOS startup. Note that you need to initialise libserial after network_init is called.
  4. Design a simple IPC protocol to transfer data from the user program to your operating system (Recommended reading: seL4 Reference Manual, Chapter 4 (all) and Chapter 10 (Section 10.1, 10.2, 10.2.2.1, 10.3.1.9,). Note that an endpoint has already been set up between the tty_test application and sos.)
  5. Write the client side implementation in sos_write.
  6. Change the syscall_loop in main.c to recognise your new protocol, and print out a debug message when you receive one of these messages.
  7. Edit tty_test.c so that it tests your sos_write function.
  8. Change the server side so that it now prints the data to libserial, which will send it onto the network. 1, Test that all of tty_test's output now goes to the netcat console, not the console debugger.

Assessment

Milestone submission

See the milestone submission guidelines for instructions on submitting your milestone solution.

Milestone Demonstration

You will need to demonstrate user applications printing to the 2nd console via libserial, running on the hardware to the supervisor during the demonstration period. You should be prepared to show which files you modified in your solution, and explain any design decisions you made.

Note that since you do not have consistent virtual memory management yet, your protocol will be fairly simple for now. However, it should be upgraded as more parts of the system are completed. Your supervisor will be particularly interested in the details of your IPC interface with different sized blocks of data etc, and how you plan to improve it in future.

Hint: sending a byte at a time is not a good solution.

You will let the supervisor know who your partner is so that group accounts can be created for you.