Skip to content

13 · From pinout to debugger: LP-MSPM0C1104

This tutorial takes one MCU from an empty pin diagram to firmware you step through in VS Code, and runs the same firmware in the embeddyn Lab (video version):

flowchart LR
  P[Pin Configurator<br/>pinout .zpinproj] -->|bare-metal export| F[firmware project<br/>DriverLib + CMake]
  F -->|./build.sh| E[build/app.elf]
  E -->|devboards setup| S[env.sh · debug.sh · gdb.sh<br/>.vscode · lab.yaml]
  S -->|F5| D[VS Code + cortex-debug<br/>→ Renode GDB server]
  S -->|Open lab.yaml| L[embeddyn Lab<br/>LEDs · buttons · sliders · console]

The finished result is examples/mechatronics/firmware/mspm0c1104-app. Follow the steps with your own pins, or read along there.

What you need

Tool Why Where it comes from
embeddyn + the pin configurator the Lab, the setup builder, the Pins workspace this checkout: ./run.sh --check (installs the pins extra and fetches externals/pin_configurator)
Renode, embeddyn's fork emulates the board; GDB server Build Renode with custom cores; its env.sh puts dotnet on PATH
TI MSPM0 SDK DriverLib, startup code, linker scripts ti.com/tool/MSPM0-SDK (tested with 2.01.00.03)
Arm GNU toolchain with gdb arm-none-eabi-gcc with newlib, arm-none-eabi-gdb xPack GNU Arm Embedded GCC (tested with 15.2.1); distribution packages often lack newlib or gdb
VS Code + cortex-debug source-level debugging code --install-extension marus25.cortex-debug
CMake ≥ 3.20 the generated project your distribution

TI SysConfig is not needed: the configurator writes the DriverLib setup files (ti_msp_dl_config.c/.h) itself.

Short on disk records?

The xPack toolchain is about 8,000 files. For a Cortex-M0+ you only need bin/, libexec/, arm-none-eabi/include, arm-none-eabi/lib/*.specs, ldscripts, thumb/v6-m/nofp and lib/gcc/arm-none-eabi/<version>/{include,include-fixed,thumb/v6-m/nofp}, about 2,200 files. Leave out lib/python3.* (only arm-none-eabi-gdb-py needs it).

1 · Start the pin configurator

In the Lab: Pins workspace (Alt+8) ▸ Start. The configurator runs as a child process of the Lab and opens in the frame; ⧉ Window gives it a browser window of its own. Without the Lab: python externals/pin_configurator/run.py --port 5100.

2 · The board package (once per MCU and package)

The configurator lists the board packages in externals/pin_configurator/boards/. lp_mspm0c1104 is the MSPM0C1104 in the LaunchPad's 20-pin VSSOP. For another MSPM0 part, generate the pin table from TI's data:

cd externals/pin_configurator
python scripts/maintenance/generate_mspm0_board_pins.py "$MSPM0_SDK_PATH" /path/to/sysconfig \
    MSPM0C110X "VSSOP-20(DGS20)" labels.json      # labels.json: {"PA22": "LED1", ...}, optional

Paste its output into a board file (copy boards/lp_mspm0c1104.py), check the pin sides (the script assumes four sides; a VSSOP has two), set soc, package, flash_size_kb, sram_size_kb, clock_hz and the peripherals' base addresses (#define <PERIPHERAL>_BASE in $MSPM0_SDK_PATH/source/ti/devices/msp/m0p/<family>.h). Then register it in boards/__init__.py. The packages a family comes in are listed in src/data/mspm0_pinmux.json (families.<FAMILY>.packages).

3 · Assign the pins

Pick the board lp_mspm0c1104, click a pin, choose its function, name it and set its properties. This tutorial's pinout:

Function Pin (package pin) Settings
LED1 PA22 (17), GPIO output name LED1
S1 PA16 (12), GPIO input name S1, pull-up (the button goes to GND)
Console UART0 PA17 TX (13), PA18 RX (14) the XDS110 back channel, 115200 8N1
PWM PA2 (8), TIMA0_CCP0 name PWM
Analog input PA25 (20), ADC0 channel 2 name POT
I2C0 PA0 SDA (4), PA11 SCL (11)

Keep PA19 (SWDIO), PA20 (SWCLK) and PA1/NRST free: they are the debug port and the reset pin.

Save the pinout with Save project as lp_mspm0c1104.zpinproj in the firmware folder (step 4). The configurator reopens it with Open project, and the setup builder (step 6) reads it.

4 · Export the firmware project

Generate ▸ Bare metal (target baremetal) with scope project writes a complete CMake project:

File What it is Regenerated by
main.c your application scope project only
pin_config.c/.h pin_config_apply(): calls SYSCFG_DL_init() project and init
ti_msp_dl_config.c/.h clocks, pins, UART, timer, ADC, I2C setup (DriverLib), names like GPIO_A_LED1_PIN project and init
lp_mspm0c1104.syscfg the same setup for TI SysConfig/CCS project and init
CMakeLists.txt, arm-none-eabi.cmake build with MSPM0_SDK_PATH and ARM_GCC_PATH scope project only

Export with project once. When the pinout changes later, export with init: it rewrites only the setup files, never your main.c.

5 · Write the application and build

main.c uses the generated names (ti_msp_dl_config.h): DL_GPIO_togglePins(GPIO_A_PORT, GPIO_A_LED1_PIN), DL_UART_Main_transmitDataBlocking(UART_0_INST, c), DL_TimerA_setCaptureCompareValue(PWM_TIMA0_INST, ...), DL_ADC12_startConversion(ADC12_0_INST)... The example blinks LED1 (faster while S1 is held), sweeps the PWM duty and prints tick N S1=up pwm=P% adc=A every half second. The C1104 has 1 KB of RAM, so it prints numbers without printf.

./build.sh            # Debug (-Og -g3): build/lp_mspm0c1104.elf, .hex, .bin
./build.sh release    # -Os

build.sh reads env.sh (step 6). Before that exists, set ARM_GCC_PATH and MSPM0_SDK_PATH in the shell.

6 · Set up the emulation environment

One command makes the project debuggable in Renode and runnable in the Lab:

python -m embeddyn.mechatronics.devboards setup lp_mspm0c1104 examples/mechatronics/firmware/mspm0c1104-app \
    --elf build/lp_mspm0c1104.elf --pinout lp_mspm0c1104.zpinproj

You can also use the form in the Lab: Pins ▸ Firmware project: emulation setup (board, folder, ELF, pinout ▸ Set up). Either way it writes:

File What it does
env.sh this computer's paths, detected: RENODE_ENV (Renode's own env script, sourced first), RENODE_BIN, ARM_GCC_PATH, EMBEDDYN_PYTHON, EMBEDDYN_HOME, SDK paths. Kept on later runs (--force rewrites it); not committed
env.sh.example the same with placeholders, for the repository
debug.sh the board in Renode with the ELF and a GDB server on :3333, halted until a debugger connects
gdb.sh arm-none-eabi-gdb from env.sh; cortex-debug uses it, so VS Code needs no settings
build.sh for a CMake project without one
.vscode/tasks.json build, renode: gdb server (after build, in the background), renode: stop, merged by label
.vscode/launch.json the cortex-debug attach configuration: preLaunchTask starts Renode, postDebugTask stops it
lab.yaml the Lab project: the board running the ELF, its LED, button and console, and the pinout's parts
renode/lab.resc, renode/lab-feeds.repl for analog inputs: the board's script plus a sensor feed that sets the ADC channel voltages

What the pinout becomes in the Lab:

Pinout Lab
GPIO output LED (a gpio_state binding)
GPIO input push button (gpio; pull-up means pressed = low)
ADC channel slider in volts (on MSPM0 through a PropertyFeed calling SetChannelVoltage)
timer CCP output gauge of the PWM duty (register_ratio: 1 - CCn / (LOAD + 1))
the board's console UART serial monitor (already on the board)
I2C, SPI, other UARTs listed as notes: give them a device model in a Renode .repl

7 · Debug in VS Code

Open the firmware folder in VS Code and press F5:

  1. the build task builds the ELF;
  2. renode: gdb server starts Renode (its Monitor appears in a terminal panel);
  3. cortex-debug runs gdb.sh, attaches to localhost:3333 and runs to main.

From there: breakpoints, stepping, variables (ticks, adc_last, pwm_duty_permille), the call stack, memory. Stopping the session runs renode: stop. Each session starts a fresh Renode, so the CPU always begins at the reset vector.

Drive the emulated hardware from the Debug Console:

-exec monitor sysbus.iomux.s1 Press                 # hold S1 (Release lets go; the pin updates when the CPU runs)
-exec monitor sysbus.adc0 SetChannelVoltage 2 1.2   # 1.2 V on ADC0 channel 2 (PA25): the firmware reads 372
-exec monitor sysbus.iomux.led1 State               # is LED1 lit?
-exec monitor peripherals                           # everything the board has

Without VS Code:

./debug.sh                                                     # terminal 1: Renode, waiting for gdb
./gdb.sh build/lp_mspm0c1104.elf -ex "target remote :3333" -ex "break main" -ex continue    # terminal 2

For the peripheral register view, add an SVD file with setup --svd path/to/MSPM0C110X.svd. TI ships it in the MSPM0C1X0X device pack for Keil and CMSIS. See also Debug emulated firmware with cortex-debug.

8 · Run it in the Lab

Open lab.yaml: the Open lab.yaml button of the setup form, Open ▸ Project file, or embeddyn lab examples/mechatronics/firmware/mspm0c1104-app/lab.yaml --open. Press Run:

  • LP-MSPM0C1104: LED1 blinks; hold S1 and it blinks faster, and the console shows S1=down;
  • the POT slider sets PA25: at 3.0 V the console shows adc=930;
  • the PWM duty gauge follows the sweep;
  • the serial monitor shows the firmware's console. Its send box writes to UART0 RX.

Turn on real-time to watch it at wall-clock speed. Add instruments (oscilloscope, logic analyser) from the library and wire them to the board's signals to look closer.

9 · The everyday loop

  • Change code: edit main.c, F5 (or Run in the Lab after ./build.sh). The Lab project points at build/lp_mspm0c1104.elf, so it always runs the latest build.
  • Change pins: in the configurator, Open project (.zpinproj), change the pins, Save project, export with scope init into the same folder, then run setup again with --force to rebuild lab.yaml. Your main.c is kept. --force also rewrites env.sh, so run it from a shell where the tools are found or set again.
  • A new project elsewhere: export the bare-metal project into an empty folder (scope project), save the .zpinproj there, build once, run setup with that folder. Nothing in the generated files points into this checkout except env.sh (paths) and renode/lab.resc (the board's script), which setup rewrites.

Troubleshooting

Symptom Cause, fix
Emulation workspace or status bar: renode missing the Lab's shell has no RENODE_BIN: python -m embeddyn.mechatronics.devboards user-env --renode /path/to/renode writes ~/.config/embeddyn/env.sh, which run.sh loads; restart the Lab
dotnet: command not found when Renode starts Renode's env script was not sourced: set RENODE_ENV in env.sh to the env.sh of the Renode build
F5 waits, nothing connects another Renode still holds :3333: run the task renode: stop, or pkill -f "StartGdbServer 3333"
break main never hits that Renode was already running (an earlier gdb started it): restart debug.sh
nosys.specs: No such file the toolchain has no newlib: use the xPack toolchain (What you need)
arm-none-eabi-gdb: not found ARM_GCC_PATH in env.sh points to a folder without gdb
The Lab run stops: File does not exist in a .resc the board's script moved: run setup again (it rewrites renode/lab.resc)
adc=0 in the Lab the ADC needs the sensor feed: the Lab project must use renode/lab.resc (setup with the pinout)