PINE64
Bare metal on Pinephone Pro - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone Pro (https://forum.pine64.org/forumdisplay.php?fid=177)
+--- Forum: PinePhone Pro Software (https://forum.pine64.org/forumdisplay.php?fid=179)
+--- Thread: Bare metal on Pinephone Pro (/showthread.php?tid=19956)



Bare metal on Pinephone Pro - alain - 08-19-2025

Hello,

I would like to boot a bare metal program (that just starts and enters in an infinite loop) (asm+c) on my ppp thank to U-Boot, but U-Boot don't boot my program and blinks the multicolor led in red, and then shut down. What's wrong in my code ? 

start.S
Code:
.global start start: msr DAIFSet, #7 bl main spin: b spin

spl.lds
Code:
ENTRY(start) SECTIONS { . = 0x02000000; . = ALIGN(4); .text : { *(.text) } . = ALIGN(4); .rodata : { *(.rodata*) } . = ALIGN(4); .data : { *(.data*) } . = ALIGN(4); .got : { *(.got) } _end = .; . = ALIGN(8); __bss_start__ = .; .bss_start (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; } .bss __bss_base (OVERLAY) : { *(.bss*) . = ALIGN(4); __bss_limit = .; } .bss_end __bss_limit (OVERLAY) : { KEEP(*(.__bss_end)); } __bss_end__ = .; }

main.c
Code:
/* * * Tom Trebisky  12-31-2021 */ typedef volatile unsigned int vu32; typedef unsigned int u32; struct gpio {     vu32 data;     vu32 dir;     u32 _pad0[2];     u32 _pad1[8];     vu32 ie;     vu32 im;     vu32 il;     vu32 ip;     vu32 is;     vu32 ris;     vu32 debounce;     vu32 eoi;     vu32 ext;     u32 _pad2[3];     vu32 sync; }; #define GPIO0_BASE ((struct gpio *) 0xff720000) #define GPIO1_BASE ((struct gpio *) 0xff730000) #define GPIO2_BASE ((struct gpio *) 0xff780000) #define GPIO3_BASE ((struct gpio *) 0xff788000) #define GPIO4_BASE ((struct gpio *) 0xff790000) #define GPIO_BASE GPIO0_BASE #define LED_BIT (8+3) #define LED_PIN 24 #define LED_MASK 1<<LED_PIN void main ( void ) {     volatile int count = 100000000;     while ( count-- )         ; }

Makefile
Code:
BOARD = rk3399 CROSS_COMPILE = aarch64-linux-gnu- # ------------------------------------- OBJS = start.o main.o TARGET = $(BOARD).bin # CFLAGS := -g -Wall -Wextra -ffreestanding -fno-builtin -mlittle-endian CFLAGS := -g -Wall -ffreestanding -fno-builtin -mlittle-endian CFLAGS += -march=armv8-a+crc CFLAGS += -mtune=cortex-a53 CFLAGS += -I. LDFLAGS := -Bstatic \ -Tspl.lds \ -Wl,--start-group \ -Wl,--end-group \ -Wl,--build-id=none \ -nostdlib CC = $(CROSS_COMPILE)gcc $(CFLAGS) LD = $(CROSS_COMPILE)gcc $(LDFLAGS) OBJCOPY = $(CROSS_COMPILE)objcopy DUMP = $(CROSS_COMPILE)objdump LOAD = tools/loader -h64 # This gives us dependencies in .d files. # CFLAGS += -MMD # This gives us a map file. # CFLAGS += -Wl,-Map=$(BOARD).map,--cref \ .c.o: @echo " [CC]   $<" @$(CC) $< -c -o $@ .S.o: @echo " [CC]   $<" @$(CC) $< -c -o $@ # ------------------------------------- all: install #all: $(TARGET) install: $(TARGET) # cp $(TARGET) /var/lib/tftpboot $(BOARD).elf: $(OBJS) @echo " [LD]   $(BOARD).elf" @$(LD) $(OBJS) -o $(BOARD).elf $(TARGET): $(BOARD).elf @#echo " [IMG]  $(TARGET) @$(OBJCOPY) -O binary $(BOARD).elf $(TARGET) dis: $(BOARD).elf $(DUMP) -d $(BOARD).elf -z >$(BOARD).dis fetch: cp ../USB_loader/loader tools usb:  $(TARGET) $(LOAD) $(TARGET) sdcard:  $(TARGET) $(LOAD) -o $(TARGET) | dd of=/dev/sdf seek=1 conv=fdatasync .PHONY: clean clean: rm -f *.o rm -f *.img rm -f *.elf rm -f *.bin rm -f *.map rm -f *.dis