Commit Graph
1225 Commits
Author SHA1 Message Date
René van Dorst 75aa23468c Merge pull request #374 from bloqaudio/upload-cleanup
httpd: clean up the upload path in handle_post()
2026-09-01 17:30:56 +00:00
logicog 89b4cf83ce Merge pull request #314 from DrDoof/feat/stp-v2
stp: Spanning Tree support for the RTL837x switches
2026-09-01 18:52:20 +02:00
bloqaudio 005209f97a httpd: split the upload fragment handlers out of handle_post()
The tail of handle_post() interleaved the config and firmware upload
paths behind one config_upload conditional. Give each path its own
function, handle_config_fragment() and handle_firmware_fragment(), and
reduce handle_post() to routing.

Both handlers keep their own copy of the buffer-and-bounds-check
prologue: with SDCC a shared helper costs 2 bytes of direct RAM for
the fragment pointer (a spill slot when the parameter lives in xdata,
a DSEG home when it does not), and direct RAM is fully allocated. The
memory layout is unchanged from the pre-split code.
2026-09-01 09:59:52 -05:00
bloqaudio f0f142fbe0 httpd: track buffered upload bytes in one accumulator 2026-09-01 09:59:52 -05:00
bloqaudio daf9d8965a httpd: scope the multipart parse cursors to their functions
cfg_pos, cfg_hdr, cfg_body, cfg_end, cfg_last and cfg_bl are used only
by config_take(), so move them out of file scope and into the function.
The five cursors stay static: SDCC register-caches automatic xdata
locals and spills them through DSEG slots, which costs 6 bytes of direct
RAM this build has no room for; static keeps the access pattern of the
old globals and the memory layout is unchanged. cfg_bl produces no spill
slot at the current register pressure, so it is a plain local. The
mechanism is recorded in issue #386.

handle_post() reused cfg_pos and cfg_end as scratch for unrelated
values; those uses get their own named locals, frag_len and
payload_start.
2026-09-01 09:59:52 -05:00
René van Dorst 58b12c4aa6 Merge pull request #384 from DrDoof/fix/cmd-history-ring
cmd: keep the history pointer inside the ring
2026-09-01 09:22:12 +02:00
d00f 4ce3e33447 cmd: keep the history pointer inside the ring
The pointer is masked when it advances over the command text, then
incremented once more for the newline without masking, so it can come to
rest one past the end of the ring.

Both readers walk from the pointer with their own index masked every
step, so an index that sits outside the ring is never reached and the
walk does not end. `history` on the console spins there, and so does
`/cmd_log`, which the web page fetches whenever settings are saved: it
fills the transmit buffer and keeps going past it.
2026-09-01 09:02:28 +02:00
René van Dorst e60a09fb7e Merge pull request #383 from DrDoof/fix/isolate-off-top-port
cmd: let "isolate off" put the top port back in the member list
2026-09-01 08:23:05 +02:00
d00f 828963b586 cmd: let "isolate off" put the top port back in the member list
The member mask is filled with a loop that stops one short, so the
highest front panel port never gets its bit and stays isolated from the
port that was just opened up. Every other loop over the port range in
the tree treats machine.max_port as the last port rather than the one
past it.
2026-09-01 04:11:30 +02:00
d00f 3a3967960f stp: take the review notes on the port and priority arguments
The port argument went through its own digit test and machine table
lookup; cmd_parse_port_separator() does both and also checks the port
exists on this board, which the open-coded test did not.

A port priority was masked to its top nibble, so "prio 17" quietly became
16. The bridge priority next to it refuses what it cannot represent, and
now the port priority does too.
2026-08-31 22:55:41 +02:00
d00f e38abf27c9 Merge upstream/main into the Spanning Tree branch 2026-08-31 22:48:14 +02:00
d00f 05ded88f85 stp: keep the FDB update's counters to the function that uses them
Both only ever served stp_fdb_update(), so they belong there. Internal RAM
has room for them on this branch and on the one that carries the
aggregation module too.
2026-08-31 22:18:28 +02:00
logicog dc22c4908b Merge pull request #376 from bloqaudio/fix/make-clean-tools
Makefile: have clean and distclean recurse into the tool directory
2026-08-31 21:58:58 +02:00
d00f c0d9bf7f0d stp: take the review notes on types and register reads
stp_enabled is a flag, so say bool. cmpBytes() returns a comparison
result, so say int8_t. The three busy waits this branch adds read the
status straight out of the SFR instead of copying four bytes to xdata
first.
2026-08-31 21:50:19 +02:00
René van Dorst 1947356ec5 Merge pull request #368 from vDorst/fix_all_compiler_warnings
Disable all `__sfr32` SDCC bug 4070 and fix all compiler warnings.
2026-08-31 19:47:06 +00:00
René van Dorst 2fa4686b33 fix review points. 2026-08-31 21:00:37 +02:00
d00f bd06f7f5e5 stp: do not let auto edge undo a loop block
A port held out of forwarding because a loop was seen on it stops hearing
the frames that justified the hold, so its BPDU age climbs. The auto edge
branch lives inside the same countdown as the hold, reads that age, and
promotes the port back to forwarding after three seconds. The loop opens,
a BPDU comes back, the block is applied again, and the two take turns.

Measured on a looped pair present when the tree came up: twenty cycles in
one window and fifteen in the next, each block followed by a promotion,
still going when the capture ended.

The countdown alone cannot tell a loop hold from an ordinary listen, so
record the hold and leave the port alone while it stands.
2026-08-31 14:26:05 +02:00
René van Dorst b6d2d7c072 Merge pull request #351 from DrDoof/feat/lag-interface
port: let a pvid name an aggregation group
2026-08-31 13:37:14 +02:00
René van Dorst 3c72f0e1b6 Merge pull request #372 from vDorst/fix_macros
Fix define macros, was missing the do {} while (0) wrapping
2026-08-31 13:07:29 +02:00
bloqaudio 6be5693385 Makefile: have clean and distclean recurse into the tool directory
make clean left tools/output in place, so the host tools were never
rebuilt after a clean. SUBDIRSCLEAN, which builds the per-directory
clean target names for exactly that purpose, was defined but nothing
consumed it. Give clean and distclean those targets as prerequisites
and add the rule that runs the subdirectory's own clean, which
tools/Makefile already provides.
2026-08-30 21:49:56 -05:00
d00f 8e9bb56a29 nic: send a frame with the layout it actually has
tcpip_output() decides whether to splice in the 802.1Q tag, and that
decision also moves the frame: the header is shifted forward over its
padding, so a tagged frame starts at uip_buf with the q_frame layout,
while an untagged one keeps the padding and the nonq_frame layout.

nic_tx_packet() took that decision a second time, from management_vlan
alone. That agreed while the sender suppressed the management VLAN around
the transmission, but not since the tag is skipped per frame for a
CPU-tagged one: the descriptor then still sits behind the padding while
the transfer is set up for the shifted layout. The frame goes out four
bytes early and its length is read from the offset where tx_seq and
chksum_flags live, so a sixty byte BPDU is sent as around 1800 bytes of
whatever follows it. Looped back it is no longer a BPDU, the port hears
nothing, auto edge promotes it and the loop stays open.

Record the decision where it is taken and let the transfer follow it.

A variable rather than an argument because internal RAM is full once the
aggregation module shares the image: the overlay area ends at 0x7f, and
an argument or any temporary for the condition no longer fits.
2026-08-31 02:52:00 +02:00
d00f 7f0e7fdc82 Merge upstream/main into the Spanning Tree branch
Both conflicts are the register keyword removal meeting a change of ours,
so each takes main's signature and keeps what the branch was saying:
nic_rx_packet() still returns a bool, and port_ingress_filter_get() stays
declared.

main has since put its own copy of the STP module in BANK2, so the pragma
this branch carried is now duplicated. The one with main's comment stays.
2026-08-30 21:58:54 +02:00
René van Dorst f187261085 Fix all compiler warnings.
- Many times we need help the compiler to reason about variable type or
define.
2026-08-30 21:41:30 +02:00
René van Dorst aba69cd640 DHCP: Added workarounds for SDCC bug 4070 2026-08-30 21:37:37 +02:00
René van Dorst b6dcb75130 Disable all __sfr32 due to bug SDCC 4070 and add workarounds.
Generate wrong address for `a4` location.
Both on read from and write to a __sfr32 variable.

Workaround:
Use two __sfr16 instead of one __sfr32.
We still get some optimalizations / better code gen.
2026-08-30 21:36:03 +02:00
René van Dorst 4e04735a5f Fix define macros, was missing the do {} while (0) wrapping 2026-08-30 19:35:37 +02:00
René van Dorst fc3c686564 Merge pull request #359 from bloqaudio/fix/upload-preamble-split
httpd: buffer a firmware upload's part header before streaming
2026-08-30 16:48:53 +00:00
bloqaudio e826180d06 httpd: pass stream_upload() state through an xdata struct 2026-08-30 04:09:30 -05:00
bloqaudio b63117ba6c httpd: scan the upload preamble with a register cursor
The preamble scan cursor and the buffered-length parameter carry no
state between calls, so they do not need static xdata slots. As plain
locals the compiler places both in registers, trimming 64 bytes of
BANK1 code and two bytes of xdata.

The offsets shared by config_take() stay static: direct data space is
fully allocated on machines like the SWTGW218AS, so plain locals there
add overlay bytes that no longer link, and xdata-class locals spill
three temporaries into direct space while growing the code by roughly
120 bytes. Document pre_acc, whose accumulation across TCP segments is
why it must remain global.
2026-08-30 04:09:30 -05:00
bloqaudio be7796a22c httpd: send a real verdict for firmware uploads
A firmware upload previously ended in a silent connection close, leaving
the client unable to distinguish a verified upload from a failed one.
Send an explicit 200/400 verdict with the CRC result, with
Content-Length so the browser completes the response before the reset,
and only reset the chip once the verdict has been fully ACKed.

The unconditional close after a config upload is gone since the
buffered config path answers with its own response, so drop the
now-unreachable close hack from the streaming path.
2026-08-30 04:09:30 -05:00
bloqaudio 1bd4a8d3cc httpd: buffer a firmware upload's part header before streaming
A firmware image cannot be buffered whole, so the upload is streamed to
flash, and stream_upload() already resumes across TCP segments. The
multipart preamble did not: handle_post() walked the part headers from the
start of whichever segment it held, so a client that split inside the
octet-stream part header lost its place, never started streaming, and the
request hung. Firefox splits exactly there, right after filename=".

Buffer the multipart body only until the octet-stream part header is
complete, locate the payload, then stream from that point; later segments
stream as before. The header reuses the configuration buffer, which is idle
during a firmware upload, so no extra memory is needed.
2026-08-30 04:09:30 -05:00
René van Dorst 1db30f22de Merge pull request #330 from vDorst/SRAM-easy-changes
Sram easy changes
2026-08-29 18:33:29 +00:00
logicog 4c70e654d1 Merge pull request #363 from vDorst/refactor_remove_keyword_register
Remove register keyword from all the function arguments.
2026-08-29 11:56:22 +02:00
feelfree69 3c24f2bdea Merge pull request #260 from donbernhardo/fix-kp-9000-6xhml-x2-led-mux
Add KP-9000 6XH and 6XHML PCB-revisions to Machine targets
2026-08-29 10:16:16 +02:00
donbernhardo 3e610392a9 Merge remote-tracking branch 'origin/main' into fix-kp-9000-6xhml-x2-led-mux
# Conflicts:
#	machine.c
2026-08-28 23:01:38 +02:00
René van Dorst 146771f5ca Merge pull request #362 from bloqaudio/fix/v210-bank0
leds: move the SWTG018AS-V2.1.0 custom LED init to BANK2
2026-08-27 16:32:09 +02:00
René van Dorst bf0bea1edd Remove register keyword from all the function arguments.
Adds no value.
2026-08-26 21:52:31 +02:00
René van Dorst 907ad08830 uip: uip_arp_update() put more arguments in xdata
Saves 7-bytes.
2026-08-26 20:51:32 +02:00
René van Dorst 7cf0115182 httpd: scan_header() put argument on xdata
Saves 2 bytes
2026-08-26 20:51:32 +02:00
René van Dorst adfbead438 syslog: syslog_callback() put local variables on xdata.
Save atleast 2 bytes.
2026-08-26 20:51:32 +02:00
René van Dorst 301774040b uip: place some pointer in xdata.
Saves 2 bytes.
2026-08-26 20:51:32 +02:00
René van Dorst 683037f410 httpd: rename gen_random_bytes to gen_random_hex_chars
This reflexs the function better.
Moving `byte` arguments to __xdata which saves 1 SRAM byte.
2026-08-26 20:51:27 +02:00
René van Dorst 57b820c4e8 httpd: mark pointer variable as __xdata.
Otherwise it is put on SRAM location.

Saves 6 SRAM bytes
2026-08-26 20:49:58 +02:00
d00f 75b223223c Merge upstream/main into the Spanning Tree branch
cmd_parser.c conflicted twice: main rewrote the pvid command around the
new port-separator and atoi helpers, next to the line where this branch
delegates "stp" to stp_parse(). Both belong, so the STP delegation keeps
main's pvid body.

The linker caught what the merge could not see: main changed atoi_byte()
to return the digit count and leave the value in atoi_results_u8, where
it used to return non-zero on failure and write through a pointer. Note
the sense is inverted, so the three calls in rtl837x_stp.c are adjusted
rather than just re-arranged.
2026-08-26 16:29:39 +02:00
d00f 9a6e2b3e01 pins: put the module back in BANK2
This branch moved rtl837x_pins to the common window in eaff953 to reclaim
BANK2 for the per-port status work, which was free at the time because the
module was only the I2C and GPIO pin helpers.

main has since put the SFP EEPROM transfer there, so the module now weighs
934 bytes and the common window is 156 bytes short. BANK2 has room for it
again, and that is where main keeps it.

Common segment +934 bytes, BANK2 -934.
2026-08-26 01:05:40 +02:00
d00f 6e394300c8 Merge upstream/main into the Spanning Tree branch
Only httpd.c conflicted: main added the buffered configuration upload
next to the pointers this branch had moved into xdata to free internal
RAM. Both belong, so the new globals sit above declarations that keep
their storage class.
2026-08-25 23:28:09 +02:00
bloqaudio 801150431b stp: host the spanning tree module in BANK2
All entry points are already __banked and none of the code runs in
interrupt context, so the module can leave the resident bank. This
relieves pressure on bank 0, which no longer fits a machine with a
custom init table.
2026-08-25 10:05:19 -05:00
logicog 45d0aac118 Merge pull request #326 from vDorst/SRAM-cmd-parse-port-helper
Add/refactor helpers to parse IP, numbers and port arguments
2026-08-25 12:49:00 +02:00
René van Dorst ee05cd4000 Fix: send_counters(), port-argument have to be physical port number.
Not the physical port index!
2026-08-25 07:55:17 +02:00
René van Dorst 74013bb14f CMD: Treat port zero as CPU-port 2026-08-25 07:55:17 +02:00