Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit 1400837

Browse files
committed
Initial commit
0 parents  commit 1400837

File tree

113 files changed

+11191
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+11191
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.ali
2+
*.ci
3+
*.o
4+
*.d
5+
*.stderr
6+
*.stdout
7+
obj/
8+
bsp/**/runtime/lib/
9+
bsp/**/runtime/share/
10+
bsp/**/runtime/**/target_properties

LICENSE

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
HEX FIVE SECURITY, INC.
2+
SOFTWARE EVALUATION AGREEMENT
3+
4+
THE TERMS AND CONDITIONS CONTAINED HEREIN CONSTITUTE A LEGAL AGREEMENT.
5+
THIS AGREEMENT ("AGREEMENT") CONTAINS THE ENTIRE AGREEMENT BETWEEN YOU
6+
LICENSEE ("YOU") AND HEX FIVE SECURITY, INC. ("HEX FIVE") WITH RESPECT TO
7+
THE TERMS AND CONDITIONS DESCRIBED HEREIN. READ THIS AGREEMENT CAREFULLY.
8+
BY DOWNLOADING/INSTALLING THE PRODUCT, YOU ACKNOWLEDGE THAT (1) YOU ARE
9+
AUTHORIZED TO ENTER THIS AGREEMENT FOR AND ON BEHALF OF YOUR COMPANY, AND
10+
ARE DOING SO, AND (2) YOU HAVE READ AND UNDERSTAND AND AGREE THAT YOU AND
11+
THE COMPANY SHALL BE BOUND BY THESE TERMS AND CONDITIONS AND ALL
12+
MODIFICATIONS AND ADDITIONS PROVIDED FOR
13+
14+
Software products included with this product that are not Hex Five
15+
products are licensed to you by the software provider. Please refer to
16+
the license contained in the provider's product for the terms of use
17+
before using such products.
18+
19+
1. License Grant. Hex Five grants you a limited, non-exclusive, non-
20+
transferable license to use, for non-commercial, non-production
21+
evaluation purposes only, the Hex Five software program(s), known as
22+
MultiZone(TM) Security (the "Software") and related product documentation at
23+
no charge subject to the terms and restrictions set forth in this License
24+
Agreement. You are not permitted to use the Software in any manner not
25+
expressly authorized by this License. You acknowledge and agree that
26+
ownership of the Software and all subsequent copies thereof regardless of
27+
the form or media are held by Hex Five.
28+
29+
2. Term of Agreement. Your license is effective until terminated by Hex
30+
Five (at Hex Five's sole discretion and without notice). The License will
31+
terminate automatically if you fail to comply with any of the limitations
32+
or other requirements described herein. At termination you shall cease
33+
all use of the Software and destroy all copies, full or partial of the
34+
Software.
35+
36+
3. Ownership Rights. The Software and related documentation are protected
37+
by United States copyright laws and international treaties. Hex Five,
38+
third party component providers and open source component providers own
39+
and retain all right, title and interest in and to the Software and
40+
related documentation, including all copyrights, patents, trade secret
41+
rights, trademarks and other intellectual property rights therein.
42+
43+
4. Use of Name and Trademarks. You shall not use the name, trade names or
44+
trademarks of Hex Five or any of its affiliates in any advertising,
45+
promotional literature or any other material, whether in written,
46+
electronic or other form without express written permission of Hex Five.
47+
48+
5. Restrictions.
49+
(A) You may not rent, lease, lend, redistribute or sublicense the
50+
Software. You may not copy the Software except to make archival or backup
51+
copies, provided that the backup copy must include all copyright or other
52+
proprietary notices contained on the original. You may not copy the
53+
related product documentation. You may not modify, reverse engineer,
54+
decompile, or disassemble the Software, except to the extent the
55+
foregoing restriction is expressly prohibited by applicable law. You may
56+
not publish any results from tests using the Software without the express
57+
written permission of Hex Five.
58+
59+
(B) Certain components of the Software are provided under various Open
60+
Source licenses that have been made available to Hex Five. You may modify
61+
or replace only these Open-Sourced Components; provided that (i) the
62+
resultant Software is used in place of the unmodified Software, on a
63+
single computer; and (ii) you otherwise comply with the terms of this
64+
License and any applicable licensing terms governing use of the Open-
65+
Sourced Components. Hex Five is not obligated to provide any maintenance,
66+
technical or other support for the resultant Software.
67+
68+
(C) This license is strictly for non-commercial, non-production
69+
evaluation purposes. You agree and acknowledge that you may not use the
70+
Software for any commercial purpose whatsoever.
71+
72+
6. Feedback. You agree that any feedback or ideas you provide to us
73+
regarding any Software or any suggested improvements thereto (together,
74+
the "Feedback") will be the exclusive property of Hex Five. To the extent
75+
you own any rights in the Feedback, you agree to assign and hereby do
76+
assign to us all right, title and interest in and to the Feedback. You
77+
agree to perform all acts reasonably requested by us to perfect and
78+
enforce such rights, including without limitation executing copyright
79+
assignments. We will reimburse you for direct out of pocket costs
80+
incurred in complying with our requests.
81+
82+
7. Exclusion of Warranties. THE SOFTWARE IS PROVIDED TO LICENSEE "AS IS",
83+
AND ANY USE BY LICENSEE OF THE SOFTWARE WILL BE AT LICENSEE'S SOLE RISK.
84+
HEX FIVE MAKES NO WARRANTIES RELATING TO THE SOFTWARE AND EXPRESSLY
85+
DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT
86+
LIMITATION THOSE OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
87+
88+
8. Limitation of Liability. IN NO EVENT SHALL HEX FIVE BE LIABLE FOR ANY
89+
INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES WHATSOEVER,
90+
INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, LOSS OF DATA,
91+
BUSINESS INTERRUPTON OR ANY OTHER COMMERCIAL DAMAGES OR LOSSES, ARISING
92+
OUT OF OR RELATED TO YOUR USE OR INABILITY TO USE THE HEX FIVE SOFTWARE,
93+
HOWEVER CAUSED, REGARDLESS OF THE THEORY OF LIABILTY (CONTRACT, TORT OR
94+
OTHERWISE) AND EVEN IF HEX FIVE HAS BEEN ADVISED OF THE POSSIBILITY OF
95+
SUCH DAMAGES.
96+
97+
9. Governing Law, Dispute Resolution. This Agreement is governed by the
98+
law of the State of California, U.S.A., without reference to conflict of
99+
laws principles. The application of the United Nations Convention of
100+
Contracts for the International Sale of Goods is expressly excluded.
101+
Venue for any disputes shall be in the state and federal courts located
102+
in San Jose, California.
103+
104+
10.No Export. You agree not to export, directly or indirectly, the
105+
Software or any components thereof to any country for which the U.S.
106+
Government or any agency thereof at the time of export requires an export
107+
license or other government approval without first obtaining such license
108+
or approval.
109+
110+
11.Assignment/Transfers. You may not assign or transfer this Agreement,
111+
in whole or in part, without Hex Five's prior written consent. Any
112+
attempted assignment or transfer in violation of this Section will be
113+
null and void.
114+
115+
12.Third Party Acknowledgements.
116+
(A) Aspects of the Software utilize or include third party software and
117+
other copyrighted material. Acknowledgements, licensing terms and
118+
disclaimers for such material are available when accessing the Software
119+
on the Hex Five website, and your use of such material is governed by
120+
their respective terms.
121+
(B) The Software includes certain software provided under various Open
122+
Source licenses. You may obtain complete machine-readable copies of the
123+
source code and licenses for the Open Source software at the Hex Five
124+
Open Source website (https://www.hex-five.com/oslicenses). Open Source
125+
Software is distributed WITHOUT ANY WARRANTY, without even the implied
126+
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
127+
128+
13.Severability. If any provision of this Agreement is held invalid,
129+
illegal or unenforceable, the validity, legality and enforceability of
130+
any of the remaining provisions of this Agreement shall not in any way be
131+
affected or impaired.
132+
133+
14.Entire Agreement. This Agreement is the entire agreement between you
134+
and Hex Five concerning the Software and all related documentation and
135+
supersedes any other prior or contemporaneous agreements or
136+
communications with respect to the Software and related documentation,
137+
whether written or oral.

Makefile

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Copyright(C) 2018 Hex Five Security, Inc. - All Rights Reserved
2+
3+
4+
#############################################################
5+
# Toolchain definitions
6+
#############################################################
7+
8+
ifndef RISCV
9+
$(error RISCV not set)
10+
endif
11+
12+
ifndef GNAT
13+
$(error GNAT not set)
14+
endif
15+
16+
export CROSS_COMPILE := $(abspath $(RISCV))/bin/riscv64-unknown-elf-
17+
export CC := $(CROSS_COMPILE)gcc
18+
export OBJDUMP := $(CROSS_COMPILE)objdump
19+
export OBJCOPY := $(CROSS_COMPILE)objcopy
20+
export GDB := $(CROSS_COMPILE)gdb
21+
export AR := $(CROSS_COMPILE)ar
22+
23+
24+
#############################################################
25+
# Platform definitions
26+
#############################################################
27+
28+
BOARD ?= X300
29+
ifeq ($(BOARD),E31)
30+
ARCH := rv32
31+
RISCV_ARCH := $(ARCH)imac
32+
RISCV_ABI := ilp32
33+
else ifeq ($(BOARD),X300)
34+
ARCH := rv32
35+
RISCV_ARCH := $(ARCH)imac
36+
RISCV_ABI := ilp32
37+
else ifeq ($(BOARD),E51)
38+
ARCH := rv64
39+
RISCV_ARCH := $(ARCH)imac
40+
RISCV_ABI := lp64
41+
else ifeq ($(BOARD),S51)
42+
ARCH := rv64
43+
RISCV_ARCH := $(ARCH)imac
44+
RISCV_ABI := lp64
45+
else
46+
$(error Unsupported board $(BOARD))
47+
endif
48+
49+
50+
#############################################################
51+
# Arguments/variables available to all submakes
52+
#############################################################
53+
54+
export BOARD
55+
export RISCV_ARCH
56+
export RISCV_ABI
57+
58+
59+
#############################################################
60+
# Rules for building multizone
61+
#############################################################
62+
63+
.PHONY: all
64+
all: clean
65+
$(MAKE) -C zone1
66+
$(MAKE) -C zone2
67+
$(MAKE) -C zone3
68+
java -jar multizone.jar -c bsp/$(BOARD)/multizone.cfg zone1/zone1.hex zone2/zone2.hex zone3/zone3.hex --arch=$(BOARD)
69+
70+
.PHONY: clean
71+
clean:
72+
$(MAKE) -C zone1 clean
73+
$(MAKE) -C zone2 clean
74+
$(MAKE) -C zone3 clean
75+
rm -f multizone.hex
76+
77+
78+
#############################################################
79+
# Load and debug variables and rules
80+
#############################################################
81+
82+
ifndef OPENOCD
83+
$(error OPENOCD not set)
84+
endif
85+
86+
OPENOCD := $(abspath $(OPENOCD))/bin/openocd
87+
88+
OPENOCDCFG ?= bsp/$(BOARD)/openocd.cfg
89+
OPENOCDARGS += -f $(OPENOCDCFG)
90+
91+
GDB_PORT ?= 3333
92+
GDB_LOAD_ARGS ?= --batch
93+
GDB_LOAD_CMDS += -ex "set mem inaccessible-by-default off"
94+
GDB_LOAD_CMDS += -ex "set remotetimeout 240"
95+
GDB_LOAD_CMDS += -ex "set arch riscv:$(ARCH)"
96+
GDB_LOAD_CMDS += -ex "target extended-remote localhost:$(GDB_PORT)"
97+
GDB_LOAD_CMDS += -ex "monitor reset halt"
98+
GDB_LOAD_CMDS += -ex "monitor flash protect 0 64 last off"
99+
GDB_LOAD_CMDS += -ex "load"
100+
GDB_LOAD_CMDS += -ex "monitor resume"
101+
GDB_LOAD_CMDS += -ex "monitor shutdown"
102+
GDB_LOAD_CMDS += -ex "quit"
103+
104+
.PHONY: load
105+
106+
load:
107+
$(OPENOCD) $(OPENOCDARGS) & \
108+
$(GDB) multizone.hex $(GDB_LOAD_ARGS) $(GDB_LOAD_CMDS)
109+

README.md

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# multizone-ada
2+
MultiZone™ Security Trusted Execution Environment Ada Example
3+
4+
This repository, maintained by Hex Five Security, is a companion to the
5+
[multizone-sdk](https://github.com/hex-five/multizone-sdk) repository, intended
6+
to showcase Ada running on MultiZone.
7+
8+
This repo supports only the Hex Five X300 - RV32ACIMU Core for Xilinx Arty
9+
A7-35T FPGA whereas MultiZone Security SDK supports the following cores /
10+
boards:
11+
- Hex Five X300 - RV32ACIMU Core for Xilinx Arty A7-35T FPGA
12+
- Andes N25 - RV32ACIMU Core for GOWIN GW2A-55K FPGA
13+
- SiFive E31 - RV32ACIMU Core for Xilinx Arty A7-35T FPGA
14+
- SiFive E51 - RV64ACIMU Core for Xilinx Arty A7-35T FPGA
15+
- SiFive S51 - RV64ACIMU Core for Xilinx Arty A7-35T FPGA
16+
17+
For Questions or feedback - send email to info 'at' hex-five.com.
18+
19+
### Installation ###
20+
21+
Upload the bitstream to the Arty board following directions from SiFive - https://sifive.cdn.prismic.io/sifive%2Fed96de35-065f-474c-a432-9f6a364af9c8_sifive-e310-arty-gettingstarted-v1.0.6.pdf
22+
23+
Install the GNAT Community Edition for RISC-V ELF from https://www.adacore.com/download.
24+
25+
Install the certified RISC-V toolchain for Linux - directions specific to a fresh Ubuntu 18.04 LTS, other Linux distros generally a subset
26+
```
27+
sudo apt update
28+
sudo apt upgrade -y
29+
sudo apt install git make default-jre libftdi1-dev
30+
sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4
31+
wget https://github.com/hex-five/multizone-sdk/releases/download/v0.1.0/riscv-gnu-toolchain-20181226.tar.xz
32+
tar -xvf riscv-gnu-toolchain-20181226.tar.xz
33+
wget https://github.com/hex-five/multizone-sdk/releases/download/v0.1.0/riscv-openocd-20181226.tar.xz
34+
tar -xvf riscv-openocd-20181226.tar.xz
35+
git clone https://github.com/hex-five/multizone-ada
36+
sudo apt-get install libusb-0.1-4
37+
sudo apt-get install screen
38+
```
39+
40+
If you have not already done so, you need to edit or create a file to place the USB devices until plugdev group so you can access them without root privileges:
41+
```
42+
sudo vi /etc/udev/rules.d/99-openocd.rules
43+
```
44+
Then place the following text in that file if it is not already there
45+
```
46+
# These are for the HiFive1 Board
47+
SUBSYSTEM=="usb", ATTR{idVendor}=="0403",
48+
ATTR{idProduct}=="6010", MODE="664", GROUP="plugdev"
49+
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403",
50+
ATTRS{idProduct}=="6010", MODE="664", GROUP="plugdev"
51+
# These are for the Olimex Debugger for use with E310 Arty Dev Kit
52+
SUBSYSTEM=="usb", ATTR{idVendor}=="15ba",
53+
ATTR{idProduct}=="002a", MODE="664", GROUP="plugdev"
54+
SUBSYSTEM=="tty", ATTRS{idVendor}=="15ba",
55+
ATTRS{idProduct}=="002a", MODE="664", GROUP="plugdev"
56+
```
57+
Detach and re-attach the USB devices for these changes to take effect.
58+
59+
Add environment variables and a path to allow the Makefiles to find the toolchain
60+
61+
edit ~/.bashrc and ~/.profile and place the following text at the bottom of both files.
62+
63+
Add environment variables and a path to allow the build script to find the
64+
toolchain. For example, edit ~/.bashrc and ~/.profile and place the following
65+
text at the bottom of both files:
66+
```
67+
export GNAT=/home/<username>/GNAT/2018-riscv32-elf
68+
export RISCV=/home/<username>/riscv-gnu-toolchain-20181226
69+
export OPENOCD=/home/<username>/riscv-openocd-20181226
70+
export PATH="$PATH:/home/<username>/riscv-gnu-toolchain-20181226/bin"
71+
```
72+
Close and restart the terminal session for these changes to take effect.
73+
74+
### Compile and Upload the Project to the Arty Board ###
75+
76+
```
77+
cd multizone-ada/
78+
make clean
79+
make
80+
```
81+
82+
This will result in a HEX file that is now ready to upload to the Arty board.
83+
84+
```
85+
make load
86+
```
87+
88+
### Operate the Demo ###
89+
90+
The system contains three zones:
91+
- Zone 1: UART Console (115200 baud, 8N1) with commands that enable the following:
92+
- load, store exec - issue discrete load / store / exec commands to test the boundaries of physical memory protection in Zone 1
93+
- invalid commands generate hardware exceptions that send a response to the user via handlers that are registered in main.c
94+
- send / recv messages to / from other zones
95+
- timer - set a soft timer in ms
96+
- yield - measure the round trip time through three zones when you yield context
97+
- stats - complete a number of yield commands and calculate statistics on performance
98+
- restart - restart the console
99+
- Zone 2: LED PWM + Interrupts
100+
- This Zone is running a modified version of SiFive's coreplexip_welcome demo with trap and emulate functions
101+
- Buttons 0-2 are mapped to interrupts in this Zone, they will cause the LED to change color for 5s and send a message to zone 1
102+
- These interrupt handlers themselves can be interrupted and resumed by pressing another button before the first handler is complete
103+
- Zone 3: Robot Control
104+
- This zone controls a robot via GPIO; if you do not have the robot then this zone simply yields for you
105+
- Robot commands are all issued ia messages from zone 1:
106+
- send 3 > - unfold
107+
- send 3 1 - begin recursive dance
108+
- send 3 0 - stop recursive dance when it reaches home
109+
- send 3 < - fold
110+
111+
### For More Information ###
112+
113+
See the MultiZone Manual (Pending) or visit [http://www.hex-five.com](https://www.hex-five.com)

bsp/X300/ada/LICENSE

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (C) 2015-2016, AdaCore
2+
Copyright (C) 2019, Hex Five Security, Inc.
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in the
11+
documentation and/or other materials provided with the distribution.
12+
* Neither the name of the copyright holder nor the
13+
names of its contributors may be used to endorse or promote products
14+
derived from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)