Skip to content

Commit

Permalink
Initial codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Nov 29, 2023
0 parents commit c73c926
Show file tree
Hide file tree
Showing 172 changed files with 26,915 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/arm_cross_compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
on:
workflow_call:
inputs:
connect-type:
required: true
type: string
# Debug flag indicates whether to build a debug build (no optimization, debugger symbols)
debug-flag:
required: false
type: boolean

jobs:
build_arm:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: cpp
env:
APT_ARM_TOOLCHAIN: "gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libspdlog-dev"
APT_LIBRARIES: "libspdlog-dev:armhf libpcap-dev:armhf protobuf-compiler 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-get --yes install ${{ env.APT_ARM_TOOLCHAIN }} ${{ env.APT_LIBRARIES }}

- name: Build debug strings
if: ${{ inputs.debug-flag }}
run: |
echo "debug_flag_compile=DEBUG\=1" >> $GITHUB_ENV
echo "debug_flag_filename=debug-" >> $GITHUB_ENV
- name: Compile
run: make all -j 6 CONNECT_TYPE=${{ inputs.connect-type }} ${{ env.debug_flag_compile }} CROSS_COMPILE=arm-linux-gnueabihf-

# We need to tar the binary outputs to retain the executable
# file permission. Currently, actions/upload-artifact only
# supports .ZIP files.
# This is workaround for https://github.com/actions/upload-artifact/issues/38
- name: Tar binary output
run: tar -czvf ${{ env.debug_flag_filename }}piscsi-${{ inputs.connect-type }}.tar.gz ./bin

- name: Upload binaries
uses: actions/upload-artifact@v3
with:
name: ${{ env.debug_flag_filename }}arm-binaries-${{ inputs.connect-type }}.tar.gz
path: cpp/${{ env.debug_flag_filename }}piscsi-${{ inputs.connect-type }}.tar.gz
15 changes: 15 additions & 0 deletions .github/workflows/build_code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Compile on macos

on:
workflow_dispatch:
push:
paths:
- 'cpp/**'
- '.github/workflows/macos_compile.yml'

jobs:
debug-fullspec:
uses: uweseimet/scsi2pi/.github/workflows/macos_compile.yml@main
with:
connect-type: "FULLSPEC"
debug-flag: true
107 changes: 107 additions & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Unit tests; SonarCloud analysis

on:
workflow_dispatch:
push:
paths:
- 'cpp/**'
- '.github/workflows/cpp.yml'
pull_request:
paths:
- 'cpp/**'
- '.github/workflows/cpp.yml'
branches:
- 'develop'
- 'main'

env:
APT_PACKAGES: libspdlog-dev libpcap-dev protobuf-compiler libgtest-dev libgmock-dev

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

- name: Install dependencies
run: sudo apt-get install ${{ env.APT_PACKAGES }}

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

- name: Run unit tests
run: (set -o pipefail && bin/piscsi_test | tee piscsi_test_log.txt)

sonarcloud:
runs-on: ubuntu-22.04
if: github.repository == 'uweseimet/scsi2pi'
env:
SOURCES: cpp
BUILD_WRAPPER_OUT_DIR: "$HOME/.build_wrapper_out" # Directory where build-wrapper output will be placed
SONAR_SCANNER_VERSION: 5.0.1.3006
SONAR_SERVER_URL: "https://sonarcloud.io"
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT_KEY: "scsi2pi"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Install dependencies
run: sudo apt-get install ${{ env.APT_PACKAGES }}

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- uses: actions/cache@v3
name: Cache SonarCloud setup
id: sonar-install-cache
with:
path: ~/.sonar
key: sonar-with-build-wrapper-${{ env.SONAR_SCANNER_VERSION }}

- name: Set up SonarCloud scanner
if: steps.sonar-install-cache.outputs.cache-hit != 'true'
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
run: |
mkdir -p $HOME/.sonar
curl -sSLo /tmp/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o /tmp/sonar-scanner.zip -d $HOME/.sonar/
- name: Set up SonarCloud build wrapper
if: steps.sonar-install-cache.outputs.cache-hit != 'true'
env:
BUILD_WRAPPER_DOWNLOAD_URL: ${{ env.SONAR_SERVER_URL }}/static/cpp/build-wrapper-linux-x86.zip
run: |
curl -sSLo /tmp/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o /tmp/build-wrapper-linux-x86.zip -d $HOME/.sonar/
- name: Generate coverage
run: >-
(mkdir -p ${{ env.BUILD_WRAPPER_OUT_DIR }} || true) &&
$HOME/.sonar/build-wrapper-linux-x86/build-wrapper-linux-x86-64
--out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }}
make -j $(nproc) -C $SOURCES coverage
- name: Run gcov
working-directory: cpp
run: gcov --preserve-paths $(find -name '*.gcno')

- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >-
$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin/sonar-scanner
--define sonar.host.url="${{ env.SONAR_SERVER_URL }}"
--define sonar.projectKey=${{ env.SONAR_PROJECT_KEY }}
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
--define sonar.cfamily.gcov.reportsPath=.
--define sonar.coverage.exclusions="cpp/**/test/**"
--define sonar.cpd.exclusions="cpp/**/test/**"
--define sonar.inclusions="cpp/**
34 changes: 34 additions & 0 deletions .github/workflows/macos_compile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
on:
workflow_call:
inputs:
connect-type:
required: true
type: string
# Debug flag indicates whether to build a debug build (no optimization, debugger symbols)
debug-flag:
required: false
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
echo "debug_flag_filename=debug-" >> $GITHUB_ENV
- name: Compile
run: make all -j 6 CONNECT_TYPE=${{ inputs.connect-type }} ${{ env.debug_flag_compile }}
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.(ytanaka@ipc-tokai.or.jp)
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.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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>.

# How to switch between PiSCSI and SCSI2Pi

As already mentioned, SCSI2Pi is not meant to completely replace PiSCSI. Instead, I intend to provide standard Debian packages with binaries that replace the PiSCSI backend binaries. Just by installing such a package your PiSCSI installation will profit from a more modern and well maintained SCSI emulation codebase.<br />
If need should be, you can switch back any time by just running PiSCSI's easysetup script. SCSI2Pi does not modify anything except binaries and manpages, which can easily be reverted.<br />
Naturally, in case you have to switch back to PiSCSI I would appreciate your feedback on any issues caused by SCSI2Pi which you do not observe with PiSCSI 23.11.01, which is the last release I have contributed to. Just create a GitHub ticket with details on what is working with PiSCSI but not with SCSI2Pi. But please note: The SCSI2Pi project only accepts tickets that target SCSI2Pi, but none related to PiSCSI.<br />
Even though I cannot give any guarantees I will try to stay compatible with PiSCSI on the one hand while on the other hand offering new backend features. The same applies to the <a href="https://www.piscsi.de">PiSCSI Control Android app</a>, which is going to be renamed to SCSI Control. I will try to keep it compatible also with PiSCSI. Currently I do not see an issue with that.
Being compatible and not a full replacement also means being compatible with most of the documentation on the <a href="https://github.com/PiSCSI/piscsi/wiki">PiSCSI Wiki</a>. More general information on SCSI2Pi is available on the <a href="https://www.scsi2pi.net">SCSI2Pi website.</a> The GitHub site focuses on development work.

# 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.<br />
Also see the <a href="https://www.scsi2pi.net/en/developer.html">developer notes</a> on the SCSI2Pi website.
Loading

0 comments on commit c73c926

Please sign in to comment.