Skip to content

Commit

Permalink
Initial codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Nov 30, 2023
0 parents commit 8e03d52
Show file tree
Hide file tree
Showing 174 changed files with 26,412 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# When creating a new ticket please provide information on your environment.

- The Pi type:


- The Pi OS version (output of 'lsb_release -a'):


- The SCSI2Pi release or git revision:


- The computer/sampler connected to the RaSCSI/PiSCSI board:


# Describe the issue
65 changes: 65 additions & 0 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Run SonarCloud analysis

on:
workflow_dispatch:

jobs:
code_analysis:
runs-on: ubuntu-latest

defaults:
run:
working-directory: cpp

env:
PACKAGES: protobuf-compiler libspdlog-dev libpcap-dev libprotobuf-dev libgmock-dev
BUILD_WRAPPER_OUT_DIR: "$HOME/.build_wrapper_out"
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_PROJECT_KEY: "uweseimet_scsi2pi"
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

steps:
- uses: actions/checkout@v3
with:
# Shallow clones should be disabled for a better relevancy of analysis
fetch-depth: 0

- name: Install additional packages
run: sudo apt install --yes ${{ env.PACKAGES }}

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin

- name: Set up Python for gcovr
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Install gcovr
run: pip install gcovr==5.0 # 5.1 is not supported

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v1

- name: Run build-wrapper
run: |
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make -j $(nproc) coverage DEBUG=1
- name: Generate coverage data
run: gcovr --sonarqube > coverage.xml

- name: Run sonar-scanner
run: |
sonar-scanner \
--define sonar.host.url=${{ env.SONAR_SERVER_URL }} \
--define sonar.projectKey=${{ env.SONAR_PROJECT_KEY }} \
--define sonar.organization=${{ env.SONAR_ORGANIZATION }} \
--define sonar.cfamily.build-wrapper-output=${{ env.BUILD_WRAPPER_OUT_DIR }} \
--define sonar.coverageReportPaths=coverage.xml \
--define sonar.exclusions="obj/**,bin/**,generated/**" \
--define sonar.coverage.exclusions="test/**" \
--define sonar.cpd.exclusions="test/**"
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and test binaries

on:
workflow_call:
push:
paths:
- 'cpp/**,proto/**'
pull_request:
paths:
- 'cpp/**,proto/**'
types:
- assigned
- opened
- synchronize
- reopened
branches:
- 'main'
- 'develop'

jobs:
fullspec:
uses: uweseimet/scsi2pi/.github/workflows/compile_and_test.yml@main
with:
connect-type: "FULLSPEC"

standard:
uses: uweseimet/scsi2pi/.github/workflows/compile.yml@main
with:
connect-type: "STANDARD"

debug-fullspec:
uses: uweseimet/scsi2pi/.github/workflows/compile.yml@main
with:
connect-type: "FULLSPEC"
debug-flag: true
39 changes: 39 additions & 0 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Compile on amd64

on:
workflow_dispatch:
inputs:
connect-type:
required: true
type: choice
description: Board type
options:
- FULLSPEC
- STANDARD
default: FULLSPEC
debug-flag:
required: true
type: boolean
default: false

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: cpp
env:
PACKAGES: "libspdlog-dev libpcap-dev libprotobuf-dev libgmock-dev protobuf-compiler"
steps:
- uses: actions/checkout@v3

- name: Install additional packages
run: sudo apt install --yes ${{ env.TOOLCHAIN }} ${{ env.PACKAGES }}

- name: Build debug strings
if: ${{ inputs.debug-flag }}
run: |
echo "debug_flag_compile=DEBUG\=1" >> $GITHUB_ENV
- name: Compile
run: make all -j $(nproc) CONNECT_TYPE=${{ inputs.connect-type }} ${{ env.debug_flag_compile }}
25 changes: 25 additions & 0 deletions .github/workflows/compile_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Compile and test on amd64

on:
workflow_call:
push:
paths:
- 'cpp/**'
- .github/workflows/compile_and_text.yml

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: cpp
env:
PACKAGES: "libspdlog-dev libpcap-dev libprotobuf-dev libgmock-dev protobuf-compiler"
steps:
- uses: actions/checkout@v3

- name: Install additional packages
run: sudo apt install --yes ${{ env.PACKAGES }}

- name: Compile and test
run: make cpp test -j $(nproc) CONNECT_TYPE=FULLSPEC
51 changes: 51 additions & 0 deletions .github/workflows/cross_compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Cross-compile for arm

on:
workflow_dispatch:
inputs:
connect-type:
required: true
type: string
default: "FULLSPEC"
debug-flag:
required: true
type: boolean
default: false

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: cpp
env:
APT_ARM_TOOLCHAIN: "g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf protobuf-compiler"
APT_LIBRARIES: "libspdlog-dev:armhf libpcap-dev:armhf libprotobuf-dev:armhf"
steps:
- uses: actions/checkout@v3

- name: Add armhf as architecture
run: sudo dpkg --add-architecture armhf

- name: Reconfigure apt for arch amd64
run: sudo sed -i "s/deb /deb [arch=amd64] /g" /etc/apt/sources.list

- name: Add armhf repos (jammy)
run: sudo bash -c "echo \"deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy main multiverse restricted universe\" >> /etc/apt/sources.list"

- name: Add armhf repos (jammy-updates)
run: sudo bash -c "echo \"deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main multiverse restricted universe\" >> /etc/apt/sources.list"

- name: Update apt
run: sudo apt update

- name: Install apt packages
run: sudo apt install --yes ${{ env.APT_ARM_TOOLCHAIN }} ${{ env.APT_LIBRARIES }}

- name: Build debug strings
if: ${{ inputs.debug-flag }}
run: |
echo "debug_flag_compile=DEBUG\=1" >> $GITHUB_ENV
- name: Compile
run: make all -j $(nproc) CONNECT_TYPE=${{ inputs.connect-type }} ${{ env.debug_flag_compile }} CROSS_COMPILE=arm-linux-gnueabihf-
32 changes: 32 additions & 0 deletions .github/workflows/macos_compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Compile on macos

on:
workflow_dispatch:
inputs:
debug-flag:
required: false
default: true
type: boolean

jobs:
build_macos:
runs-on: macos-13
defaults:
run:
working-directory: cpp
steps:
- uses: actions/checkout@v3

- name: Install Homebrew
run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

- name: Install packages
run: brew install protobuf spdlog

- name: Build debug strings
if: ${{ inputs.debug-flag }}
run: |
echo "debug_flag_compile=DEBUG\=1" >> $GITHUB_ENV
- name: Compile
run: make all -j 6 CONNECT_TYPE=FULLSPEC ${{ env.debug_flag_compile }}
34 changes: 34 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run unit tests

on:
workflow_dispatch:
inputs:
connect-type:
required: true
type: string
default: "FULLSPEC"
debug-flag:
required: true
type: boolean
default: false

env:
PACKAGES: protobuf-compiler libspdlog-dev libpcap-dev libprotobuf-dev libgmock-dev

jobs:
unit_tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: cpp
steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: sudo apt install --yes ${{ env.PACKAGES }}

- name: Build unit tests
run: make -j $(nproc) test

- name: Run unit tests
run: bin/s2p_test
33 changes: 33 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
BSD 3-Clause License

Copyright (C) 2001-2006 PI.([email protected])
Copyright (C) 2014-2020 GIMONS
Copyright (C) 2020-2021 akuker
Copyright (C) PiSCSI project contributors (github.com/PiSCSI/piscsi)
Copyright (C) 2021-2023 Uwe Seimet
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DEFAULT_GOAL: all

TARGETS := all clean install

SUBDIRS := cpp doc

$(TARGETS): $(SUBDIRS)

$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)

.PHONY: $(TARGETS) $(SUBDIRS)
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# What is SCSI2Pi?

The PiSCSI/RaSCSI board extends the Raspberry Pi with a SCSI interface. SCSI2Pi (or simply just S2P) is an alternative to the <a href="https://github.com/PiSCSI/piscsi">PiSCSI software</a>. SCSI2Pi focuses on improving the backend and is compatible with the PiSCSI web UI and the <a href="https://www.piscsi.net">PiSCSI Control app</a>.<br />
You can switch from PiSCSI to SCSI2Pi (or back, if needed) in seconds, by installing/de-installing a Debian package. This package will contain the SCSI2Pi-Binaries, i.e. there is no time-consuming compilation required. At least that's the plan.<br />
SCSI2Pi emulates several SCSI or SASI devices like hard disks, CD-ROM drives, printers or network adapters at the same time. This way you can easily add devices to computers like 68k Macs, Atari ST/TT/Falcon, Amigas, old PCs, Unix workstations or samplers. Compared to PiSCSI the SCSI2Pi backend offers numerous extensions, new device emulations, performance improvements and bug fixes. These add to the extensive changes I contributed to the PiSCSI project in the past. Almost the complete original codebase I have re-implemented in modern C++.<br />
SCSI2Pi was chosen as the name for this project because there are not that many choices anymore when looking for a name that contains both "SCSI" and "Pi" ;-).<br />
<a href="https://www.scsi2pi.net">The SCSI2Pi project</a> has not yet been fully set up and it will still take a bit of time until there is a first release. Note that the current sources on GitHub are only temporary, and the repository will be re-initialized with fresh sources when SCSI2Pi is ready to start.

# Who am I?

In the past I was the main C++ code contributor for PiSCSI. I re-engineered most of the legacy C++ code and updated it to C++-20, which is the latest C++ standard you can currently use on the Pi. I also revised the complete device emulation architecture. All in all this resulted in more modular code and drastically improved SonarQube code metrics. Besides adding numerous <a href="https://www.scsi2pi.net/en/scsi2pi.html">new features</a> and improving the compatibility with many platforms, I also fixed numerous bugs in the legacy codebase and added an extensive set of unit tests. Further I am the author of the <a href="https://www.piscsi.de">PiSCSI Control app</a> for Android, which is the remote control for your RaSCSI/PiSCSI boards.

# How is SCSI2Pi related to PiSCSI and the former RaSCSI?

Over time, within the PiSCSI project the interest in replacing the old, often buggy or unnecessary code became rather low. In addition, developers for the required pull request reviews were missing, and many of the features that have been promised for a long time are not addressed. This is why I decided to further improve the software in a separate project. The major part of the current (23.11.01) PiSCSI codebase has been contributed by me anyway.
There was also no interest in further exploiting the initiator mode feature of the FULLSPEC board. This mode, together with new command line tools, offers solutions for use cases that have never been addressed before, neither with PiSCSI nor its predecessor RaSCSI.
From my perspective this situation was not satisfying, and this is why I decided to set up SCSI2Pi as an alternative project that is compatible with the RaSCSI/PiSCSI board.

# SCSI2Pi goals

The intention of SCSI2Pi is not to completely replace the PiSCSI software, where great work is still being done on the web interface, for instance, and on supporting users in social media.
The goal of SCSI2Pi is to improve the actual SCSI emulation, i.e. the C++ core, and to address compatibility issues, mainly (but not only) with usually rather exotic platforms. SCSI2Pi focuses on vintage computers like Macs, Ataris, Amigas, workstations and on samplers. There is no support for the X68000, in particular the host bridge, though. In PiSCSI the related code has always been in a bad shape, nobody has been willing to test it. It might not even be working. Most of the other features of PiSCSI are supported by SCSI2Pi - many of these I implemented anyway ;-). There are <a href="https://www.scsi2pi.net">more new features to come</a>.
See the <a href="https://github.com/uweseimet/scsi2pi/wiki">SCSI2PI wiki</a> on how to switch between PiSCSI and SCSI2Pi.

# Contributing to SCSI2Pi

If you are interested in the Pi and/or SCSI, in modern C++ and platform-independent programming, you are very welcome as a developer or a code reviewer.<br />
Did I just say "platform independent programming", even though SCSI2Pi is about the Pi? I did indeed, because I have ensured that the PiSCSI code also compiles and partially runs on regular Linux PCs, on BSD and even on macos. This is important for developers and for testing, because the faster your development machine, the better. In general, a C provides a much better development environment than a Pi. I am using Eclipse CDT on a Linux PC as my primary development platform, by the way.
Loading

0 comments on commit 8e03d52

Please sign in to comment.