Skip to content

Commit

Permalink
Final removal of bare-metal toolchain dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
roscopeco committed Oct 6, 2024
1 parent e52c783 commit 686101e
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
; Often with just the PC crash address you can narrow down the source code
; causing the problem with e.g:
;
; m68k-elf-addr2line -e myprogram.elf 0x1234
; m68k-elf-rosco-addr2line -e myprogram.elf 0x1234
;
; This will often give a line "near" the problem (usually after the actual
; cause), but is still very helpful.
Expand Down
3 changes: 2 additions & 1 deletion code/firmware/rosco_m68k_firmware/stage2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include ../common.mk

CC=m68k-elf-rosco-gcc
LD=m68k-elf-rosco-gcc
OBJCOPY=m68k-elf-rosco-objcopy

CFLAGS= \
-std=c11 -g -nostartfiles --param=min-pagesize=0 \
Expand Down Expand Up @@ -108,7 +109,7 @@ $(BINARY_ZIP): $(BINARY) $(LZG)
$(LZG) -9 $< $@

$(BINARY_ZIP_OBJ): $(BINARY_ZIP)
m68k-elf-objcopy -I binary -O elf32-m68k -B m68k --rename-section .data=.zipdata $< $@
$(OBJCOPY) -I binary -O elf32-m68k -B m68k --rename-section .data=.zipdata $< $@

ifneq ($(XOSERA_API_MINIMAL),false)
boot_menu/libboot_menu.a:
Expand Down
2 changes: 1 addition & 1 deletion code/software/dhrystone/dhrystone.c
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void Proc0()
Proc4();
IntLoc1 = 2;
IntLoc2 = 3;
IntLoc3 = 0; // Xark: m68k-elf-gcc -O1 forces this (with -O2 it figures it out)
IntLoc3 = 0; // Xark: m68k-elf-rosco-gcc -O1 forces this (with -O2 it figures it out)
strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
EnumLoc = Ident2;
BoolGlob = ! Func2(String1Loc, String2Loc);
Expand Down
10 changes: 5 additions & 5 deletions code/software/libs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ CFLAGS=-std=c11 $(FLAGS)
CXXFLAGS=-std=c++20 -fno-exceptions -fno-rtti $(FLAGS)
ASFLAGS=-Felf -m$(CPU) -quiet $(DEFINES)
ARFLAGS=
CC=m68k-elf-gcc
CXX=m68k-elf-g++
LD=m68k-elf-ld
AR=m68k-elf-ar
RANLIB=m68k-elf-ranlib
CC=m68k-elf-rosco-gcc
CXX=m68k-elf-rosco-g++
LD=m68k-elf-rosco-ld
AR=m68k-elf-rosco-ar
RANLIB=m68k-elf-rosco-ranlib
AS=vasmm68k_mot
RM_F=rm -f
RM_RF=$(RM_F) -r
Expand Down
16 changes: 13 additions & 3 deletions code/software/libs/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
# Rosco_m68k Standard Libraries
# Rosco_m68k Bare-Metal Standard Libraries

> **Note**: These libraries are should only be used for legacy programs, or where
> bare-metal with minimal C runtime support is specifically needed.
>
> If you have a need to use these, you'll know why you need them and what you're
> getting yourself into. You will need to compile free-standing and without standard
> includes etc.
>
> For most use-cases, it is recommended to use the C libraries and support code that
> comes with the `m68k-elf-rosco` toolchain.
This directory contains the standard libraries that support writing
programs for the rosco_m68k. The libraries are contained in
Expand Down Expand Up @@ -93,8 +103,8 @@ the correct linker script might be:

```
export LIBDIR=../libs/build
m68k-elf-gcc -ffreestanding -o kmain.o -c kmain.c
m68k-elf-ld T $LIBDIR/ld/serial/rosco_m68k_program.ld -L $LIBDIR -o myprog.bin main.o -lstart_serial
m68k-elf-rosco-gcc -ffreestanding -o kmain.o -c kmain.c
m68k-elf-rosco-ld T $LIBDIR/ld/serial/rosco_m68k_program.ld -L $LIBDIR -o myprog.bin main.o -lstart_serial
```

For a more complete example, see the `Makefile` in one of the example
Expand Down
2 changes: 1 addition & 1 deletion code/software/libs/src/debug_stub/debug_stub.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
; Often with just the PC crash address you can narrow down the source code
; causing the problem with e.g:
;
; m68k-elf-addr2line -e myprogram.elf 0x1234
; m68k-elf-rosco-addr2line -e myprogram.elf 0x1234
;
; This will often give a line "near" the problem (usually after the actual
; cause), but is still very helpful.
Expand Down
10 changes: 5 additions & 5 deletions code/software/libs/src/debug_stub/include/debug_stub.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
*
* If you have a rosco_m68k elf file, generated with debug information (-g)
* then you can usually get the C source line of the code that caused the
* exception (or close to it, often the line after) using m68k-elf-addr2line,
* the "-e" option followed by your program elf file and the PC address from
* the debug information printed (preceeded with "0x" for hex). For example,
* for the crash above:
* exception (or close to it, often the line after) using
* m68k-elf-rosco-addr2line, the "-e" option followed by your program elf
* file and the PC address from the debug information printed (preceeded
* with "0x" for hex). For example, for the crash above:
*
* m68k-elf-addr2line -e example.elf 0x115A
* m68k-elf-rosco-addr2line -e example.elf 0x115A
*
* NOTE: On 68010/12 CPUs the PC counter (and "op") may be up to five words
* ahead of the actual location where the exception occurred on a bus or
Expand Down
4 changes: 2 additions & 2 deletions code/software/libs/src/start_serial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ the correct linker script might be:

```bash
export LIBDIR=../libs/build
m68k-elf-gcc -ffreestanding -o kmain.o -c kmain.c
m68k-elf-ld T $LIBDIR/ld/serial/rosco_m68k_program.ld -L $LIBDIR -o myprog.bin main.o -lstart_serial
m68k-elf-rosco-gcc -ffreestanding -o kmain.o -c kmain.c
m68k-elf-rosco-ld T $LIBDIR/ld/serial/rosco_m68k_program.ld -L $LIBDIR -o myprog.bin main.o -lstart_serial
```

For a more complete example, see the `Makefile` in one of the example
Expand Down
20 changes: 10 additions & 10 deletions code/software/software.mk
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ CXXFLAGS=-std=c++20 -fno-exceptions -fno-rtti $(FLAGS)
GCC_LIBS?=$(shell $(CC) --print-search-dirs \
| grep libraries:\ = \
| sed 's/libraries: =/-L/g' \
| sed 's/:/m68000\/ -L/g')m68000/
| sed 's/:/\/ -L/g')
LIBS=$(EXTRA_LIBS) -lprintf -lcstdlib -lmachine -lstart_serial -lgcc
ASFLAGS=-mcpu=$(CPU) -march=$(ARCH)
VASMFLAGS=-Felf -m$(CPU) -quiet -Lnf $(DEFINES)
LDFLAGS=-T $(LDSCRIPT) -L $(SYSLIBDIR) -Map=$(MAP) --gc-sections --oformat=elf32-m68k $(EXTRA_LDFLAGS)

CC=m68k-elf-gcc
CXX=m68k-elf-g++
AS=m68k-elf-as
LD=m68k-elf-ld
NM=m68k-elf-nm
LD=m68k-elf-ld
OBJDUMP=m68k-elf-objdump
OBJCOPY=m68k-elf-objcopy
SIZE=m68k-elf-size
CC=m68k-elf-rosco-gcc
CXX=m68k-elf-rosco-g++
AS=m68k-elf-rosco-as
LD=m68k-elf-rosco-ld
NM=m68k-elf-rosco-nm
LD=m68k-elf-rosco-ld
OBJDUMP=m68k-elf-rosco-objdump
OBJCOPY=m68k-elf-rosco-objcopy
SIZE=m68k-elf-rosco-size
VASM=vasmm68k_mot
RM=rm -f
CP=cp
Expand Down
12 changes: 6 additions & 6 deletions code/tools/r68k/firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ CFLAGS=-std=c11 -ffreestanding -nostartfiles -Wall -Wpedantic -Werror \
$(DEFINES)
LDFLAGS=-T ./rosco_m68k_translator.ld -Map=$(MAP)
ASFLAGS=-Felf -m$(CPU) -quiet $(DEFINES) -align
CC=m68k-elf-gcc
LD=m68k-elf-ld
CC=m68k-elf-rosco-gcc
LD=m68k-elf-rosco-ld
AS=vasmm68k_mot
OBJCOPY=m68k-elf-objcopy
OBJDUMP=m68k-elf-objdump
SIZE=m68k-elf-size
NM=m68k-elf-nm
OBJCOPY=m68k-elf-rosco-objcopy
OBJDUMP=m68k-elf-rosco-objdump
SIZE=m68k-elf-rosco-size
NM=m68k-elf-rosco-nm
RM=rm -f

# Output config
Expand Down
2 changes: 1 addition & 1 deletion code/tools/r68k/firmware/debug_stub/debug_stub.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
; Often with just the PC crash address you can narrow down the source code
; causing the problem with e.g:
;
; m68k-elf-addr2line -e myprogram.elf 0x1234
; m68k-elf-rosco-addr2line -e myprogram.elf 0x1234
;
; This will often give a line "near" the problem (usually after the actual
; cause), but is still very helpful.
Expand Down

0 comments on commit 686101e

Please sign in to comment.