File tree Expand file tree Collapse file tree 7 files changed +100
-0
lines changed
Expand file tree Collapse file tree 7 files changed +100
-0
lines changed Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: MIT OR Apache-2.0
2+ #
3+ # Copyright (c) 2025 Devansh Lodha <devanshlodha12@gmail.com>
4+
5+ # This Makefile is designed to be called from the parent directory's
6+ # Docker environment, which provides the aarch64-elf toolchain.
7+
8+ CROSS_COMPILE ?= aarch64-elf-
9+ OBJCOPY = $(CROSS_COMPILE ) objcopy
10+ AS = $(CROSS_COMPILE ) as
11+ LD = $(CROSS_COMPILE ) ld
12+
13+ IMG_NAME = halt_stub.img
14+ ELF_NAME = halt_stub.elf
15+ OBJ_NAME = start.o
16+
17+ .PHONY : all clean
18+
19+ all : $(IMG_NAME )
20+
21+ $(IMG_NAME ) : $(ELF_NAME )
22+ @echo " --- Building Halt Stub Image ---"
23+ @$(OBJCOPY ) -O binary $(ELF_NAME ) $(IMG_NAME )
24+
25+ $(ELF_NAME ) : $(OBJ_NAME )
26+ @$(LD ) -T linker.ld -o $(ELF_NAME ) $(OBJ_NAME )
27+
28+ $(OBJ_NAME ) : start.s
29+ @$(AS ) -o $(OBJ_NAME ) start.s
30+
31+ clean :
32+ @rm -f $(IMG_NAME ) $(ELF_NAME ) $(OBJ_NAME )
Original file line number Diff line number Diff line change 1+ _ ����
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: MIT OR Apache-2.0
3+ *
4+ * Copyright (c) 2025 Devansh Lodha <devanshlodha12@gmail.com>
5+ */
6+
7+ ENTRY (_start)
8+ SECTIONS
9+ {
10+ . = 0x80000 ;
11+ .text : { *(.text .boot ) }
12+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * SPDX-License-Identifier: MIT OR Apache-2.0
3+ *
4+ * Copyright (c) 2025 Devansh Lodha <devanshlodha12@gmail.com>
5+ */
6+
7+ .section ".text.boot"
8+ .global _start
9+ _start:
10+ wfe // Wait for event (low-power idle)
11+ b _start
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: MIT OR Apache-2.0
2+ #
3+ # Copyright (c) 2025 Devansh Lodha <devanshlodha12@gmail.com>
4+
5+ adapter driver cmsis-dap
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: MIT OR Apache-2.0
2+ #
3+ # Copyright (c) 2025 Devansh Lodha <devanshlodha12@gmail.com>
4+
5+ # 1. Connect to the OpenOCD server.
6+ target remote localhost:3333
7+
8+ # 2. Reset the Pi and halt it at the very beginning.
9+ monitor reset init
10+
11+ # 3. Load your program's symbols and code into the Pi's RAM.
12+ load
13+
14+ # 4. Set the Program Counter to the start of our code.
15+ set $pc = 0x80000
Original file line number Diff line number Diff line change 1+ # SPDX-License-Identifier: MIT OR Apache-2.0
2+ #
3+ # Copyright (c) 2025 Devansh Lodha <devanshlodha12@gmail.com>
4+
5+ transport select swd
6+ adapter speed 4000
7+ reset_config srst_push_pull srst_only
8+ set _CHIPNAME bcm2712
9+ set _DAP_TAPID 0x4ba00477
10+ set _CHIPCORES 4
11+ swd newdap $_CHIPNAME cpu -expected-id $_DAP_TAPID
12+ dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
13+ set _DBGBASE {0x80010000 0x80110000 0x80210000 0x80310000}
14+ set _CTIBASE {0x80020000 0x80120000 0x80220000 0x80320000}
15+ for { set _core 0 } { $_core < $_CHIPCORES } { incr _core } {
16+ set _CTINAME $_CHIPNAME.cti$_core
17+ set _TARGETNAME $_CHIPNAME.cpu$_core
18+ cti create $_CTINAME -dap $_CHIPNAME.dap -ap-num 0 -baseaddr [lindex $_CTIBASE $_core]
19+ target create $_TARGETNAME aarch64 -dap $_CHIPNAME.dap -coreid $_core -dbgbase [lindex $_DBGBASE $_core] -cti $_CTINAME
20+ $_TARGETNAME configure -event gdb-attach { halt }
21+ }
22+ targets $_CHIPNAME.cpu0
23+ init
24+ $_CHIPNAME.cpu0 configure -event reset-init { halt }
You can’t perform that action at this time.
0 commit comments