diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index 8bb0ab7fce..81d137a761 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -254,6 +254,11 @@ rule KernelArchitectureSetup architecture HAIKU_BOOT_PLATFORM ?= u-boot ; HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; } + case cubieboard4 : + { + HAIKU_BOOT_PLATFORM ?= u-boot ; + HAIKU_BOOT_FLOPPY_IMAGE_SIZE = 1440 ; + } case verdex : { HAIKU_BOOT_PLATFORM ?= u-boot ; diff --git a/build/jam/board/cubieboard4/BoardSetup b/build/jam/board/cubieboard4/BoardSetup new file mode 100644 index 0000000000..a2b136b869 --- /dev/null +++ b/build/jam/board/cubieboard4/BoardSetup @@ -0,0 +1,64 @@ +# Cubieboard 4 board-specific definitions +# This likely could be easily used for other Allwinner chipsets + +HAIKU_BOARD_DESCRIPTION = "Cubieboard 4 (CC-A80)" ; +HAIKU_BOARD_FDT_NAME = "cubieboard4" ; + +# +# Various hardcoded addresses +# + +# 0x20000000 = SDRAM start +# 0x20007800 = haiku_loader_linux.ub +# 0x20087800 = BASE + +HAIKU_BOARD_LOADER_BASE = 0x20087800 ; +HAIKU_BOARD_LOADER_ENTRY_RAW = $(HAIKU_BOARD_LOADER_BASE) ; +HAIKU_BOARD_LOADER_ENTRY_NBSD = `printf \"obase=16;ibase=16;8 + %x\\n\" $(HAIKU_BOARD_LOADER_BASE)|bc` ; +HAIKU_BOARD_LOADER_ENTRY_LINUX = `printf \"obase=16;ibase=16;10 + %x\\n\" $(HAIKU_BOARD_LOADER_BASE)|bc` ; + +# +# mmc/SD image +# + +# TODO: Update to https://github.com/cubieboard/CC-A80-binaries when accepted upstream +HAIKU_BOARD_FIRMWARE_URL = "https://github.com/kallisti5/CC-A80-binaries/raw/master/bin" ; + +# u-boot image +# Dear Cubbieboard, add fdt_addr_r, ramdisk_addr_r, kernel_addr_r to u-boot +HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME = boot.scr ; +HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT = "\ + fatload mmc 0 0x20800000 haiku-floppyboot.tgz.ub \ + fatload mmc 0 0x20007800 haiku_loader_linux.ub \ + bootm 0x20007800 0x20800000" ; + +HAIKU_BOARD_SDIMAGE_FAT_SIZE = 32 ; +HAIKU_BOARD_SDIMAGE_FILES = + haiku_loader_linux.ub + haiku-floppyboot.tgz.ub + $(HAIKU_BOARD_SDIMAGE_UBOOT_SCRIPT_NAME) +; + +HAIKU_BOARD_SDIMAGE_BEGIN = 40950 ; # 512-byte sectors (divisible by 63) +HAIKU_BOARD_SDIMAGE_SIZE = 128 ; # MiB + +boot0File = [ DownloadFile sdcard-boot0 : $(HAIKU_BOARD_FIRMWARE_URL)/sdcard-boot0 ] ; +boot1File = [ DownloadFile sdcard-boot1 : $(HAIKU_BOARD_FIRMWARE_URL)/sdcard-boot1 ] ; + +# The Allwinner chips require an SD card "blessed" with +# the boot0 SPL and boot1 (u-boot) at a fixed location on +# the SD card. (Dear AW, please support loading from FAT) +HAIKU_BOARD_SDIMAGE_BOOT0_FILE = $(boot0File) ; +HAIKU_BOARD_SDIMAGE_BOOT0_SEEK = 8192 ; +HAIKU_BOARD_SDIMAGE_BOOT1_FILE = $(boot1File) ; +HAIKU_BOARD_SDIMAGE_BOOT1_SEEK = 19554304 ; + +# +# gcc flags for the specific cpu +# + +local flags = -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard ; + +HAIKU_ASFLAGS_$(HAIKU_PACKAGING_ARCH) += $(flags) ; +HAIKU_CCFLAGS_$(HAIKU_PACKAGING_ARCH) += $(flags) ; +HAIKU_C++FLAGS_$(HAIKU_PACKAGING_ARCH) += $(flags) ; diff --git a/configure b/configure index 0f474ded89..651098925b 100755 --- a/configure +++ b/configure @@ -89,8 +89,8 @@ options: architecture of the Haiku to build, subsequent ones the secondary architectures. --target-board ARM only: Specify the board to build for. Must be - one of beagle,rpi1,rpi2,verdex,overo. - --update re-runs last configure invocation [must be given + one of beagle,rpi1,rpi2,cubieboard4,verdex,overo. + --update re-runs last configure invocation [cubieboard4must be given as first option!] --use-clang Build with host Clang instead of GCC cross compiler @@ -485,6 +485,7 @@ supportedTargetBoards=" beagle rpi1 rpi2 + cubieboard4 verdex overo " diff --git a/headers/private/kernel/arch/arm/board/cubieboard4/board_config.h b/headers/private/kernel/arch/arm/board/cubieboard4/board_config.h new file mode 100644 index 0000000000..f517c7f01a --- /dev/null +++ b/headers/private/kernel/arch/arm/board/cubieboard4/board_config.h @@ -0,0 +1,45 @@ +/* + * Copyright 2012-2015 Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck, kallisti5@unixzen.com + */ +#ifndef _BOARD_SUN9I_BOARD_CONFIG_H +#define _BOARD_SUN9I_BOARD_CONFIG_H + +// https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/arch/arm/boot/dts/sun9i-a80.dtsi +// http://linux-sunxi.org/A80/Memory_map + +#define BOARD_NAME_PRETTY "Allwinner A80" + +#define BOARD_CPU_TYPE_ARM7 1 +#define BOARD_CPU_A80 1 + +//#include + +// For now we just pick up APB1 devices + CPUS +#define DEVICE_BASE 0x07000000 +#define DEVICE_SIZE 0x1008FFF + +#define VECT_BASE 0xFFFF0000 +#define VECT_SIZE SIZE_4K + +#define SDRAM_BASE 0x20000000 +#define SDRAM_SIZE 0x4000000 + // 64Mb (although it is really 0x1FFFFFFFF) + +// UART Settings + +// snps,dw-apb-uart? +#define BOARD_UART1_BASE 0x07000000 +#define BOARD_UART2_BASE BOARD_UART1_BASE + 0x400 +#define BOARD_UART3_BASE BOARD_UART2_BASE + 0x400 + +#define BOARD_UART_DEBUG BOARD_UART1_BASE + +#define BOARD_UART_CLOCK 24000000 + /* 2.4Mhz */ + + +#endif /* _BOARD_SUN9I_BOARD_CONFIG_H */ diff --git a/src/system/boot/platform/u-boot/Jamfile b/src/system/boot/platform/u-boot/Jamfile index cd55c2473c..d169fe996a 100644 --- a/src/system/boot/platform/u-boot/Jamfile +++ b/src/system/boot/platform/u-boot/Jamfile @@ -160,11 +160,12 @@ actions BuildUImageScript1 rule BuildUBootSDImage image : files { Depends $(image) : $(files) ; - SDIMAGE_BLOCK_SIZE on $(image) = 1048576 ; # 1M - SDIMAGE_SIZE on $(image) = $(HAIKU_BOARD_SDIMAGE_SIZE) ; + SDIMAGE_BLOCK_SIZE on $(image) = 1048576 ; # 1MiB SDIMAGE_MTOOLS_H on $(image) = 255 ; SDIMAGE_MTOOLS_S on $(image) = 63 ; SDIMAGE_MTOOLS_C on $(image) = 8 ; + SDIMAGE_SIZE on $(image) = $(HAIKU_BOARD_SDIMAGE_SIZE) ; + SDIMAGE_BEGIN on $(image) = $(HAIKU_BOARD_SDIMAGE_BEGIN:E=63) ; BuildUBootSDImage1 $(image) : $(files) ; } @@ -183,7 +184,7 @@ actions BuildUBootSDImage1 heads=$(SDIMAGE_MTOOLS_H) sectors=$(SDIMAGE_MTOOLS_S) mformat_only' > $(1).mtools # partition it - MTOOLSRC=$(1).mtools mpartition -cI -T 0xc i: + MTOOLSRC=$(1).mtools mpartition -b$(SDIMAGE_BEGIN) -cI -T 0xc i: # format the image MTOOLSRC=$(1).mtools mformat -L 32 -v "Haiku" i: @@ -201,6 +202,35 @@ actions BuildUBootSDImage1 #cat $(2[0]) >> $(1) } + +rule BlessSDImage image +{ + # "Blesses" SD cards by writing out data to a fixed point outside of the + # filesystem. Handy if your board needs an SPL or boot0 at a fixed point. + if $(HAIKU_BOARD_SDIMAGE_BOOT0_FILE) { + Depends $(image) : $(HAIKU_BOARD_SDIMAGE_BOOT0_FILE) ; + } + + if $(HAIKU_BOARD_SDIMAGE_BOOT1_FILE) { + Depends $(image) : $(HAIKU_BOARD_SDIMAGE_BOOT1_FILE) ; + } + + BlessSDImage1 $(image) : $(HAIKU_BOARD_SDIMAGE_BOOT0_FILE) $(HAIKU_BOARD_SDIMAGE_BOOT1_FILE) ; +} + + +actions BlessSDImage1 bind HAIKU_BOARD_SDIMAGE_BOOT0_SEEK HAIKU_BOARD_SDIMAGE_BOOT1_SEEK +{ + if [ $(HAIKU_BOARD_SDIMAGE_BOOT0_SEEK:E=-1) -ge 0 ]; then + dd if=$(2[1]) of=$(1) bs=1 seek=$(HAIKU_BOARD_SDIMAGE_BOOT0_SEEK) conv=notrunc + fi + + if [ $(HAIKU_BOARD_SDIMAGE_BOOT1_SEEK:E=-1) -ge 0 ]; then + dd if=$(2[2]) of=$(1) bs=1 seek=$(HAIKU_BOARD_SDIMAGE_BOOT1_SEEK) conv=notrunc + fi +} + + # uimage targets BuildUImage haiku_loader.ub : haiku_loader : -A $(TARGET_ARCH) -O $(uImageFakeOS) -T kernel -C none @@ -250,6 +280,7 @@ Depends haiku-flash-uimage : haiku-$(HAIKU_BOOT_BOARD)_flash_image_uimage.img ; # SD/mmc image targets BuildUBootSDImage haiku-$(HAIKU_BOOT_BOARD).mmc : $(HAIKU_IMAGE) $(HAIKU_BOARD_SDIMAGE_FILES) ; +BlessSDImage haiku-$(HAIKU_BOOT_BOARD).mmc ; NotFile haiku-mmc-image ; Depends haiku-mmc-image : haiku-$(HAIKU_BOOT_BOARD).mmc ;