├── LICENSE ├── README.md └── docker └── main ├── Dockerfile ├── files ├── Murax.launch └── project.bash └── startup.sh /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpinalDev - Development Environment for SpinalHDL 2 | 3 | [SpinalHDL](https://github.com/SpinalHDL/SpinalHDL) is a hardware description language (HDL). SpinalHDL written on top of Scala and allows for high level constructs. This repository contains a **Dockerfile** for FPGA/ASIC development with SpinalHDL. The Dockerfile and content of this README is mostly based on the instructions found at . The container includes a number of tools, libraries and dependencies related to SpinalHDL. 4 | 5 | 6 | ## Container Content 7 | 8 | The following tools and libraries are installed: 9 | 10 | - [Scala](https://www.scala-lang.org/)/[Sbt](https://www.scala-sbt.org/) 11 | - [SpinalHDL](https://github.com/SpinalHDL/SpinalHDL) 12 | - SpinalHDL core 13 | - SpinalHDL lib 14 | - SpinalSim 15 | - [SpinalTemplate](https://github.com/SpinalHDL/SpinalTemplateSbt) 16 | - [VexRiscv CPU](https://github.com/SpinalHDL/VexRiscv) 17 | - [VexRiscv SoC software](https://github.com/SpinalHDL/VexRiscvSocSoftware) 18 | - [CocoTB](https://github.com/potentialventures/cocotb) 19 | - [GTK wave](http://gtkwave.sourceforge.net/) 20 | - [Verilator](https://www.veripool.org/wiki/verilator) 21 | - [RiscV gcc cross-compiler](https://github.com/riscv/riscv-gnu-toolchain) 22 | - [Yosys](http://www.clifford.at/yosys/) 23 | - [IceStorm Tools](http://www.clifford.at/icestorm/) 24 | - IcePack/IceUnPack/Icetime/IceProg 25 | /IceMulti/IcePLL/IceBRAM 26 | - [Arachne-PNR](https://github.com/cseed/arachne-pnr) 27 | - general tools: GIT/python/emacs/... 28 | - X11/ xfce4 desktop environment 29 | - Remote Desktop (rdp) Server listening on port 3389 30 | - [Intellij IDE](https://www.jetbrains.com/idea/) with [Scala plugin](https://plugins.jetbrains.com/plugin/1347-scala) 31 | - Eclipse IDE 32 | 33 | 34 | ## Getting Started 35 | 36 | The best way to get started is to download the image for this 37 | container directly from Doc Hub and then run the container and play 38 | inside it. Here are the steps for Ubuntu. 39 | 40 | 1. Install docker client (e.g. see [docker docks](https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce)) 41 | 2. Get the image, either 42 | * get image from docker hub 43 | * `sudo docker pull plex1/spinaldev` 44 | * OR build image yourself 45 | * `git clone https://github.com/plex1/SpinalDev.git` 46 | * `cd SpinalDev/docker/main/` 47 | * `sudo docker build -t plex1/spinaldev .` 48 | 3. Add X access for root 49 | * `xhost local:root` 50 | 4. Run the docker container 51 | * `sudo docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -p 3389:3389 plex1/spinaldev:latest` 52 | 5. You are now logged into the development environment as the user spinaldev 53 | 54 | As a first step you can run the following commands. They build and test an example design. 55 | ```sh 56 | # Go to a SpinalHDL example project 57 | cd projects/spinal/SpinalTemplateSbt 58 | 59 | # Generate the Verilog of the design 60 | sbt "runMain mylib.MyTopLevelVerilog" 61 | 62 | # Inspect generated files 63 | ls 64 | cat MyTopLevel.v 65 | 66 | # Run the scala testbench 67 | sbt "runMain mylib.MyTopLevelSim" 68 | 69 | # Inspect the waveform of the simulation 70 | gtkwave simWorkspace/MyTopLevel/test.vcd& 71 | 72 | ``` 73 | Have fun! 74 | 75 | 76 | ## Remote Desktop 77 | 78 | There is a remote desktop server running in the container. To connect from linux you may execute the following command. 79 | 80 | `rdesktop -z -P -x l -g 1024x768 127.0.0.1:3389` 81 | 82 | Then login as user spinaldev with password spinaldev. To connect from windows you may use the native remote desktop client. 83 | 84 | 85 | ## Tour of the environment 86 | 87 | ### Build the CPU 88 | The VexRiscv risc-v processor can be build with the following set of commands. 89 | 90 | ```sh 91 | # Go to a risc-v cpu 92 | cd /home/spinaldev/projects/spinal/VexRiscv 93 | 94 | # Generate the verilog of the cpu 95 | sbt "runMain vexriscv.demo.GenFull" 96 | 97 | # Inspect generated files 98 | ls 99 | head VexRiscv.v 100 | ``` 101 | 102 | ### Run a simulation of the CPU 103 | The cpu including software can be simulated and debugged in the container. First, we start a simulation using verilator. 104 | 105 | ```sh 106 | # Run a simulation of the cpu with a port for OpenOCD to connect to 107 | cd src/test/cpp/regression 108 | make run DEBUG_PLUGIN_EXTERNAL=yes 109 | 110 | ``` 111 | 112 | The last message shows BOOT which means that the simulation is running in a process. We open a second terminal. E.g. via docker from your host: 113 | ``` 114 | docker exec -u spinaldev -it container_id bash 115 | ``` 116 | In this second terminal we run the following commands to start the OpenOCD server. The server is connected to the simulation which we started above. 117 | 118 | ```sh 119 | # Start the OpenOCD server 120 | cd /opt/openocd_riscv/ 121 | src/openocd -c "set VEXRISCV_YAML /home/spinaldev/projects/spinal/VexRiscv/cpu0.yaml" -f tcl/target/vexriscv_sim.cfg 122 | ``` 123 | 124 | We should now have two terminals open and we will open a third one (e.g. as describe above). Here we run the actual debugger and connect it to the OpenOCD server via tcp port 3333. 125 | ```sh 126 | # Run the debugger with prebuild uart example sw 127 | riscv64-unknown-elf-gdb ~/projects/spinal/VexRiscv/src/test/resources/elf/uart.elf 128 | target remote localhost:3333 129 | monitor reset halt 130 | load 131 | continue 132 | ``` 133 | Now, the simulation of the cpu is running and messages shoud be printed in the first terminal. Specifically, we can see the uart output of the program. 134 | 135 | ### Build the software 136 | Software for the VexRiscv can be compiled as follows. In this example the uart program for the briey soc is built. 137 | ```sh 138 | # Build the elf file 139 | cd ~/projects/spinal/VexRiscvSocSoftware/projects/briey/uart 140 | make all 141 | 142 | # Inspect the generated files 143 | ls build/ 144 | 145 | ``` 146 | 147 | ### Create programming file 148 | This container contains all the tools to generate the programming files for a lattice iCE40 149 | FPGAs. A script to generate the [Murax System-on-chip](https://github.com/SpinalHDL/VexRiscv#murax-soc) for the [iCE40HX8K-EVB](https://www.olimex.com/Products/FPGA/iCE40/iCE40HX8K-EVB/open-source-hardware) open source hardware board is provided in the VexRiscv repository. The following command is necssary to build the bin file. 150 | ```sh 151 | # Compilation / synthesis / place and route / bitstream generation 152 | cd ~/projects/spinal/VexRiscv/scripts/Murax/iCE40HX8K-EVB 153 | make compile 154 | 155 | # Inspect the generated files 156 | ls bin/ 157 | 158 | ``` 159 | 160 | 161 | ## Docker Volumes 162 | 163 | When working with projects in SpinalDev it is recommended to use docker volumes. The data in containers is not persistent. Therfore the data needs to be stored on the host and mounted in the container (volumes). Docker has build in methods to deal with volumes. It is recommeded to mount the complete home directory (/home/spinaldev). This is because in home some application data is stored. E.g the for the intellij editor this data is under ~/.idea. Without keeping this data upd to date, the idea application and projects become unsynchronized and projects cannot be opened anymore. The following procedure to generate the docker volumes is recommended. The first time when the docker run command is executed the content of the docker home directory is copied onto the host (in this example under /home/username/spinalvol). 164 | 165 | ```sh 166 | mkdir /home/username/spinalvol 167 | sudo docker volume create --driver local --opt type=none --opt device=/home/username/spinalvol --opt o=bind spinalvol 168 | sudo docker volume inspect spinalvol 169 | 170 | sudo docker run -it --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v spinalvol:/home/spinaldev -p 3389:3389 plex1/spinaldev:latest 171 | ``` 172 | 173 | See also on the [docker website](https://docs.docker.com/engine/admin/volumes/volumes/). 174 | 175 | 176 | ## Create your own projects 177 | 178 | To create your own projects run the `project.bash` script and follow the instructions. 179 | 180 | ```sh 181 | cd /home/spinaldev/projects/user 182 | ./project.bash -h 183 | ``` 184 | -------------------------------------------------------------------------------- /docker/main/Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # SpinalDev Dockerfile 3 | # 4 | # https://github.com/plex1/SpinalDev 5 | # 6 | # This Dockerfile creates a image full of useful tools for 7 | # SpinalHDL development. See associated README.md for more 8 | # information. This Dockerfile is mostly based on the instructions 9 | # found at https://spinalhdl.github.io/SpinalDoc. 10 | 11 | # Pull base image 12 | FROM ubuntu:16.04 13 | 14 | # Set the maintainer 15 | MAINTAINER Felix Arnold (plex1) 16 | 17 | # Global arguments 18 | ARG USER=spinaldev 19 | ARG USERPWD=spinaldev 20 | ARG WORKDIR=/home/spinaldev 21 | ARG ROOTPWD=spinaldev 22 | 23 | # Set frontend required for docker 24 | ENV DEBIAN_FRONTEND noninteractive 25 | 26 | ####### Packages ####################################### 27 | # Install some base tools and x11 tools 28 | RUN apt-get update && apt-get install -y \ 29 | apt-utils \ 30 | sudo \ 31 | unzip \ 32 | wget \ 33 | adwaita-icon-theme-full \ 34 | emacs \ 35 | git \ 36 | x11-apps \ 37 | xfce4\ 38 | xrdp \ 39 | xfce4-terminal 40 | 41 | 42 | ####### Linux ########################################## 43 | 44 | # Change root password 45 | RUN echo "root:${ROOTPWD}" | chpasswd 46 | 47 | # Create the default user 48 | RUN useradd -m -s /bin/bash -d ${WORKDIR} ${USER} 49 | RUN echo "${USER}:${USERPWD}" | chpasswd 50 | RUN adduser ${USER} sudo 51 | 52 | # Customize terminal 53 | RUN echo 'RESET="\[$(tput sgr0)\]"' >> $WORKDIR/.bashrc 54 | RUN echo 'GREEN="\[$(tput setaf 2)\]"' >> $WORKDIR/.bashrc 55 | RUN echo 'export PS1="${GREEN}\u:\W${RESET} $ "' >> $WORKDIR/.bashrc 56 | 57 | # owner settings: 58 | # - user root for all files in /opt 59 | # - user spinaldev for all files in /home/spinaldev 60 | 61 | 62 | ####### Spinal HDL and tools ############################## 63 | 64 | USER root 65 | # Install java and scala 66 | RUN apt-get update && apt-get install -y \ 67 | openjdk-8-jdk \ 68 | scala 69 | 70 | # Install sbt 71 | RUN apt-get install -y apt-transport-https #required for sbt debian 72 | RUN echo "deb https://dl.bintray.com/sbt/debian /" | sudo tee -a /etc/apt/sources.list.d/sbt.list 73 | RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2EE0EA64E40A89B84B2DF73499E82A75642AC823 74 | RUN apt-get update 75 | RUN apt-get -y install sbt 76 | 77 | USER $USER 78 | 79 | # Install spinal core & lib 80 | RUN mkdir -p $WORKDIR/tools/spinal 81 | RUN git clone https://github.com/SpinalHDL/SpinalHDL.git $WORKDIR/tools/spinal/SpinalHDL 82 | WORKDIR $WORKDIR/tools/spinal/SpinalHDL 83 | RUN sbt clean compile publishLocal 84 | 85 | RUN mkdir -p $WORKDIR/projects/spinal 86 | RUN cd $WORKDIR/projects/spinal 87 | RUN git clone https://github.com/SpinalHDL/VexRiscv.git $WORKDIR/projects/spinal/VexRiscv 88 | RUN git clone https://github.com/SpinalHDL/SpinalTemplateSbt.git $WORKDIR/projects/spinal/SpinalTemplateSbt 89 | RUN git clone https://github.com/SpinalHDL/VexRiscvSocSoftware.git $WORKDIR/projects/spinal/VexRiscvSocSoftware 90 | 91 | USER root 92 | 93 | # Install verilator 94 | # Verilator (version 3.9+ required, in general apt-get will give 3.8) 95 | RUN apt-get update && apt-get install -y \ 96 | git \ 97 | make \ 98 | autoconf \ 99 | g++ \ 100 | flex \ 101 | bison 102 | 103 | USER $USER 104 | 105 | RUN mkdir -p $WORKDIR/tools 106 | RUN git clone http://git.veripool.org/git/verilator $WORKDIR/tools/verilator 107 | RUN unset VERILATOR_ROOT 108 | WORKDIR $WORKDIR/tools/verilator 109 | # Create ./configure script 110 | RUN autoconf 111 | RUN ./configure 112 | RUN make -j$(nproc) 113 | USER root 114 | RUN echo "${USER} ALL =(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers 115 | USER $USER 116 | RUN sudo make install 117 | 118 | # Install COCOTB 119 | RUN sudo apt-get update && sudo apt-get install -y \ 120 | gcc \ 121 | g++ \ 122 | swig \ 123 | python-dev 124 | 125 | WORKDIR $WORKDIR/tools 126 | 127 | RUN git clone https://github.com/potentialventures/cocotb 128 | RUN export COCOTB=$WORKDIR/tools/cocotb 129 | RUN echo 'export COCOTB=$WORKDIR/tools/cocotb' >> ~/.bashrc 130 | 131 | # Install GTKWave 132 | RUN sudo apt-get install -y gtkwave 133 | 134 | RUN mkdir -p $WORKDIR/projects/user 135 | 136 | 137 | ####### RICSV ############################################# 138 | 139 | USER root 140 | 141 | # Make a working folder and set the necessary environment variables. 142 | ENV RISCV /opt/riscv 143 | ENV NUMJOBS 1 144 | 145 | 146 | # Add the GNU utils bin folder to the path. 147 | ENV PATH $RISCV/bin:$PATH 148 | RUN echo 'export PATH=/opt/riscv/bin:$PATH' >> $WORKDIR/.bashrc 149 | 150 | # Set the version variables 151 | ARG RISCV_GCC_VER=riscv64-unknown-elf-gcc-20170612-x86_64-linux-centos6 152 | 153 | WORKDIR /opt 154 | 155 | # Download pre-built gcc compiler 156 | RUN wget https://static.dev.sifive.com/dev-tools/$RISCV_GCC_VER.tar.gz -q && \ 157 | tar -xzvf $RISCV_GCC_VER.tar.gz && \ 158 | mv $RISCV_GCC_VER /opt/riscv && \ 159 | rm $RISCV_GCC_VER.tar.gz 160 | 161 | # Run a simple test to make sure compile is setup corretly 162 | RUN mkdir -p $RISCV/test 163 | WORKDIR $RISCV/test 164 | RUN echo '#include \n int main(void) { printf("Hello \ 165 | world!\\n"); return 0; }' > hello.c 166 | RUN riscv64-unknown-elf-gcc -o hello hello.c 167 | 168 | 169 | ####### FPGA/ASIC FLOW #################################### 170 | 171 | WORKDIR /opt 172 | 173 | #openocd-riscv-vecriscv 174 | RUN apt-get install -y \ 175 | libtool automake libusb-1.0.0-dev texinfo libusb-dev libyaml-dev pkg-config 176 | 177 | RUN git clone https://github.com/SpinalHDL/openocd_riscv.git && \ 178 | cd openocd_riscv && \ 179 | ./bootstrap && \ 180 | ./configure --enable-ftdi --enable-dummy && \ 181 | make 182 | 183 | #icepack see http://www.clifford.at/icestorm/ 184 | #icepack dependencies 185 | RUN apt-get install -y \ 186 | pkg-config \ 187 | libftdi-dev \ 188 | libffi-dev 189 | 190 | #yosys dependencies 191 | RUN apt-get install -y \ 192 | tcl-dev \ 193 | clang\ 194 | gawk \ 195 | libreadline-dev \ 196 | mercurial 197 | 198 | # yosys 199 | RUN git clone https://github.com/YosysHQ/yosys.git yosys && \ 200 | cd yosys && \ 201 | make -j$(nproc) && \ 202 | make install 203 | 204 | # icepack 205 | RUN git clone https://github.com/cliffordwolf/icestorm.git icestorm && \ 206 | cd icestorm && \ 207 | make -j$(nproc) && \ 208 | make install 209 | 210 | # arachne-pnr 211 | RUN git clone https://github.com/YosysHQ/arachne-pnr.git arachne-pnr && \ 212 | cd arachne-pnr && \ 213 | make -j$(nproc) && \ 214 | make install 215 | 216 | # iceprogduino 217 | # see https://github.com/OLIMEX/iCE40HX1K-EVB/tree/master/programmer/iceprogduino 218 | 219 | #RUN sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list 220 | RUN apt-get update 221 | 222 | # next-pnr dependencies 223 | RUN apt-get install -y \ 224 | cmake \ 225 | python3-dev\ 226 | qt5-default \ 227 | libboost-dev \ 228 | libboost-filesystem-dev \ 229 | libboost-thread-dev \ 230 | libboost-program-options-dev \ 231 | libboost-python-dev \ 232 | libboost-iostreams-dev\ 233 | libboost-dev \ 234 | libeigen3-dev 235 | 236 | # next-pnr 237 | RUN git clone https://github.com/YosysHQ/nextpnr nextpnr && \ 238 | cd nextpnr && \ 239 | cmake -DARCH=ice40 && \ 240 | make -j$(nproc) && \ 241 | make install 242 | 243 | ####### IntelliJ ####################################### 244 | 245 | USER root 246 | 247 | # Set the version variables 248 | ARG INTELLIJ_VER=2020.1 249 | ARG INTELLIJ_SUBVER=1 250 | # version id can be found on jetbrains webpage when downloading of scala plugin 251 | ARG INTELLIJ_VERID=47787 252 | 253 | # Download and install intellij 254 | RUN wget https://download.jetbrains.com/idea/ideaIC-$INTELLIJ_VER.$INTELLIJ_SUBVER.tar.gz -O /tmp/intellij.tar.gz -q && \ 255 | mkdir -p /opt/intellij && \ 256 | tar -xf /tmp/intellij.tar.gz --strip-components=1 -C /opt/intellij && \ 257 | rm /tmp/intellij.tar.gz 258 | RUN cd /opt/intellij/bin && \ 259 | ln -s idea.sh intellij 260 | 261 | # Add intellij to path 262 | RUN echo 'export PATH=$PATH:/opt/intellij/bin/' >> $WORKDIR/.bashrc 263 | 264 | USER $USER 265 | 266 | # Download and install intellij scala plugin 267 | 268 | RUN mkdir -p $WORKDIR/.IdeaIC$INTELLIJ_VER/config/plugins && \ 269 | wget https://plugins.jetbrains.com/plugin/download?updateId=$INTELLIJ_VERID -O $WORKDIR/.IdeaIC$INTELLIJ_VER/config/plugins/scalaplugin.zip -q && \ 270 | cd $WORKDIR/.IdeaIC$INTELLIJ_VER/config/plugins/ && \ 271 | unzip -o -q scalaplugin.zip && \ 272 | rm scalaplugin.zip 273 | 274 | ####### Eclipse ########################################### 275 | 276 | USER root 277 | WORKDIR /opt 278 | 279 | RUN wget https://github.com/gnu-mcu-eclipse/org.eclipse.epp.packages/releases/download/v4.5.1-20190101-2018-12/20190101-2023-gnumcueclipse-4.5.1-2018-12-R-linux.gtk.x86_64.tar.gz -O eclipse.tar.gz -q && \ 280 | tar -xvzf eclipse.tar.gz && \ 281 | rm eclipse.tar.gz 282 | 283 | ENV PATH /opt/eclipse:$PATH 284 | RUN echo 'export PATH=/opt/eclipse:$PATH' >> $WORKDIR/.bashrc 285 | 286 | 287 | ########## add project templates and project tool (project.bash) ###### 288 | USER $USER 289 | 290 | #RUN git clone https://github.com/plex1/SpinalDevTemplateStandalone.git $WORKDIR/projects/user/SpinalDevTemplateStandalone 291 | 292 | #RUN git clone https://github.com/plex1/SpinalDevTemplateSoc.git $WORKDIR/projects/user/SpinalDevTemplateSoc 293 | 294 | USER root 295 | COPY ./files/project.bash $WORKDIR/projects/user/ 296 | RUN chown -R $USER $WORKDIR/projects/user/project.bash 297 | RUN chmod +x $WORKDIR/projects/user/project.bash 298 | 299 | ####### Startup Script #################################### 300 | 301 | USER root 302 | WORKDIR / 303 | # run the startup script each time the container is created 304 | COPY ./startup.sh /opt 305 | RUN chmod +x /opt/startup.sh 306 | ENTRYPOINT ["/opt/startup.sh"] 307 | 308 | 309 | 310 | 311 | -------------------------------------------------------------------------------- /docker/main/files/Murax.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docker/main/files/project.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # script to support management of SpinalHDL user projects 4 | # e.g. to create and compile projects 5 | 6 | usage="$(basename "$0") (create | run) -n name [-t type] [-a action] [-h] [-y] 7 | 8 | -- script to support management of SpinalHDL user projects 9 | 10 | where: 11 | 12 | create: create projects 13 | run: run projects (use action below) 14 | no args: interactive mode 15 | 16 | -h show this help text 17 | -n project name : name of the project 18 | -t type of project : standalone, soc, workshop 19 | -a project action : fwcompile, fwtest, impl, swbuild, intellij, eclipse, openocd, configfile_copy, configfile_prog, gtkwave 20 | -y user does not need to confirm action 21 | (action needs to be specified for $(basename "$0") run) 22 | 23 | Example 1: 24 | ./$(basename "$0") # press 'y' to enter interactive mode 25 | 26 | Example 2: 27 | ./$(basename "$0") create -n myproj -t soc # create project 28 | ./$(basename "$0") run -n myproj -t soc -a fwcompile # compile hdl and generate verilog 29 | ./$(basename "$0") run -n myproj -t soc -a swbuild # build sw and and genrate binary 30 | ./$(basename "$0") run -n myproj -t soc -a fwtest # run testbench (needs sw binary) 31 | " 32 | 33 | directory="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 34 | 35 | type="" 36 | name="" 37 | confirm="" 38 | 39 | # extract first argument (main action) 40 | mainaction="$1" 41 | 42 | if [ "$#" != "0" ] && [ "$mainaction" != "-h" ] 43 | then 44 | shift 1 45 | if [ "$mainaction" != "create" ] && [ "$mainaction" != "run" ] 46 | then 47 | echo "main action" "$mainaction" "not yet supported" 48 | exit 1 49 | fi 50 | fi 51 | 52 | 53 | # extract next arguments 54 | while getopts ':h:t:n:y:a:' option; do 55 | 56 | case "$option" in 57 | h) echo "$usage" 58 | exit 59 | ;; 60 | t) type=$OPTARG 61 | ;; 62 | n) name=$OPTARG 63 | ;; 64 | a) action=$OPTARG 65 | ;; 66 | :) 67 | if [ "$OPTARG" == "y" ] 68 | then 69 | confirm="y" 70 | elif [ "$OPTARG" != "h" ] 71 | then 72 | printf "missing argument for -%s\n" "$OPTARG" >&2 73 | exit 1 74 | else 75 | echo "$usage" >&2; exit 76 | fi 77 | ;; 78 | \?) printf "illegal option: -%s\n" "$OPTARG" >&2 79 | echo "$usage" >&2 80 | exit 1 81 | ;; 82 | esac 83 | done 84 | shift $((OPTIND - 1)) 85 | 86 | #interactive mode if no arguments are provided 87 | if [ "$type" == "" ] || [ "$name" == "" ] 88 | then 89 | echo "$usage" >&2 90 | echo "entering interactive mode ..." 91 | read -p "Continue [y/n]: " continue 92 | case $continue in 93 | [Yy]*) ;; 94 | *) echo "Aborted"; exit ;; 95 | esac 96 | read -p "Create project [c] or run project [r]: " cr 97 | case $cr in 98 | [c]*) 99 | mainaction="create" 100 | read -p "Project name: " name 101 | read -p "Project type: " type 102 | ;; 103 | [r]*) 104 | mainaction="run" 105 | read -p "Project name : " name 106 | # automatically detect type 107 | if [ -d "$directory/$name/hdl" ] 108 | then 109 | type="standalone" 110 | else 111 | type="soc" 112 | fi 113 | read -p "Project action: " action 114 | ;; 115 | *) echo "Aborted"; exit ;; 116 | esac 117 | 118 | fi 119 | 120 | echo "type: $type, name: $name" 121 | source "$directory/$name/spinaldev.conf" 122 | 123 | # main action create 124 | if [ "$mainaction" == "create" ] 125 | then 126 | 127 | case "$type" in 128 | ("standalone") 129 | echo "creating standalone project named $name ..." 130 | command="cd $directory; git clone https://github.com/plex1/SpinalDevTemplateStandalone.git $name" 131 | ;; 132 | ("soc") 133 | echo "creating SoC project named $name ..." 134 | command="cd $directory; git clone https://github.com/plex1/SpinalDevTemplateSoc.git $name" 135 | ;; 136 | 137 | ("workshop") 138 | echo "creating SoC project named $name ..." 139 | command="cd $directory; git clone https://github.com/SpinalHDL/SpinalWorkshop.git $name" 140 | ;; 141 | 142 | *) 143 | echo "project type" "$type" "not found! Aborted ..." 144 | exit 145 | ;; 146 | 147 | esac 148 | 149 | # main action run 150 | elif [ "$mainaction" == "run" ] 151 | then 152 | 153 | if [ "$type" == "standalone" ] 154 | then 155 | dirpart="" 156 | else 157 | dirpart="fw/" 158 | fi 159 | 160 | case "$action" in 161 | 162 | ("swbuild") 163 | echo "building sw for project named $name ..." 164 | if [ "$type" == "soc" ] 165 | then 166 | command="cd $directory/$name/sw; make" 167 | else 168 | echo "not possible to build sw for this project type" 169 | exit 1 170 | fi 171 | ;; 172 | ("fwcompile") 173 | echo "compile the spinal HDL firmware for project named $name ..." 174 | command="cd $directory/$name/${dirpart}hdl; sbt run" 175 | ;; 176 | ("fwtest") 177 | echo "run the spinal HDL test bench for project named $name ..." 178 | command="cd $directory/$name/${dirpart}hdl;sbt test:run" 179 | ;; 180 | ("impl") 181 | echo "implement design for project named $name ..." 182 | command="cd $directory/$name/${dirpart}impl/$SPINALDEV_IMPL_NAME; make compile" 183 | ;; 184 | ("intellij") 185 | echo "start intellij ..." 186 | echo "[INFO] First time run: press all ok and wait for syncing to be done" 187 | command="intellij $directory/$name/${dirpart}hdl &" 188 | ;; 189 | 190 | ("gtkwave") 191 | echo "start gtkwave ..." 192 | 193 | command="gtkwave $directory/$name/${dirpart}hdl/simWorkspace/MuraxCustom/test.vcd &" 194 | ;; 195 | 196 | ("openocd") 197 | echo "Run OpenOCD ..." 198 | echo "[INFO] fwtest needs to be running before this action is executed. When OpenOCD is running you are able to connect with Eclipse." 199 | command="cd /opt/openocd_riscv/; src/openocd -f tcl/interface/jtag_tcp.cfg -c \"set MURAX_CPU0_YAML /home/spinaldev/projects/user/${name}/fw/hdl/cpu0.yaml\" -f tcl/target/murax.cfg " 200 | ;; 201 | 202 | ("eclipse") 203 | echo "start eclipse ..." 204 | echo "see https://github.com/SpinalHDL/VexRiscv#by-using-gnu-mcu-eclipse" 205 | 206 | command="eclipse &" 207 | ;; 208 | 209 | "configfile_copy") 210 | echo "copy programming file ..." 211 | command="scp $directory/$name/${dirpart}impl/$SPINALDEV_IMPL_NAME/$SPINALDEV_IMPL_PROGFILE $SPINALDEV_REMOTE_UNAME@$SPINALDEV_REMOTE_HOST:$SPINALDEV_REMOTE_PATH" 212 | ;; 213 | "configfile_prog") 214 | echo "remote programming" 215 | command="ssh $SPINALDEV_REMOTE_UNAME@$SPINALDEV_REMOTE_HOST 'sudo ~/raspice40/program.sh ${SPINALDEV_IMPL_PROGFILE#*/}'" 216 | ;; 217 | *) 218 | echo "action " "$action" "not found! Aborted ..." 219 | exit 220 | ;; 221 | 222 | esac 223 | fi 224 | 225 | # perfomm main action 226 | echo "Action: " "\"$command\"" 227 | if [ "$confirm" != "y" ] 228 | then 229 | read -p "Confirm action [y/n]: " confirm 230 | fi 231 | case $confirm in 232 | [Yy]*) eval "$command"; ret_code=$? ;; 233 | *) echo "Aborted"; exit ;; 234 | esac 235 | 236 | # describe result 237 | if [ $ret_code == 0 ] && [ "$mainaction" == "create" ] 238 | then 239 | echo "You'll now find your project template in the folder: " "$directory/$name" 240 | fi 241 | 242 | echo "Script done" 243 | -------------------------------------------------------------------------------- /docker/main/startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | /etc/init.d/xrdp start 5 | 6 | echo "xrdp sever started" 7 | 8 | # change back to user 9 | su - spinaldev 10 | 11 | # needed to run parameters CMD 12 | exec "$@" 13 | 14 | 15 | --------------------------------------------------------------------------------