Skip to content

Commit

Permalink
Add some initial imx board support, needs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arturo182 committed Jan 15, 2020
1 parent 74d445f commit ee187a1
Show file tree
Hide file tree
Showing 18 changed files with 1,784 additions and 16 deletions.
25 changes: 20 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
include lib/tinyusb/tools/top.mk
include lib/tinyusb/examples/make.mk
TINYUSB_PATH ?= lib/tinyusb

# Force using the local board directory
TOP := $(shell realpath `pwd`)
include $(TINYUSB_PATH)/examples/make.mk

INC += \
hw \
hw/bsp \
hw/bsp/$(BOARD) \
src \
$(TOP)/hw
lib/tinyusb/tools \
_build/build-$(BOARD)

SRC_C += \
SRC_C = \
$(addprefix $(CURRENT_PATH)/, $(wildcard src/*.c))

CFLAGS += -Wno-unused-parameter

include lib/tinyusb/examples/rules.mk
UF2_VERSION_BASE = $(shell git describe --always --tags)
$(BUILD)/uf2_version.h: Makefile
@echo "#define UF2_VERSION_BASE \"$(UF2_VERSION_BASE)\""> $@

OBJ += $(BUILD)/uf2_version.h

include $(TOP)/hw/chip/$(CHIP_FAMILY)/$(CHIP_VARIANT).mk
include $(TINYUSB_PATH)/tools/top.mk
include $(TINYUSB_PATH)/examples/rules.mk
42 changes: 42 additions & 0 deletions hw/bsp/bsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020, Artur Pacholec
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/

#ifndef _BOARD_H_
#define _BOARD_H_

#include <stdint.h>
#include <stdbool.h>

#include "board_config.h"

void board_flash_flush(void);
uint32_t board_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks);
uint32_t board_flash_write_blocks(const uint8_t *src, uint32_t lba, uint32_t num_blocks);
uint32_t board_millis(void);
void board_reset(void);
void board_led_write(bool state);
void board_init(void);

#endif
2 changes: 2 additions & 0 deletions hw/bsp/mimxrt1010_evk/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHIP_FAMILY = mimxrt10xx
CHIP_VARIANT = MIMXRT1011DAE5A
20 changes: 20 additions & 0 deletions hw/bsp/mimxrt1010_evk/board_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef _BOARD_CONFIG_H_
#define _BOARD_CONFIG_H_

#define VENDOR_NAME "NXP"
#define PRODUCT_NAME "MIMXRT1010-EVK"
#define VOLUME_LABEL "UF2BOOT"
#define INDEX_URL ""
#define BOARD_ID "MIMXRT1010-EVK"

#define USB_VID 0x239A
#define USB_PID 0x0077

// The EVK uses 16MB Flash but that would force the MSC
// drive to be larger than 65535 sectors and requires
// additional modifications to the code, we'll take care
// of that in the future. For now 8MB works.
//#define BOARD_FLASH_SIZE 0x1000000
#define BOARD_FLASH_SIZE 0x800000

#endif
12 changes: 12 additions & 0 deletions hw/chip/mimxrt10xx/MIMXRT1011DAE5A.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
MCU_DIR = hw/mcu/nxp/sdk/devices/MIMXRT1011

include hw/chip/mimxrt10xx/family.mk

CFLAGS += -DCPU_MIMXRT1011DAE5A

SRC_C += $(MCU_DIR)/system_MIMXRT1011.c

SRC_S += $(MCU_DIR)/gcc/startup_MIMXRT1011.S

LD_FILE = ../../hw/chip/mimxrt10xx/MIMXRT1011xxxxx_flexspi_nor.ld

115 changes: 115 additions & 0 deletions hw/chip/mimxrt10xx/MIMXRT1011xxxxx_flexspi_nor.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
ENTRY(Reset_Handler)

_minimum_stack_size = 64K;
_minimum_heap_size = 0;

MEMORY
{
FLASH_CONFIG (rx) : ORIGIN = 0x60000400, LENGTH = 3K
FLASH_IVT (rx) : ORIGIN = 0x60001000, LENGTH = 4K
FLASH_ISR (rx) : ORIGIN = 0x60002000, LENGTH = 1K
FLASH_TEXT (rx) : ORIGIN = 0x60002400, LENGTH = 27K
RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 32K
OCRAM (rwx) : ORIGIN = 0x20200000, LENGTH = 64K
}

__StackTop = ORIGIN(OCRAM) + LENGTH(OCRAM);
_bootloader_dbl_tap = ORIGIN(RAM) + LENGTH(RAM) - 4;
__RAM_VECTOR_TABLE_SIZE_BYTES = 0;

SECTIONS
{
.flash_config :
{
. = ALIGN(4);
KEEP(* (.boot_hdr.conf))
. = ALIGN(4);
} > FLASH_CONFIG

.ivt :
{
. = ALIGN(4);
KEEP(* (.boot_hdr.ivt))
KEEP(* (.boot_hdr.boot_data))
KEEP(* (.boot_hdr.dcd_data))
. = ALIGN(4);
} > FLASH_IVT

.interrupts :
{
__VECTOR_TABLE = .;
__VECTOR_RAM = .;

. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} > FLASH_ISR

.text :
{
. = ALIGN(4);
*(EXCLUDE_FILE(
*flexspi_nor_flash_ops.o
*fsl_flexspi.o
) .text*) /* .text* sections (code) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} > FLASH_TEXT

.ARM.exidx :
{
*(.ARM.exidx*)
*(.gnu.linkonce.armexidx.*)
_etext = .; /* define a global symbol at end of code */
__etext = .; /* define a global symbol at end of code */
} > FLASH_TEXT

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

.data : AT (_sidata)
{
. = ALIGN(4);
__data_start__ = .; /* create a global symbol at data start */

*(.data*) /* .data* sections */
*flexspi_nor_flash_ops.o(.text*)
*fsl_flexspi.o(.text*)
. = ALIGN(4);

__data_end__ = .; /* define a global symbol at data end */
} > RAM

/* Uninitialized data section */
.bss :
{
. = ALIGN(4);
__bss_start__ = .;

*(.bss*)
*(COMMON)

. = ALIGN(4);
__bss_end__ = .;
PROVIDE(end = .);
} > RAM

.heap :
{
. = ALIGN(8);
_heap_start = .; /* define a global symbol at heap start */

. += _minimum_heap_size;

__HeapLimit = .;
} > OCRAM

.stack :
{
. = ALIGN(8);
. += _minimum_stack_size;
} > OCRAM

.ARM.attributes 0 : { *(.ARM.attributes) }
}

Loading

0 comments on commit ee187a1

Please sign in to comment.