Skip to content

Boot Zephyr from SYSLINUX

chiachuanwu edited this page May 2, 2019 · 1 revision
  1. Setup the virtual disk

    $ dd if=/dev/zero of=disk.img bs=$((1024 * 1024)) count=100
    $ parted -s disk.img mktable msdos mkpart primary 0 100% toggle 1 boot
    $ sudo losetup --show -Pf disk.img
    /dev/loopX
    
    $ sudo chown $LOGNAME:$LOGNAME /dev/loopX*
    $lsblk
    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    loopX 7:0 0 100M 0 loop 
    └─loopXp1 259:6 0 100M 0 loop
    $ mkfs.fat -F32 /dev/loopXp1
    $ sudo mount -o uid=$(id -u) /dev/loopXp1 /mnt
    
    • /dev/loopX , X can be 1,2,3,4, for this case /dev/loop5 .
  2. Install SYSLINUX on the drive.

    $ sudo extlinux --device /dev/loopXp1 -i /mnt
    
  3. Build Zephyr for QEMU.

    $ git clone http://github.com/zephyrproject-rtos/zephyr.git
    $ source zephyr-env.sh
    $ cmake -DBOARD=qemu_x86 -H$ZEPHYR_BASE/tests/kernel/fifo/fifo_timeout/ -Bbuild-x86-f
    $ make -C build-x86-f
    $ cp build-x86-f/zephyr/zephyr.elf /mnt
    
  4. Create the SYSLINUX config.

    $ tee <<EOF > /mnt/syslinux.cfg
    timeout 0
    prompt 0
    default zephyr
    LABEL zephyr
    kernel elf.c32
    append zephyr.elf
    
  5. Run QEMU on the disk.

    $ /opt/zephyr-sdk-0.9.5/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-i386 \
    -m 1024 -cpu qemu32,+nx,+pae \
    -enable-kvm \
    -device isa-debug-exit,iobase=0xf4,iosize=0x04 \
    -clock dynticks -no-acpi -balloon none \
    -L /usr/share/qemu -bios bios.bin \
    -machine type=pc-0.14 \
    -serial stdio \
    -hda disk.img
    
    $ vncviewer 127.0.0.1:5900
    
Clone this wiki locally