Skip to content

Commit 3b94832

Browse files
committed
apple2: Generate a special bootloader for AT2 (QFN32) boards
This is required because pin PA10 (rotary select) is reassigned for an Apple2 stepper phase. The regular bootloader is unaware of this and will spuriously enter update mode if the phase signal is low when the Gotek powers on or resets. Thanks to Mauricio Matte for testing.
1 parent 197736b commit 3b94832

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ logfile-%: FORCE
3434
$(MAKE) target mcu=$* target=apple2 level=logfile
3535
$(MAKE) target mcu=$* target=quickdisk level=logfile
3636

37+
apple2-bootloader-%: FORCE
38+
$(MAKE) target mcu=$* target=apple2-bootloader level=prod
39+
3740
all-%: FORCE prod-% debug-% logfile-% ;
3841

39-
all: FORCE all-stm32f105 all-at32f435 ;
42+
all: FORCE all-stm32f105 all-at32f435 apple2-bootloader-stm32f105;
4043

4144
clean: FORCE
4245
rm -rf out
@@ -112,6 +115,14 @@ _dist: FORCE
112115
out/$(mcu)/logfile/quickdisk/target.bin $(mcu) & \
113116
wait
114117

118+
_dist_apple2_at2_bootloader: f := $(t)/alt/apple2/at2-bootloader
119+
_dist_apple2_at2_bootloader: n := $(PROJ)-apple2-at2-bootloader-$(VER)
120+
_dist_apple2_at2_bootloader: FORCE
121+
mkdir -p $(f)
122+
cd out/stm32f105/prod/apple2-bootloader; \
123+
cp -a target.dfu $(f)/$(n).dfu; \
124+
cp -a target.hex $(f)/$(n).hex
125+
115126
dist: level := prod
116127
dist: t := $(ROOT)/out/$(PROJ)-$(VER)
117128
dist: FORCE all
@@ -126,6 +137,7 @@ dist: FORCE all
126137
$(MAKE) _legacy_dist mcu=stm32f105 level=$(level) t=$(t)
127138
$(MAKE) _dist mcu=stm32f105 n=at415-st105 level=$(level) t=$(t)
128139
$(MAKE) _dist mcu=at32f435 n=at435 level=$(level) t=$(t)
140+
$(MAKE) _dist_apple2_at2_bootloader level=$(level) t=$(t)
129141
$(PYTHON) scripts/mk_qd.py --window=6.5 $(t)/alt/quickdisk/Blank.qd
130142
cp -a COPYING $(t)/
131143
cp -a README $(t)/

Rules.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@ FLAGS += -Wundef
1919

2020
## STM32F105
2121
ifeq ($(mcu),stm32f105)
22+
2223
FLAGS += -mcpu=cortex-m3
24+
25+
# Build hack for an Apple2-specific bootloader which knows that QFN32 pin
26+
# PA10 is reassigned.
27+
ifeq ($(target),apple2-bootloader)
28+
override target=bootloader
29+
FLAGS += -DAPPLE2_BOOTLOADER=1
30+
endif
31+
2332
ifeq ($(target),bootloader)
2433
# Debug bootloader doesn't fit in 32kB
2534
override level=prod

src/gotek/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ unsigned int board_get_buttons(void)
8484
x &= _rbit32(gpioc->idr) >> 23;
8585
x = ~x & 7;
8686

87-
#if TARGET == TARGET_apple2
87+
#if (TARGET == TARGET_apple2) || defined(APPLE2_BOOTLOADER)
8888
/* Apple 2: QFN32 select pin PA10 is reassigned as stepper phase #0. */
8989
if (mcu_package == MCU_QFN32)
9090
return x;

0 commit comments

Comments
 (0)