add cmake for pi zero (renamed from pi zero_w), build but the flash size seem wrong (only 24 bytes for text)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm1176jzf-s CACHE INTERNAL "System Processor")
|
||||
#set(SUFFIX "")
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
BCM_VERSION=2835
|
||||
)
|
||||
endfunction()
|
@@ -1,4 +1,4 @@
|
||||
CPU_CORE = arm1176
|
||||
CPU_CORE = arm1176jzf-s
|
||||
CFLAGS += -DBCM_VERSION=2835 \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_BCM2835
|
||||
|
@@ -27,6 +27,13 @@
|
||||
#include "bsp/board_api.h"
|
||||
#include "board.h"
|
||||
|
||||
// Suppress warning caused by mcu driver
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#endif
|
||||
|
||||
#include "broadcom/cpu.h"
|
||||
#include "broadcom/gpio.h"
|
||||
#include "broadcom/interrupts.h"
|
||||
@@ -34,6 +41,10 @@
|
||||
#include "broadcom/caches.h"
|
||||
#include "broadcom/vcmailbox.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
// LED
|
||||
#define LED_PIN 18
|
||||
#define LED_STATE_ON 1
|
||||
|
107
hw/bsp/broadcom_32bit/family.cmake
Normal file
107
hw/bsp/broadcom_32bit/family.cmake
Normal file
@@ -0,0 +1,107 @@
|
||||
include_guard()
|
||||
|
||||
set(MCU_DIR ${TOP}/hw/mcu/broadcom)
|
||||
|
||||
# include board specific
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
|
||||
|
||||
# toolchain set up
|
||||
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
|
||||
|
||||
set(FAMILY_MCUS BCM2835 CACHE INTERNAL "")
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# BOARD_TARGET
|
||||
#------------------------------------
|
||||
# only need to be built ONCE for all examples
|
||||
function(add_board_target BOARD_TARGET)
|
||||
if (TARGET ${BOARD_TARGET})
|
||||
return()
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED LD_FILE_GNU)
|
||||
set(LD_FILE_GNU ${MCU_DIR}/broadcom/link.ld)
|
||||
endif ()
|
||||
set(LD_FILE_Clang ${LD_FILE_GNU})
|
||||
|
||||
if (NOT DEFINED STARTUP_FILE_${CMAKE_C_COMPILER_ID})
|
||||
set(STARTUP_FILE_GNU ${MCU_DIR}/broadcom/boot.s)
|
||||
endif ()
|
||||
set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
|
||||
|
||||
add_library(${BOARD_TARGET} STATIC
|
||||
${MCU_DIR}/broadcom/gen/interrupt_handlers.c
|
||||
${MCU_DIR}/broadcom/gpio.c
|
||||
${MCU_DIR}/broadcom/interrupts.c
|
||||
${MCU_DIR}/broadcom/mmu.c
|
||||
${MCU_DIR}/broadcom/caches.c
|
||||
${MCU_DIR}/broadcom/vcmailbox.c
|
||||
${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
|
||||
)
|
||||
target_compile_options(${BOARD_TARGET} PUBLIC
|
||||
-O0
|
||||
-ffreestanding
|
||||
-mgeneral-regs-only
|
||||
-fno-exceptions
|
||||
-std=c17
|
||||
)
|
||||
target_include_directories(${BOARD_TARGET} PUBLIC
|
||||
${MCU_DIR}
|
||||
)
|
||||
|
||||
update_board(${BOARD_TARGET})
|
||||
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_GNU}"
|
||||
-nostdlib -nostartfiles
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--script=${LD_FILE_Clang}"
|
||||
)
|
||||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR")
|
||||
target_link_options(${BOARD_TARGET} PUBLIC
|
||||
"LINKER:--config=${LD_FILE_IAR}"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
|
||||
#------------------------------------
|
||||
# Functions
|
||||
#------------------------------------
|
||||
function(family_configure_example TARGET RTOS)
|
||||
family_configure_common(${TARGET} ${RTOS})
|
||||
|
||||
# Board target
|
||||
add_board_target(board_${BOARD})
|
||||
|
||||
#---------- Port Specific ----------
|
||||
# These files are built for each example since it depends on example's tusb_config.h
|
||||
target_sources(${TARGET} PUBLIC
|
||||
# BSP
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c
|
||||
)
|
||||
target_include_directories(${TARGET} PUBLIC
|
||||
# family, hw, board
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../
|
||||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD}
|
||||
)
|
||||
|
||||
# Add TinyUSB target and port source
|
||||
family_add_tinyusb(${TARGET} OPT_MCU_BCM2835 ${RTOS})
|
||||
target_sources(${TARGET}-tinyusb PUBLIC
|
||||
${TOP}/src/portable/synopsys/dwc2/dcd_dwc2.c
|
||||
)
|
||||
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD})
|
||||
|
||||
# Link dependencies
|
||||
target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb)
|
||||
|
||||
# Flashing
|
||||
family_flash_jlink(${TARGET})
|
||||
endfunction()
|
@@ -1,5 +1,4 @@
|
||||
MCU_DIR = hw/mcu/broadcom
|
||||
DEPS_SUBMODULES += $(MCU_DIR)
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
@@ -27,15 +26,13 @@ SRC_C += \
|
||||
$(MCU_DIR)/broadcom/caches.c \
|
||||
$(MCU_DIR)/broadcom/vcmailbox.c
|
||||
|
||||
SKIP_NANOLIB = 1
|
||||
|
||||
LD_FILE = $(MCU_DIR)/broadcom/link$(SUFFIX).ld
|
||||
|
||||
INC += \
|
||||
$(TOP)/$(BOARD_PATH) \
|
||||
$(TOP)/$(MCU_DIR)
|
||||
|
||||
SRC_S += $(MCU_DIR)/broadcom/boot$(SUFFIX).S
|
||||
SRC_S += $(MCU_DIR)/broadcom/boot$(SUFFIX).s
|
||||
|
||||
$(BUILD)/kernel$(SUFFIX).img: $(BUILD)/$(PROJECT).elf
|
||||
$(OBJCOPY) -O binary $^ $@
|
||||
|
Reference in New Issue
Block a user