Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// </h>
*/

.equ Stack_Size, 0x00000100
.equ Stack_Size, 0x00002000
.section ".stack", "w"
.align 3
.globl __cs3_stack_mem
Expand All @@ -26,16 +26,15 @@ __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

/*
// <h> Heap Configuration
// <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
// </h>
*/

.equ Heap_Size, 0x00001000
.equ Heap_Size, 0x00002000

.section ".heap", "w"
.align 3
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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__
Expand Down
89 changes: 89 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

64 changes: 64 additions & 0 deletions checksum.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright (c) 2013, The DDK Project
* Dmitry Nedospasov <dmitry at nedos dot net>
* Thorsten Schroeder <ths at modzero dot ch>
* Andrew Karpow <andy at ndyk dot de>
*
* All rights reserved.
*
* This file is part of Die Datenkrake (DDK).
*
* "THE BEER-WARE LICENSE" (Revision 42):
* <andy at ndyk dot de> 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 <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>

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;
}
1 change: 0 additions & 1 deletion jtag_1149.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include <stdio.h>
#include <stdlib.h>
#include <ctl_api.h>
#include <string.h>

#include "jtag_1149.h"
Expand Down
Loading