cargo: update as SaiTLS

pull/4/head
occheung 2021-01-29 16:46:07 +08:00
parent 49c5fec30f
commit d0d475bfbf
4 changed files with 50 additions and 45 deletions

62
Cargo.lock generated
View File

@ -1,5 +1,35 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "SaiTLS"
version = "0.1.0"
source = "git+https://git.m-labs.hk/M-Labs/SaiTLS.git#99f92f84bafe62c5a57698c10632246173d4d2f3"
dependencies = [
"aes-gcm",
"byteorder",
"ccm",
"chacha20poly1305",
"chrono",
"ed25519-dalek",
"embedded-nal",
"generic-array 0.14.4",
"heapless",
"hkdf",
"hmac 0.10.1",
"intrusive-collections",
"log",
"managed 0.8.0",
"nom",
"num_enum",
"p256",
"rand_core",
"rsa",
"sha-1",
"sha2",
"smoltcp",
"x25519-dalek",
]
[[package]]
name = "aead"
version = "0.3.2"
@ -606,6 +636,7 @@ dependencies = [
name = "humpback-dds"
version = "0.1.0"
dependencies = [
"SaiTLS",
"alloc-cortex-m",
"cortex-m",
"cortex-m-log",
@ -626,7 +657,6 @@ dependencies = [
"serde",
"sfkv",
"smoltcp",
"smoltcp-tls",
"stm32h7xx-hal",
]
@ -1131,36 +1161,6 @@ dependencies = [
"managed 0.7.2",
]
[[package]]
name = "smoltcp-tls"
version = "0.1.0"
source = "git+https://git.m-labs.hk/M-Labs/smoltcp-tls.git#0c6807f59315e040244b3400c3eae691540eef6b"
dependencies = [
"aes-gcm",
"byteorder",
"ccm",
"chacha20poly1305",
"chrono",
"ed25519-dalek",
"embedded-nal",
"generic-array 0.14.4",
"heapless",
"hkdf",
"hmac 0.10.1",
"intrusive-collections",
"log",
"managed 0.8.0",
"nom",
"num_enum",
"p256",
"rand_core",
"rsa",
"sha-1",
"sha2",
"smoltcp",
"x25519-dalek",
]
[[package]]
name = "spin"
version = "0.5.2"

View File

@ -18,7 +18,7 @@ minimq = { git = "https://github.com/quartiq/minimq.git", branch = "master" }
heapless = "0.5.6"
nom = { version = "5.1.2", default-features = false, features = [] }
ryu = "1.0"
smoltcp-tls = { git = "https://git.m-labs.hk/M-Labs/smoltcp-tls.git", features = [ "nal_tcp_stack" ] }
SaiTLS = { git = "https://git.m-labs.hk/M-Labs/SaiTLS.git", features = [ "nal_tcp_stack" ] }
rand_core = { version = "0.5.1", default-features = false, features = [] }
sfkv = "0.1.0"
serde = { version = "1.0", default-features = false, features = ["derive"] }

View File

@ -9,7 +9,7 @@ MEMORY
/* SRAM */
SRAM1 : ORIGIN = 0x30000000, LENGTH = 128K
SRAM2 : ORIGIN = 0x30020000, LENGTH = 128K
SRAM2 (rwx) : ORIGIN = 0x30020000, LENGTH = 128K
SRAM3 (rwx) : ORIGIN = 0x30040000, LENGTH = 32K
SRAM4 : ORIGIN = 0x38000000, LENGTH = 64K
@ -34,6 +34,10 @@ SECTIONS {
*(.axisram .axisram.*);
. = ALIGN(8);
} > AXISRAM
.sram2 (NOLOAD) : ALIGN(4) {
*(.sram2 .sram2.*);
. = ALIGN(4);
} > SRAM2
.sram3 (NOLOAD) : ALIGN(4) {
*(.sram3 .sram3.*);
. = ALIGN(4);

View File

@ -11,7 +11,7 @@ use stm32h7xx_hal::{pac, prelude::*, spi};
use stm32h7xx_hal::ethernet;
use smoltcp as net;
use smoltcp_tls as tls;
use SaiTLS as tls;
use minimq::{ MqttClient, QoS };
@ -71,6 +71,10 @@ static mut NET_STORE: NetStorage = NetStorage {
#[link_section = ".sram3.eth"]
static mut DES_RING: ethernet::DesRing = ethernet::DesRing::new();
#[link_section = ".sram3.tx_store"]
static mut TX_STORAGE: [u8; 8192] = [0; 8192];
#[link_section = ".sram3.rx_store"]
static mut RX_STORAGE: [u8; 8192] = [0; 8192];
struct RngStruct {
rng: Rng
@ -114,10 +118,10 @@ fn main() -> ! {
}
logger::init();
// Enable SRAM3 for the descriptor ring.
// Enable SRAM3 for the descriptor ring and smoltcp buffers.
dp.RCC.ahb2enr.modify(|_, w| w.sram3en().set_bit());
// // Reset RCC clock
// dp.RCC.rsr.write(|w| w.rmvf().set_bit());
// Enable SRAM2 for the RAM management buffer
dp.RCC.ahb2enr.modify(|_, w| w.sram2en().set_bit());
let pwr = dp.PWR.constrain();
let vos = pwr.freeze();
@ -264,7 +268,7 @@ fn main() -> ! {
let urukul = Urukul::new(
parts.spi1, parts.spi2, parts.spi3, parts.spi4, parts.spi5, parts.spi6, parts.spi7
);
);
let mut mqtt_mux = MqttMux::new(urukul, flash, flash_store, net_config.name.as_str());
@ -277,14 +281,12 @@ fn main() -> ! {
next_ms += 400_000.cycles();
let mut tls_socket_entries: [_; 1] = Default::default();
let mut tls_socket_set = smoltcp_tls::set::TlsSocketSet::new(
let mut tls_socket_set = tls::set::TlsSocketSet::new(
&mut tls_socket_entries[..]
);
let mut tx_storage = [0; 4096];
let mut rx_storage = [0; 4096];
let tx_buffer = net::socket::TcpSocketBuffer::new(&mut tx_storage[..]);
let rx_buffer = net::socket::TcpSocketBuffer::new(&mut rx_storage[..]);
let tx_buffer = net::socket::TcpSocketBuffer::new(unsafe { &mut TX_STORAGE[..] });
let rx_buffer = net::socket::TcpSocketBuffer::new(unsafe { &mut RX_STORAGE[..] });
let mut tcp_socket = net::socket::TcpSocket::new(rx_buffer, tx_buffer);
tcp_socket.set_keep_alive(
Some(net::time::Duration::from_secs(2))
@ -301,7 +303,7 @@ fn main() -> ! {
tls_socket_set
);
let mut client = MqttClient::<consts::U256, _>::new(
let mut client = MqttClient::<consts::U2048, _>::new(
net_config.broker_ip,
net_config.name.as_str(),
tls_stack,
@ -328,7 +330,6 @@ fn main() -> ! {
// Process MQTT messages about Urukul/Control
let connection = match client
.poll(|_client, topic, message, _properties| {
// Why is topic a string while message is a slice?
mqtt_mux.process_mqtt_ingress(topic, message);
}) {
Ok(_) => true,