Skip to content

Commit 727717b

Browse files
committed
Try using linkerscript embedding for menu binary
This puts it in text section, at least
1 parent 81df708 commit 727717b

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

code/veccart/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ASFLAGS += -DHW_VER=$(HW_VER_VAL)
4646
BINARY=veccart
4747
OBJS=main.o menu.o romemu.o msc.o xprintf.o usb_msc.o ff_diskio.o \
4848
fatfs/ff.o fatfs/option/unicode.o flash.o led.o delay.o \
49-
highscore.o multicart.o
49+
highscore.o
5050

5151
LIBNAME = opencm3_stm32f4
5252
ARCH_FLAGS = -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mcpu=cortex-m4 -DSTM32F4
@@ -123,7 +123,7 @@ rom.o: rom.inc rom.c rom.h
123123
%.list: %.elf
124124
$(VERBOSE)$(OBJDUMP) -S $(*).elf > $(*).list
125125

126-
%.elf: $(OBJS) $(LDSCRIPT)
126+
%.elf: $(OBJS) $(LDSCRIPT) multicart.ld
127127
$(LD) -o $(*).elf $(OBJS) $(LDFLAGS)
128128
$(PREFIX)-size $(*).elf
129129

@@ -135,8 +135,8 @@ multicart:
135135
make -C ../multicart/
136136
cp ../multicart/multicart.bin ./multicart
137137

138-
multicart.o: multicart
139-
$(BINLD) -r -b binary -o $@ $<
138+
multicart.ld: multicart
139+
cat $< | hexdump -v -e '"BYTE(0x" 1/1 "%02X" ")\n"' > $@
140140

141141
clean:
142142
rm -f multicart

code/veccart/main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,8 @@
5050

5151
// Externs
5252
extern GameFileRecord* pActiveGameData;
53-
extern char* _binary_multicart_start;
54-
extern char* _binary_multicart_end;
55-
extern size_t* _binary_multicart_size;
53+
extern char* multicart_start;
54+
extern char* multicart_end;
5655

5756
//Memory for the menu ROM and the running cartridge.
5857
//We keep both in memory so we can quickly exchange them when a reset has been detected.
@@ -130,7 +129,7 @@ void loadRomWithHighScore(char *fn, bool load_hs_mode, bool use_embedded_menu) {
130129
n = sizeof(menuData);
131130
}
132131
if (romData == menuData && use_embedded_menu == true) {
133-
memcpy(menuData, _binary_multicart_start, *_binary_multicart_size);
132+
memcpy(menuData, multicart_start, multicart_start-multicart_end);
134133
} else {
135134
fr = f_open(&f, fn, FA_READ);
136135
if (fr) {

code/veccart/stm32f411rct6.ld

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@ ram (rwx) : ORIGIN = 0x20000400, LENGTH = 127K
77
}
88
/* Include the common ld script. */
99
INCLUDE cortex-m-generic.ld
10+
11+
SECTIONS {
12+
.text : {
13+
14+
/* ... */
15+
16+
multicart_start = .;
17+
INCLUDE "multicart.ld" ;
18+
multicart_end = .;
19+
20+
/* ... */
21+
}
22+
}
23+

0 commit comments

Comments
 (0)