This series adds board emulation for the Microchip PIC32MK GPK/MCM family
of 32-bit MIPS32 microcontrollers (microAptiv core, 120 MHz).
PIC32MK is widely used in automotive, industrial, and motor-control
applications. The emulation targets the PIC32MK1024MCM100 variant
(1 MB Flash, 256 KB RAM), reference datasheet DS60001519E.
# What is implemented
The following peripherals are modelled:
- CPU: MIPS32 microAptiv (M4K-derived), little-endian
- Memory: 256 KB SRAM, 1 MB Flash (NVM) with DataEEPROM emulation
- EVIC: vectored interrupt controller with 8-level priority
- UART1-6: 16-byte TX/RX FIFOs, baud-rate divisor, interrupt support
- Timer1-9: 16/32-bit, prescaler, period register, interrupt
- GPIO: ports A-G, ANSEL/TRIS/PORT/LAT/ODC, CN mismatch interrupt
- SPI1-6: master and slave modes, 8/16/32-bit frames
- I2C1-5: master/slave, 7/10-bit addressing
- DMA: 8 channels, cell-triggered transfers
- CAN FD: 4 instances, hardware FIFO, TX object, SocketCAN backend
- USB: CDC-ACM class, chardev backend for host connectivity
- OC1-16: Output Compare (PWM mode detection, diagnostic event stream)
- IC1-16: Input Capture (stub, register model)
- ADCHS: 12-bit ADC with 43 channels, software trigger
- CRU: Clock and Reset Unit (software reset, PBCLK divisor)
- WDT: Watchdog Timer (clear register, timeout reset)
- CFG: Configuration bit registers (DEVCFG0-3)
# What is NOT implemented
- PWM actual waveform generation (OC emits diagnostic events only)
- Input Capture signal measurement (IC is a register stub)
- DMA linked-list (pattern match) transfers
- USB isochronous / bulk / HID endpoints
- PPS (peripheral pin select) remapping
# Testing
A minimal MIPS32 assembly firmware is included
(tests/functional/mipsel/pic32mk_test_fw.S) that initialises the CPU,
writes a known string to UART1, and halts. The functional test asserts
that QEMU serial output matches the expected string.
Four qtest cases cover UART register behaviour, GPIO SET/CLR/INV
sub-registers, and CAN FD loopback.
Build and run:
mkdir build && cd build
../configure --target-list=mipsel-softmmu
make -j$(nproc)
./qemu-system-mipsel -M pic32mk -nographic -serial stdio \
-kernel tests/functional/mipsel/pic32mk_test_fw.elf
The datasheet (DS60001519E) is publicly available from Microchip's
website and is not included in this series.
Signed-off-by: Ericson Joseph <ericsonjoseph@gmail.com>
---
Ericson Joseph (3):
hw/mips: add Microchip PIC32MK GPK/MCM board
tests: add PIC32MK functional and qtest coverage
docs: document the PIC32MK machine in target-mips.rst
MAINTAINERS | 9 +
configs/targets/mipsel-softmmu.mak | 1 +
docs/system/target-mips.rst | 52 ++
hw/mips/Kconfig | 8 +
hw/mips/meson.build | 21 +
hw/mips/pic32mk.c | 815 ++++++++++++++++++++
hw/mips/pic32mk_adchs.c | 583 ++++++++++++++
hw/mips/pic32mk_canfd.c | 1143 ++++++++++++++++++++++++++++
hw/mips/pic32mk_cfg.c | 247 ++++++
hw/mips/pic32mk_cru.c | 375 +++++++++
hw/mips/pic32mk_dataee.c | 463 +++++++++++
hw/mips/pic32mk_dma.c | 255 +++++++
hw/mips/pic32mk_evic.c | 399 ++++++++++
hw/mips/pic32mk_gpio.c | 418 ++++++++++
hw/mips/pic32mk_i2c.c | 184 +++++
hw/mips/pic32mk_ic.c | 384 ++++++++++
hw/mips/pic32mk_nvm.c | 572 ++++++++++++++
hw/mips/pic32mk_oc.c | 293 +++++++
hw/mips/pic32mk_spi.c | 532 +++++++++++++
hw/mips/pic32mk_timer.c | 294 +++++++
hw/mips/pic32mk_uart.c | 334 ++++++++
hw/mips/pic32mk_usb.c | 1033 +++++++++++++++++++++++++
hw/mips/pic32mk_wdt.c | 230 ++++++
include/hw/mips/pic32mk.h | 952 +++++++++++++++++++++++
include/hw/mips/pic32mk_adchs.h | 87 +++
include/hw/mips/pic32mk_canfd.h | 210 +++++
include/hw/mips/pic32mk_evic.h | 45 ++
include/hw/mips/pic32mk_usb.h | 181 +++++
tests/functional/mipsel/meson.build | 28 +
tests/functional/mipsel/pic32mk_test_fw.S | 64 ++
tests/functional/mipsel/pic32mk_test_fw.ld | 20 +
tests/functional/mipsel/test_pic32mk.py | 57 ++
tests/qtest/meson.build | 4 +-
tests/qtest/pic32mk-canfd-test.c | 411 ++++++++++
tests/qtest/pic32mk-test.c | 457 +++++++++++
35 files changed, 11160 insertions(+), 1 deletion(-)
---
base-commit: 759c456b1d22fe4083c8b384da27d3f56fd53f82
change-id: 20260429-pic32mk-board-support-5da07e77ddbc
Best regards,
--
Ericson Joseph <ejoseph@voltumotor.com>