diff --git a/Makefile b/Makefile index a9f72194..46568abe 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ DEFAULT_CONFIG_LOCATION = 454656 CONFIG_LOCATION = 458752 HTML_LOCATION = 262144 +# Startup configuration embedded in the image. Override it to build a specific +# machine with its own configuration: make MACHINE= CONFIG= +CONFIG ?= config.txt + SDCC_TOOLCHAIN = sdcc-$(shell cat sdcc/* | cksum | cut -d' ' -f1) SDCC_PREFIX = toolchain/$(SDCC_TOOLCHAIN) ifeq ($(origin CC),default) @@ -56,6 +60,7 @@ ifndef BUILDDIR BUILDDIR = output/$(MACHINE) endif +CONFIG_STAMP := $(BUILDDIR)/.config VERSION_HEADER := version.h GIT_VERSION := $(shell git rev-parse --short HEAD) @@ -78,9 +83,10 @@ BUILD_DATE := $(shell date -u -d @$(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S" 2>/d || date -u -r $(SOURCE_DATE_EPOCH) +"%Y-%m-%d %H:%M:%S") endif -# $(MACHINE_SRC) is listed here so an unknown $MACHINE fails before anything else -# is built, including the tools/ subdirectory. -all: create_build_dir $(VERSION_HEADER) $(MACHINE_SRC) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin +# $(MACHINE_SRC) and $(CONFIG) are listed here so an unknown $MACHINE or a +# missing config file fails before anything else is built, including the tools/ +# subdirectory. +all: create_build_dir $(VERSION_HEADER) $(MACHINE_SRC) $(CONFIG) $(SUBDIRS) $(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin bank_size: tools/bank_occupancy.sh "$(MACHINE)" @@ -101,6 +107,12 @@ $(MACHINE_SRC): @echo " Example: make MACHINE=KP_9000_6XHML_X2" >&2 @false +# Fail with a clear message when CONFIG names a file that does not exist. +$(CONFIG): + @echo "ERROR: CONFIG='$(CONFIG)' does not exist." >&2 + @echo " Point CONFIG at a configuration file, or omit it to use config.txt." >&2 + @false + # Keep the per-machine definition in first position to fail immediately on an # invalid $MACHINE value SRCS = \ @@ -220,6 +232,12 @@ FORCE: $(CCFLAGS_STAMP): FORCE | create_build_dir @echo '$(CC_FLAGS)' | cmp -s - $@ 2>/dev/null || echo '$(CC_FLAGS)' > $@ +# The same for $(CONFIG): its path is stamped so switching to a config file +# older than the image still rebuilds it, while $(CONFIG) itself as a normal +# prerequisite covers edits to the selected file. +$(CONFIG_STAMP): FORCE | create_build_dir + @echo '$(CONFIG)' | cmp -s - $@ 2>/dev/null || echo '$(CONFIG)' > $@ + $(BUILDDIR)/%.rel: %.c $(CCFLAGS_STAMP) | create_build_dir html_data.h $(CC) -MMD $(CC_FLAGS) -o $@ -c $< @@ -233,11 +251,11 @@ $(BUILDDIR)/rtlplayground.ihx: $(OBJS) $(BUILDDIR)/crtbank.rel $(BUILDDIR)/crc16 $(BUILDDIR)/rtlplayground.img: $(BUILDDIR)/rtlplayground.ihx objcopy --input-target=ihex -O binary $< $@ -$(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.img | tools +$(BUILDDIR)/rtlplayground-$(FILENAME_EXTENSION).bin: $(BUILDDIR)/rtlplayground.img $(CONFIG) $(CONFIG_STAMP) | tools if [ -e $@ ]; then rm $@; fi - tools/$(BUILDDIR)/imagebuilder -i $^ $@ - tools/$(BUILDDIR)/fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ - tools/$(BUILDDIR)/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d config.txt $@ + tools/$(BUILDDIR)/imagebuilder -i $(BUILDDIR)/rtlplayground.img $@ + tools/$(BUILDDIR)/fileadder -a $(DEFAULT_CONFIG_LOCATION) -s $(IMAGESIZE) -d "$(CONFIG)" $@ + tools/$(BUILDDIR)/fileadder -a $(CONFIG_LOCATION) -s $(IMAGESIZE) -d "$(CONFIG)" $@ tools/$(BUILDDIR)/fileadder -a $(HTML_LOCATION) -s $(IMAGESIZE) -z -d $(HTML_MIN) -b BANK1 $@ tools/$(BUILDDIR)/crc_calculator -u $@ ln -sf $(MACHINE)/rtlplayground-$(FILENAME_EXTENSION).bin $(BUILDDIR)/../rtlplayground.bin diff --git a/README.md b/README.md index 25c0a02d..0deddc6f 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,13 @@ The name selects the board definition `machine/.c`; `make` without a `MACHINE` value stops with an error listing what is expected. If your board is not in the list yet, see [Adding a new device](doc/adding-a-device.md). +To embed a machine-specific startup configuration, pass `CONFIG`: +``` +make MACHINE=DEFAULT_8C_1SFP CONFIG=configs/DEFAULT_8C_1SFP.txt +``` +`CONFIG` defaults to `config.txt`; the selected file is embedded in the image +and changing it triggers a rebuild. + > [!TIP] > You can write configuration parameters in config.txt (see below) in order your switch to get > straight at the first boot, a correct IP configuration. diff --git a/html/app.js b/html/app.js index b4c1f459..9e8432fa 100644 --- a/html/app.js +++ b/html/app.js @@ -954,6 +954,7 @@ function byPort(a){return a.sort(function(x,y){return x.portNum-y.portNum})} function pollStatus(){ return getJSON("/status.json").then(function(s){ byPort(s); + S.ports=s; var now=Date.now(); if(!S.n){ S.n=s.length; @@ -975,7 +976,7 @@ function pollStatus(){ }; }); } - S.prev=s;S.prevT=now;S.ports=s; + S.prev=s;S.prevT=now; updateStrip(); var hk=tabHooks[curTab]; if(hk&&hk.status)hk.status(); diff --git a/html/index.html b/html/index.html index 2660cfbc..5695f819 100644 --- a/html/index.html +++ b/html/index.html @@ -125,12 +125,20 @@ label.row span.lb{width:110px;flex:none;color:var(--fg2);font-size:13px} .port .pn{font-weight:650;font-size:12px} .port .ps{font-size:9px;color:var(--fg2);display:block;line-height:1.2} .port .jack{ - display:block;width:16px;height:10px;margin:2px auto 1px;border-radius:2px; - border:2px solid var(--fg2);border-top-width:4px;opacity:.55; + display:block;width:21px;height:12px;margin:4px auto 2px;border-radius:2px; + border:2px solid var(--fg2);border-top-width:8px;opacity:.55;position:relative; } -.port.sfp .jack{width:24px;height:9px;border-top-width:3px} +.port .jack:before{content:""; + position:absolute;bottom:100%;left:50%;transform:translateX(-50%); + width:6px;height:5px;margin-bottom:7px;border-radius: 1px 1px 0 0; + background-color:var(--fg2); +} +.port.sfp .jack{width:24px;height:16px;margin:0 auto 2px;border-top-width:5px} +.port.sfp .jack:before{width:10px;margin-bottom:2px;border-radius:0 0 1px 1px;background-color:var(--panel2)} .port.up{border-color:var(--pc);background:color-mix(in srgb,var(--pc) 10%,var(--panel2))} .port.up .jack{border-color:var(--pc);opacity:1} +.port.up .jack:before{background-color:var(--pc)} +.port.up.sfp .jack:before{background-color:color-mix(in srgb,var(--pc) 10%,var(--panel2))} .port.up .ps{color:var(--pc);font-weight:600} .port.dis{opacity:.45;border-style:dashed} .badge{font-size:11px;font-weight:600;border-radius:10px;padding:1px 8px;background:var(--panel2);color:var(--fg2)}