From: Yehowshua Immanuel Date: Fri, 14 Feb 2020 22:53:25 +0000 (-0500) Subject: update to work with mac X-Git-Tag: 24jan2021_ls180~664^2 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3da204edd6f951b07056eb84c82a7d5766f06387;p=litex.git update to work with mac --- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 88284352..3c932141 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -70,3 +70,4 @@ Copyright (c) 2015-2019 William D. Jones Copyright (c) 2013-2014 Yann Sionneau Copyright (c) 2015 Yves Delley Copyright (c) 2015 Zach Smith +Copyright (c) 2020 Yehowshua Immanuel diff --git a/README.md b/README.md index 8bb0a405..8c6d2ed3 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![LiteX](https://raw.githubusercontent.com/enjoy-digital/litex/master/doc/litex.png) +![LiteX](doc/litex.png) ``` Copyright 2012-2020 / EnjoyDigital ``` @@ -95,6 +95,9 @@ Migen documentation can be found here: https://m-labs.hk/migen/manual # Quick start guide (for advanced users) 0. Install Python 3.5+ and FPGA vendor's development tools. 1. Install Migen/LiteX and the LiteX's cores: + +On MacOS, make sure you have [HomeBrew](https://brew.sh) installed. Then do, ``brew install wget``. + ```sh $ wget https://raw.githubusercontent.com/enjoy-digital/litex/master/litex_setup.py $ chmod +x litex_setup.py @@ -105,28 +108,47 @@ $ ./litex_setup.py init install --user (--user to install to user directory) $ ./litex_setup.py update ``` 3. Install a RISC-V toolchain: + +For Linux: ```sh $ wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz $ tar -xvf riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14.tar.gz $ export PATH=$PATH:$PWD/riscv64-unknown-elf-gcc-8.1.0-2019.01.0-x86_64-linux-ubuntu14/bin/ ``` +MacOS: +```sh +$ wget https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin.tar.gz +$ tar -xvf riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin.tar.gz +$ export PATH=$PATH:$PWD/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-apple-darwin/bin/ +``` 4. Build the target of your board...: Go to litex-boards/litex_boards/xxyy/targets (xxyy being community/official/partner) and execute the target you want to build -5. ... and/or install Verilator and test LiteX on your computer: - Download and install Verilator: http://www.veripool.org/ - On Fedora: +5. ... and/or install [Verilator](http://www.veripool.org/) and test LiteX on your computer + +On Fedora: ```sh $ sudo dnf install libevent-devel json-c-devel ``` - On Ubuntu: +On Ubuntu: ```sh -$ sudo apt install libevent-dev libjson-c-dev +$ sudo apt install libevent-dev libjson-c-dev verilator +$ litex_sim +``` +On MacOS: + + +```sh +$ brew install json-c verilator libevent +$ brew cask install tuntap $ litex_sim ``` 6. Run a terminal program on the board's serial port at 115200 8-N-1. - You should get the BIOS prompt. + + You should get the BIOS prompt like the one below. + +![bios_screenshot](doc/bios_screenshot.png) # Contact -E-mail: florent@enjoy-digital.fr \ No newline at end of file +E-mail: florent@enjoy-digital.fr diff --git a/doc/bios_screenshot.png b/doc/bios_screenshot.png new file mode 100644 index 00000000..8de4f862 Binary files /dev/null and b/doc/bios_screenshot.png differ diff --git a/litex/build/sim/core/Makefile b/litex/build/sim/core/Makefile index b1c88028..28b45058 100644 --- a/litex/build/sim/core/Makefile +++ b/litex/build/sim/core/Makefile @@ -1,8 +1,16 @@ include variables.mak +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S),Darwin) + CFLAGS += -I/usr/local/include/ + LDFLAGS += -L/usr/local/lib + LDFLAGS += -lpthread -ljson-c -lm -lstdc++ -ldl -levent +else + CC ?= gcc + CFLAGS += -Wall -$(OPT_LEVEL) -ggdb $(if $(COVERAGE), -DVM_COVERAGE) + LDFLAGS += -lpthread -Wl,--no-as-needed -ljson-c -lm -lstdc++ -Wl,--no-as-needed -ldl -levent +endif -CC ?= gcc -CFLAGS += -Wall -$(OPT_LEVEL) -ggdb $(if $(COVERAGE), -DVM_COVERAGE) -LDFLAGS += -lpthread -Wl,--no-as-needed -ljson-c -lm -lstdc++ -Wl,--no-as-needed -ldl -levent CC_SRCS ?= "--cc dut.v" diff --git a/litex/build/sim/core/modules/ethernet/Makefile b/litex/build/sim/core/modules/ethernet/Makefile index 211b76d5..d29bf1c2 100644 --- a/litex/build/sim/core/modules/ethernet/Makefile +++ b/litex/build/sim/core/modules/ethernet/Makefile @@ -1,5 +1,6 @@ include ../variables.mak CFLAGS += -Itapcfg/src/include +UNAME_S := $(shell uname -s) all: $(OBJ_DIR)/ethernet.so @@ -8,7 +9,11 @@ include ../rules.mak OBJS = $(addprefix $(OBJ_DIR)/, ethernet.o tapcfg.o taplog.o) $(OBJ_DIR)/ethernet.so: $(OBJS) +ifeq ($(UNAME_S),Darwin) + $(CC) $(LDFLAGS) -o $@ $^ +else $(CC) $(LDFLAGS) -Wl,-soname,$@ -o $@ $^ +endif $(OBJ_DIR)/tapcfg.o: tapcfg/src/lib/tapcfg.c $(CC) $(CFLAGS) -c -o $@ $< diff --git a/litex/build/sim/core/modules/rules.mak b/litex/build/sim/core/modules/rules.mak index 7cbe265c..62ff2428 100644 --- a/litex/build/sim/core/modules/rules.mak +++ b/litex/build/sim/core/modules/rules.mak @@ -1,8 +1,14 @@ +UNAME_S := $(shell uname -s) + $(OBJ_DIR)/%.o: %.c $(CC) -c $(CFLAGS) -I../.. -o $@ $< $(OBJ_DIR)/%.so: $(OBJ_DIR)/%.o +ifeq ($(UNAME_S),Darwin) + $(CC) $(LDFLAGS) -o $@ $^ +else $(CC) $(LDFLAGS) -Wl,-soname,$@ -o $@ $< +endif .PHONY: clean clean: diff --git a/litex/build/sim/core/modules/variables.mak b/litex/build/sim/core/modules/variables.mak index 6c504f3c..dee2a983 100644 --- a/litex/build/sim/core/modules/variables.mak +++ b/litex/build/sim/core/modules/variables.mak @@ -1,5 +1,13 @@ CC ?= gcc -CFLAGS += -Wall -O3 -ggdb -fPIC -Werror +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S),Darwin) + CFLAGS += -I/usr/local/include/ + LDFLAGS += -L/usr/local/lib -ljson-c + CFLAGS += -Wall -O3 -ggdb -fPIC +else + CFLAGS += -Wall -O3 -ggdb -fPIC -Werror +endif LDFLAGS += -levent -shared -fPIC OBJ_DIR ?= . diff --git a/litex/build/sim/core/modules/xgmii_ethernet/Makefile b/litex/build/sim/core/modules/xgmii_ethernet/Makefile index 39f54cd8..ece1f013 100644 --- a/litex/build/sim/core/modules/xgmii_ethernet/Makefile +++ b/litex/build/sim/core/modules/xgmii_ethernet/Makefile @@ -1,5 +1,6 @@ include ../variables.mak CFLAGS += -Itapcfg/src/include +UNAME_S := $(shell uname -s) all: $(OBJ_DIR)/xgmii_ethernet.so @@ -8,7 +9,11 @@ include ../rules.mak OBJS = $(addprefix $(OBJ_DIR)/, xgmii_ethernet.o tapcfg.o taplog.o) $(OBJ_DIR)/xgmii_ethernet.so: $(OBJS) +ifeq ($(UNAME_S),Darwin) + $(CC) $(LDFLAGS) -o $@ $^ +else $(CC) $(LDFLAGS) -Wl,-soname,$@ -o $@ $^ +endif $(OBJ_DIR)/tapcfg.o: tapcfg/src/lib/tapcfg.c $(CC) $(CFLAGS) -c -o $@ $<