Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加macos编译支持 #4

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions build/envsetup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ if [ $? -ne 0 ]; then
export PATH="$PATH:$TREMO_SDK_PATH/tools/toolchain/bin/"
fi
fi

if [ `uname` = "Darwin" ];then
echo "your operation system is osx,please select your default device"
DEVICES=($(ls /dev/cu.*))
echo $DEVICES
read index
export SERIAL_PORT=${DEVICES[index]}
echo $SERIAL_PORT
elif [ `uname` = "Linux" ];then
echo "your operation system is linux, default device is /dev/ttyUSB0 "
fi

5 changes: 5 additions & 0 deletions build/make/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export HOST_ARCH := Cortex-M4F

ifeq ($(shell uname), Linux)
export EXECUTABLE_SUFFIX :=
else ifeq ($(shell uname), Darwin)
export EXECUTABLE_SUFFIX :=
else
export EXECUTABLE_SUFFIX := .exe
endif
Expand Down Expand Up @@ -67,10 +69,13 @@ $(foreach src,$(CXX_SOURCES),$(eval $(call BUILD_CXX_PROCESS,$(PROJECT),$(src)))

# flash settings
TREMO_LOADER := $(SCRIPTS_PATH)/tremo_loader.py

SERIAL_PORT ?= /dev/ttyUSB0
SERIAL_BAUDRATE ?= 921600
$(PROJECT)_ADDRESS ?= 0x08000000



##################################################################################################
ifeq ($(IDE),keil)
all: keil_project
Expand Down
16 changes: 12 additions & 4 deletions build/make/gen_3rd_project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ keil_gen_script := $(SCRIPTS_PATH)/keil.py
FILE_CREATE = $(file >$(1),$(2))
FILE_APPEND = $(file >>$(1),$(2))

PATH_PREFIX := $(shell realpath $(TREMO_SDK_PATH) --relative-to=.)/
SRC_PATH := $(foreach src, $($(PROJECT)_SOURCE),'$(addprefix $(PATH_PREFIX),$(shell realpath $(src) --relative-to=$(TREMO_SDK_PATH)))'$(comma))
LIB_PATH := $(foreach lib, $($(PROJECT)_LIBS),'$(addprefix $(PATH_PREFIX),$(shell realpath $(lib) --relative-to=$(TREMO_SDK_PATH)))'$(comma))
INC_PATH := $(foreach inc, $($(PROJECT)_INC_PATH),$(addprefix $(PATH_PREFIX),$(shell realpath $(inc) --relative-to=$(TREMO_SDK_PATH)))$(semi))
RP := realpath

ifeq ($(shell uname), Linux)
export RP := realpath
else ifeq ($(shell uname), Darwin)
export RP := grealpath
endif

PATH_PREFIX := $(shell $(RP) $(TREMO_SDK_PATH) --relative-to=.)/
SRC_PATH := $(foreach src, $($(PROJECT)_SOURCE),'$(addprefix $(PATH_PREFIX),$(shell $(RP) $(src) --relative-to=$(TREMO_SDK_PATH)))'$(comma))
LIB_PATH := $(foreach lib, $($(PROJECT)_LIBS),'$(addprefix $(PATH_PREFIX),$(shell $(RP) $(lib) --relative-to=$(TREMO_SDK_PATH)))'$(comma))
INC_PATH := $(foreach inc, $($(PROJECT)_INC_PATH),$(addprefix $(PATH_PREFIX),$(shell $(RP) $(inc) --relative-to=$(TREMO_SDK_PATH)))$(semi))
DEFINES := $(foreach dflags, $($(PROJECT)_DEFINES), $(dflags)$(comma))
ASMDEFINES := $(foreach adflags,$($(PROJECT)_AFLAGS),$(adflags)$(comma))
C_MiscControls := $($(PROJECT)_CFLAGS)
Expand Down
3 changes: 3 additions & 0 deletions build/scripts/tremo_loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import traceback
import serial
import os
import sys
Expand Down Expand Up @@ -226,6 +227,7 @@ def tremo_flash(args):

# flash
tremo = TremoLoader(args.port)

tremo.connect()
tremo.set_baudrate(args.baud)
for address, filename in download_files:
Expand Down Expand Up @@ -339,6 +341,7 @@ def tremo_read_sn(args):
sn = tremo_read_sn(args)
print('The SN is: %s' % binascii.hexlify(sn))
except Exception as e:
traceback.print_exc()
print(str(e))


Expand Down
35 changes: 35 additions & 0 deletions platform/user/init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef __USER_INIT_H
#define __USER_INIT_H


#include <stdio.h>

#include "tremo_rcc.h"
#include "tremo_gpio.h"
#include "tremo_uart.h"
#include "tremo_regs.h"

void uart_log_init(void)
{
// uart0
gpio_set_iomux(GPIOB, GPIO_PIN_0, 1);
gpio_set_iomux(GPIOB, GPIO_PIN_1, 1);

/* uart config struct init */
uart_config_t uart_config;
uart_config_init(&uart_config);

uart_config.baudrate = UART_BAUDRATE_115200;
uart_init(CONFIG_DEBUG_UART, &uart_config);
uart_cmd(CONFIG_DEBUG_UART, ENABLE);
}

void board_init(const rcc_peripheral_t *peripheral_array, size_t length)
{
for (size_t i = 0; i < length; i++)
{
rcc_enable_peripheral_clk(peripheral_array[i], true);
}
}

#endif
2 changes: 1 addition & 1 deletion projects/ASR6601CB-EVAL/examples/lora/pingpong/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(void)
{
// Target board initialization
board_init();

printf("......");
app_start();
}

Expand Down
35 changes: 35 additions & 0 deletions projects/ASR6601CB-EVAL/tutorial/dht11/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

PROJECT := $(notdir $(CURDIR))

$(PROJECT)_SOURCE := $(wildcard src/*.c) \
$(TREMO_SDK_PATH)/platform/system/printf-stdarg.c \
$(TREMO_SDK_PATH)/platform/system/system_cm4.c \
$(TREMO_SDK_PATH)/platform/system/startup_cm4.S \
$(wildcard $(TREMO_SDK_PATH)/drivers/peripheral/src/*.c)

$(PROJECT)_INC_PATH := inc \
$(TREMO_SDK_PATH)/platform/CMSIS \
$(TREMO_SDK_PATH)/platform/common \
$(TREMO_SDK_PATH)/platform/system \
$(TREMO_SDK_PATH)/platform/user \
$(TREMO_SDK_PATH)/drivers/peripheral/inc

$(PROJECT)_CFLAGS := -Wall -Os -ffunction-sections -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -fsingle-precision-constant -std=gnu99 -fno-builtin-printf -fno-builtin-sprintf -fno-builtin-snprintf
$(PROJECT)_DEFINES := -DCONFIG_DEBUG_UART=UART0 -DUSE_MODEM_LORA -DREGION_CN470

$(PROJECT)_LDFLAGS := -Wl,--gc-sections -Wl,--wrap=printf -Wl,--wrap=sprintf -Wl,--wrap=snprintf

$(PROJECT)_LIBS :=

$(PROJECT)_LINK_LD := cfg/gcc.ld

# please change the settings to download the app
#SERIAL_PORT :=
#SERIAL_BAUDRATE :=
#$(PROJECT)_ADDRESS :=

##################################################################################################
include $(TREMO_SDK_PATH)/build/make/common.mk



156 changes: 156 additions & 0 deletions projects/ASR6601CB-EVAL/tutorial/dht11/cfg/gcc.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*
*****************************************************************************
*/

/* Entry Point */
ENTRY(Reset_Handler)

/* Highest address of the user mode stack */
_estack = 0x20004000; /* end of RAM */

/* Generate a link error if heap and stack don't fit into RAM */
_HEAP_SIZE = 0x0000; /* required amount of heap */
_STACK_SIZE = 0x1000; /* required amount of stack */

/* Specify the memory areas */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
}

/* Define output sections */
SECTIONS
{

/* The startup code goes first into FLASH */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH


/* The program code and other data goes into FLASH */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)

KEEP (*(.init))
KEEP (*(.fini))

. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH

/* Constant data goes into FLASH */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH

.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
.ARM : {
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
} >FLASH

.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >FLASH

.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
} >FLASH

.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
} >FLASH

/* used by the startup to initialize data */
_sidata = LOADADDR(.data);

/* Initialized data sections goes into RAM, load LMA copy after code */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */

. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT>FLASH

/* Uninitialized data section */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)

. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM

/*********************************************************************************
* Heap
*********************************************************************************/
.heap :
{
. = ALIGN(4);
_heap_bottom = . ;
end = _heap_bottom;
_end = end;
__end = end;
. += _HEAP_SIZE ;
_heap_top = .;
} >RAM

/*********************************************************************************
* Stack
*********************************************************************************/
.stack :
{
. = ALIGN(4);
_stack_bottom = . ;
. += _STACK_SIZE ;
_stack_top = .;
} >RAM

/* Remove information from the standard libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}

.ARM.attributes 0 : { *(.ARM.attributes) }
}
11 changes: 11 additions & 0 deletions projects/ASR6601CB-EVAL/tutorial/dht11/cfg/ram.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FUNC void Setup (void) {
SP = _RDWORD(0x08000000); // Setup Stack Pointer
PC = _RDWORD(0x08000004); // Setup Program Counter
_WDWORD(0xE000ED08, 0x08000000); // Setup Vector Table Offset Register
}

load ./Objects/project.elf incremental

Setup(); // Setup for Running

g, main
14 changes: 14 additions & 0 deletions projects/ASR6601CB-EVAL/tutorial/dht11/inc/dht11.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

#ifndef __DHT11_DTH11_H
#define __DHT11_DTH11_H


#include "tremo_delay.h"



void dht11_setup(uint8_t gpio_pin);

void dht11_read();

#endif
21 changes: 21 additions & 0 deletions projects/ASR6601CB-EVAL/tutorial/dht11/inc/tremo_it.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef __TREMO_IT_H
#define __TREMO_IT_H

#ifdef __cplusplus
extern "C" {
#endif

void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);

#ifdef __cplusplus
}
#endif

#endif /* __TREMO_IT_H */
1 change: 1 addition & 0 deletions projects/ASR6601CB-EVAL/tutorial/dht11/keil.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
..\..\..\tools\keil\KeilProjectGen.exe ..\..\..\ .\utils\keil_config.ini project project
Loading