This commit is contained in:
regymm 2024-01-27 16:34:41 +09:00
parent 41013d4c9d
commit 1298023463
2 changed files with 35 additions and 3 deletions

View file

@ -22,8 +22,8 @@ build_libftdi:
EMCC=${EMSCRIPTEN_DIR}/emcc
INCLUDES=-I./installed/include/libftdi1 -I./installed/include/libusb-1.0
DEFINES=-DBLASTERII_DIR=\"\" -DDATA_DIR=\"/usr/local/share\" -DFTDI_VERSION=105 -DISE_DIR=\"/opt/Xilinx/14.7\" -DUSE_DEVICE_ARG -DVERSION=\"v0.11.0-wasm\"
#OPTIMIZE=-O3 # release, takes 30 mins
OPTIMIZE=-O1 # iteration
OPTIMIZE=-O3 # release, takes 30 mins
#OPTIMIZE=-O1 # iteration
#OPTIMIZE=-g # debug
CFLAGS=$(OPTIMIZE) -pthread -fexceptions $(INCLUDES) $(DEFINES)
LDFLAGS=$(OPTIMIZE) --bind -fexceptions installed/lib/libusb-1.0.a installed/lib/libftdi1.a -s "EXPORTED_RUNTIME_METHODS=['callMain']" -s ASYNCIFY -s ASYNCIFY_STACK_SIZE=512000 -s ALLOW_MEMORY_GROWTH -s INVOKE_RUN=0 -s USE_PTHREADS=1 # -s TOTAL_MEMORY=2048MB -s ASSERTIONS=1 --shell-file wasmFPGAloader_shell.html -s NO_EXIT_RUNTIME=1 #-s NO_DISABLE_EXCEPTION_CATCHING -s DISABLE_EXCEPTION_CATCHING=0 # -s SAFE_HEAP=0 -s NO_DISABLE_EXCEPTION_CATCHING -s MEMORY64=0
@ -38,4 +38,4 @@ wasmFPGALoader.js: $(OBJECTS)
$(EMCC) $(LDFLAGS) $(OBJECTS) -o $@
clean:
-rm wasmFPGAloader.{js,wasm} $(OBJECTS)
-rm wasmFPGALoader.{js,wasm} $(OBJECTS)

32
README.md Normal file
View file

@ -0,0 +1,32 @@
## wasmFPGALoader
[openFPGALoader](https://github.com/trabucayre/openFPGALoader) ported to WebAssembly, using WebUSB backend. Program all your FPGA boards from the browser!
Reference article: [here](https://web.dev/articles/porting-libusb-to-webusb)
#### Build
```
git submodule update --init
make build_libusb
make build_libftdi
make
```
#### Host
HTTPS must be used for WebUSB, and two add_headers as in Nginx conf file are necessary for SharedArrayBuffer.
```
mkdir certs
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ./certs/nginx.key -out ./certs/nginx.crt
docker run --rm -p 443:443 -p 80:80 \
-v $(pwd):/usr/share/nginx/html:ro \
-v $(pwd)/certs:/etc/nginx/ssl \
-v $(pwd)/nginx.conf:/etc/nginx/conf.d/default.conf:ro \
-d nginx
```
#### WebUSB
Only Chromium-based browsers are supported. On Windows, .... can be used to replace/install required FTDI drivers.