Bare metal on Pinephone Pro
#1
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
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  bookworm vs trixie discussion for mobian in pinephone pro. zetabeta 21 22,014 10-20-2025, 07:01 AM
Last Post: biketool
  Seeking Contributors: Apache NuttX Real-Time Operating System for PinePhone Pro lupyuen 4 7,877 08-19-2025, 01:38 AM
Last Post: geometrylitegame12
Star FreeBSD developer build for PinePhone Pro teekay 1 2,786 05-03-2025, 11:02 AM
Last Post: tllim
  freeBSD is booted on pinephone pro with console output zetabeta 5 5,780 04-18-2025, 12:56 AM
Last Post: teekay
  How to Clone Kali Linux to PinePhone Pro with Terabyte IFW TOF 2 5,869 02-26-2025, 02:15 AM
Last Post: TOF
  Anyone gotten latest Ubuntu Touch to work on PinePhone Pro? dchang0 4 9,185 12-22-2024, 04:21 PM
Last Post: dchang0
  Megapixels on Mobian Bookworm on PinePhone Pro - Not Launching X0X0X0X0X0 3 5,200 10-28-2024, 10:46 AM
Last Post: Jite
  tow-boot, just bought pinephone pro stratofall 4 4,979 07-30-2024, 03:43 PM
Last Post: stratofall
  Tow-Boot, a new U-Boot option for Pinephone Pro and other devices Ulfnic 60 102,552 02-13-2024, 02:54 PM
Last Post: fxc
  A Btrfs Image for Arch SXMO on the Pinephone Pro mburns 2 3,895 11-23-2023, 08:44 AM
Last Post: mburns

Forum Jump:


Users browsing this thread: 1 Guest(s)