Skip to content

Commit

Permalink
Add instructions for running this in Termux on Android
Browse files Browse the repository at this point in the history
Also update the scripts to all support a QEMU_ARGS env variable so that
on android we can set the necessary args. Probably eventually someone
else will want to use that var too.
  • Loading branch information
fsmv committed Sep 18, 2024
1 parent 4400a8d commit b9e29e0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,37 @@ the call, but you can open up that file and try out the other commands too.
2. Choose either the user or system-wide Path variable and add both `C:\Program Files\NASM` & `C:\Program Files\qemu`
4. `boot.bat bootstrap-lisp.asm` (alternatively you can use the bash script in the git bash prompt)

#### Android

1. Install [Termux](https://play.google.com/store/apps/details/id=com.termux)
from the play store (or f-droid)

2. Install qemu and the assembler, and git to clone the repo
`pkg install x11-repo && pkg install qemu-system-x86-64 nasm git`

3. (Optional) Set up X11 for graphical display

1. Install the Termux X11 apk from
https://github.com/termux/termux-x11/releases (you most likely need the
arm64 one), or from f-droid
2. In the Termux X11 app settings configure the output display resolution
mode to custom and the resolution to 720x480
3. Install the necessary packages in the main Termux app:
`pkg install termux-x11-nightly`

4. Clone bootstrap-os `git clone https://github.com/fsmv/bootstrap-os.git && cd bootstrap-os`

5. To run in Termux:
1. `export QEMU_ARGS=-display gtk,show-menubar=off -L /data/data/com.termux/files/usr/share/qemu"`
If you like you can put this in `~/.bashrc` to save it
2. `termux-x11 :0 -xstartup "./boot bootstrap-lisp.asm"`
- Alternatively (if you didn't install the X11 app) you can run:
`./test -DHEADLESS lisp/tester.asm`
it will print the test results using the qemu debug console feature.

I tried to run the debugger but I wasn't able to install a version of gdb that
understands x86 in Termux (it only does arm) so debugging won't work.

## Reference Manuals

This project depends on the
Expand Down
2 changes: 1 addition & 1 deletion boot
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ name="${file%%.*}"
binfile="bin/$name.bin"

mkdir -p `dirname $binfile`
nasm $file -f bin -o $binfile ${@:1:$(($#-1))} && qemu-system-x86_64 -drive file=$binfile,format=raw,if=ide
nasm $file -f bin -o $binfile ${@:1:$(($#-1))} && qemu-system-x86_64 $QEMU_ARGS -drive file=$binfile,format=raw,if=ide
4 changes: 2 additions & 2 deletions debug
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ nasm $bit16file -f elf32 -F dwarf -g -w+gnu-elf-extensions -o $elffile ${@:1:$((
rm $bit16file

if ! which qemu-system-i386 > /dev/null; then
printf "\nYou need to install qemu-arch-extra to use the debugger\n"
printf "\nYou need to install qemu-system-i386 (qemu-arch-extra package in some distributions) to use the debugger\n"
exit 127
fi

qemu-system-i386 -s -S -drive file=$binfile,format=raw,if=ide &
qemu-system-i386 $QEMU_ARGS -s -S -drive file=$binfile,format=raw,if=ide &

# Note: If you turn off the offset for the add-symbol-file command then gdb can
# load the source code line numbers correctly but the fancy real-mode-gdb config
Expand Down
6 changes: 1 addition & 5 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ if [ "$#" -eq 0 ]; then
exit 1
fi

if [ -z "$QEMU" ]; then
QEMU="qemu-system-x86_64"
fi

file=${@: -1}
name="${file%%.*}"
binfile="bin/$name.bin"
Expand All @@ -21,7 +17,7 @@ fi
PID=$$
compile() {
nasm $file -f bin -o $binfile -DDEBUGCON ${@:2:$(($#-2))} && \
$QEMU $HEADLESS_ARGS -debugcon stdio -drive file=$binfile,format=raw,if=ide
qemu-system-x86_64 $QEMU_ARGS $HEADLESS_ARGS -debugcon stdio -drive file=$binfile,format=raw,if=ide
# Kill the process if we had a compile error so that we exit with non-zero
# status even though we used a pipe which exits with the tee status
ERR=$?
Expand Down

0 comments on commit b9e29e0

Please sign in to comment.