Skip to content

PiC32MZ Deployment

Carlos Moratelli edited this page May 3, 2017 · 1 revision

Follow the bellow instructions for deployment on PIC32MZ boards.

Flashing the bootloader

The prplHypervisor™ requires a bootloader to pre-configure and upload the hypervisor's binaries to the board. Thus, use the MPLABX IPE to flash the corresponding bootloader to your board. The bootloader can be found in the prpl-hypervisor/bin folder. The available bootloaders are:

  • Microchip_Curiosity_UART.hex (Microchip PIC32MZ Curiosity board);
  • Microchip_Eth_Starter_Kit_UART.hex (Microchip PIC32MZ Embedded Connectivity Starter Kit);
  • chipKIT-WiFire-EF.hex (Digilent PIC32MZ Chipkit Wi-Fire Board).

These bootloaders were generated from the project https://github.com/chipKIT32/PIC32-avrdude-bootloader.

Connect the board to your host computer using a standard A to mini B cable. Use the mini B debugger connector on the board. After flashed, the a LED on your board will keep blinking showing the that the bootloader is ready to upload the hypervisor.

Note: You only need to flash the bootloader once.

Compiling the prplHypervisor

From the prpl-hypervisor folder created with git clone command, go to the platform corresponding to your board. The available platforms (folders) are:

  • platform/pic32mz_starter_kit;
  • platform/pic32mz_chipkit_Wifire, and;
  • platform/pic32mz_curiosity.

In the chosen folder, use the make command to compile the hypervisor with its default configuration, using the MIPS-MTI toolchain. This process will generate the firmware.hex file. This file contains the hypervisor and guests. Example:

~/prplHypervisor/platform/pic32mz_starter_kit$: make
gcc -o genconf cfg_reader/genconf.c -lconfig
#execute first and exit in case of errors
./genconf samples_cfg/sample-1VM.cfg || (exit 1)
blink
#execute and export to a makefile variable the ouput of the script
mips-mti-elf-gcc -EL -O2 -mtune=m14k -mips32r2 -Wa,-mvirt -mno-check-zero-division -msoft-float -fshort-double -c -ffreestanding -nostdlib -fomit-frame-pointer -G 0 -DETHERNET_SUPPORT -DUSB_SUPPORT -DCPU_SPEED=200000000 -DHYPVERSION="v0.11.27 (g9100f1a)" -I../../arch/mips/pic32mz_starter_kit/include -I../../arch/mips/common/include -I../../sys/lib/include -I../../sys/kernel/include -I../../platform/pic32mz_starter_kit/include \
               ../../sys/lib/libc.c \
               ../../sys/lib/linkedlist.c \
               ../../sys/lib/malloc.c


...


mips-mti-elf-size blink.elf
  text    data     bss     dec     hex filename
 12248      16    1424   13688    3578 blink.elf
make[1]: Saindo do diretório `/home/moratelli/hyper/prpl-hypervisor/bare-metal-apps/apps/blink'
../../scripts/genhex.sh blink
0+1 registros de entrada
1+0 registros de saída
65536 bytes (66 kB) copiados, 0,000635281 s, 103 MB/s
0+1 registros de entrada
1+0 registros de saída
32768 bytes (33 kB) copiados, 0,000245427 s, 134 MB/s

Note: See the main Makefile in your platform directory. You may want to modify the input configuration file (CFG_FILE), CROSS_COMPILER or the optional features. Example:

#Input CFG file for VMs configuration
CFG_FILE = ../samples_cfg/sample-1VM.cfg

# CROSS Compiler 
CROSS_COMPILER = mips-mti-elf-

# Optional Device Drivers
CONFIG_INTERVMCOMM_DRV = yes
CONFIG_PIC32MZ_USB_DRV = yes
CONFIG_PIC32MZ_ETHERNET_DRV = yes
CONFIG_VIRTUAL_IO_DRV = yes
CONFIG_INTERRUPT_REDIRECT_DRV = yes

Uploading the firmware

Upload the resulting firmware.hex file to the board using the make load command. Make sure that you have a cable connected to the UART port on your board. The following table shows the required cables for the supported boards.

Board Required Cables Connections
Microchip PIC32MZ Connectivity Starter Kit 2 x Standard A to mini B cables. Connect the cables to connectors J3 (power) and J11 (UART).
Digilent PIC32MZ Chiptkit Wi-Fire 1 x Standard A to mini B cables. Connect the cable to connector J1 (power/UART).
Microchip PIC32MZ Curiosity board 1 x Standard A to mini B cables and 1 x Serial to USB adapter. Connect the mini B cable connector to J3 (power). Use the USB adapter on the UART pins on MikroBus 1.

Expected make load command output.

~/prplHypervisor/platform/pic32mz_starter_kit$: make load

stty 115200 raw cs8 -hupcl -parenb -crtscts clocal cread ignpar ignbrk -ixon -ixoff -ixany -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke -F /dev/ttyACM0

./pic32prog -S -d /dev/ttyACM0 firmware.hex

Programmer for Microchip PIC32 microcontrollers, Version 2.0.186
Copyright: (C) 2011-2015 Serge Vakulenko
Adapter: STK500v2 Bootloader
Program area: 1d000000-1d1fffff
Processor: Bootloader
Flash memory: 2048 kbytes
Boot memory: 80 kbytes
Data: 131072 bytes
Erase: done
Program flash: ################################# done
Program rate: 6600 bytes per second

During power on, the bootloader will wait for 3 seconds before automatically loading the application. During this time, it is possible to flash a new firmware. Thus, before trying to upload a new firmware, press the reset button on your board and wait for the blinking led.

Serial output

You can make a cat command to the corresponding serial port to see the application’s output. The expected output of the default hypervisor configuration is listed below. The default configuration generates the ping-pong application.

===========================================================
prplHypervsior v0.11.112 (ge35a934) [Oct 13 2016, 20:26:29]
Copyright (c) 2016, prpl Foundation
===========================================================
CPU ID:        M5150
ARCH:          Microchip Starter Kit
SYSCLK:        200MHz
Heap Size:     29Kbytes
Scheduler      5ms
VMs:           2

Initializing Virtual Machines.
Configuring ping VM starting at 0x80008000 RAM address.
Configuring pong VM starting at 0x80010000 RAM address.
PIC32mz in Vectored Interrupt Mode.
Inter-VM communication hypercalls registered.
Software reset interrupt (SW1) registered at offset 0x220.
Initializing USB device in Host mode.
USB interrupt vector at 0x240
Device mapping hypercalls registered.
Ethernet PHY at 0
Ethernet interface en0: interrupt 153, MAC address d8:80:39:75:a6:1a
Ethernet device is a SMSC LAN8740A
CP0 Timer interrupt registered at 0x260.
ping VM ID 1
Target VCPU not
pong VM ID 2 initialized.
pong VM: message from VM ID 1: "ping? 5" (8 bytes)
ping VM: message from VM ID 2: "pong!" (6 bytes)
pong VM: message from VM ID 1: "ping? 20" (9 bytes)
ping VM: message from VM ID 2: "pong!" (6 bytes)
pong VM: message from VM ID 1: "ping? 35" (9 bytes)
ping VM: message from VM ID 2: "pong!" (6 bytes)
pong VM: message from VM ID 1: "ping? 50" (9 bytes)
ping VM: message from VM ID 2: "pong!" (6 bytes)
pong VM: message from VM ID 1: "ping? 65" (9 bytes)
...