A kernel module to program Cortex-M MCU by emulating ARM Serial Wire Debug (SWD) protocol.
- Some SoCs like raspberry-pi which has powerful application core running Linux kernel but no real-time processing unit.
- Some MPUs like AM33x used by Beaglebone-Black has a PRU and STM32MP1x has a cortex-m core.
- This kernel module aims to make the SoC which has no sub-core have an external extended cortex-m sub-core and control it by SoC via emulated SWD protocol.
Please refer this figure for the wiring
- Set the _swclk_pin and _swdio_pin.
- Set the core
- compile
- use (Please refere to the test cases)
Structure of rpu_sysfs "/sys/class/swd/rpu"
/sys/class/swd/rpu ├── core_name // core name ├── core_mem // mem info/layout of core ├── control // control the core to be halt or unhalt ├── flash // read/write on flash ├── ram // read/write on ram └── status // check the core is halt or unhalt
- halt core by "$ echo 0 > /sys/class/swd/rpu/control"
- do read/write on ram/flash. i.e. "$ cat blink_$corename.bin > /sys/class/swd/rpu/flash"
- unhalt core by "$ echo 1 > /sys/class/swd/rpu/control"
stm32f103c8t6(bluepill)
Reset line | Test Alive | Read IDCODE | Write to RAM | Read from RAM | Write to Flash | Read from Flash | Erase entire Flash | |
---|---|---|---|---|---|---|---|---|
RPI3-B+ | ||||||||
RPI4 |
Core halt | Core unhalt | Write to RAM | Read from RAM | Write to Flash | Read from Flash | |
---|---|---|---|---|---|---|
RPI3-B+ | ||||||
RPI4 |
stm32f411ceu6(blackpill)
Reset line | Test Alive | Read IDCODE | Write to RAM | Read from RAM | Write to Flash | Read from Flash | Erase entire Flash | |
---|---|---|---|---|---|---|---|---|
RPI3-B+ | ||||||||
RPI4 |
Core halt | Core unhalt | Write to RAM | Read from RAM | Write to Flash | Read from Flash | |
---|---|---|---|---|---|---|
RPI3-B+ | ||||||
RPI4 |
- rpi kernel header
$ sudo apt update
$ sudo apt install raspberrypi-kernel-headers
- gcc, make, git
$ git clone https://github.com/Nothing-Lt/swd_module.git --recursive
$ cd swd_module/src
$ make
- Install swd_module
$ sudo insmod swd.ko
$ sudo dtoverlay swd-device-overlay.dtbo
Test program for rpu and swd are preapred
$ cd swd_module/test/swd
$ make
$ run_test.sh stm32f103c8t6 #or stm32f411ceu6
$ cd swd_module/test/rpu
$ make
$ run_test.sh