Skip to content

Commit

Permalink
Fix incomplete string in BIOS and missing sections in linker scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Cliche committed Jun 8, 2024
1 parent bb99553 commit dd6e4b4
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 162 deletions.
4 changes: 3 additions & 1 deletion soc/rtl/mmm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ all: top.bin
clean:
rm -f *.hex *.asc *.json *.bin *.log

prom.mem:
make -C ../../src/bios

top.json: $(SRC) prom.mem
make -C ../../src/bios
$(YOSYS) -ql top.log -p 'verilog_defines $(DEFINES) ; read_verilog -sv $(SRC); synth_ecp5 -top $(TOP_MODULE) -json top.json -abc9'

top.asc: top.json $(PIN_DEF)
Expand Down
4 changes: 3 additions & 1 deletion soc/rtl/ulx3s/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ all: top.bin
clean:
rm -f *.hex *.asc *.json *.bin *.log

top.json: $(SRC) prom.mem
prom.mem:
make -C ../../src/bios

top.json: $(SRC) prom.mem
$(YOSYS) -ql top.log -p 'verilog_defines $(DEFINES) ; read_verilog -sv $(SRC); synth_ecp5 -top $(TOP_MODULE) -json top.json -abc9'

top.asc: top.json $(PIN_DEF)
Expand Down
2 changes: 1 addition & 1 deletion soc/src/bios/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ prom.mem: program.bin
program.bin: program.elf program.lst
${OBJCOPY} -O binary program.elf program.bin

program.elf: $(PROGRAM_SOURCE) $(EXTRA_SOURCE)
program.elf: $(PROGRAM_SOURCE) $(EXTRA_SOURCE) $(LDFILE)
${CC} $(RISCV_CC_OPT) -nostartfiles -O3 -T $(LDFILE) -I ../../lib -I ../common $(CC_OPT) $(PROGRAM_SOURCE) -o program.elf -lm

.PHONY: all clean
42 changes: 27 additions & 15 deletions soc/src/bios/program.ld
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
/* Ref.: https://github.com/YosysHQ/picorv32/blob/main/picosoc/sections.lds */

MEMORY
{
ram (rwx) : ORIGIN = 0xF0000000, LENGTH = 512*4
ROM (rx) : ORIGIN = 0xF0000000, LENGTH = 2048
}

SECTIONS {
.memory : {
. = 0x000000;
*(.init);
*(.text);
*(.sbss);
. = ALIGN(4);
end = .;
} >ram

.heap : {
. = ALIGN(4);
_heap_start = .;
_end = .;
} >ram
}
/*
* This is the initialized data
*/
.data : {
. = ALIGN(4);

*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
. = ALIGN(4);

/* Initialized data */
*(.data)
*(.data*)
*(.sdata)
*(.sdata*)
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.srodata) /* .rodata sections (constants, strings, etc.) */
*(.srodata*) /* .rodata* sections (constants, strings, etc.) */

. = ALIGN(4);
} > ROM
}
2 changes: 1 addition & 1 deletion soc/src/examples/3drenderer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LIB_SOURCE = ../lib/io.c ../lib/syscalls.c ../lib/array.c ../lib/SDL2/sdl.c ../l
PROGRAM_SOURCE = src/start.S src/*.c
SERIAL ?= /dev/tty.usbserial-D00039

LDFILE ?= program.ld
LDFILE ?= ../lib/program.ld

all: program.hex

Expand Down
23 changes: 0 additions & 23 deletions soc/src/examples/3drenderer/program.ld

This file was deleted.

2 changes: 1 addition & 1 deletion soc/src/examples/benchmark_dhrystone/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LIB_SOURCE = ../lib/io.c ../lib/syscalls.c
PROGRAM_SOURCE = start.S *.c
SERIAL ?= /dev/tty.usbserial-D00039

LDFILE ?= program.ld
LDFILE ?= ../lib/program.ld

all: program.hex

Expand Down
23 changes: 0 additions & 23 deletions soc/src/examples/benchmark_dhrystone/program.ld

This file was deleted.

2 changes: 1 addition & 1 deletion soc/src/examples/demo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LIB_SOURCE = $(FAT32_SOURCE) ../lib/io.c ../lib/syscalls.c ../lib/sd_card.c ../l
PROGRAM_SOURCE = start.S program.c ../../../../common/graphite.c ../../../../common/cube.c ../../../../common/teapot.c ../../../../common/tex32x32.c ../../../../common/tex64x64.c
SERIAL ?= /dev/tty.usbserial-D00039

LDFILE ?= program.ld
LDFILE ?= ../lib/program.ld

EXTRA_CC_ARGS = -DRV_FIXED_POINT_EXTENSION=1

Expand Down
23 changes: 0 additions & 23 deletions soc/src/examples/demo/program.ld

This file was deleted.

60 changes: 60 additions & 0 deletions soc/src/examples/lib/program.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* Ref.: https://github.com/YosysHQ/picorv32/blob/main/picosoc/sections.lds */

MEMORY
{
RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 16*1024*1024
}

__stacktop = ORIGIN(RAM) + LENGTH(RAM);

SECTIONS {


/*
* This is the initialized data
*/
.data : {
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start; used by startup code in order to initialise the .data section in RAM */
_ram_start = .; /* create a global symbol at ram start (e.g., for garbage collector) */


*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
. = ALIGN(4);

/* Initialized data */
*(.data)
*(.data*)
*(.sdata)
*(.sdata*)
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
*(.srodata) /* .rodata sections (constants, strings, etc.) */
*(.srodata*) /* .rodata* sections (constants, strings, etc.) */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end; used by startup code in order to initialise the .data section in RAM */
} > RAM

/* Uninitialized data section */
.bss : {
. = ALIGN(4);
_sbss = .; /* define a global symbol at bss start; used by startup code */
*(.bss)
*(.bss*)
*(.sbss)
*(.sbss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end; used by startup code */
} >RAM

/* this is to define the start of the heap, and make sure we have a minimum size */
.heap : {
. = ALIGN(4);
_heap_start = .; /* define a global symbol at heap start */
_end = .; /* as expected by syscalls.c */
} >RAM
}
2 changes: 1 addition & 1 deletion soc/src/examples/test_graphite/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ LIB_SOURCE = ../lib/io.c ../lib/syscalls.c
PROGRAM_SOURCE = start.S program.c ../../../../common/graphite.c ../../../../common/cube.c ../../../../common/teapot.c ../../../../common/tex32x32.c ../../../../common/tex64x64.c
SERIAL ?= /dev/tty.usbserial-D00039

LDFILE ?= program.ld
LDFILE ?= ../lib/program.ld

EXTRA_CC_ARGS = -DRV_FIXED_POINT_EXTENSION=1

Expand Down
23 changes: 0 additions & 23 deletions soc/src/examples/test_graphite/program.ld

This file was deleted.

2 changes: 1 addition & 1 deletion soc/src/examples/test_sdcard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FAT32_SOURCE = ../lib/fat/fat_access.c ../lib/fat/fat_cache.c ../lib/fat/fat_fil
PROGRAM_SOURCE = start.S program.c ../lib/syscalls.c ../lib/io.c ../lib/sd_card.c $(FAT32_SOURCE)
SERIAL ?= /dev/tty.usbserial-D00039

LDFILE ?= program.ld
LDFILE ?= ../lib/program.ld

all: program.hex

Expand Down
23 changes: 0 additions & 23 deletions soc/src/examples/test_sdcard/program.ld

This file was deleted.

2 changes: 1 addition & 1 deletion soc/src/examples/test_video/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RISCV_CC_OPT ?= -march=rv32i -mabi=ilp32
PROGRAM_SOURCE = start.S program.c
SERIAL ?= /dev/tty.usbserial-D00039

LDFILE ?= program.ld
LDFILE ?= ../lib/program.ld

all: program.hex

Expand Down
23 changes: 0 additions & 23 deletions soc/src/examples/test_video/program.ld

This file was deleted.

0 comments on commit dd6e4b4

Please sign in to comment.