1
00:00:00,200 --> 00:00:11,771
This tutorial builds a network of 124 emulated microcontrollers on one UART line, like an RS-485 bus, all running the same firmware.

2
00:00:11,771 --> 00:00:23,269
We start from a pinout, write one firmware for every node, describe the network, run and monitor it, deploy a new build to all nodes in one step, and look at the frames in the Lab.

3
00:00:23,269 --> 00:00:31,134
Every node is an LP-MSPM0C1104. In Pins, start the pin configurator.

4
00:00:31,134 --> 00:00:40,911
Pin Configurator workspace, board MSPM0C1104. The network needs UART 0 only, plus an LED.

5
00:00:40,911 --> 00:00:49,940
PA17 and PA18: UART 0, the network line. Every node's TX and RX sit on the same wire.

6
00:00:51,380 --> 00:00:56,190
PA22: LED 1, toggled on every frame the node sends.

7
00:00:56,190 --> 00:01:00,628
Save the pinout in the project folder, uartnet-demo.

8
00:01:03,150 --> 00:01:12,064
Generate Files, Files, the bare-metal target with scope Full project, and Save to folder: a DriverLib project with CMake.

9
00:01:12,064 --> 00:01:21,941
Then Set up for emulation: env.sh with this computer's Renode and Arm GCC, build.sh, and the VS Code files.

10
00:01:22,214 --> 00:01:35,172
One binary runs on every node. A frame is a start byte, addressee, sender, length, a command and a CRC-8. Node 1 is the master; it polls the others, they answer with their status.

11
00:01:35,172 --> 00:01:47,733
The address is not compiled in: it is a configuration word at the end of flash, 0x3FF8, which production programming writes per node, and embeddyn writes per emulated node.

12
00:01:47,733 --> 00:02:00,521
At start-up the firmware reads that word: the node id in the low byte, the node count above it. Receive is interrupt-driven with the FIFO on; between frames the node sleeps in WFI.

13
00:02:00,521 --> 00:02:10,503
The master polls node 2 to 124 in turn, waits 4 milliseconds for each answer with one retry, then broadcasts a summary of the round.

14
00:02:10,503 --> 00:02:14,165
Build it with ./build.sh release.

15
00:02:14,165 --> 00:02:27,145
uartnet.yaml describes the network: the board, 124 nodes, the one firmware, the build command, the UART on the line, and where each node's configuration word goes.

16
00:02:27,145 --> 00:02:42,035
The quantum is how often Renode synchronises the nodes. Keep it at or below one character time, 87 microseconds at 115200 baud, or frames garble; embeddyn warns when it is longer.

17
00:02:42,035 --> 00:02:52,028
uartnet script writes the Renode script: one machine per node, all UARTs connected to one hub, the ELF loaded and the node's word written.

18
00:02:53,628 --> 00:03:07,443
uartnet run starts all 124 nodes in one Renode and follows the line: a status line every second, with frames, nodes heard, bad frames, firmware versions and the master's summary.

19
00:03:07,443 --> 00:03:14,680
Time-lapse: Renode loads 124 nodes (about 20 s), then a poll round of 123 slaves takes about 25 s of real time

20
00:03:31,283 --> 00:03:41,212
After the first round, the master's summary: 123 nodes answered, none missing, firmware version 1, no bad frame on the line.

21
00:03:41,212 --> 00:03:49,905
In a second terminal, uartnet monitor --all decodes every frame on the line: who sent it, to whom, and what it says.

22
00:03:51,805 --> 00:03:59,206
Now develop: change the code, here the firmware version from 1 to 2, while the network keeps running.

23
00:03:59,206 --> 00:04:10,993
uartnet deploy builds, loads the new ELF into every node of the running network, writes the addresses again and restarts all 124 nodes at the same virtual instant.

24
00:04:10,993 --> 00:04:17,565
Time-lapse: the run's status lines after the deploy

25
00:04:17,565 --> 00:04:22,809
One build, one command, 124 nodes running it.

26
00:04:22,809 --> 00:04:34,258
The project's VS Code tasks wrap the same commands. network: deploy is the default build task: edit, press Control Shift B, and every node runs the new code.

27
00:04:34,258 --> 00:04:47,052
In the Lab, one Renode instance with the option network: uartnet.yaml is the whole network. Bindings with a machine name reach single nodes, here LED 1 of the first and the last node.

28
00:04:47,872 --> 00:04:51,017
Open the project's lab.yaml.

29
00:04:55,232 --> 00:05:05,825
Run it for 0.3 seconds of virtual time: Renode loads the 124 nodes, then the Lab steps them in 50 millisecond steps.

30
00:05:13,825 --> 00:05:24,084
The Analyzer lists every frame on the line: time, UART, sender and addressee by node name, and the decoded command: POLL, STATUS, SUMMARY.

31
00:05:24,084 --> 00:05:30,068
Filter by type: type==SUMMARY keeps the master's summaries.

32
00:05:31,488 --> 00:05:38,522
Select one: the field tree and the bytes, with the CRC checked. Bad frames are flagged red.

33
00:05:38,522 --> 00:05:47,105
src==node042 follows a single node; the pcap button exports the line for Wireshark.

34
00:05:48,925 --> 00:06:01,928
That is the whole network: one pinout, one firmware, one file that makes 124 nodes of it, a monitor of the line, and one command that deploys your next build to every node.
