Patches: Kernel

  1. Apply the patch Apply the patch
  2. Compile Mecrisp-Stellaris

Testing A Patch Before Applying

patch --dry-run  < myfile.patch

mecrisp-stellaris-2.3.7/mecrisp-stellaris-source/common% patch --dry-run < simpler-stackprint-deepinsight.s.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- deepinsight.s      2017-05-10 13:00:55.263208835 +1000
|+++ deepinsight-simplestackprint.s     2017-04-28 09:30:54.000000000 +1000
--------------------------
Patching file deepinsight.s using Plan A...
Hunk #1 succeeded at 87.
Hunk #2 succeeded at 116.
done

Applying patches

patch < myfile.patch

Reversing Patches

patch -R < myfile.patch

Create a Patch

diff -u oldfile newfile > myfile.patch

Patch: Simpler Stack Printer

Reason: While some write new Words to modify the default Stack printer ”.s”, I prefer to patch the assembly source code.

From :         Stack: [7 ] 42 1 2 3 4 5 6  TOS: 7  \*>
To:            .s [7 ] 42 1 2 3 4 5 6 7  ok.

* Applies to: mecrisp-stellaris-2.3.7/mecrisp-stellaris-source/common/deepinsight.s
* :download:`Simpler Stack Printer patch<patches/simpler-stackprint-deepinsight.s.patch>`

STM32F0

Patch: Move Terminal From USART1 to USART2

Reason: To provide a byte of eleven consecutive bits, PA-4 to PA-15.
  • USART 1 is the default
  • Both USART1 and USART2 are enabled with SF1 which is also default
Board MCU Comms Type TX RX
STM32F0 Discovery STM32F051R8 USART1 PA9 PA10
or        
STM32F0 Discovery STM32F051R8 USART2 PA2 PA3

Patch: Add RTS/CTS Handshaking To USART1

Reason, so the MCU UART1 can tell the PC terminal to stop sending data when required. The PC can also tell the MCU to stop sending data.

GPIO Flow control In/Out ALT Function Notes: PC is probably connected to a USB/3/3v serial dongle
PA12 USART1_RTS OUT AF1 output to PC (CTS) to STOP sending data when LOW
PA11 USART1_CTS IN AF1 input from PC (RTS), it’s CLEAR to send data when LOW
PA9 USART1_TX OUT AF1 to PC RX
PA10 USART1_RX IN AF1 to PC TX
  • Applies to: mecrisp-stellaris-2.4.2/mecrisp-stellaris-source/stm32f051/terminal.s but may apply to all STM32F0 Cortex M0 chips
  • If you use this patch and don’t connect hardware handshaking, you’ll need to take PA11 LOW with a jumper to talk to the MCU
  • DOWNLOAD: terminal.rts.cts.s.patch
  • For info on hardware handshaking, click here

Compiling

Compiling Mecrisp-Stellaris is easy.

  • You’ll need none-arm-eabi installed, which is available for FreeBSD. OpenBSD and Linux (at least).

Compile example for mecrisp-stellaris-x.x.x

  • cd mecrisp-stellaris-x.x.x/mecrisp-stellaris-source
  • ./assemble
  • ./tidyup
  • The new image is now available in mecrisp-stellaris-x.x.x/your-mcu/mecrisp-stellaris-your-mcu.bin (except Linux)