Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
david-welch-netronome committed Jan 18, 2021
1 parent 0ed39bb commit eba7af1
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 14 deletions.
12 changes: 12 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,16 @@ code to jump into a C program and go from there. The blinker directory
(in this project) is perhaps a place to use as a beginning point on an
embedded program.

Google
ARM DDI 0100E
or
ARM DDI 0100I

https://www.scss.tcd.ie/~waldroj/3d1/arm_arm.pdf
http://morrow.ece.wisc.edu/ECE353/arm_reference/ddi0100e_arm_arm.pdf
http://reds.heig-vd.ch/share/cours/aro/ARM_Thumb_instructions.pdf
They have a rev B here...Which was the blue covered one in print.
http://www.home.marutan.net/arcemdocs/
https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/third-party/archives/ddi0100e_arm_arm.pdf
https://www.cs.miami.edu/~burt/learning/Csc521.141/Documents/arm_arm.pdf

24 changes: 24 additions & 0 deletions new_one/nothumb2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#ARMGNU ?= arm-none-eabi
ARMGNU ?= arm-linux-gnueabi

XCPU = -mcpu=cortex-m0

AOPS = --warn --fatal-warnings $(XCPU)
LOPS = -nostdlib -nostartfiles

all : notmain.bin

clean:
rm -f *.bin
rm -f *.o
rm -f *.elf
rm -f *.list

flash.o : flash.s
$(ARMGNU)-as $(AOPS) flash.s -o flash.o

notmain.bin : flash.ld flash.o
$(ARMGNU)-ld $(LOPS) -T flash.ld flash.o -o notmain.elf
$(ARMGNU)-objdump -D notmain.elf > notmain.list
$(ARMGNU)-objcopy -O binary notmain.elf notmain.bin
11 changes: 11 additions & 0 deletions new_one/nothumb2/flash.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

MEMORY
{
ram : ORIGIN = 0x00000000, LENGTH = 0x1000
}

SECTIONS
{
.text : { *(.text*) } > ram
}

18 changes: 18 additions & 0 deletions new_one/nothumb2/flash.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

.cpu cortex-m0
.thumb

.thumb_func
.global _start
_start:
stacktop: .word 0x20001000
.word reset

.thumb_func
reset:
nop
nop
dmb
bkpt
bkpt
bkpt
45 changes: 33 additions & 12 deletions new_one/thumbulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ unsigned int read32 ( unsigned int );

unsigned int read_register ( unsigned int );

#define DBUGFETCH 0
#define DBUGRAM 0
#define DBUGRAMW 0
#define DBUGREG 0
#define DBUG 0
#define DISS 1
//#define DBUGFETCH 0
//#define DBUGRAM 0
//#define DBUGRAMW 0
//#define DBUGREG 0
//#define DBUG 0
//#define DISS 1

unsigned int DBUGFETCH = 0;
unsigned int DBUGRAM = 0;
unsigned int DBUGRAMW = 0;
unsigned int DBUGREG = 0;
unsigned int DBUG = 0;
unsigned int DISS = 0;



#define ROMADDMASK 0xFFFFF
#define RAMADDMASK 0xFFFFF
Expand Down Expand Up @@ -918,6 +927,15 @@ if(DISS) fprintf(stderr,"\n");
rb+=pc;
rb+=2;
write_register(14,rb);
//read_register(15);
//fetch16();
rc=pc&ROMADDMASK;
rd=rom[rc>>1];
if((rd&0xF800)!=0xF800)
{
fprintf(stderr,"0x%08X 0x%04X 0x%04X thumb2 not supported\n",pc-2,inst,rd);
exit(1);
}
return(0);
}
else
Expand All @@ -932,12 +950,12 @@ if(DISS) fprintf(stderr,"bl 0x%08X\n",rb);
write_register(15,rb);
return(0);
}
else
if((inst&0x1800)==0x0800) //H=b01
{
fprintf(stderr,"cannot BLX to arm 0x%08X 0x%04X\n",pc-2,inst);
exit(1);
}
//else
//if((inst&0x1800)==0x0800) //H=b01
//{
//fprintf(stderr,"cannot BLX to arm 0x%08X 0x%04X\n",pc-2,inst);
//exit(1);
//}
}

//BLX(2)
Expand Down Expand Up @@ -2106,6 +2124,9 @@ int main ( int argc, char *argv[] )
for(ra=2;ra<argc;ra++)
{
if(strcmp(argv[ra],"--vcd")==0) output_vcd=1;
if(strcmp(argv[ra],"--diss")==0) DISS=1;
if(strcmp(argv[ra],"--dbugram")==0) DBUGRAM=1;
if(strcmp(argv[ra],"--dbugreg")==0) DBUGREG=1;
}
fp=fopen(argv[1],"rb");
if(fp==NULL)
Expand Down
4 changes: 2 additions & 2 deletions thumbulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ if(DISS) fprintf(stderr,"ble 0x%08X\n",rb-3);
rb<<=1;
rb+=pc;
rb+=2;
if(DISS) fprintf(stderr,"B 0x%08X\n",rb-3);
if(DISS) fprintf(stderr,"B 0x%08X\n",rb-4);
write_register(15,rb);
return(0);
}
Expand Down Expand Up @@ -933,7 +933,7 @@ if(DISS) fprintf(stderr,"\n");
rb+=(inst&((1<<11)-1))<<1;;
rb+=2;

if(DISS) fprintf(stderr,"bl 0x%08X\n",rb-3);
if(DISS) fprintf(stderr,"bl 0x%08X\n",rb-2);
write_register(14,(pc-2)|1);
write_register(15,rb);
return(0);
Expand Down

0 comments on commit eba7af1

Please sign in to comment.