Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ xen/qa7/syn/ip/**
#q[ak]7.ip_user_files/**
#q[ak]7.runs/**
#q[ak]7.src/**
*.bin
*.hex
*.mem
*.mif
58 changes: 58 additions & 0 deletions docker/Dockerfile.ubuntu-noble
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
FROM ubuntu:24.04 as builder
LABEL org.opencontainers.image.authors="yshestakov@gmail.com"
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV RT11=/usr/local/share/rt11
RUN apt-get -q update
RUN apt-get -yq install \
cmake gcc g++ iverilog git make jq curl unzip \
libpcre3-dev libedit-dev libpng-dev libpcap-dev \
libsdl2-dev libsdl2-ttf-dev libvdeplug-dev
RUN git clone https://github.com/nzeemin/ukncbtl-utils.git /usr/local/src/ukncbtl-utils
RUN cd /usr/local/src/ukncbtl-utils; \
make -C rt11dsk V=1 all && install -m 755 rt11dsk/rt11dsk /usr/local/bin/
# https://gunkies.org/wiki/Installing_RT-11_5.3_on_SIMH
#
WORKDIR /usr/local/src/
RUN curl -LO -s https://github.com/simh/simh/archive/refs/heads/master.zip && \
unzip -x master.zip && ls -l
RUN cd simh-master && make pdp11 && install -m 755 BIN/pdp11 /usr/local/bin/
ADD dectape.c /usr/local/src/
RUN gcc -o /usr/local/bin/dectape /usr/local/src/dectape.c
#
FROM ubuntu:24.04 as worker
LABEL org.opencontainers.image.authors="yshestakov@gmail.com"
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
ENV RT11=/usr/local/share/rt11
RUN apt-get -q update
RUN apt-get -yq install \
iverilog git make vim jq curl dos2unix srecord \
libsdl2-2.0-0 \
libsdl2-ttf-2.0-0 \
libpcre3 \
libedit2 \
libpng16-16t64 \
libpcap0.8t64 \
libvdeplug2t64
COPY --from=builder /usr/local/bin/* /usr/local/bin/
COPY --from=builder /usr/local/src/simh-master/BIN/pdp11 /usr/local/bin/
RUN mkdir -p /usr/local/share/rt11/Disks
WORKDIR $RT11
# 1. Get an empty RL02 disk image where your installation will live.
RUN curl -LO -s http://www.dbit.com/pub/pdp11/empty/rl02.dsk.gz && \
gunzip rl02.dsk.gz && \
mv rl02.dsk Disks/empty-rl02.dsk
# 2. Get the Mentec software kit distributed as RL02 image
RUN curl -LO -s http://simh.trailing-edge.com/kits/rtv53swre.tar.Z
RUN zcat rtv53swre.tar.Z |tar -xvf - && rm rtv53swre.tar.Z
ADD STARTF.COM .
ADD HALT.MAC .
ADD HALT.SAV .
ADD initial.ini .
ADD boot.ini .
ADD init_rt11os_image.sh .
ADD comp_mac2sav.sh /usr/local/bin/
RUN ls -l
RUN ./init_rt11os_image.sh
#WORKDIR /work
12 changes: 12 additions & 0 deletions docker/HALT.MAC
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.TITLE HALT-ME
.MCALL .TTYOUT,.EXIT
PROG:: MOV #MSG,R1 ;STARTING ADDRESS OF STRING
1$: MOVB (R1)+,R0 ;FETCH NEXT CHARACTER
BEQ DONE ;IF ZERO, EXIT LOOP
.TTYOUT ;OTHERWISE PRINT IT
BR 1$ ;REPEAT LOOP
DONE: HALT
.EXIT

MSG: .ASCIZ /HALT SYSTEM /
.END PROG
Binary file added docker/HALT.SAV
Binary file not shown.
64 changes: 64 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Development env in Docker
The goal of creating such Docker container is to enable automated build and
tests running as part of CI workflow.

# What is added to the container

* SIMH 4.0-pre with `EXPECT/SEND` commands added, only `pdp11` binary
* `rt11dsk` tool by Zeemen to copy in/out files into RL02 disks
* `dectape` tool by by Bob Frazier to copy in/out files using "DEC tape" aka `MT0` device in RT-11
* RT-11 v5.3 (free for hobby use in SIMH), installed OS in the `rt11os.dsk` image
* Icarus Verilog to run test benches.

# Docker image build flow

1. Create intermedita `builder` image to compile SIMH, `dectape` and `rt11dsk` from sources
2. Create final `worker` image, copy binaries from the `builder` image
3. Download Mentec software kit (RT11 V5.3) distributed as RL02 image
4. Automated installation of RT11 according to the
[Installing RT-11 5.3 on SIMH](https://gunkies.org/wiki/Installing_RT-11_5.3_on_SIMH) document
5. Copying a few helper scripts into the image including `comp_mac2sav.sh`

The process is scripted into `docker/build_image.sh` script and it used Podman tool.
It should work with `docker` tool as well:

```sh
docker build -t quay.io/yshestakov/cpu11-tools:latest -f docker/Dockerfile.ubuntu-noble docker/
```

Resulting Docker image could be fetched from
[Quay.io/yshestakov/cp11-tools](https://quay.io/repository/yshestakov/cpu11-tools?tab=tags&tag=latest)

# Usage

How to run the container and get interfactive shell (`docker` could be used instead of `podman`):

```
podman run --rm -ti \
-v $(pwd):/work \
quay.io/yshestakov/cpu11-tools:latest \
/bin/bash $@
```


## Compile `test.mac` for T11 as an example


```sh
cd t11/tst
../../docker/run.sh /work/docker/comp_mac2sav.sh test.mac
```

Resulting files will be storede in `t11/tst/out` relative to root of checked out `cpu11.git` repo

## Run Icarus Verilog for T11

```sh
cd ~/work/cpu11/t11/hdl/syn/sim/de0
~/work/cpu11/docker/run.sh -c 'cd /work/t11/hdl/syn/sim/de0; ./run_iverilog.sh'
```

Need to note that `~/work/cpu11` is the directory where `cpu11.git` is checked out



1 change: 1 addition & 0 deletions docker/STARTF.COM
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set error none
14 changes: 14 additions & 0 deletions docker/boot.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set cpu 11/23+ 256K noidle
set throttle 10%
set console wru=035
set tto 8b
attach LPT lpt.txt
set rl0 writeenabled
set rl0 rl02
attach rl0 -n rt11os.dsk
set rl1 writeenabled
set rl1 rl02
attach rl1 -n work.dsk
; set rl1 badblock
boot rl0
exit
3 changes: 3 additions & 0 deletions docker/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
cd $(dirname $0)/..
podman build -t quay.io/yshestakov/cpu11-tools:latest -f docker/Dockerfile.ubuntu-noble docker/ $@
97 changes: 97 additions & 0 deletions docker/comp_mac2sav.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash -e
if [ $# -eq 0 ] ; then
echo "Usage: $0 file.mac" >&2
exit 1
fi
ROOT=$(realpath $(dirname $0)/..)
FN="$1"
# echo "ROOT is $ROOT; EXT_ROOT is $EXT_ROOT; WD is $WD"
PFX=${WD#$EXT_ROOT/}
# echo "PFX is $PFX"
LOCAL_FN=$ROOT/$PFX/$(basename $FN)
LOCAL_OUT_DIR="$ROOT/$PFX/out"
mkdir -p $LOCAL_OUT_DIR
# echo "LOCAL_FN is $LOCAL_FN"
NN=$(basename ${FN%.*})
# echo "NN is $NN"

tmpini=$(mktemp -t XXXXXX.ini)
function atexit()
{
test -e "$tmpini" && rm -f "$tmpni"
}
trap atexit EXIT TERM INT
RT11=${RT11:-/usr/local/share/rt11}
cp "$RT11/Disks/empty-formatted.dsk" "/dev/shm/work.dsk"
cp $RT11/rt11os.dsk /dev/shm/
# Create STARTF.COM to be executed on start of RT-11
cat <<EOF > /dev/shm/STARTF.COM
SET ERROR NONE
DATE $(date +%d-%b-91 |tr a-z A-Z)
MACRO MT0:$NN.MAC /list:DL1:$NN.LST /object:DL1:$NN.OBJ
PRINT DL1:$NN.LST
LINK DL1:$NN.OBJ /EXE:DL1:$NN.SAV
LINK DL1:$NN.OBJ /EXE:DL1:$NN.LDA /LDA
COPY DL1:$NN.LDA PC:
COPY DL1:$NN.* MT0:
R HALT
EOF
# ^^^
unix2dos /dev/shm/STARTF.COM
rt11dsk a /dev/shm/work.dsk $LOCAL_FN >/dev/null
rt11dsk d /dev/shm/rt11os.dsk STARTF.COM >/dev/null
rt11dsk a /dev/shm/rt11os.dsk /dev/shm/STARTF.COM >/dev/null
> /dev/shm/lpt.txt
> /dev/shm/test.ptp
mkdir -p /tmp/empty/
cp $LOCAL_FN /tmp/empty/
touch -t 9101011200 /tmp/empty/*
/work/docker/dectape -o /tmp/empty/ /dev/shm/test.tap
# Create INI file to run SIMH / pdp11
cat <<EOF >$tmpini
set cpu 11/23+ 256K noidle
set throttle 10%
set console wru=035
set tto 8b
set lpt enable
attach LPT /dev/shm/lpt.txt
set PTP enable
ATTACH PTP /dev/shm/test.ptp
attach TM0 /dev/shm/test.tap
set rl1 writeenabled
set rl1 rl02
attach rl1 -n /dev/shm/work.dsk
set rl0 writeenabled
set rl0 rl02
attach rl0 -n /dev/shm/rt11os.dsk
; EXPECT "MACRO-E-Errors detected:" SEND "PRINT $NN.lst\r"; GO
boot rl0
DETACH TM0
DETACH PTP
EXIT
EOF
# Run SIMH / pdp11
pdp11 $tmpini
# Copy out results
dectape -o /dev/shm/test.tap $LOCAL_OUT_DIR
cp -p /dev/shm/test.ptp $LOCAL_OUT_DIR/
cp -p /dev/shm/lpt.txt $LOCAL_OUT_DIR/$NN.lpt.txt
touch $LOCAL_OUT_DIR/*.*
# exit with 0 (true) of no errors found, else 1 (false)
grep -q "MACRO-E-Errors" /dev/shm/lpt.txt && exit 1
CPUID=${PFX%/*}
case "$CPUID" in
vm3|f11)
SZ=0x8000
;;
*)
SZ=0x4000
;;
esac
ls -l $LOCAL_OUT_DIR
base_fn="$LOCAL_OUT_DIR/$NN"
srec_cat $LOCAL_OUT_DIR/$(tr a-z A-Z <<<$NN).LDA -dec_binary -o ${base_fn}.bin -binary
srec_cat ${base_fn}.bin -binary -fill 0x00 0x0000 $SZ -byte-swap 2 -o ${base_fn}.mem --VMem 16
srec_cat ${base_fn}.bin -binary -fill 0x00 0x0000 $SZ -byte-swap 2 -o ${base_fn}.hex -Intel
srec_cat ${base_fn}.bin -binary -fill 0x00 0x0000 $SZ -byte-swap 2 -o ${base_fn}.mif -Memory_Initialization_File 16 -obs=2

Loading