Skip to content

Commit 27544a2

Browse files
xorbitdpgeorge
authored andcommitted
esp32/boards: Add Silicognition ManT1S board definition.
New board planned to be launched on Crowd Supply in late 2025. ESP32-based core module with IEEE 802.3cg 10BASE-T1S Single Pair Ethernet networking and power distribution over data lines. Signed-off-by: Patrick Van Oosterwijck <[email protected]>
1 parent b4ab3a8 commit 27544a2

File tree

8 files changed

+190
-0
lines changed

8 files changed

+190
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"deploy": [
3+
"../deploy.md"
4+
],
5+
"deploy_options": {
6+
"flash_offset": "0x1000"
7+
},
8+
"docs": "",
9+
"features": [
10+
"BLE",
11+
"External Flash",
12+
"External RAM",
13+
"WiFi"
14+
],
15+
"features_non_filterable": [
16+
"T1S",
17+
"10BASE-T1S"
18+
],
19+
"images": [
20+
"mant1s-board-top.jpg"
21+
],
22+
"mcu": "esp32",
23+
"product": "ManT1S",
24+
"thumbnail": "",
25+
"url": "https://mant1s.net/",
26+
"vendor": "Silicognition LLC"
27+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
freeze("modules")
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# µPing (MicroPing) for MicroPython
2+
# copyright (c) 2018 Shawwwn <[email protected]>
3+
# License: MIT
4+
5+
# Internet Checksum Algorithm
6+
# Author: Olav Morken
7+
# https://github.com/olavmrk/python-ping/blob/master/ping.py
8+
# Adjusted for ruff formatting to include in ManT1S MicroPython
9+
10+
import utime
11+
import uselect
12+
import uctypes
13+
import usocket
14+
import ustruct
15+
import urandom
16+
17+
18+
# @data: bytes
19+
def checksum(data):
20+
if len(data) & 0x1: # Odd number of bytes
21+
data += b"\0"
22+
cs = 0
23+
for pos in range(0, len(data), 2):
24+
b1 = data[pos]
25+
b2 = data[pos + 1]
26+
cs += (b1 << 8) + b2
27+
while cs >= 0x10000:
28+
cs = (cs & 0xFFFF) + (cs >> 16)
29+
cs = ~cs & 0xFFFF
30+
return cs
31+
32+
33+
def ping(host, count=4, timeout=5000, interval=10, quiet=False, size=64):
34+
# prepare packet
35+
assert size >= 16, "pkt size too small"
36+
pkt = b"Q" * size
37+
pkt_desc = {
38+
"type": uctypes.UINT8 | 0,
39+
"code": uctypes.UINT8 | 1,
40+
"checksum": uctypes.UINT16 | 2,
41+
"id": uctypes.UINT16 | 4,
42+
"seq": uctypes.INT16 | 6,
43+
"timestamp": uctypes.UINT64 | 8,
44+
} # packet header descriptor
45+
h = uctypes.struct(uctypes.addressof(pkt), pkt_desc, uctypes.BIG_ENDIAN)
46+
h.type = 8 # ICMP_ECHO_REQUEST
47+
h.code = 0
48+
h.checksum = 0
49+
h.id = urandom.getrandbits(16)
50+
h.seq = 1
51+
52+
# init socket
53+
sock = usocket.socket(usocket.AF_INET, usocket.SOCK_RAW, 1)
54+
sock.setblocking(0)
55+
sock.settimeout(timeout / 1000)
56+
addr = usocket.getaddrinfo(host, 1)[0][-1][0] # ip address
57+
sock.connect((addr, 1))
58+
not quiet and print("PING %s (%s): %u data bytes" % (host, addr, len(pkt)))
59+
60+
seqs = list(range(1, count + 1)) # [1,2,...,count]
61+
c = 1
62+
t = 0
63+
n_trans = 0
64+
n_recv = 0
65+
finish = False
66+
while t < timeout:
67+
if t == interval and c <= count:
68+
# send packet
69+
h.checksum = 0
70+
h.seq = c
71+
h.timestamp = utime.ticks_us()
72+
h.checksum = checksum(pkt)
73+
if sock.send(pkt) == size:
74+
n_trans += 1
75+
t = 0 # reset timeout
76+
else:
77+
seqs.remove(c)
78+
c += 1
79+
80+
# recv packet
81+
while 1:
82+
socks, _, _ = uselect.select([sock], [], [], 0)
83+
if socks:
84+
resp = socks[0].recv(4096)
85+
resp_mv = memoryview(resp)
86+
h2 = uctypes.struct(uctypes.addressof(resp_mv[20:]), pkt_desc, uctypes.BIG_ENDIAN)
87+
# TODO: validate checksum (optional)
88+
seq = h2.seq
89+
if h2.type == 0 and h2.id == h.id and (seq in seqs): # 0: ICMP_ECHO_REPLY
90+
t_elasped = (utime.ticks_us() - h2.timestamp) / 1000
91+
ttl = ustruct.unpack("!B", resp_mv[8:9])[0] # time-to-live
92+
n_recv += 1
93+
not quiet and print(
94+
"%u bytes from %s: icmp_seq=%u, ttl=%u, time=%f ms"
95+
% (len(resp), addr, seq, ttl, t_elasped)
96+
)
97+
seqs.remove(seq)
98+
if len(seqs) == 0:
99+
finish = True
100+
break
101+
else:
102+
break
103+
104+
if finish:
105+
break
106+
107+
utime.sleep_ms(1)
108+
t += 1
109+
110+
# close
111+
sock.close()
112+
ret = (n_trans, n_recv)
113+
not quiet and print("%u packets transmitted, %u packets received" % ret)
114+
return ret
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set(SDKCONFIG_DEFAULTS
2+
boards/sdkconfig.base
3+
boards/sdkconfig.spiram
4+
boards/sdkconfig.ble
5+
boards/sdkconfig.240mhz
6+
boards/SIL_MANT1S/sdkconfig.board
7+
)
8+
9+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#define MICROPY_HW_BOARD_NAME "Silicognition ManT1S"
2+
#define MICROPY_HW_MCU_NAME "ESP32-PICO-V3-02"
3+
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "mant1s"
4+
5+
#define MICROPY_HW_I2C0_SCL (32)
6+
#define MICROPY_HW_I2C0_SDA (33)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Partition table for MicroPython with OTA support using 8MB flash
2+
# Notes: the offset of the partition table itself is set in
3+
# $IDF_PATH/components/partition_table/Kconfig.projbuild.
4+
# Name, Type, SubType, Offset, Size, Flags
5+
nvs, data, nvs, 0x9000, 0x4000,
6+
otadata, data, ota, 0xd000, 0x2000,
7+
phy_init, data, phy, 0xf000, 0x1000,
8+
ota_0, app, ota_0, 0x10000, 0x200000,
9+
ota_1, app, ota_1, 0x210000, 0x200000,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
I2C_SCL,GPIO32
2+
I2C_SDA,GPIO33
3+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 8 MB flash
2+
3+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
4+
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
5+
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=
6+
CONFIG_ESPTOOLPY_FLASHSIZE="8MB"
7+
8+
# Fast flash
9+
10+
CONFIG_ESPTOOLPY_FLASHMODE_QIO=y
11+
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
12+
13+
# Partition table
14+
15+
CONFIG_PARTITION_TABLE_CUSTOM=y
16+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="boards/SIL_MANT1S/partitions-8MiB-ota.csv"
17+
18+
# Network name
19+
20+
CONFIG_LWIP_LOCAL_HOSTNAME="ManT1S"

0 commit comments

Comments
 (0)