Patches: Kernel¶
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 |
Applies to: mecrisp-stellaris-2.3.6/mecrisp-stellaris-source/stm32f051/terminal.s
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
For info on hardware handshaking, click here
Rebuild Your Kernel¶
Compiling Mecrisp-Stellaris is easy.
You’ll need “none-arm-eabi” installed, which is available for FreeBSD. OpenBSD and Linux (at least).
Warning
If you have compile ERRORS, make sure you have the LATEST VERSION of “none-arm-eabi” installed!
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)
STM32F103 PATCH¶
For mecrisp-stellaris-2.5.3
Download¶
https://sourceforge.net/projects/mecrisp-stellaris-folkdoc/files/tp-allpatch-stm32f103ra-2.5.3.patch
Features¶
Serial Port Connection is USART2¶
Baud Rate: 460800, 8,N,1
USART2 |
MCU Signal |
3.3v/USB Dongle |
---|---|---|
PA1 |
RTS |
CTS |
PA2 |
TX |
RX |
PA3 |
RX |
TX |
RED error warnings
Register print Word enabled
.regs
lr: 000023E1
r0: 0000291C
r1: 00000000
r2: 0000291C
r3: 00000000
r4: 00005278
r5: 20004F3C
r6: 20004F8C
r7: 20000288
sp: 20000364
No stair stepping, no need to add a \r in your terminal configuration
Hardware handshaking, see table above
uncluttered stack print
1 ok.
2 ok.
3 ok.
.s [3 ] 536891276 1 2 3 ok.
Patching¶
Directory Layout¶
To apply the patch.
.
├── mecrisp-stellaris-2.5.3
└── tp-allpatch-stm32f103ra-2.5.3.patch
Patch Command¶
patch < tp-allpatch-stm32f103ra-2.5.3.patch
Build Guide¶
Run patch command above
Cd to mecrisp-stellaris-2.5.3/mecrisp-stellaris-source/stm32f103-ra
Run gmake (freebsd) or make
Be sure to erase ALL the Flash on the chip FIRST.
Flash mecrisp-stellaris-2.5.3/mecrisp-stellaris-source/stm32f103-ra/mecrisp-stellaris-stm32f103.bin to your STM32F103 chip.