Code for both a 64-bit linux riscv system (fedora linux risc-v) as well as code for an esp32c3
The esp32c3 downloads the input with C code provided by espressif becuase that would be insane to have to do just to learn riscv.
The linux environment just reads in the input from a file. I'll probably start with code that works on both systems but then move on to taking advantage of extra instructions on the linux system
Esp32c3 build uses the esp-idf environment
I left the .devcontainer the esp-idf plugin autogenerated in case that's helpful but I'm not familiar with it
To build change into the esp32c3 directory and go through setup:
I have no idea if I'll run out of SRAM before getting through all the days so...
might have to update the CMakeLists.txt
also to remove some days solutions
and then also update the main.c
runner to swap those days to the default unimplemented
function
idf.py set-target esp32c3
idf.py menuconfig # change the wifi ssid/password
idf.py build
If you forgot to override the wifi in menuconfig or didn't run that you can just change CONFIG_ESP_WIFI_SSID
and CONFIG_ESP_WIFI_PASSWORD
in the generated sdkconfig
file
Also add your AOC token with CONFIG_ESP_WIFI_AOC_TOKEN
The linux code I compile on QEMU directly. For fun I'm using Odin as the launcher but it does mean it's a bit more involved currently than a C runner because the fedora rawhide riscv64 I'm using can't currently be upgraded so I can't install Odin.
Instead, I build odin via wsl2 to an object file, and then copy that object plus all the assembly files into qemu where I then run gcc over them
e.g.: from the riscv64
directory
odin build . -target:linux_riscv64 -build-mode:obj # generates main.o
scp -r -P 10000 main.o days riscv@localhost:riscv/ # scp files to qemu setup
# you could even use nvim in the fedora qemu environment if you want
ssh -P 10000 riscv@localhost
cd riscv
gcc -o main main.o days/2023/day*.S
TODO: add a bat/bash script to automate the qemu build