diff --git a/Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.s b/Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.S
similarity index 90%
rename from Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.s
rename to Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.S
index 129c532..d04504a 100755
--- a/Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.s
+++ b/Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.S
@@ -16,7 +16,7 @@
//
*/
- .equ Stack_Size, 0x00000100
+ .equ Stack_Size, 0x00002000
.section ".stack", "w"
.align 3
.globl __cs3_stack_mem
@@ -26,8 +26,7 @@ __cs3_stack_mem:
.space Stack_Size
.endif
.size __cs3_stack_mem, . - __cs3_stack_mem
- .set __cs3_stack_size, . - __cs3_stack_mem
-
+ .set __cs3_stack_size, . - __cs3_stack_mem
/*
// Heap Configuration
@@ -35,7 +34,7 @@ __cs3_stack_mem:
//
*/
- .equ Heap_Size, 0x00001000
+ .equ Heap_Size, 0x00002000
.section ".heap", "w"
.align 3
@@ -66,10 +65,10 @@ __cs3_interrupt_vector_cortex_m:
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
- .long SVC_Handler /* SVCall Handler */
+ .long vPortSVCHandler /* SVC_Handler */ /* SVCall Handler */
.long DebugMon_Handler /* Debug Monitor Handler */
.long 0 /* Reserved */
- .long PendSV_Handler /* PendSV Handler */
+ .long xPortPendSVHandler /* PendSV_Handler */ /* PendSV Handler */
.long SysTick_Handler /* SysTick Handler */
/* External Interrupts */
@@ -124,6 +123,17 @@ __cs3_interrupt_vector_cortex_m:
__cs3_reset_cortex_m:
.fnstart
.if (RAM_MODE)
+/* init data section in ram */
+ LDR R0, =__cs3_region_init_ram
+ LDR R1, =__cs3_region_start_ram
+ LDR R2, =_edata
+copy_loop:
+ LDR R3, [R0]
+ STR R3, [R1]
+ ADD R0, #4
+ ADD R1, #4
+ CMP R1, R2
+ BLT copy_loop
/* Clear .bss section (Zero init) */
MOV R0, #0
LDR R1, =__bss_start__
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2fb5f62
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,89 @@
+TARGET = ddk-arm
+
+#### Setup ####
+TOOLCHAIN = arm-none-eabi
+
+CC = $(TOOLCHAIN)-gcc
+CP = $(TOOLCHAIN)-objcopy
+SIZE = $(TOOLCHAIN)-size
+CHECKSUM= ./checksum
+
+CFLAGS += -Os -ffunction-sections -fdata-sections
+CFLAGS += -mthumb -mcpu=cortex-m3 -std=c99 -I./
+CFLAGS += -IBase/Core/CM3/DeviceSupport/NXP/LPC17xx
+CFLAGS += -IBase/Core/CM3/CoreSupport
+CFLAGS += -IBase/FreeRTOSV7.3.0/FreeRTOS/Source/include
+CFLAGS += -IBase/FreeRTOSV7.3.0/FreeRTOS/Source/portable/GCC/ARM_CM3
+CFLAGS += -IBase/CDL/Drivers/include
+CFLAGS += -IBase/directc
+CFLAGS += -D RAM_MODE=1
+LFLAGS = -Wl,--gc-sections -Tlpc17xx.ld
+CPFLAGS = -Obinary
+CRT0 = ./Base/Core/CM3/DeviceSupport/NXP/LPC17xx/startup/gcc/startup_LPC17xx.S
+
+SRC = \
+buffer.c \
+helper.c \
+io.c \
+led.c \
+main.c \
+stats.c \
+uart.c \
+tests.c \
+jtag_1149.c \
+cli.c \
+syscalls.c \
+Base/Core/CM3/DeviceSupport/NXP/LPC17xx/system_LPC17xx.c \
+Base/CDL/Drivers/source/lpc17xx_clkpwr.c \
+Base/CDL/Drivers/source/lpc17xx_exti.c \
+Base/CDL/Drivers/source/lpc17xx_gpio.c \
+Base/CDL/Drivers/source/lpc17xx_libcfg_default.c \
+Base/CDL/Drivers/source/lpc17xx_nvic.c \
+Base/CDL/Drivers/source/lpc17xx_pinsel.c \
+Base/CDL/Drivers/source/lpc17xx_systick.c \
+Base/CDL/Drivers/source/lpc17xx_timer.c \
+Base/CDL/Drivers/source/lpc17xx_uart.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/croutine.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/list.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/queue.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/tasks.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/timers.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/portable/MemMang/heap_4.c \
+Base/FreeRTOSV7.3.0/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c \
+Base/directc/dpalg.c \
+Base/directc/dpchain.c \
+Base/directc/dpcom.c \
+Base/directc/dpcore.c \
+Base/directc/dpfrom.c \
+Base/directc/dpjtag.c \
+Base/directc/dpnvm.c \
+Base/directc/dpsecurity.c \
+Base/directc/dpuser.c \
+Base/directc/dputil.c \
+bitstream/bitstream.c
+
+OBJ = $(SRC:.c=.o)
+
+
+.PHONY: clean install
+
+#### Rules ####
+all: $(TARGET).bin
+
+%.o: %.c
+ $(CC) -c $(CFLAGS) $< -o $@
+
+$(TARGET).elf: $(OBJ) $(CRT0)
+ $(CC) $(LFLAGS) $(CFLAGS) $^ -o $@
+
+$(TARGET).bin: $(TARGET).elf $(CHECKSUM)
+ $(CP) $(CPFLAGS) $< $@
+ $(CHECKSUM) $@
+ $(SIZE) $<
+
+$(CHECKSUM): checksum.c
+ gcc -o $@ $<
+
+clean:
+ rm -f $(OBJ) $(CHECKSUM) $(TARGET).elf $(TARGET).bin
+
diff --git a/checksum.c b/checksum.c
new file mode 100644
index 0000000..7be4e1f
--- /dev/null
+++ b/checksum.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2013, The DDK Project
+ * Dmitry Nedospasov
+ * Thorsten Schroeder
+ * Andrew Karpow
+ *
+ * All rights reserved.
+ *
+ * This file is part of Die Datenkrake (DDK).
+ *
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * wrote this file. As long as you retain this notice
+ * you can do whatever you want with this stuff.
+ * If we meet some day, and you think this stuff is worth it, you can buy us a
+ * beer in return. Die Datenkrake Project.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE DDK PROJECT BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * File: checksum.c
+ * Description: LPC 17xx checksum insertion program
+ */
+
+
+#include
+#include
+#include
+#include
+#include
+
+int main(int argc, char *argv[])
+{
+ int32_t fd, i, *addr;
+
+ if(argc < 2)
+ {
+ fprintf(stderr, "Usage: %s file\n", argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ if((fd = open(argv[1], O_RDWR)) == -1 ||
+ (addr = mmap(NULL, 8 * sizeof(uint32_t), PROT_READ |
+ PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED)
+ {
+ fprintf(stderr, "Error opening '%s'\n", argv[1]);
+ exit(EXIT_FAILURE);
+ }
+
+ addr[7] = 0;
+ for(i = 0; i < 7; i++)
+ addr[7] += addr[i];
+
+ addr[7] = -addr[7];
+
+ return EXIT_SUCCESS;
+}
diff --git a/jtag_1149.c b/jtag_1149.c
index 5e7c9ad..29ee357 100644
--- a/jtag_1149.c
+++ b/jtag_1149.c
@@ -32,7 +32,6 @@
#include
#include
-#include
#include
#include "jtag_1149.h"
diff --git a/lpc17xx.ld b/lpc17xx.ld
new file mode 100644
index 0000000..fec7c7a
--- /dev/null
+++ b/lpc17xx.ld
@@ -0,0 +1,216 @@
+/* Linker script for Cortex-M3
+ *
+ * Version:CodeSourcery Sourcery G++ Lite 2007q3-53
+ * BugURL:https://support.codesourcery.com/GNUToolchain/
+ *
+ * Copyright 2007 CodeSourcery.
+ *
+ * The authors hereby grant permission to use, copy, modify, distribute,
+ * and license this software and its documentation for any purpose, provided
+ * that existing copyright notices are retained in all copies and that this
+ * notice is included verbatim in any distributions. No written agreement,
+ * license, or royalty fee is required for any of the authorized uses.
+ * Modifications to this software may be copyrighted by their authors
+ * and need not follow the licensing terms described here, provided that
+ * the new terms are clearly indicated on the first page of each file where
+ * they apply. */
+
+OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+/*ENTRY(_start)*/
+SEARCH_DIR(.)
+
+MEMORY
+{
+ rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
+ ram (rwx) : ORIGIN = 0x10000000, LENGTH = 32K
+
+ sram1(rwx) : ORIGIN = 0x2007C000, LENGTH = 16k
+ sram2(rwx) : ORIGIN = 0x20004000, LENGTH = 16k
+}
+
+/* These force the linker to search for particular symbols from
+ * the start of the link process and thus ensure the user's
+ * overrides are picked up
+ */
+
+EXTERN(__cs3_reset_cortex_m)
+EXTERN(__cs3_interrupt_vector_cortex_m)
+EXTERN(__cs3_start_c main __cs3_stack __cs3_stack_size __cs3_heap_end)
+
+PROVIDE(__cs3_stack = __cs3_region_start_ram + __cs3_region_size_ram);
+PROVIDE(__cs3_stack_size = __cs3_region_start_ram + __cs3_region_size_ram - _end);
+PROVIDE(__cs3_heap_start = _end);
+PROVIDE(__cs3_heap_end = __cs3_region_start_ram + __cs3_region_size_ram);
+
+SECTIONS
+{
+ .text :
+ {
+ CREATE_OBJECT_SYMBOLS
+ __cs3_region_start_rom = .;
+ *(.cs3.region-head.rom)
+ __cs3_interrupt_vector = __cs3_interrupt_vector_cortex_m;
+ *(.cs3.interrupt_vector)
+ /* Make sure we pulled in an interrupt vector. */
+ ASSERT (. != __cs3_interrupt_vector_cortex_m, "No interrupt vector");
+ *(.rom)
+ *(.rom.b)
+
+ __cs3_reset = __cs3_reset_cortex_m;
+ *(.cs3.reset)
+ /* Make sure we pulled in some reset code. */
+ ASSERT (. != __cs3_reset, "No reset code");
+
+ /* CRP section */
+ . = 0x000002fc;
+ KEEP(*(.crp))
+
+ . = ALIGN(4);
+ *(.text .text.* .gnu.linkonce.t.*)
+ *(.plt)
+ *(.gnu.warning)
+ *(.glue_7t) *(.glue_7) *(.vfp11_veneer)
+
+ *(.rodata .rodata.* .gnu.linkonce.r.*)
+
+ *(.ARM.extab* .gnu.linkonce.armextab.*)
+ *(.gcc_except_table)
+ *(.eh_frame_hdr)
+ *(.eh_frame)
+
+ . = ALIGN(4);
+ KEEP(*(.init))
+
+ . = ALIGN(4);
+ __preinit_array_start = .;
+ KEEP (*(.preinit_array))
+ __preinit_array_end = .;
+
+ . = ALIGN(4);
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+
+ . = ALIGN(0x4);
+ KEEP (*crtbegin.o(.ctors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*crtend.o(.ctors))
+
+ . = ALIGN(4);
+ KEEP(*(.fini))
+
+ . = ALIGN(4);
+ __fini_array_start = .;
+ KEEP (*(.fini_array))
+ KEEP (*(SORT(.fini_array.*)))
+ __fini_array_end = .;
+
+ KEEP (*crtbegin.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*crtend.o(.dtors))
+
+ . = ALIGN(4);
+ __cs3_regions = .;
+ LONG (0)
+ LONG (__cs3_region_init_ram)
+ LONG (__cs3_region_start_ram)
+ LONG (__cs3_region_init_size_ram)
+ LONG (__cs3_region_zero_size_ram)
+ }
+
+ /* .ARM.exidx is sorted, so has to go in its own output section. */
+ __exidx_start = .;
+ .ARM.exidx :
+ {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ } >rom
+ __exidx_end = .;
+ .text.align :
+ {
+ . = ALIGN(8);
+ _etext = .;
+ } >rom
+ __cs3_region_size_rom = LENGTH(rom);
+ __cs3_region_num = 1;
+
+ .data :
+ {
+ __cs3_region_start_ram = .;
+ *(.cs3.region-head.ram)
+ KEEP(*(.jcr))
+ *(.got.plt) *(.got)
+ *(.shdata)
+ *(.data .data.* .gnu.linkonce.d.*)
+ *(.ram)
+ . = ALIGN (8);
+ _edata = .;
+ } >ram AT>rom
+ .bss :
+ {
+ __bss_start__ = .;
+ *(.shbss)
+ *(.bss .bss.* .gnu.linkonce.b.*)
+ *(COMMON)
+ __bss_end__ = .;
+ *(.ram.b)
+ . = ALIGN (8);
+ _end = .;
+ __end = .;
+ } >ram AT>rom
+ /* This used for USB RAM section */
+ .usb_ram (NOLOAD):
+ {
+ *.o (USB_RAM)
+ } > sram2
+ .heap (NOLOAD) :
+ {
+ *(.heap)
+ } >sram1
+ .stack (__cs3_stack - __cs3_stack_size) (NOLOAD):
+ {
+ *(.stack)
+ _estack = .;
+ PROVIDE(estack = .);
+ } >sram1
+
+ __cs3_region_init_ram = LOADADDR (.data);
+ __cs3_region_init_size_ram = _edata - __cs3_region_start_ram;
+ __cs3_region_zero_size_ram = _end - _edata;
+ __cs3_region_size_ram = LENGTH(ram);
+ __cs3_region_num = 1;
+
+ .stab 0 (NOLOAD) : { *(.stab) }
+ .stabstr 0 (NOLOAD) : { *(.stabstr) }
+ /* DWARF debug sections.
+ * Symbols in the DWARF debugging sections are relative to the beginning
+ * of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+
+ .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
+ .ARM.attributes 0 : { KEEP (*(.ARM.attributes)) }
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
diff --git a/syscalls.c b/syscalls.c
new file mode 100644
index 0000000..83d3cfc
--- /dev/null
+++ b/syscalls.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2013, The DDK Project
+ * Dmitry Nedospasov
+ * Thorsten Schroeder
+ * Andrew Karpow
+ *
+ * All rights reserved.
+ *
+ * This file is part of Die Datenkrake (DDK).
+ *
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * , and
+ * wrote this file. As long as you retain this notice you can do whatever
+ * you want with this stuff. If we meet some day, and you think this stuff is
+ * worth it, you can buy us a beer in return. Die Datenkrake Project.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE DDK PROJECT BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * File: syscalls.c
+ * Description: Newlib syscall wrapper for libc compatibility
+ *
+ */
+
+#include
+#include
+#include
+
+#include "uart.h"
+
+#undef errno
+extern int errno;
+
+int _read(int file, char *ptr, int len)
+{
+ char c;
+ int i;
+
+ for (i = 0; i < len; i++)
+ {
+ c = __getchar();
+
+ *ptr++ = c;
+ __putchar(c);
+
+ if(c == '\r' && i < len - 1)
+ {
+ *ptr = '\n';
+ __putchar(*ptr);
+ i++;
+ break;
+ }
+ }
+ return i;
+}
+
+int _write(int file, char *ptr, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ __putchar(*ptr++);
+
+ return len;
+}
+
+int _close(int file) {
+ return 0;
+}
+
+
+int _lseek(int file, int ptr, int dir)
+{
+ return 0;
+}
+
+int _isatty(int file) {
+ return 1;
+}
+
+int _fstat(int file, struct stat *st)
+{
+ st->st_mode = S_IFCHR;
+ return 0;
+}
+
+extern char __cs3_heap_end[]; /* end is set in the linker command */
+static char *heap_ptr; /* Points to current end of the heap. */
+
+void *_sbrk(ptrdiff_t nbytes)
+{
+ char *base; /* errno should be set to ENOMEM on error */
+
+ if (!heap_ptr) { /* Initialize if first time through. */
+ heap_ptr = __cs3_heap_end;
+ }
+ base = heap_ptr; /* Point to end of heap. */
+ heap_ptr += nbytes; /* Increase heap. */
+
+ return base; /* Return pointer to start of new heap area. */
+}
diff --git a/uart.c b/uart.c
index a53ffc9..4c61bb8 100644
--- a/uart.c
+++ b/uart.c
@@ -37,7 +37,6 @@
#include
#include
#include
-#include
#include "lpc17xx_uart.h"
#include "lpc17xx_pinsel.h"
diff --git a/uart.h b/uart.h
index 529bd3a..dc0123e 100644
--- a/uart.h
+++ b/uart.h
@@ -51,8 +51,10 @@ int getchar_nb(void);
// for stdio (printf, scanf, etc) - blocking!
int __getchar(void);
void __putchar(int);
+#ifndef __GNUC__
void putchar(int);
int getchar(void);
+#endif
void uart1_init(const uint32_t , const bool);
void UART1_IRQHandler(void);
@@ -73,4 +75,4 @@ int getchar3(void);
void putchar3(int);
-#endif
\ No newline at end of file
+#endif