summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2024-05-04 12:36:40 +0700
committerhathach <[email protected]>2024-05-04 12:36:40 +0700
commitc020a0190d5f22c0f761ce0a5ec4a6e35e4d0662 (patch)
treea2167bc74dee5201916f1054aafbca3bc4a0be28 /hw
parent666702f478dd91d5d2ea4f194d77f835844a19cd (diff)
add cmake for f1c100s
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/f1c100s/board.h1
-rw-r--r--hw/bsp/f1c100s/board.mk52
-rw-r--r--hw/bsp/f1c100s/boards/f1c100s/board.cmake3
-rw-r--r--hw/bsp/f1c100s/boards/f1c100s/board.h6
-rw-r--r--hw/bsp/f1c100s/boards/f1c100s/board.mk1
-rw-r--r--hw/bsp/f1c100s/family.c (renamed from hw/bsp/f1c100s/f1c100s.c)46
-rw-r--r--hw/bsp/f1c100s/family.cmake114
-rw-r--r--hw/bsp/f1c100s/family.mk58
8 files changed, 203 insertions, 78 deletions
diff --git a/hw/bsp/f1c100s/board.h b/hw/bsp/f1c100s/board.h
deleted file mode 100644
index 0ef9a1700..000000000
--- a/hw/bsp/f1c100s/board.h
+++ /dev/null
@@ -1 +0,0 @@
-// Nothing valuable here
diff --git a/hw/bsp/f1c100s/board.mk b/hw/bsp/f1c100s/board.mk
deleted file mode 100644
index 3596e5414..000000000
--- a/hw/bsp/f1c100s/board.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-MCU_DIR = hw/mcu/allwinner/f1c100s
-DEPS_SUBMODULES += hw/mcu/allwinner
-DEFINES += -D__ARM32_ARCH__=5 -D__ARM926EJS__
-
-CFLAGS += \
- -ffreestanding \
- -std=gnu99 \
- -march=armv5te \
- -mtune=arm926ej-s \
- -mfloat-abi=soft \
- -marm \
- -mno-thumb-interwork \
- -Wno-unused-parameter \
- -Wno-float-equal \
- -DCFG_TUSB_MCU=OPT_MCU_F1C100S \
- -Wno-error=cast-align \
- -Wno-error=address-of-packed-member \
- $(DEFINES)
-
-LD_FILE = hw/mcu/allwinner/f1c100s/f1c100s.ld
-# TODO may skip nanolib
-LDFLAGS += -nostdlib -lgcc -specs=nosys.specs -specs=nano.specs
-
-SRC_C += \
- src/portable/sunxi/dcd_sunxi_musb.c \
- $(MCU_DIR)/machine/sys-uart.c \
- $(MCU_DIR)/machine/exception.c \
- $(MCU_DIR)/machine/sys-clock.c \
- $(MCU_DIR)/machine/sys-copyself.c \
- $(MCU_DIR)/machine/sys-dram.c \
- $(MCU_DIR)/machine/sys-mmu.c \
- $(MCU_DIR)/machine/sys-spi-flash.c \
- $(MCU_DIR)/machine/f1c100s-intc.c \
- $(MCU_DIR)/lib/malloc.c \
- $(MCU_DIR)/lib/printf.c
-
-SRC_S += \
- $(MCU_DIR)/machine/start.S \
- $(MCU_DIR)/lib/memcpy.S \
- $(MCU_DIR)/lib/memset.S
-
-INC += \
- $(TOP)/$(MCU_DIR)/include \
- $(TOP)/$(BOARD_PATH)
-
-# flash target using xfel
-flash: flash-xfel
-
-exec: $(BUILD)/$(PROJECT).bin
- xfel ddr
- xfel write 0x80000000 $<
- xfel exec 0x80000000
diff --git a/hw/bsp/f1c100s/boards/f1c100s/board.cmake b/hw/bsp/f1c100s/boards/f1c100s/board.cmake
new file mode 100644
index 000000000..98ed56c57
--- /dev/null
+++ b/hw/bsp/f1c100s/boards/f1c100s/board.cmake
@@ -0,0 +1,3 @@
+function(update_board TARGET)
+ # nothing to do
+endfunction()
diff --git a/hw/bsp/f1c100s/boards/f1c100s/board.h b/hw/bsp/f1c100s/boards/f1c100s/board.h
new file mode 100644
index 000000000..3b56a3a57
--- /dev/null
+++ b/hw/bsp/f1c100s/boards/f1c100s/board.h
@@ -0,0 +1,6 @@
+#ifndef BOARD_H
+#define BOARD_H
+
+// Nothing valuable here
+
+#endif
diff --git a/hw/bsp/f1c100s/boards/f1c100s/board.mk b/hw/bsp/f1c100s/boards/f1c100s/board.mk
new file mode 100644
index 000000000..be830bd8c
--- /dev/null
+++ b/hw/bsp/f1c100s/boards/f1c100s/board.mk
@@ -0,0 +1 @@
+# nothing to do
diff --git a/hw/bsp/f1c100s/f1c100s.c b/hw/bsp/f1c100s/family.c
index 272b756f2..6df4a0ed8 100644
--- a/hw/bsp/f1c100s/f1c100s.c
+++ b/hw/bsp/f1c100s/family.c
@@ -39,10 +39,9 @@ extern void sys_uart_putc(char c);
static void timer_init(void);
-void board_init(void)
-{
+void board_init(void) {
arch_local_irq_disable();
- do_init_mem_pool();
+ do_init_mem_pool();
f1c100s_intc_init();
timer_init();
printf("Timer INIT done\n");
@@ -50,42 +49,38 @@ void board_init(void)
}
// No LED, no button
-void board_led_write(bool state)
-{
-
+void board_led_write(bool state) {
+ (void) state;
}
-uint32_t board_button_read(void)
-{
+uint32_t board_button_read(void) {
return 0;
}
-int board_uart_read(uint8_t* buf, int len)
-{
+int board_uart_read(uint8_t* buf, int len) {
+ (void) buf;
+ (void) len;
return 0;
}
-int board_uart_write(void const * buf, int len)
-{
+int board_uart_write(void const* buf, int len) {
int txsize = len;
while (txsize--) {
- sys_uart_putc(*(uint8_t const*)buf);
+ sys_uart_putc(*(uint8_t const*) buf);
buf++;
}
return len;
}
-#if CFG_TUSB_OS == OPT_OS_NONE
+#if CFG_TUSB_OS == OPT_OS_NONE
volatile uint32_t system_ticks = 0;
-uint32_t board_millis(void)
-{
+uint32_t board_millis(void) {
return system_ticks;
}
-static void timer_handler(void)
-{
- volatile uint32_t *temp_addr = (uint32_t *)(0x01C20C00 + 0x04);
+static void timer_handler(void) {
+ volatile uint32_t* temp_addr = (uint32_t*) (0x01C20C00 + 0x04);
/* clear timer */
*temp_addr |= 0x01;
@@ -95,36 +90,37 @@ static void timer_handler(void)
static void timer_init(void) {
uint32_t temp;
- volatile uint32_t *temp_addr;
+ volatile uint32_t* temp_addr;
/* reload value */
temp = 12000000 / 1000;
- temp_addr = (uint32_t *)(0x01C20C00 + 0x14);
+ temp_addr = (uint32_t*) (0x01C20C00 + 0x14);
*temp_addr = temp;
/* continuous | /2 | 24Mhz | reload*/
temp = (0x00 << 7) | (0x01 << 4) | (0x01 << 2) | (0x00 << 1);
- temp_addr = (uint32_t *)(0x01C20C00 + 0x10);
+ temp_addr = (uint32_t*) (0x01C20C00 + 0x10);
*temp_addr &= 0xffffff00;
*temp_addr |= temp;
/* open timer irq */
temp = 0x01 << 0;
- temp_addr = (uint32_t *)(0x01C20C00);
+ temp_addr = (uint32_t*) (0x01C20C00);
*temp_addr |= temp;
/* set init value */
- temp_addr = (uint32_t *)(0x01C20C00 + 0x18);
+ temp_addr = (uint32_t*) (0x01C20C00 + 0x18);
*temp_addr = 0;
/* begin run timer */
temp = 0x01 << 0;
- temp_addr = (uint32_t *)(0x01C20C00 + 0x10);
+ temp_addr = (uint32_t*) (0x01C20C00 + 0x10);
*temp_addr |= temp;
f1c100s_intc_set_isr(F1C100S_IRQ_TIMER0, timer_handler);
f1c100s_intc_enable_irq(F1C100S_IRQ_TIMER0);
}
+
#else
static void timer_init(void) { }
#endif
diff --git a/hw/bsp/f1c100s/family.cmake b/hw/bsp/f1c100s/family.cmake
new file mode 100644
index 000000000..0903a0143
--- /dev/null
+++ b/hw/bsp/f1c100s/family.cmake
@@ -0,0 +1,114 @@
+include_guard()
+
+set(SDK_DIR ${TOP}/hw/mcu/allwinner/f1c100s)
+
+include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake)
+
+# toolchain set up
+set(CMAKE_SYSTEM_PROCESSOR arm926ej-s CACHE INTERNAL "System Processor")
+set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/arm_${TOOLCHAIN}.cmake)
+
+set(FAMILY_MCUS F1C100S 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 ()
+
+ # LD_FILE and STARTUP_FILE can be defined in board.cmake
+ if (NOT DEFINED LD_FILE_GNU)
+ set(LD_FILE_GNU ${SDK_DIR}/f1c100s.ld)
+ endif ()
+ set(LD_FILE_Clang ${LD_FILE_GNU})
+
+ if (NOT DEFINED STARTUP_FILE_GNU)
+ set(STARTUP_FILE_GNU ${SDK_DIR}/machine/start.S)
+ endif ()
+ set(STARTUP_FILE_Clang ${STARTUP_FILE_GNU})
+
+ add_library(${BOARD_TARGET} STATIC
+ ${SDK_DIR}/lib/malloc.c
+ ${SDK_DIR}/lib/printf.c
+ ${SDK_DIR}/lib/memcpy.S
+ ${SDK_DIR}/lib/memset.S
+ ${SDK_DIR}/machine/sys-uart.c
+ ${SDK_DIR}/machine/exception.c
+ ${SDK_DIR}/machine/sys-clock.c
+ ${SDK_DIR}/machine/sys-copyself.c
+ ${SDK_DIR}/machine/sys-dram.c
+ ${SDK_DIR}/machine/sys-mmu.c
+ ${SDK_DIR}/machine/sys-spi-flash.c
+ ${SDK_DIR}/machine/f1c100s-intc.c
+ ${STARTUP_FILE_${CMAKE_C_COMPILER_ID}}
+ )
+
+ target_compile_definitions(${BOARD_TARGET} PUBLIC
+ __ARM32_ARCH__=5
+ )
+ target_include_directories(${BOARD_TARGET} PUBLIC
+ ${SDK_DIR}/include
+ )
+
+ update_board(${BOARD_TARGET})
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ -lgcc
+ --specs=nosys.specs --specs=nano.specs
+ "LINKER:--defsym=__bss_end__=__bss_end"
+ "LINKER:--defsym=__bss_start__=__bss_start"
+ "LINKER:--defsym=end=__bss_end"
+ )
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ target_link_options(${BOARD_TARGET} PUBLIC
+ "LINKER:--script=${LD_FILE_GNU}"
+ )
+ 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_F1C100S ${RTOS})
+ target_sources(${TARGET}-tinyusb PRIVATE
+ ${TOP}/src/portable/sunxi/dcd_sunxi_musb.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()
diff --git a/hw/bsp/f1c100s/family.mk b/hw/bsp/f1c100s/family.mk
new file mode 100644
index 000000000..be416e72e
--- /dev/null
+++ b/hw/bsp/f1c100s/family.mk
@@ -0,0 +1,58 @@
+SDK_DIR = hw/mcu/allwinner/f1c100s
+
+include $(TOP)/$(BOARD_PATH)/board.mk
+CPU_CORE ?= arm926ej-s
+
+#CFLAGS += \
+# -march=armv5te \
+# -mtune=arm926ej-s \
+# -mfloat-abi=soft \
+# -marm \
+
+CFLAGS += \
+ -ffreestanding \
+ -std=gnu99 \
+ -mno-thumb-interwork \
+ -D__ARM32_ARCH__=5 \
+ -D__ARM926EJS__ \
+ -Wno-float-equal \
+ -Wno-unused-parameter \
+ -DCFG_TUSB_MCU=OPT_MCU_F1C100S \
+ -Wno-error=array-bounds \
+
+LD_FILE = ${SDK_DIR}/f1c100s.ld
+
+# TODO may skip nanolib
+LDFLAGS += \
+ -nostdlib -lgcc \
+ --specs=nosys.specs --specs=nano.specs \
+
+SRC_C += \
+ src/portable/sunxi/dcd_sunxi_musb.c \
+ ${SDK_DIR}/machine/sys-uart.c \
+ ${SDK_DIR}/machine/exception.c \
+ ${SDK_DIR}/machine/sys-clock.c \
+ ${SDK_DIR}/machine/sys-copyself.c \
+ ${SDK_DIR}/machine/sys-dram.c \
+ ${SDK_DIR}/machine/sys-mmu.c \
+ ${SDK_DIR}/machine/sys-spi-flash.c \
+ ${SDK_DIR}/machine/f1c100s-intc.c \
+ ${SDK_DIR}/lib/malloc.c \
+ ${SDK_DIR}/lib/printf.c
+
+SRC_S += \
+ ${SDK_DIR}/machine/start.S \
+ ${SDK_DIR}/lib/memcpy.S \
+ ${SDK_DIR}/lib/memset.S
+
+INC += \
+ $(TOP)/${SDK_DIR}/include \
+ $(TOP)/$(BOARD_PATH)
+
+# flash target using xfel
+flash: flash-xfel
+
+exec: $(BUILD)/$(PROJECT).bin
+ xfel ddr
+ xfel write 0x80000000 $<
+ xfel exec 0x80000000