mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 07:07:38 +03:00
wip: qemu for development
This commit is contained in:
parent
3ce11f14ce
commit
080a9bb1bb
12
docs/emulation.md
Normal file
12
docs/emulation.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Emulation (development)
|
||||||
|
|
||||||
|
TODO: write this
|
||||||
|
|
||||||
|
Build the program using `env:emulation`, this is required to re-route `Serial.print` to qemu's stdout.
|
||||||
|
|
||||||
|
To run it:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd scripts/emulation
|
||||||
|
docker compose up
|
||||||
|
```
|
||||||
@ -20,7 +20,6 @@ board_upload.offset_address = 0x10000
|
|||||||
|
|
||||||
build_flags =
|
build_flags =
|
||||||
-DARDUINO_USB_MODE=1
|
-DARDUINO_USB_MODE=1
|
||||||
-DARDUINO_USB_CDC_ON_BOOT=1
|
|
||||||
-DMINIZ_NO_ZLIB_COMPATIBLE_NAMES=1
|
-DMINIZ_NO_ZLIB_COMPATIBLE_NAMES=1
|
||||||
-DEINK_DISPLAY_SINGLE_BUFFER_MODE=1
|
-DEINK_DISPLAY_SINGLE_BUFFER_MODE=1
|
||||||
-DDISABLE_FS_H_WARNING=1
|
-DDISABLE_FS_H_WARNING=1
|
||||||
@ -54,9 +53,21 @@ extends = base
|
|||||||
build_flags =
|
build_flags =
|
||||||
${base.build_flags}
|
${base.build_flags}
|
||||||
-DCROSSPOINT_VERSION=\"${crosspoint.version}-dev\"
|
-DCROSSPOINT_VERSION=\"${crosspoint.version}-dev\"
|
||||||
|
-DCROSSPOINT_EMULATED=0
|
||||||
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
|
||||||
|
[env:emulation]
|
||||||
|
extends = base
|
||||||
|
build_flags =
|
||||||
|
${base.build_flags}
|
||||||
|
-DCROSSPOINT_VERSION=\"${crosspoint.version}-emu\"
|
||||||
|
-DCROSSPOINT_EMULATED=1
|
||||||
|
-DARDUINO_USB_CDC_ON_BOOT=0 # Disable USB CDC on boot for Serial output via UART
|
||||||
|
|
||||||
[env:gh_release]
|
[env:gh_release]
|
||||||
extends = base
|
extends = base
|
||||||
build_flags =
|
build_flags =
|
||||||
${base.build_flags}
|
${base.build_flags}
|
||||||
-DCROSSPOINT_VERSION=\"${crosspoint.version}\"
|
-DCROSSPOINT_VERSION=\"${crosspoint.version}\"
|
||||||
|
-DCROSSPOINT_EMULATED=0
|
||||||
|
-DARDUINO_USB_CDC_ON_BOOT=1
|
||||||
|
|||||||
25
scripts/emulation/Dockerfile
Normal file
25
scripts/emulation/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM debian:12
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
ARG DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# Update container
|
||||||
|
RUN apt-get update && apt-get upgrade -y
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 \
|
||||||
|
libgcrypt20 libglib2.0-0 libpixman-1-0 libsdl2-2.0-0 libslirp0 -y
|
||||||
|
|
||||||
|
# Install ESP-IDF
|
||||||
|
ENV PATH="~/.local/bin:${PATH}"
|
||||||
|
RUN mkdir -p ~/esp && cd ~/esp && git clone --quiet --recursive https://github.com/espressif/esp-idf.git && ln -s /usr/bin/python3 /usr/bin/python
|
||||||
|
RUN cd ~/esp/esp-idf && export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets" && ./install.sh && /bin/bash -c "source ./export.sh"
|
||||||
|
|
||||||
|
# Install qemu
|
||||||
|
RUN cd ~/esp/esp-idf && python tools/idf_tools.py install qemu-riscv32
|
||||||
|
|
||||||
|
RUN echo "alias idf='source /root/esp/esp-idf/export.sh'" >> .bashrc
|
||||||
|
|
||||||
|
# Start from a Bash prompt
|
||||||
|
CMD [ "/bin/bash" ]
|
||||||
33
scripts/emulation/docker-compose.yml
Normal file
33
scripts/emulation/docker-compose.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
services:
|
||||||
|
crosspoint-emulator:
|
||||||
|
build: .
|
||||||
|
container_name: crosspoint-emulator
|
||||||
|
volumes:
|
||||||
|
- ../..:/app:ro
|
||||||
|
tmpfs:
|
||||||
|
- /tmp
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
|
stop_signal: SIGKILL
|
||||||
|
entrypoint:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -x;
|
||||||
|
source /root/esp/esp-idf/export.sh
|
||||||
|
|
||||||
|
cd /tmp
|
||||||
|
|
||||||
|
cp /app/.pio/build/emulation/*.bin .
|
||||||
|
dd if=/dev/zero bs=1M count=16 of=./flash.bin
|
||||||
|
dd if="bootloader.bin" bs=1 count=$(stat -c%s "bootloader.bin") seek=0 conv=notrunc of=./flash.bin
|
||||||
|
dd if="partitions.bin" bs=1 count=$(stat -c%s "partitions.bin") seek=$((16#8000)) conv=notrunc of=./flash.bin
|
||||||
|
dd if="firmware.bin" bs=1 count=$(stat -c%s "firmware.bin") seek=$((16#10000)) conv=notrunc of=./flash.bin
|
||||||
|
|
||||||
|
qemu-system-riscv32 \
|
||||||
|
-nographic \
|
||||||
|
-M esp32c3 \
|
||||||
|
-drive \
|
||||||
|
file=flash.bin,if=mtd,format=raw
|
||||||
@ -278,7 +278,7 @@ void setupDisplayAndFonts() {
|
|||||||
|
|
||||||
bool isUsbConnected() {
|
bool isUsbConnected() {
|
||||||
// U0RXD/GPIO20 reads HIGH when USB is connected
|
// U0RXD/GPIO20 reads HIGH when USB is connected
|
||||||
return digitalRead(UART0_RXD) == HIGH;
|
return CROSSPOINT_EMULATED || digitalRead(UART0_RXD) == HIGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isWakeupAfterFlashing() {
|
bool isWakeupAfterFlashing() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user