compile and generated update-uf2 for rt10xx but it doesn't seem to run
This commit is contained in:
parent
88b761c8d4
commit
0f86d5486c
10 changed files with 136 additions and 53 deletions
2
lib/uf2
2
lib/uf2
|
|
@ -1 +1 @@
|
|||
Subproject commit 8d3af12417c9eb4cf5e019744a55a14ef77420ed
|
||||
Subproject commit 5dcd6266fa3bd15b2b0eb0a37ea67e10a3c52dcd
|
||||
|
|
@ -43,7 +43,6 @@ PORT_DIR = ports/$(PORT)
|
|||
BOARD_DIR = $(PORT_DIR)/boards/$(BOARD)
|
||||
TINYUSB_DIR = lib/tinyusb/src
|
||||
|
||||
|
||||
# Bootloader src, board folder and TinyUSB stack
|
||||
SRC_C += \
|
||||
$(subst $(TOP)/,,$(wildcard $(TOP)/src/*.c)) \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
PORT = mimxrt10xx
|
||||
UF2_FAMILY_ID = 0x4fb2d5bd
|
||||
|
||||
#-------------- Cross Compiler ------------
|
||||
CROSS_COMPILE = arm-none-eabi-
|
||||
|
|
@ -23,7 +24,8 @@ CFLAGS += \
|
|||
-D__ARMVFP__=0 -D__ARMFPV5__=0 \
|
||||
-DXIP_EXTERNAL_FLASH=1 \
|
||||
-DXIP_BOOT_HEADER_ENABLE=1 \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX
|
||||
-DCFG_TUSB_MCU=OPT_MCU_MIMXRT10XX \
|
||||
-DBOARD_UF2_FAMILY_ID=$(UF2_FAMILY_ID)
|
||||
|
||||
# mcu driver cause following warnings
|
||||
CFLAGS += -Wno-error=unused-parameter
|
||||
|
|
@ -57,7 +59,20 @@ INC += \
|
|||
$(TOP)/$(MCU_DIR)/project_template
|
||||
|
||||
include ../rules.mk
|
||||
|
||||
#-------------- Self-update --------------
|
||||
include ../self_update.mk
|
||||
|
||||
#$(SELF_BUILD_OBJ)/self_update/$(OUTNAME).c: $(BUILD)/$(OUTNAME).bin
|
||||
# $(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py --carray $^ -o $@
|
||||
SELF_LDFLAGS = $(LDFLAGS) -Wl,--defsym,m_text_start=0xC000 -Wl,--defsym,m_text_end=0x20000
|
||||
|
||||
# required for uf2 conversion
|
||||
$(SELF_BUILD_OBJ)/$(SELF_OUTNAME).hex: $(SELF_BUILD_OBJ)/$(SELF_OUTNAME).elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O ihex -R .flash_config -R .ivt -R .interrupts $^ $@
|
||||
|
||||
# required for self-update elf compile
|
||||
$(SELF_BUILD_OBJ)/self_update/$(OUTNAME).c: $(SELF_BUILD_OBJ)/self_update/$(OUTNAME)-textonly.bin
|
||||
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py --carray $^ -o $@
|
||||
|
||||
$(SELF_BUILD_OBJ)/self_update/$(OUTNAME)-textonly.bin: $(BUILD)/$(OUTNAME).elf
|
||||
@$(OBJCOPY) -O binary -R .flash_config -R .ivt -R .interrupts $^ $@
|
||||
|
|
|
|||
|
|
@ -130,3 +130,11 @@ void board_flash_write (uint32_t addr, void const *src, uint32_t len)
|
|||
// Overwrite part or all of the page cache with the src data.
|
||||
memcpy(_flash_cache + (addr & (SECTOR_SIZE - 1)), src, len);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TINYUF2_SELF_UPDATE
|
||||
void board_self_update(const uint8_t * bootloader_bin, uint32_t bootloader_len)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -364,6 +364,8 @@ int board_uart_write(void const * buf, int len)
|
|||
//--------------------------------------------------------------------+
|
||||
// USB Interrupt Handler
|
||||
//--------------------------------------------------------------------+
|
||||
#ifndef TINYUF2_SELF_UPDATE
|
||||
|
||||
void USB_OTG1_IRQHandler(void)
|
||||
{
|
||||
#if CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST
|
||||
|
|
@ -385,3 +387,5 @@ void USB_OTG2_IRQHandler(void)
|
|||
tud_int_handler(1);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -36,9 +36,6 @@
|
|||
#include "fsl_device_registers.h"
|
||||
#include "board.h"
|
||||
|
||||
// Family ID for updating Application
|
||||
#define BOARD_UF2_FAMILY_ID 0x4fb2d5bd
|
||||
|
||||
// Flash Start Address of Application
|
||||
#define BOARD_FLASH_APP_START 0x6000C000 // FlexSPI_AMBA_BASE + 0xC000
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,21 @@
|
|||
** ###################################################################
|
||||
*/
|
||||
|
||||
/* text section default to bootloader build, self-update build will define
|
||||
it as application. The typical values should be
|
||||
- TinyUF2 : 0x2400 - 0xC000
|
||||
- Self-update: 0xC000 - 0x20000
|
||||
*/
|
||||
m_text_start = DEFINED(m_text_start) ? m_text_start : 0x2400;
|
||||
m_text_end = DEFINED(m_text_end) ? m_text_end : 0xC000;
|
||||
|
||||
/* Specify the memory areas */
|
||||
MEMORY
|
||||
{
|
||||
m_flash_config (RX) : ORIGIN = m_flash_config_origin, LENGTH = 0x00000C00
|
||||
m_ivt (RX) : ORIGIN = m_flash_base + 0x1000, LENGTH = 0x00001000
|
||||
m_interrupts (RX) : ORIGIN = m_flash_base + 0x2000, LENGTH = 0x00000400
|
||||
m_text (RX) : ORIGIN = m_flash_base + 0x2400, LENGTH = 0xC000-0x2400
|
||||
m_text (RX) : ORIGIN = m_flash_base + m_text_start, LENGTH = m_text_end - m_text_start
|
||||
m_data (RW) : ORIGIN = 0x20000000, LENGTH = m_data_length - 4 /* double tap */
|
||||
m_data2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00010000
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
# Common make rules for all
|
||||
# ---------------------------------------
|
||||
|
||||
OUTNAME = tinyuf2-$(BOARD)
|
||||
|
||||
PYTHON3 ?= python3
|
||||
MKDIR = mkdir
|
||||
SED = sed
|
||||
CP = cp
|
||||
|
|
@ -21,14 +24,6 @@ endif
|
|||
|
||||
ASFLAGS += $(CFLAGS)
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD)/obj/, $(SRC_C:.c=.o))
|
||||
|
||||
# Verbose mode
|
||||
ifeq ("$(V)","1")
|
||||
$(info CFLAGS $(CFLAGS) ) $(info )
|
||||
|
|
@ -36,46 +31,53 @@ $(info LDFLAGS $(LDFLAGS)) $(info )
|
|||
$(info ASFLAGS $(ASFLAGS)) $(info )
|
||||
endif
|
||||
|
||||
# Assembly files can be name with upper case .S, convert it to .s
|
||||
SRC_S := $(SRC_S:.S=.s)
|
||||
|
||||
# Due to GCC LTO bug https://bugs.launchpad.net/gcc-arm-embedded/+bug/1747966
|
||||
# assembly file should be placed first in linking order
|
||||
BUILD_OBJ = $(BUILD)/obj
|
||||
OBJ += $(addprefix $(BUILD_OBJ)/, $(SRC_S:.s=.o))
|
||||
OBJ += $(addprefix $(BUILD_OBJ)/, $(SRC_C:.c=.o))
|
||||
|
||||
# Set all as default goal
|
||||
.DEFAULT_GOAL := all
|
||||
all: $(BUILD)/tinyuf2-$(BOARD).bin $(BUILD)/tinyuf2-$(BOARD).hex size
|
||||
|
||||
uf2: $(BUILD)/tinyuf2-$(BOARD).uf2
|
||||
|
||||
$(BIN):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
copy-artifact: $(BIN) $(BUILD)/tinyuf2-$(BOARD).bin $(BUILD)/tinyuf2-$(BOARD).hex
|
||||
@$(CP) $(BUILD)/tinyuf2-$(BOARD).bin $<
|
||||
@$(CP) $(BUILD)/tinyuf2-$(BOARD).hex $<
|
||||
all: $(BUILD)/$(OUTNAME).bin $(BUILD)/$(OUTNAME).hex size
|
||||
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
$(OBJ): | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
$(BUILD)/tinyuf2-$(BOARD).elf: $(OBJ)
|
||||
$(BUILD)/$(OUTNAME).elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
@$(CC) -o $@ $(LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
|
||||
$(BUILD)/tinyuf2-$(BOARD).bin: $(BUILD)/tinyuf2-$(BOARD).elf
|
||||
$(BUILD)/$(OUTNAME).bin: $(BUILD)/$(OUTNAME).elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O binary $^ $@
|
||||
|
||||
$(BUILD)/tinyuf2-$(BOARD).hex: $(BUILD)/tinyuf2-$(BOARD).elf
|
||||
$(BUILD)/$(OUTNAME).hex: $(BUILD)/$(OUTNAME).elf
|
||||
@echo CREATE $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
UF2_FAMILY ?= 0x00
|
||||
$(BUILD)/tinyuf2-$(BOARD).uf2: $(BUILD)/tinyuf2-$(BOARD).hex
|
||||
@echo CREATE $@
|
||||
$(PYTHON) $(TOP)/tools/uf2/utils/uf2conv.py -f $(UF2_FAMILY) -c -o $@ $^
|
||||
size: $(BUILD)/$(OUTNAME).elf
|
||||
-@echo ''
|
||||
@$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) -rf $(BUILD)
|
||||
$(RM) -rf $(BIN)
|
||||
|
||||
#-------------- Compile Rules --------------
|
||||
|
||||
# We set vpath to point to the top of the tree so that the source files
|
||||
# can be located. By following this scheme, it allows a single build rule
|
||||
# to be used to compile all .c files.
|
||||
vpath %.c . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
$(BUILD_OBJ)/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
@$(CC) $(CFLAGS) -c -MD -o $@ $<
|
||||
@# The following fixes the dependency file.
|
||||
|
|
@ -88,26 +90,16 @@ $(BUILD)/obj/%.o: %.c
|
|||
|
||||
# ASM sources lower case .s
|
||||
vpath %.s . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.s
|
||||
$(BUILD_OBJ)/%.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
vpath %.S . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.S
|
||||
$(BUILD_OBJ)/%.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
size: $(BUILD)/tinyuf2-$(BOARD).elf
|
||||
-@echo ''
|
||||
@$(SIZE) $<
|
||||
-@echo ''
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) -rf $(BUILD)
|
||||
$(RM) -rf $(BIN)
|
||||
|
||||
# Print out the value of a make variable.
|
||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||
print-%:
|
||||
|
|
@ -122,7 +114,7 @@ endif
|
|||
|
||||
JLINK_IF ?= swd
|
||||
|
||||
$(BUILD)/$(BOARD).jlink: $(BUILD)/tinyuf2-$(BOARD).hex
|
||||
$(BUILD)/$(BOARD).jlink: $(BUILD)/$(OUTNAME).hex
|
||||
@echo halt > $@
|
||||
@echo r >> $@
|
||||
@echo loadfile $< >> $@
|
||||
|
|
@ -145,16 +137,15 @@ erase-jlink: $(BUILD)/$(BOARD)-erase.jlink
|
|||
$(JLINKEXE) -device $(JLINK_DEVICE) -if $(JLINK_IF) -JTAGConf -1,-1 -speed auto -CommandFile $<
|
||||
|
||||
#-------------------- Flash with STLink --------------------
|
||||
|
||||
# STM32_Programmer_CLI must be in PATH
|
||||
flash-stlink: $(BUILD)/tinyuf2-$(BOARD).elf
|
||||
flash-stlink: $(BUILD)/$(OUTNAME).elf
|
||||
STM32_Programmer_CLI --connect port=swd --write $< --go
|
||||
|
||||
erase-stlink:
|
||||
STM32_Programmer_CLI --connect port=swd --erase all
|
||||
|
||||
#-------------------- Flash with pyocd --------------------
|
||||
flash-pyocd: $(BUILD)/tinyuf2-$(BOARD).hex
|
||||
flash-pyocd: $(BUILD)/$(OUTNAME).hex
|
||||
pyocd flash -t $(PYOCD_TARGET) $<
|
||||
pyocd reset -t $(PYOCD_TARGET)
|
||||
|
||||
|
|
|
|||
62
ports/self_update.mk
Normal file
62
ports/self_update.mk
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
SELF_OUTNAME = update-tinyuf2-$(BOARD)
|
||||
|
||||
SELF_SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/self_update/*.c))
|
||||
SELF_SRC_C += self_update/$(OUTNAME).c
|
||||
|
||||
SELF_BUILD_OBJ = $(BUILD)/self_obj
|
||||
SELF_OBJ += $(addprefix $(SELF_BUILD_OBJ)/, $(SRC_S:.s=.o))
|
||||
SELF_OBJ += $(addprefix $(SELF_BUILD_OBJ)/, $(PORT_SRC_C:.c=.o))
|
||||
SELF_OBJ += $(addprefix $(SELF_BUILD_OBJ)/, $(SELF_SRC_C:.c=.o))
|
||||
|
||||
SELF_OBJ_DIRS = $(sort $(dir $(SELF_OBJ)))
|
||||
$(SELF_OBJ): | $(SELF_OBJ_DIRS)
|
||||
$(SELF_OBJ_DIRS):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
self-update: $(SELF_BUILD_OBJ)/$(SELF_OUTNAME).uf2
|
||||
|
||||
$(SELF_BUILD_OBJ)/$(SELF_OUTNAME).uf2: $(SELF_BUILD_OBJ)/$(SELF_OUTNAME).hex
|
||||
@echo CREATE $@
|
||||
$(PYTHON3) $(TOP)/lib/uf2/utils/uf2conv.py -f $(UF2_FAMILY_ID) -c -o $@ $^
|
||||
|
||||
$(SELF_BUILD_OBJ)/$(SELF_OUTNAME).elf: $(SELF_OBJ)
|
||||
@echo LINK $@
|
||||
@$(CC) -o $@ $(SELF_LDFLAGS) $^ -Wl,--start-group $(LIBS) -Wl,--end-group
|
||||
|
||||
#-------------- Compile Rules --------------
|
||||
|
||||
# We set vpath to point to the top of the tree so that the source files
|
||||
# can be located. By following this scheme, it allows a single build rule
|
||||
# to be used to compile all .c files.
|
||||
$(SELF_BUILD_OBJ)/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
@$(CC) $(CFLAGS) -DTINYUF2_SELF_UPDATE -c -MD -o $@ $<
|
||||
@# The following fixes the dependency file.
|
||||
@# See http://make.paulandlesley.org/autodep.html for details.
|
||||
@# Regex adjusted from the above to play better with Windows paths, etc.
|
||||
@$(CP) $(@:.o=.d) $(@:.o=.P); \
|
||||
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
||||
$(RM) $(@:.o=.d)
|
||||
|
||||
# ASM sources lower case .s
|
||||
vpath %.s . $(TOP)
|
||||
$(SELF_BUILD_OBJ)/%.o: %.s
|
||||
@echo AS $(notdir $@)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
# ASM sources upper case .S
|
||||
vpath %.S . $(TOP)
|
||||
$(SELF_BUILD_OBJ)/%.o: %.S
|
||||
@echo AS $(notdir $@)
|
||||
@$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $<
|
||||
|
||||
#-------------- Artifacts --------------
|
||||
$(BIN):
|
||||
@$(MKDIR) -p $@
|
||||
|
||||
copy-artifact: $(BIN)
|
||||
copy-artifact: $(BUILD)/$(OUTNAME).bin $(BUILD)/$(OUTNAME).hex $(SELF_BUILD_OBJ)/$(SELF_OUTNAME).uf2
|
||||
@$(CP) $(BUILD)/$(OUTNAME).bin $(BIN)
|
||||
@$(CP) $(BUILD)/$(OUTNAME).hex $(BIN)
|
||||
@$(CP) $(SELF_BUILD_OBJ)/$(SELF_OUTNAME).uf2 $(BIN)
|
||||
|
|
@ -53,14 +53,13 @@ int main(void)
|
|||
// Set indicator similar to WRITING
|
||||
board_timer_start(25);
|
||||
|
||||
// This should never return
|
||||
board_self_update((uint8_t const*) bindata, (uint32_t) bindata_len);
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
while(1)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void board_timer_handler(void)
|
||||
|
|
|
|||
Loading…
Reference in a new issue