init
This commit is contained in:
commit
323a9c3a55
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
bin/
|
||||||
|
*.elf
|
||||||
|
*.bin
|
||||||
|
generated.*.ld
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[submodule "libopencm3"]
|
||||||
|
path = libopencm3
|
||||||
|
url = https://github.com/libopencm3/libopencm3.git
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
18
.idea/misc.xml
Normal file
18
.idea/misc.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MakefileSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<MakefileProjectSettings>
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
<option name="version" value="2" />
|
||||||
|
</MakefileProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
|
</project>
|
7
.idea/vcs.xml
Normal file
7
.idea/vcs.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/libopencm3" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
22
Makefile
Normal file
22
Makefile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
V=1
|
||||||
|
DEBUG=1
|
||||||
|
PROJECT = dht_test
|
||||||
|
BUILD_DIR = bin
|
||||||
|
|
||||||
|
#SHARED_DIR = ../my-common-code
|
||||||
|
CFILES = main.c
|
||||||
|
#CFILES += api.c
|
||||||
|
#AFILES += api-asm.S
|
||||||
|
|
||||||
|
# TODO - you will need to edit these two lines!
|
||||||
|
DEVICE=stm32f103rcbt6
|
||||||
|
OOCD_FILE = board/stm32f4discovery.cfg
|
||||||
|
|
||||||
|
# You shouldn't have to edit anything below here.
|
||||||
|
#VPATH += $(SHARED_DIR)
|
||||||
|
#INCLUDES += $(patsubst %,-I%, . $(SHARED_DIR))
|
||||||
|
OPENCM3_DIR=libopencm3
|
||||||
|
|
||||||
|
include $(OPENCM3_DIR)/mk/genlink-config.mk
|
||||||
|
include rules.mk
|
||||||
|
include $(OPENCM3_DIR)/mk/genlink-rules.mk
|
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
## Build
|
||||||
|
|
||||||
|
0. git submodule update --init (This is only needed once)
|
||||||
|
1. make -C libopencm3 # (Only needed once)
|
||||||
|
2. make
|
||||||
|
|
||||||
|
|
1
libopencm3
Submodule
1
libopencm3
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 44928416eacb4c8d7774b1385c7f38fb226d080b
|
156
main.c
Normal file
156
main.c
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||||
|
*
|
||||||
|
* This library is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libopencm3/cm3/nvic.h>
|
||||||
|
#include <libopencm3/stm32/rcc.h>
|
||||||
|
#include <libopencm3/stm32/gpio.h>
|
||||||
|
#include <libopencm3/stm32/timer.h>
|
||||||
|
|
||||||
|
static void delay(int count)
|
||||||
|
{
|
||||||
|
for (int i=0; i < count; i++) {
|
||||||
|
__asm__("nop");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void gpio_setup(void)
|
||||||
|
{
|
||||||
|
/* Enable GPIOA clock. */
|
||||||
|
/* Manually: */
|
||||||
|
// RCC_APB2ENR |= RCC_APB2ENR_IOPCEN;
|
||||||
|
/* Using API functions: */
|
||||||
|
rcc_periph_clock_enable(RCC_GPIOB);
|
||||||
|
|
||||||
|
/* Set GPIO5 (in GPIO port A) to 'output push-pull'. */
|
||||||
|
/* Manually: */
|
||||||
|
// GPIOA_CRH = (GPIO_CNF_OUTPUT_PUSHPULL << (((5 - 8) * 4) + 2));
|
||||||
|
// GPIOA_CRH |= (GPIO_MODE_OUTPUT_2_MHZ << ((5 - 8) * 4));
|
||||||
|
/* Using API functions: */
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO0);
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO1);
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tim_setup(void)
|
||||||
|
{
|
||||||
|
nvic_enable_irq(NVIC_TIM3_IRQ);
|
||||||
|
nvic_set_priority(NVIC_TIM3_IRQ, 1); // interupts will not work without it???
|
||||||
|
|
||||||
|
rcc_periph_clock_enable(RCC_TIM3);
|
||||||
|
rcc_periph_reset_pulse(RST_TIM3);
|
||||||
|
|
||||||
|
timer_set_mode(TIM3, TIM_CR1_CKD_CK_INT, TIM_CR1_CMS_EDGE, TIM_CR1_DIR_UP);
|
||||||
|
timer_set_prescaler(TIM3, 1152); // set timer tickrate to 500khz
|
||||||
|
//timer_set_oc_value(TIM3, TIM_OC1, 0x1000);
|
||||||
|
timer_set_period(TIM3, 0xffff);
|
||||||
|
timer_one_shot_mode(TIM3);
|
||||||
|
|
||||||
|
timer_ic_set_input(TIM3, TIM_IC3, TIM_IC_IN_TI3);
|
||||||
|
//timer_ic_set_polarity(TIM3, TIM_IC3, TIM_IC_FALLING); // TIM_IC_RISING
|
||||||
|
//timer_ic_enable(TIM3, TIM_IC3);
|
||||||
|
|
||||||
|
timer_enable_counter(TIM3);
|
||||||
|
timer_enable_irq(TIM3, TIM_DIER_UIE);
|
||||||
|
timer_enable_irq(TIM3, TIM_DIER_CC1IE); // end start condition
|
||||||
|
timer_enable_irq(TIM3, TIM_DIER_CC3IE);
|
||||||
|
|
||||||
|
// start condition
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO0);
|
||||||
|
gpio_clear(GPIOB, GPIO0);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum DHT11_STATE {
|
||||||
|
DHT11_START,
|
||||||
|
DHT11_RESPONSE,
|
||||||
|
DHT11_BIT0,
|
||||||
|
DHT11_BIT1,
|
||||||
|
DHT11_END
|
||||||
|
};
|
||||||
|
|
||||||
|
int dht11_state = DHT11_START;
|
||||||
|
|
||||||
|
void tim3_isr(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (timer_get_flag(TIM3, TIM_SR_UIF)) // timer reached end
|
||||||
|
{
|
||||||
|
timer_clear_flag(TIM3, TIM_SR_UIF);
|
||||||
|
//gpio_toggle(GPIOB, GPIO1);
|
||||||
|
gpio_toggle(GPIOB, GPIO2);
|
||||||
|
|
||||||
|
//timer_set_counter(TIM3, 0);
|
||||||
|
//timer_clear_flag(TIM3, TIM_SR_UIF);
|
||||||
|
//timer_set_oc_value(TIM3, TIM_OC1, 1000);
|
||||||
|
} else if (timer_get_flag(TIM3, TIM_SR_CC1IF))
|
||||||
|
{
|
||||||
|
timer_clear_flag(TIM3, TIM_SR_CC3IF);
|
||||||
|
if (dht11_state == DHT11_START){
|
||||||
|
gpio_set(GPIOB, GPIO0);
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO0);
|
||||||
|
|
||||||
|
// setup timer to wait for start response from dht11
|
||||||
|
timer_ic_set_polarity(TIM3, TIM_IC3, TIM_IC_FALLING); // TIM_IC_RISING
|
||||||
|
timer_ic_enable(TIM3, TIM_IC3);
|
||||||
|
|
||||||
|
dht11_state = DHT11_START;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (timer_get_flag(TIM3, TIM_SR_CC3IF)) // PB0 changed value
|
||||||
|
{
|
||||||
|
timer_clear_flag(TIM3, TIM_SR_CC3IF);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (timer_get_flag(TIM3, TIM_SR_CC3OF))
|
||||||
|
{
|
||||||
|
timer_clear_flag(TIM3, TIM_SR_CC3OF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dht_start_signal(void)
|
||||||
|
{
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO0);
|
||||||
|
gpio_clear(GPIOB, GPIO0);
|
||||||
|
delay(205000);
|
||||||
|
//delay(30000);
|
||||||
|
gpio_set(GPIOB, GPIO0);
|
||||||
|
delay(100);
|
||||||
|
gpio_set_mode(GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, GPIO0);
|
||||||
|
}
|
||||||
|
|
||||||
|
volatile int bla=0;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]);
|
||||||
|
gpio_setup();
|
||||||
|
tim_setup();
|
||||||
|
|
||||||
|
/* Blink the LED (PA5) on the board. */
|
||||||
|
while (1) {
|
||||||
|
/* Using API function gpio_toggle(): */
|
||||||
|
gpio_toggle(GPIOB, GPIO1); /* LED on/off */
|
||||||
|
delay(4000000);
|
||||||
|
dht_start_signal();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
24
openocd.cfg
Normal file
24
openocd.cfg
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# This is an ST NUCLEO F103RB board with a single STM32F103RBT6 chip.
|
||||||
|
# http://www.st.com/web/catalog/tools/FM116/SC959/SS1532/LN1847/PF259875
|
||||||
|
|
||||||
|
interface ftdi
|
||||||
|
transport select swd
|
||||||
|
ftdi_vid_pid 0x0403 0x6010
|
||||||
|
|
||||||
|
# ftdi_device_desc "USB Serial Converter A"
|
||||||
|
# ftdi_device_desc "FT2232H ¿ª·¢°å"
|
||||||
|
# ftdi_serial "FTZ7O8O0"
|
||||||
|
|
||||||
|
ftdi_channel 1
|
||||||
|
#adapter_khz 500
|
||||||
|
#adapter_khz 8
|
||||||
|
|
||||||
|
ftdi_layout_init 0x0018 0x05fb
|
||||||
|
ftdi_layout_signal SWD_EN -data 0
|
||||||
|
#ftdi_layout_signal nSRST -data 0x0020
|
||||||
|
ftdi_layout_signal nTRST -ndata 0x0010 -noe 0x0040
|
||||||
|
ftdi_layout_signal nSRST -ndata 0x0020 -noe 0x0040
|
||||||
|
|
||||||
|
source [find target/stm32f1x.cfg]
|
||||||
|
|
||||||
|
reset_config srst_only
|
177
rules.mk
Normal file
177
rules.mk
Normal file
@ -0,0 +1,177 @@
|
|||||||
|
# This version of rules.mk expects the following to be defined before
|
||||||
|
# inclusion..
|
||||||
|
### REQUIRED ###
|
||||||
|
# OPENCM3_DIR - duh
|
||||||
|
# PROJECT - will be the basename of the output elf, eg usb-gadget0-stm32f4disco
|
||||||
|
# CFILES - basenames only, eg main.c blah.c
|
||||||
|
# CXXFILES - same for C++ files. Must have cxx suffix!
|
||||||
|
# DEVICE - the full device name, eg stm32f405ret6
|
||||||
|
# _or_
|
||||||
|
# LDSCRIPT - full path, eg ../../examples/stm32/f4/stm32f4-discovery/stm32f4-discovery.ld
|
||||||
|
# OPENCM3_LIB - the basename, eg: opencm3_stm32f4
|
||||||
|
# OPENCM3_DEFS - the target define eg: -DSTM32F4
|
||||||
|
# ARCH_FLAGS - eg, -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
|
||||||
|
# (ie, the full set of cpu arch flags, _none_ are defined in this file)
|
||||||
|
#
|
||||||
|
### OPTIONAL ###
|
||||||
|
# INCLUDES - fully formed -I paths, if you want extra, eg -I../shared
|
||||||
|
# BUILD_DIR - defaults to bin, should set this if you are building multiarch
|
||||||
|
# OPT - full -O flag, defaults to -Os
|
||||||
|
# CSTD - defaults -std=c99
|
||||||
|
# CXXSTD - no default.
|
||||||
|
# OOCD_INTERFACE - eg stlink-v2
|
||||||
|
# OOCD_TARGET - eg stm32f4x
|
||||||
|
# both only used if you use the "make flash" target.
|
||||||
|
# OOCD_FILE - eg my.openocd.cfg
|
||||||
|
# This overrides interface/target above, and is used as just -f FILE
|
||||||
|
### TODO/FIXME/notes ###
|
||||||
|
# No support for stylecheck.
|
||||||
|
# No support for BMP/texane/random flash methods, no plans either
|
||||||
|
# No support for magically finding the library.
|
||||||
|
# C++ hasn't been actually tested with this..... sorry bout that. ;)
|
||||||
|
# Second expansion/secondary not set, add this if you need them.
|
||||||
|
|
||||||
|
BUILD_DIR ?= bin
|
||||||
|
OPT ?= -Os
|
||||||
|
CSTD ?= -std=c99
|
||||||
|
|
||||||
|
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||||
|
# If you're insane, V=99 will print out all sorts of things.
|
||||||
|
V?=0
|
||||||
|
ifeq ($(V),0)
|
||||||
|
Q := @
|
||||||
|
NULL := 2>/dev/null
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Tool paths.
|
||||||
|
PREFIX ?= arm-none-eabi-
|
||||||
|
CC = $(PREFIX)gcc
|
||||||
|
CXX = $(PREFIX)g++
|
||||||
|
LD = $(PREFIX)gcc
|
||||||
|
OBJCOPY = $(PREFIX)objcopy
|
||||||
|
OBJDUMP = $(PREFIX)objdump
|
||||||
|
OOCD ?= openocd
|
||||||
|
|
||||||
|
OPENCM3_INC = $(OPENCM3_DIR)/include
|
||||||
|
|
||||||
|
# Inclusion of library header files
|
||||||
|
INCLUDES += $(patsubst %,-I%, . $(OPENCM3_INC) )
|
||||||
|
|
||||||
|
OBJS = $(CFILES:%.c=$(BUILD_DIR)/%.o)
|
||||||
|
OBJS += $(CXXFILES:%.cxx=$(BUILD_DIR)/%.o)
|
||||||
|
OBJS += $(AFILES:%.S=$(BUILD_DIR)/%.o)
|
||||||
|
GENERATED_BINS = $(PROJECT).elf $(PROJECT).bin $(PROJECT).map $(PROJECT).list $(PROJECT).lss
|
||||||
|
|
||||||
|
TGT_CPPFLAGS += -MD
|
||||||
|
TGT_CPPFLAGS += -Wall -Wundef $(INCLUDES)
|
||||||
|
TGT_CPPFLAGS += $(INCLUDES) $(OPENCM3_DEFS)
|
||||||
|
|
||||||
|
TGT_CFLAGS += $(OPT) $(CSTD) -ggdb3
|
||||||
|
TGT_CFLAGS += $(ARCH_FLAGS)
|
||||||
|
TGT_CFLAGS += -fno-common
|
||||||
|
TGT_CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
TGT_CFLAGS += -Wextra -Wshadow -Wno-unused-variable -Wimplicit-function-declaration
|
||||||
|
TGT_CFLAGS += -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes
|
||||||
|
|
||||||
|
TGT_CXXFLAGS += $(OPT) $(CXXSTD) -ggdb3
|
||||||
|
TGT_CXXFLAGS += $(ARCH_FLAGS)
|
||||||
|
TGT_CXXFLAGS += -fno-common
|
||||||
|
TGT_CXXFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
TGT_CXXFLAGS += -Wextra -Wshadow -Wredundant-decls -Weffc++
|
||||||
|
|
||||||
|
TGT_ASFLAGS += $(OPT) $(ARCH_FLAGS) -ggdb3
|
||||||
|
|
||||||
|
TGT_LDFLAGS += -T$(LDSCRIPT) -L$(OPENCM3_DIR)/lib -nostartfiles
|
||||||
|
TGT_LDFLAGS += $(ARCH_FLAGS)
|
||||||
|
TGT_LDFLAGS += -specs=nano.specs
|
||||||
|
TGT_LDFLAGS += -Wl,--gc-sections
|
||||||
|
# OPTIONAL
|
||||||
|
#TGT_LDFLAGS += -Wl,-Map=$(PROJECT).map
|
||||||
|
ifeq ($(V),99)
|
||||||
|
TGT_LDFLAGS += -Wl,--print-gc-sections
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Linker script generator fills this in for us.
|
||||||
|
ifeq (,$(DEVICE))
|
||||||
|
LDLIBS += -l$(OPENCM3_LIB)
|
||||||
|
endif
|
||||||
|
# nosys is only in newer gcc-arm-embedded...
|
||||||
|
#LDLIBS += -specs=nosys.specs
|
||||||
|
LDLIBS += -Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
|
||||||
|
|
||||||
|
# Burn in legacy hell fortran modula pascal yacc idontevenwat
|
||||||
|
.SUFFIXES:
|
||||||
|
.SUFFIXES: .c .S .h .o .cxx .elf .bin .list .lss
|
||||||
|
|
||||||
|
# Bad make, never *ever* try to get a file out of source control by yourself.
|
||||||
|
%: %,v
|
||||||
|
%: RCS/%,v
|
||||||
|
%: RCS/%
|
||||||
|
%: s.%
|
||||||
|
%: SCCS/s.%
|
||||||
|
|
||||||
|
all: $(PROJECT).elf $(PROJECT).bin
|
||||||
|
flash: $(PROJECT).flash
|
||||||
|
|
||||||
|
# error if not using linker script generator
|
||||||
|
ifeq (,$(DEVICE))
|
||||||
|
$(LDSCRIPT):
|
||||||
|
ifeq (,$(wildcard $(LDSCRIPT)))
|
||||||
|
$(error Unable to find specified linker script: $(LDSCRIPT))
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
# if linker script generator was used, make sure it's cleaned.
|
||||||
|
GENERATED_BINS += $(LDSCRIPT)
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Need a special rule to have a bin dir
|
||||||
|
$(BUILD_DIR)/%.o: %.c
|
||||||
|
@printf " CC\t$<\n"
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(Q)$(CC) $(TGT_CFLAGS) $(CFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.cxx
|
||||||
|
@printf " CXX\t$<\n"
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(Q)$(CXX) $(TGT_CXXFLAGS) $(CXXFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.S
|
||||||
|
@printf " AS\t$<\n"
|
||||||
|
@mkdir -p $(dir $@)
|
||||||
|
$(Q)$(CC) $(TGT_ASFLAGS) $(ASFLAGS) $(TGT_CPPFLAGS) $(CPPFLAGS) -o $@ -c $<
|
||||||
|
|
||||||
|
$(PROJECT).elf: $(OBJS) $(LDSCRIPT) $(LIBDEPS)
|
||||||
|
@printf " LD\t$@\n"
|
||||||
|
$(Q)$(LD) $(TGT_LDFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) -o $@
|
||||||
|
|
||||||
|
%.bin: %.elf
|
||||||
|
@printf " OBJCOPY\t$@\n"
|
||||||
|
$(Q)$(OBJCOPY) -O binary $< $@
|
||||||
|
|
||||||
|
%.lss: %.elf
|
||||||
|
$(OBJDUMP) -h -S $< > $@
|
||||||
|
|
||||||
|
%.list: %.elf
|
||||||
|
$(OBJDUMP) -S $< > $@
|
||||||
|
|
||||||
|
%.flash: %.elf
|
||||||
|
@printf " FLASH\t$<\n"
|
||||||
|
ifeq (,$(OOCD_FILE))
|
||||||
|
$(Q)(echo "halt; program $(realpath $(*).elf) verify reset" | nc -4 localhost 4444 2>/dev/null) || \
|
||||||
|
$(OOCD) -f interface/$(OOCD_INTERFACE).cfg \
|
||||||
|
-f target/$(OOCD_TARGET).cfg \
|
||||||
|
-c "program $(realpath $(*).elf) verify reset exit" \
|
||||||
|
$(NULL)
|
||||||
|
else
|
||||||
|
$(Q)(echo "halt; program $(realpath $(*).elf) verify reset" | nc -4 localhost 4444 2>/dev/null) || \
|
||||||
|
$(OOCD) -f $(OOCD_FILE) \
|
||||||
|
-c "program $(realpath $(*).elf) verify reset exit" \
|
||||||
|
$(NULL)
|
||||||
|
endif
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf $(BUILD_DIR) $(GENERATED_BINS)
|
||||||
|
|
||||||
|
.PHONY: all clean flash
|
||||||
|
-include $(OBJS:.o=.d)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user