From 9da44c2a03f1a238cbe08a461808466b7c6feea9 Mon Sep 17 00:00:00 2001 From: Sebastian Renner Date: Mon, 20 Jan 2020 12:24:15 +0100 Subject: [PATCH] Gapuino template compiling within the framework --- DSlogic.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ templates/gapuino/Makefile | 27 +++++++++++++++++---------- templates/gapuino/README.md | 14 -------------- templates/gapuino/include/api.h | 5 ----- templates/gapuino/platformio.ini | 16 ---------------- templates/gapuino/src/api.h | 5 ----- templates/gapuino/src/main.cpp | 25 +++++++++++++------------ templates/gapuino/src/uartp.c | 3 +-- 8 files changed, 82 insertions(+), 64 deletions(-) create mode 100755 DSlogic.sh delete mode 100644 templates/gapuino/README.md delete mode 100644 templates/gapuino/include/api.h delete mode 100644 templates/gapuino/platformio.ini delete mode 100644 templates/gapuino/src/api.h diff --git a/DSlogic.sh b/DSlogic.sh new file mode 100755 index 0000000..eba5e6f --- /dev/null +++ b/DSlogic.sh @@ -0,0 +1,51 @@ +#!/bin/sh +## +## This file is part of the sigrok-util project. +## +## Copyright (C) 2016 Uwe Hermann +## +## 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 . +## + +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 diff --git a/templates/gapuino/Makefile b/templates/gapuino/Makefile index 46a895e..caa45cc 100644 --- a/templates/gapuino/Makefile +++ b/templates/gapuino/Makefile @@ -1,13 +1,20 @@ -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 diff --git a/templates/gapuino/README.md b/templates/gapuino/README.md deleted file mode 100644 index fb5ddf2..0000000 --- a/templates/gapuino/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## 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` diff --git a/templates/gapuino/include/api.h b/templates/gapuino/include/api.h deleted file mode 100644 index 0b1d09b..0000000 --- a/templates/gapuino/include/api.h +++ /dev/null @@ -1,5 +0,0 @@ -#define CRYPTO_KEYBYTES 16 -#define CRYPTO_NSECBYTES 0 -#define CRYPTO_NPUBBYTES 12 -#define CRYPTO_ABYTES 8 -#define CRYPTO_NOOVERLAP 1 diff --git a/templates/gapuino/platformio.ini b/templates/gapuino/platformio.ini deleted file mode 100644 index 4fddd3c..0000000 --- a/templates/gapuino/platformio.ini +++ /dev/null @@ -1,16 +0,0 @@ -;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 diff --git a/templates/gapuino/src/api.h b/templates/gapuino/src/api.h deleted file mode 100644 index 290a70d..0000000 --- a/templates/gapuino/src/api.h +++ /dev/null @@ -1,5 +0,0 @@ -#define CRYPTO_KEYBYTES 32 -#define CRYPTO_NSECBYTES 0 -#define CRYPTO_NPUBBYTES 12 -#define CRYPTO_ABYTES 8 -#define CRYPTO_NOOVERLAP 1 diff --git a/templates/gapuino/src/main.cpp b/templates/gapuino/src/main.cpp index a24e255..72e9df4 100644 --- a/templates/gapuino/src/main.cpp +++ b/templates/gapuino/src/main.cpp @@ -1,9 +1,9 @@ -#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(); +} + diff --git a/templates/gapuino/src/uartp.c b/templates/gapuino/src/uartp.c index e520cfc..d25236b 100644 --- a/templates/gapuino/src/uartp.c +++ b/templates/gapuino/src/uartp.c @@ -1,5 +1,5 @@ -#include #include "uartp.h" +#include 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) { } } - -- libgit2 0.26.0