Simulink Connected I/O with STLINKV3MODS + Custom board with STM32g431cbt6

We would like to make use of our custom education board araound a STM32G431CBT6. I am well aware of the new STM32 Blockset but I do NOT want to use that one because for the students, the toolchain behind the scenes is absolutely overwhelming. It works on my or a developers desk and is great but again, setting that up on the laptops of students is a pain.
We have a working setup with the "old" Conencted I/O but need an external 64pin Nucleo board for that. So the simple question is:
-> Can I use a custom STM32G431CBT6 Board that has STLInk V3 onboard with "the old" connected IO style (NOT the new STM32 blockset)
-> As far as I understand, the questions boils down to whether there is a connected I/O server available for the specific µC and which peripherals are supported.
I guess the most straightforward/easy way would be to obtain the I/O server for a similar target and do some easy modifications but as far as I can see, Mathworks does not provide the I/O server sources?
Any help would be greatly appreciated. =)

3 Comments

Answer from AI:
Yes, you can use your custom STM32G431CBT6 board with the "old" Connected I/O style, but you will run into some architectural limitations due to how MathWorks deploys this feature.
Since you understandably want to avoid the new STM32 Microcontroller Blockset to keep student laptop setups simple, here is how the old Connected I/O mechanism works behind the scenes and how it impacts your custom board:
1. The Connected I/O Server Source Code
Your assumption is completely correct: Connected I/O relies on a pre-compiled I/O server firmware binary running on the microcontroller. It communicates with Simulink over a serial interface (via the virtual COM port provided by your onboard ST-LINK V3).
  • No source code available: MathWorks does not provide the source code or build scripts for these legacy I/O servers. You cannot modify or recompile the server binary itself to adapt it to custom hardware.
  • The Binary Compatibility Shortcut: Because your custom board uses the exact same microcontroller as the official NUCLEO-G431KB (or its 64-pin sibling NUCLEO-G431RB), the pre-compiled firmware binary intended for the Nucleo board is 100% flash-compatible with your custom chip.
2. How to Set It Up in Simulink
To make this work without installing the new toolchain on student laptops:
  1. Have the students use the older Simulink Coder Support Package for STMicroelectronics Nucleo Boards.
  2. In the Model Configuration Parameters (Ctrl+E -> Hardware Implementation), select NUCLEO-G431RB (or KB) as the target hardware. Simulink will trick itself into thinking it is talking to a stock Nucleo board.
  3. Under the Target Hardware Resources -> Connectivity tab, manually set the COM Port to match the one exposed by your custom board's ST-LINK V3.
3. The Major Catch: Hardcoded Pin Mapping
Because you are flashing a static, pre-compiled binary designed for a Nucleo board, the hardware pin mapping is completely hardcoded.
  • Exact Matches Work: If your custom board routes a peripheral to the exact same pin as the Nucleo board (e.g., if both use PA_5 for a specific digital line), the corresponding Connected I/O block in Simulink will work perfectly.
  • Mismatched Pins Fail: If your custom board routes an LED to PB_3, but the Nucleo hardware definition expects PA_5, you cannot change this via the Simulink block dropdowns. Because you cannot recompile the underlying I/O server binary, any pins that deviate from the stock Nucleo layout become inaccessible via the standard Connected I/O blocks.
A Frustration-Free Alternative for Students
If your custom board's pinout differs significantly from the standard Nucleo board, there is a much cleaner "zero-setup" alternative for the students' laptops:
  • The "Dummy Firmware" Serial Approach: You (the developer) write a single, lightweight firmware in STM32CubeIDE or Arduino that reads your custom pins and dumps/receives the data as a simple byte array or string over the UART/ST-LINK virtual COM port.
  • The Student Setup: On their laptops, students do not need any hardware support packages or compilers at all. They simply use the native Serial Receive and Serial Send blocks from the standard Instrument Control Toolbox in Simulink. Coupled with Simulation Pacing (to force Simulink to run in real-time), this allows them to read and write to your custom board flawlessly without a single toolchain headache.
If this doesn't work, contact support:
Hmm,
Ok that is what i feared... (no source code for the I/O link server). There IS quite a lot of difference in the pin usage, but since the board works together (mostly ADC and PWM) with an external 64 pin Nucleo, I have to check with my colleague which pins I acually need.
The question remains whether the pins that do not match the nucleo that is supported by connected IO make "trouble" even if unused.
I not fully the the "dummy FW approach".How could I e.g. provide ADC/PWM functionaltiy in simulink ? I would need to know the "procotcol" that simulink uses to talk to IO Link?
The question remains whether the pins that do not match the nucleo that is supported by connected IO make "trouble" even if unused.
Answer from AI:
No, the unused mismatched pins will not cause any software "trouble" or hardware damage on your board.
The pre-compiled MathWorks I/O server binary configures pins dynamically based on what blocks you actually drag and drop into your Simulink model. [1]
Here is exactly how the I/O server treats unused pins and why they remain perfectly safe:
1. Unused Pins Stay in their Safe Default State
The I/O server code does not blindly force all 64 pins of the Nucleo configuration into active outputs. If a pin is not mapped to an active block in your open Simulink model, the server firmware leaves it in its micro-controller reset state or configures it as a high-impedance Floating/Analog Input. Because no current is driven or sunk on those unused pins, they will not clash with whatever hardware you have wired to them on your custom board. [1]
2. Peripheral Initializations Are Safe
For internal peripherals like the ADC or TIM (PWM), the I/O server will initialize the internal hardware modules. However:
  • PWM: A timer channel will not output a physical waveform onto a pin unless the corresponding PWM Write block is present in the model.
  • ADC: The ADC might scan internal channels or the pins routed on a stock Nucleo, but reading a pin configured as an analog input is completely passive. It will not interfere with external electronics connected to those pins on your custom layout.
⚠️ The Only Real "Trouble" to Watch For: Student Error
The risk is entirely human, not electrical. Because the dropdown menus inside the Simulink blocks will still display the standard NUCLEO-G431RB pin layout: [1]
  • A student might accidentally add a Digital Write block and pick a pin (e.g., PA5 because it is labeled "User LED" on the Nucleo).
  • If PA5 on your custom board happens to be wired directly to an external low-impedance output or a ground trace without a current-limiting resistor, turning that pin into an active high/low output will cause a hardware short-circuit. [1]
Recommendation: Provide your students with a locked "hardware abstraction" Simulink canvas or a custom library where the block pins are already hardcoded and renamed to match your custom board, preventing them from opening the block dropdowns and selecting a mismatched pin by mistake.
I not fully the the "dummy FW approach".How could I e.g. provide ADC/PWM functionaltiy in simulink ? I would need to know the "procotcol" that simulink uses to talk to IO Link?
Answer from AI:
The "Dummy Firmware" approach completely abandons the proprietary MathWorks Connected I/O blockset, which means you do not need to mimic or know MathWorks' internal protocol. MathWorks wraps their I/O link server protocol inside closed-source binaries, utilizing a complex, request-response polling/streaming frame structure that handles low-level register abstractions. Reverse-engineering it is painful and fragile. [1, 2, 3]
Instead, the "Dummy Firmware" method lets you invent your own dead-simple serial protocol using standard, universal Simulink blocks that require absolutely zero hardware-specific toolchains or compilers on your students' laptops.
Here is exactly how it works for ADC and PWM functionality.
The Architecture Setup
  • On the Custom Board (Teacher Setup): You flash a static C program (written once in STM32CubeIDE) that constantly reads your exact ADC pins, writes values to your exact PWM pins, and handles simple UART text or byte streams over the ST-LINK Virtual COM port.
  • In Simulink (Student Setup): Students use standard blocks from the Instrument Control Toolbox (specifically, Serial Configuration, Serial Receive, and Serial Send). They turn on Simulation Pacing (found under the Simulation tab -> Pacing Options) to force the Simulink canvas to run in real-time wall clock speed (e.g., 1 second of simulation time = 1 second of real time).
Step-by-Step Implementation
1. The ADC Functionality (Reading Data into Simulink)
Instead of a "Connected I/O ADC" block asking for a specific pin, your dummy firmware continuously samples the ADC natively on your microcontroller and blasts the data out of the serial port.
  • Your Custom Firmware (C Code):Configure a timer to trigger an ADC conversion at a fixed rate (e.g., every 20ms / 50Hz). Convert the 12-bit ADC integer to a human-readable string and send it over UART terminated by a newline character \n.
c
// Pseudo-C inside your main loop or timer interrupt
uint16_t adc_val = HAL_ADC_GetValue(&hadc1);
printf("ADC:%d\n", adc_val); // Transmits something like "ADC:2048\n"
  • Inside the Students' Simulink Model:
  1. Students drag a Serial Receive block into their model.
  2. They configure it to use the board's COM port, set the data type to uint8 (or ASCII depending on the block variant), and set it to terminate on \n.
  3. They route the serial output into a Scanf or String Tokenizer block to look for the header "ADC:%d".
  4. The output is a raw numerical signal they can use anywhere in their control loops, view on a Scope, or display on a dashboard.
2. The PWM Functionality (Writing Data from Simulink)
To control a PWM pin, Simulink needs to pack a command value and send it down the serial wire, where your firmware parses it and updates the timer's duty-cycle register (CCR).
  • Inside the Students' Simulink Model:
  1. Students calculate a control signal or duty cycle value (e.g., an integer from 0 to 100).
  2. They pass this signal into a standard String Construct or Format block to create a packet text string like "PWM:75\n".
  3. They feed that string straight into a Serial Send block pointed at the board's COM port.
  • Your Custom Firmware (C Code):Your STM32 code listens to the UART receive interrupt. When a string arrives, it parses it using simple string manipulation or a fast state machine.
c
// Inside UART Rx Interrupt / Parser
if (sscanf(rx_buffer, "PWM:%d", &duty) == 1) {
// Clamp values safely on the hardware level
if(duty > 100) duty = 100;
// Update the Timer Capture/Compare Register directly
__HAL_TIM_SET_COMPARE(&htim1, TIM_CHANNEL_1, (duty * ARR_VAL) / 100);
}
Summary Comparison
AspectLegacy MathWorks Connected I/O The "Dummy Firmware" Serial Approach
Protocol Proprietary, closed-source Your own (e.g., Simple ASCII strings like "PWM:50\n")
MathWorks binary
Pin Hardcoded to NUCLEO-G431RB Fully customized to your exact board
Configuration routing layout in STM32CubeIDE
Student Requires specific hardware
Toolchain support packages None. Uses standard built-in Simulink
Instrument blocks
Safety Risk of student picking wrong pin Safest. Students only see a generic "Serial
via dropdowns Send" block
This approach completely shifts the hardware complexity onto you (the instructor) a single time when developing the firmware template. For the students, interacting with your board becomes identical to dealing with a standard telemetry serial link, making their laptop environment entirely independent of ST-specific drivers, blocksets, or compilers.

Sign in to comment.

Answers (2)

Hi @Franz,
I have attached a short PDF guide with the details.
In brief: I don't think the old Nucleo-based Connected I/O will work with your custom G431 board. The legacy Nucleo support package lists a fixed set of boards, and no STM32G4 board is among them. I also found no MathWorks page saying the I/O server sources are available, so MathWorks support would have to confirm that.
The Embedded Coder Support Package for STM32 (the CubeMX workflow) does list STM32G4xx and custom boards, and it includes Connected IO. The catch is that it builds the I/O server with a GNU Arm toolchain, so student laptops would need CubeMX and a compiler.
If you want no toolchain on student machines, I think the best option is a serial bridge. You build one small firmware once, which sends fixed-size packets over the ST-LINK V3 virtual COM port. Students then use only the Serial Configuration, Serial Send and Serial Receive blocks (Instrument Control Toolbox) with Simulation Pacing. The PDF describes the packet format, the Simulink settings and the caveats.
This is not true Connected I/O. You have to write the firmware and define the signals yourself, and timing is near real time at best. I haven't tested this on real hardware.
If you tell me your MATLAB release and which package your current Nucleo setup uses, I can narrow this down.

1 Comment

Above you told:
"
The Embedded Coder Support Package for STM32 (the CubeMX workflow) does list STM32G4xx and custom boards, and it includes Connected IO. The catch is that it builds the I/O server with a GNU Arm toolchain, so student laptops would need CubeMX and a compiler.
"
So If I have the Embedded Coder Support package installed, I configure the pins / peripherals ONCE, I could compile a FW that can be compiled and flashed ONCE and then has full connected IO Functionality out of Simuink? Or did I get that wrong?

Sign in to comment.

Hi @Franz,
A custom STM32G431CBT6 board can be used for Connected I/O with a custom .ioc file, but it requires the STM32 Blockset (or the Embedded Coder Support Package for STM32 Microcontrollers for MATLAB versions prior to R2026a).
The server code required for Simulink Connected I/O communication is bundled exclusively with the blockset. The server is created dynamically based on the peripherals configured in STM32CubeMX, which is why a local setup of STM32CubeMX and a toolchain compiler is required.
If you need help with installation or configuration of third-party tools across multiple student systems, please reach out to MathWorks Technical Support (Contact Support - MATLAB & Simulink). We would be happy to assist you further.
Thanks,
Aabha

Products

Release

R2026b

Asked:

on 4 Oct 2026

Answered:

on 8 Oct 2026

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!