Skip to content

Commit

Permalink
mecrisp-stellaris-ra-1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonethal committed Nov 1, 2015
1 parent de7beb4 commit a317645
Show file tree
Hide file tree
Showing 24 changed files with 4,178 additions and 2,326 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,7 @@

- Merged news from 2.1.6 into this package
- Improved tuck

01.11.2015, Matthias Koch, Mecrisp-Stellaris RA 1.2

- Jean Jonethal added STM32F303-RA and fixed a bug.
17 changes: 14 additions & 3 deletions README-RA
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,21 @@ This time, it contains an analytical compiler which keeps track
of the top five stack elements and maps them to registers
whenever possible.

Five targets are available:
KL25Z128 & LPC1114FN28 (Cortex M0), ARM Linux and LM4F120 & TM4C1294 (Cortex M4).
Currently available targets for RA testing:

For M4, you can flash your Stellaris or Tiva Launchpad with the included binary.
Cortex M0:

KL25Z128
LPC1114FN28

Cortex M4:

LM4F120
TM4C1294
ARM Linux
STM32F303

For M4, you can flash your boards with the included binaries.

For M0, you have three possibilities:

Expand Down
Binary file modified kl25z128-ra/mecrisp-stellaris-kl25z128.bin
Binary file not shown.
2,330 changes: 1,165 additions & 1,165 deletions kl25z128/mecrisp-stellaris-kl25z128.srec

Large diffs are not rendered by default.

Binary file modified linux-ra/mecrisp-stellaris-linux
Binary file not shown.
Binary file modified lm4f120-ra/mecrisp-stellaris-lm4f120.bin
Binary file not shown.
Binary file modified lpc1114fn28-ra/mecrisp-stellaris-lpc1114fn28.bin
Binary file not shown.
2,310 changes: 1,155 additions & 1,155 deletions lpc1114fn28-ra/mecrisp-stellaris-lpc1114fn28.hex

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions mecrisp-stellaris-source/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ cd stm32f303
make clean all && ls -l *.bin && md5sum *.bin && cp *.bin ../../stm32f303
cd ..

cd stm32f303-ra
make clean all && ls -l *.bin && md5sum *.bin && cp *.bin ../../stm32f303-ra
cd ..

cd stm32f401
make clean all && ls -l *.bin && md5sum *.bin && cp *.bin ../../stm32f401
cd ..
Expand Down Expand Up @@ -136,6 +140,10 @@ cd stm32f303
arm-none-eabi-objcopy --change-addresses 0x08000000 -I binary -O ihex mecrisp-stellaris-stm32f303.bin mecrisp-stellaris-stm32f303.hex
cd ..

cd stm32f303-ra
arm-none-eabi-objcopy --change-addresses 0x08000000 -I binary -O ihex mecrisp-stellaris-stm32f303.bin mecrisp-stellaris-stm32f303.hex
cd ..

cd stm32f401
arm-none-eabi-objcopy --change-addresses 0x08000000 -I binary -O ihex mecrisp-stellaris-stm32f401.bin mecrisp-stellaris-stm32f401.hex
cd ..
Expand Down
4 changes: 4 additions & 0 deletions mecrisp-stellaris-source/calculatemd5
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ cd stm32f303
md5sum *.bin
cd ..

cd stm32f303-ra
md5sum *.bin
cd ..

cd stm32f401
md5sum *.bin
cd ..
Expand Down
2 changes: 1 addition & 1 deletion mecrisp-stellaris-source/common/datastackandmacros.s
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ psp .req r7
.macro welcome Meldung
bl dotgaensefuesschen
.byte 8f - 7f @ Compute length of name field.
7: .ascii "Mecrisp-Stellaris RA 1.1 experimental"
7: .ascii "Mecrisp-Stellaris RA 1.2 experimental"
.ascii "\Meldung\n"
8: .p2align 1
.endm
Expand Down
3 changes: 3 additions & 0 deletions mecrisp-stellaris-source/common/ra/ra-tools.s
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,11 @@ get_free_register: @ Gibt den Register in r3 zurück. Setzt noch keinen Zustand.
bl get_free_register_intern

movs r3, #0 @ Nur noch r0 ist übrig geblieben

ldr r0, =allocator_base
movs r1, #unknown @ Muss die Adresskonstantenspeicherstelle wieder freigeben...
str r1, [r0, #offset_state_r0]

pop {r0, r1, r2, r4, r5, pc}

get_free_register_intern: @ Welcher Register geprüft werden soll, steht in r0. Rückgabe in r3.
Expand Down
21 changes: 21 additions & 0 deletions mecrisp-stellaris-source/stm32f303-ra/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

ARMGNU?=arm-none-eabi

COPS = -Wall -Os -nostdlib -nostartfiles -ffreestanding -save-temps
AOPS = --warn --fatal-warnings

all : mecrisp-stellaris-stm32f303.bin

mecrisp-stellaris-stm32f303.o : mecrisp-stellaris-stm32f303.s
$(ARMGNU)-as mecrisp-stellaris-stm32f303.s -o mecrisp-stellaris-stm32f303.o

mecrisp-stellaris-stm32f303.bin : memmap mecrisp-stellaris-stm32f303.o
$(ARMGNU)-ld -o mecrisp-stellaris-stm32f303.elf -T memmap mecrisp-stellaris-stm32f303.o
$(ARMGNU)-objdump -D mecrisp-stellaris-stm32f303.elf > mecrisp-stellaris-stm32f303.list
$(ARMGNU)-objcopy mecrisp-stellaris-stm32f303.elf mecrisp-stellaris-stm32f303.bin -O binary

clean:
rm -f *.bin
rm -f *.o
rm -f *.elf
rm -f *.list
193 changes: 193 additions & 0 deletions mecrisp-stellaris-source/stm32f303-ra/flash.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
@
@ Mecrisp-Stellaris - A native code Forth implementation for ARM-Cortex M microcontrollers
@ Copyright (C) 2013 Matthias Koch
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@

@ Schreiben und Löschen des Flash-Speichers im STM32F303.

@ In diesem Chip gibt es Flashschreibzugriffe mit wählbarer Breite -
@ so ist es diesmal ganz komfortabel. Leider gibt es nur weniger große
@ Sektoren, die getrennt gelöscht werden können.

@ Write and Erase Flash in STM32F303.
@ Porting: Rewrite this ! You need hflash! and - as far as possible - cflash!


.equ FLASH_Base, 0x40022000

.equ FLASH_ACR, FLASH_Base + 0x00 @ Flash Access Control Register
.equ FLASH_KEYR, FLASH_Base + 0x04 @ Flash Key Register
.equ FLASH_OPTKEYR, FLASH_Base + 0x08 @ Flash Option Key Register
.equ FLASH_SR, FLASH_Base + 0x0C @ Flash Status Register
.equ FLASH_CR, FLASH_Base + 0x10 @ Flash Control Register
.equ FLASH_AR, FLASH_Base + 0x14 @ Flash Address Register
.equ FLASH_OBR, FLASH_Base + 0x1C @ Flash Option Byte Register

@ -----------------------------------------------------------------------------
Wortbirne Flag_visible, "hflash!" @ ( x Addr -- )
@ Schreibt an die auf 2 gerade Adresse in den Flash.
h_flashkomma:
@ -----------------------------------------------------------------------------
popda r0 @ Adresse
popda r1 @ Inhalt.

@ Ist die gewünschte Stelle im Flash-Dictionary ? Außerhalb des Forth-Kerns ?
ldr r3, =Kernschutzadresse
cmp r0, r3
blo 3f

ldr r3, =FlashDictionaryEnde
cmp r0, r3
bhs 3f


@ Prüfe Inhalt. Schreibe nur, wenn es NICHT -1 ist.
ldr r3, =0xFFFF
ands r1, r3 @ High-Halfword der Daten wegmaskieren
cmp r1, r3
beq 2f @ Fertig ohne zu Schreiben

@ Prüfe die Adresse: Sie muss auf 2 gerade sein:
movs r2, #1
ands r2, r0
cmp r2, #0
bne 3f

@ Ist an der gewünschten Stelle -1 im Speicher ?
ldrh r2, [r0]
cmp r2, r3
bne 3f

@ Okay, alle Proben bestanden.

@ Im STM32F051 ist der Flash-Speicher gespiegelt, die wirkliche Adresse liegt weiter hinten !
@ Flash memory is mirrored, use true address later for write
ldr r2, =0x08000000
adds r0, r2

@ Bereit zum Schreiben !

@ Unlock Flash Control
ldr r2, =FLASH_KEYR
ldr r3, =0x45670123
str r3, [r2]
ldr r3, =0xCDEF89AB
str r3, [r2]

@ Enable write
ldr r2, =FLASH_CR
movs r3, #1 @ Select Flash programming
str r3, [r2]

@ Write to Flash !
strh r1, [r0]

@ Wait for Flash BUSY Flag to be cleared
ldr r2, =FLASH_SR

1: ldr r3, [r2]
@ ands r3, #1
movs r0, #1
ands r0, r3
bne 1b

@ Lock Flash after finishing this
ldr r2, =FLASH_CR
movs r3, #0x80
str r3, [r2]

2:bx lr
3:Fehler_Quit "Wrong address or data for writing flash !"


@ -----------------------------------------------------------------------------
Wortbirne Flag_visible, "flashpageerase" @ ( Addr -- )
@ Löscht einen 2kb großen Flashblock Deletes one 2kb Flash page
flashpageerase:
@ -----------------------------------------------------------------------------
push {r0, r1, r2, r3, lr}
popda r0 @ Adresse zum Löschen holen Fetch address to erase.

@ Ist die gewünschte Stelle im Flash-Dictionary ? Außerhalb des Forth-Kerns ? Don't erase Forth core.
ldr r3, =Kernschutzadresse
cmp r0, r3
blo 2f

ldr r2, =FLASH_KEYR
ldr r3, =0x45670123
str r3, [r2]
ldr r3, =0xCDEF89AB
str r3, [r2]

@ Enable erase
ldr r2, =FLASH_CR
movs r3, #2 @ Set Erase bit
str r3, [r2]

@ Set page to erase
ldr r2, =FLASH_AR
str r0, [r2]

@ Start erasing
ldr r2, =FLASH_CR
movs r3, #0x42 @ Start + Erase
str r3, [r2]

@ Wait for Flash BUSY Flag to be cleared
ldr r2, =FLASH_SR
1: ldr r3, [r2]
movs r0, #1
ands r0, r3
bne 1b

@ Lock Flash after finishing this
ldr r2, =FLASH_CR
movs r3, #0x80
str r3, [r2]

2:pop {r0, r1, r2, r3, pc}

@ -----------------------------------------------------------------------------
Wortbirne Flag_visible, "eraseflash" @ ( -- )
@ Löscht den gesamten Inhalt des Flashdictionaries.
@ -----------------------------------------------------------------------------
ldr r0, =FlashDictionaryAnfang
eraseflash_intern:
cpsid i
ldr r1, =FlashDictionaryEnde
ldr r2, =0xFFFF

1: ldrh r3, [r0]
cmp r3, r2
beq 2f
pushda r0
dup
write "Erase block at "
bl hexdot
writeln " from Flash"
bl flashpageerase
2: adds r0, #2
cmp r0, r1
bne 1b
writeln "Finished. Reset !"
bl Restart

@ -----------------------------------------------------------------------------
Wortbirne Flag_visible, "eraseflashfrom" @ ( Addr -- )
@ Beginnt an der angegebenen Adresse mit dem Löschen des Dictionaries.
@ -----------------------------------------------------------------------------
popda r0
b.n eraseflash_intern
38 changes: 38 additions & 0 deletions mecrisp-stellaris-source/stm32f303-ra/interrupts.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@
@ Mecrisp-Stellaris - A native code Forth implementation for ARM-Cortex M microcontrollers
@ Copyright (C) 2013 Matthias Koch
@
@ This program is free software: you can redistribute it and/or modify
@ it under the terms of the GNU General Public License as published by
@ the Free Software Foundation, either version 3 of the License, or
@ (at your option) any later version.
@
@ This program is distributed in the hope that it will be useful,
@ but WITHOUT ANY WARRANTY; without even the implied warranty of
@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ GNU General Public License for more details.
@
@ You should have received a copy of the GNU General Public License
@ along with this program. If not, see <http://www.gnu.org/licenses/>.
@

@ Routinen für die Interrupthandler, die zur Laufzeit neu gesetzt werden können.
@ Code for interrupt handlers that are exchangeable on the fly

@------------------------------------------------------------------------------
@ Alle Interrupthandler funktionieren gleich und werden komfortabel mit einem Makro erzeugt:
@ All interrupt handlers work the same way and are generated with a macro:
@------------------------------------------------------------------------------

interrupt exti0
interrupt exti1
interrupt exti2
interrupt exti3
interrupt exti4
interrupt adc
interrupt tim2
interrupt tim3
interrupt tim4

@------------------------------------------------------------------------------

Loading

0 comments on commit a317645

Please sign in to comment.