chore: housekeeping

This commit is contained in:
2024-11-12 00:55:52 +06:00
parent 5f9c966602
commit 48943ba71f
32 changed files with 715 additions and 854 deletions

View File

@@ -1,64 +1,29 @@
# ch32-node fw
fw for a ch32v203 node w/ w5500 ethernet
# CH32V203 Node Firmware
## current
Firmware for a CH32V203 MCU with a W5500 Ethernet controller.
### SysTick IRQ and DMA issue
[Enabling](https://git.hye.su/mira/ch32-node/src/branch/master/src/main.c#L54) the SysTick IRQ leads to a permanent hang of the socket.
- With a 1ms IRQ interval, the hang occurs at `DHCP_ACK` during the `check_DHCP_leasedIP` -> `sendto()` [ARP request](https://git.hye.su/mira/ch32-node/src/branch/master/lib/ioLibrary_Driver/socket.c#L563).
- With a 100ms interval, the hang occurs during the DNS request.
- With a 1s interval it works
- [Disabling SPI DMA](https://git.hye.su/mira/ch32-node/src/branch/master/src/w5500.c#L62) solves it (just commenting out `reg_wizchip_spiburst_cbfunc`), so it's most likely DMA related?
- SPI DMA only works with [prescalers](https://git.hye.su/mira/ch32-node/src/branch/master/src/spi_dma.c#L140) 8 and 64?
- Also, for some reason it needs a ~50ms delay before configuring w5500 when compiled **with** `-O0`, not needed with `-Os`...
## TODO:
UnplatformIOify this
## Diff between SPI w/ and w/o DMA:
### SPI DMA
![SPI_DMA 1](notes/SPI_DMA_no_irq_1.png)
![SPI_DMA 2](notes/SPI_DMA_no_irq_2.png)
### SPI
![SPI 1](notes/SPI_1.png)
![SPI 2](notes/SPI_2.png)
## Features
00 09 04 C0 A8 66 01 02
00 09 04 C0 A8 66 01 02 02
- W5500 Ethernet controller support
- Network protocol support including:
- DHCP client
- MQTT client
- RS485 communication
- OneWire sensors
## ~~previous (DNS Processing)~~
solved by [patching](https://git.hye.su/mira/ch32-node/commit/259d63197e06c1a92b979490d4cd8f0fdb98f8d0#diff-6ba50689ba55dac7cfe3e9b011e594098c931e21) the korean bloatlib (`dns_makequery` in DNS.c)
## Development Environment
w/ ch32v003fun
- Platform: CH32V
- Board: CH32V203C8T6
- Framework: ch32v003fun
- Build System: PlatformIO
- Compiler: RISC-V GCC 14.2.0
> Partial DNS message: `11 23 81 82 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73`
> **DNS_run() failed, res = 0**
## Project Structure
w/ WCH HAL (none-os).. I get a full response
> Receive DNS message from 192.168.102.1(53). len = 56
> Partial DNS message: `11 23 81 80 00 01 00 02 00 00 00 00 03 68 79 65 02 73 75 00 00 01 00 01 C0 0C 00 01 00 01 00 00 01 2C 00 04 68 15 33 7F C0 0C 00 01 00 01 00 00 01 2C 00 04 AC 43 B4 9A `
> Result: 172.67.180.154
`RCC_CTLR`, GPIO Registers, `SPIx_CTLR1` registers are identical
## LA
### ch32v003fun
![ch32v003fun](notes/2024-10-10-191033_1876x540_scrot.png)
```
00 00 34 11 27 01 00 00 01 00 00 00 00 00 00 03 68 79 65 00 00 00 02 73 75 00 00 00 00 01 00 01
```
- 32 bytes long
- (Post `68 79 65`): `00 00 00 02 73 75 00 00 00 00 01 00 01`
### none-os
![none-os](notes/2024-10-10-191043_1891x525_scrot.png)
```
00 00 34 11 27 01 00 00 01 00 00 00 00 00 00 03 68 79 65 02 73 75 00 00 01 00 01
```
- 27 bytes long
- (Post `68 79 65`): `02 73 75 00 00 01 00 01`
- `/include` - Header files
- `/lib` - Project libraries including WIZnet ioLibrary
- `/src` - Source code