Commit 9da44c2a by Sebastian Renner

Gapuino template compiling within the framework

parent 507f1d08
#!/bin/sh
##
## This file is part of the sigrok-util project.
##
## Copyright (C) 2016 Uwe Hermann <uwe@hermann-uwe.de>
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##
umask 022
WGET="wget -c -q"
if [ -z $PREFIX ]; then
PREFIX="/usr/local"
fi
FWDIR="$PREFIX/share/sigrok-firmware"
# Use the upstream 0.97 firmware/bitstream set. This is the only supported
# set of files in libsigrok >= 20170621.
FWURL="https://github.com/DreamSourceLab/DSView/raw/886b847c21c606df3138ce7ad8f8e8c363ee758b/DSView/res"
echo "Installing into: $FWDIR"
mkdir -p $FWDIR
$WGET $FWURL/DSLogic50.bin -O $FWDIR/dreamsourcelab-dslogic-fpga-5v.fw
$WGET $FWURL/DSLogic33.bin -O $FWDIR/dreamsourcelab-dslogic-fpga-3v3.fw
$WGET $FWURL/DSLogic.fw -O $FWDIR/dreamsourcelab-dslogic-fx2.fw
$WGET $FWURL/DSCope.bin -O $FWDIR/dreamsourcelab-dscope-fpga.fw
$WGET $FWURL/DSCope.fw -O $FWDIR/dreamsourcelab-dscope-fx2.fw
$WGET $FWURL/DSLogicPro.bin -O $FWDIR/dreamsourcelab-dslogic-pro-fpga.fw
$WGET $FWURL/DSLogicPro.fw -O $FWDIR/dreamsourcelab-dslogic-pro-fx2.fw
$WGET $FWURL/DSLogicPlus.bin -O $FWDIR/dreamsourcelab-dslogic-plus-fpga.fw
$WGET $FWURL/DSLogicPlus.fw -O $FWDIR/dreamsourcelab-dslogic-plus-fx2.fw
$WGET $FWURL/DSLogicBasic.bin -O $FWDIR/dreamsourcelab-dslogic-basic-fpga.fw
$WGET $FWURL/DSLogicBasic.fw -O $FWDIR/dreamsourcelab-dslogic-basic-fx2.fw
LFLAGS=-lm
all: gapuino
# User Test
#------------------------------------------
INC += include/
VPATH = src/
TEST_CXX = main.cpp
TEST_C = uartp.c \
$(SRC_FILES)
# If you do not want to use RTOS, comment it.
# If you want use RTOS then uncomment it.
# MBED_FLAGS += -DMBED_CONF_RTOS_PRESENT=1
gapuino: .pioenvs/gapuino/firmware.bin
# For RTOS Jenkins test, it will never finished so add a jenkins test Flag to exit().
# MBED_FLAGS +=-DJENKINS_TEST_FLAG=1
.pioenvs/gapuino/firmware.bin: FORCE
platformio run -e gapuino
# RTL Simulation
#------------------------------------------
# recordWlf=YES
# vsimDo="-do ~/wave_uart.do"
FORCE: ;
.PHONY: clean
clean:
-rm .pioenvs/gapuino/firmware.bin
include $(GAP_SDK_HOME)/tools/rules/mbed_rules.mk
## Steps to getting the GAP SDK run on Linux
In general, follow this README: https://github.com/GreenWaves-Technologies/gap_sdk/blob/master/README.md
PLUS
### Fix the -Werror flag to make openocd compile
Comment this line in gap_sdk/tools/gap8-openocd
`GCC_WARNINGS="${GCC_WARNINGS} -Werror"`
### Fix libmpfr version error
`sudo ln -s /usr/lib/libmpfr.so.6 /usr/lib/libmpfr.so.4`
#define CRYPTO_KEYBYTES 16
#define CRYPTO_NSECBYTES 0
#define CRYPTO_NPUBBYTES 12
#define CRYPTO_ABYTES 8
#define CRYPTO_NOOVERLAP 1
;PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:gapuino]
platform = riscv_gap
board = gapuino
framework = mbed
board_upload.boot_mode = jtag
board_upload.commands = reqloop ioloop start wait
#define CRYPTO_KEYBYTES 32
#define CRYPTO_NSECBYTES 0
#define CRYPTO_NPUBBYTES 12
#define CRYPTO_ABYTES 8
#define CRYPTO_NOOVERLAP 1
#include "api.h"
#include "uartp.h"
#include "crypto_aead.h"
#include "mbed.h"
#include "gap_common.h"
#include "cmsis.h"
#include "crypto_aead.h"
#include "api.h"
#include "uartp.h"
#define MAX_BYTES 100
#define CMDBUF_LEN 72
......@@ -25,13 +25,11 @@ unsigned long long int clen = 0;
int res = 0;
void setup();
//void loop();
void loop();
DigitalOut crypto_pin(CRYPTO_BUSY);
#ifdef __cplusplus
extern "C" {
#endif
void uart_wbyte(uint8_t x) {
device.putc((uint8_t) (x));
......@@ -45,9 +43,7 @@ uint8_t uart_rbyte() {
return (uint8_t) (0xff & r);
}
#ifdef __cplusplus
}
#endif
void my_assert(bool b) {
if (b)
......@@ -57,8 +53,8 @@ void my_assert(bool b) {
}
void setup() {
device.baud(9600);
PORT_SetPinMux(PORTA, 35, uPORT_MuxGPIO);
device.baud(115200);
crypto_pin = 1;
wait(100);
memset(npub, 0, CRYPTO_NPUBBYTES);
......@@ -70,13 +66,12 @@ void setup() {
device.printf("Hello, World!");
}
int main() {
setup();
void loop() {
int res;
uint16_t len = uartp_recv(cmdbuf, CMDBUF_LEN - 1);
uint8_t action = cmdbuf[0];
if (len == 0 || len > CMDBUF_LEN - 1)
return 1;
while (1) {};
uint16_t l = len - 1;
uint16_t rl = 0;
......@@ -120,3 +115,9 @@ int main() {
memcpy(cmdbuf+1, var, rl);
uartp_send(cmdbuf, rl+1);
}
int main() {
setup();
while(1) loop();
}
#include <stdint.h>
#include "uartp.h"
#include <stdint.h>
extern void uart_wbyte(uint8_t x);
extern uint8_t uart_rbyte();
......@@ -72,4 +72,3 @@ uint16_t uartp_recv(void *dst, uint16_t buf_len) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment