Skip to content
Snippets Groups Projects
Commit cabe6e89 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski
Browse files

Merge branch 'v3-sevensols' into v3-rc1

parents 8dfc70a1 5ca6e20c
Branches
Tags
No related merge requests found
Showing
with 753 additions and 45 deletions
......@@ -7,3 +7,6 @@
modules.order
.tmp_versions
Module.symvers
.cproject
.project
.settings
*.bin-*
No preview for this file type
No preview for this file type
#!/bin/sh
# A script to compile the usb loader, possibly changing the mac address
showhelp()
{
echo "Usage: $0 [options] MAC [DEV]\n"
echo "MAC:\t MAC address in hexadecimal seperated by ':' (i.e, AB:CD:EF:01:23:45)"
echo "DEV:\t The usb device (by default it is /dev/ttyACM0)"
echo "Options: "
echo "\t-h|--help\t\t Show this help message"
echo "\t-m|--memmode\t\t can be: default, df (dataflash), nf (nandflash), test."
echo "\t-e \t\t\t Completely erase the memory (Can erase your configuration)"
echo "\t--build\t\t\t Use file that you have build in the WRS_OUTPUT_DIR"
echo "\t--test\t\t\t Use file for testing the switch (not available)"
echo "\t--silent\t\t Don't ask MAC or S/N and use default 02:0B:AD:C0:FF:EE"
echo ""
exit 0
}
checkExit()
{
err=0;
if [ $1 ]; then
if [ -f $1 ]; then
return 0;
else
echo "Can't find $1" >& 2;
fi
else
echo "varname not set"
fi
exit 1
}
modifyMAC()
{
origin=$1
new=$2
cp $origin $new
# check & change mac address
X="[0-9a-fA-F][0-9a-fA-F]"
while true; do
if echo $MAC | grep "^${X}:${X}:${X}:${X}:${X}:${X}\$" > /dev/null; then
sed -i "s/02:0B:AD:C0:FF:EE/$MAC/" $new
echo "MAC is now: $MAC"
return 0
else
if [ "x$MAC" != "x" ]; then
echo "$0: Invalid MAC address \"$MAC\"" >&2;
fi
if [ $silent ]; then
return 1;
fi
read -p "Enter MAC (XX:XX:XX:XX:XX:XX): " MAC
fi
done
}
# Sanity checks
if [ -d ./usb-loader ]; then true; else
......@@ -8,54 +67,91 @@ if [ -d ./usb-loader ]; then true; else
exit 1
fi
err=0;
if [ -f ./binaries/at91bootstrap.bin ]; then true; else err=1; fi
if [ -f ./binaries/barebox.bin ]; then true; else err=1; fi
# build flasher itself
if CC=cc make -s -C usb-loader; then true; else
echo "$0: Error compiling usb-loader" >&2; exit 1;
fi
if [ $err -eq 1 ]; then
echo "$0: Can't find either ./binaries/at91bootstrap.bin" >& 2
echo "$0: or ./binaries/barebox.bin" >& 2
exit 1
# Check if atmel sam-ba is find by lusb
lsusb | grep "at91sam SAMBA" > /dev/null
if [ $? -gt "0" ]; then
echo "Did not find the sam-ba monitor in lsusb....\nPlease check that the Dataflash is short-circuited!"
exit 1;
fi
# parse command line
DEV="/dev/ttyACM0"
MAC=""
DEV=""
FLAGS=""
at91bs="./binaries/at91bootstrap.bin"
barebox="./binaries/barebox.bin"
kernel="${WRS_OUTPUT_DIR}/images/zImage"
rootfs="${WRS_OUTPUT_DIR}/images/wrs-image.jffs2.img"
while [ $# -ge 1 ]; do
case $1 in
/* ) DEV="$1"; shift ;;
-b|--build)
at91bs=${WRS_OUTPUT_DIR}/images/at91bootstrap.bin;
barebox=${WRS_OUTPUT_DIR}/images/barebox.bin
kernel=${WRS_OUTPUT_DIR}/images/zImage
rootfs=${WRS_OUTPUT_DIR}/images/wrs-image.jffs2.img
shift;;
-h|--help) showhelp; shift;;
-m|--memmode) memmode="$2"; shift; shift;;
--silent) silent=1; shift;;
/* ) DEV="-s $1"; shift ;;
*:* ) MAC="$1"; shift ;;
-*) FLAGS="${FLAGS} $1"; shift;;
* ) echo "$0: Invalid argument \"$1\"" >&2; exit 1;;
esac
done
# check mac address
if [ "x$MAC" != "x" ]; then
X="[0-9a-fA-F][0-9a-fA-F]"
if echo $MAC | grep "^${X}:${X}:${X}:${X}:${X}:${X}\$" > /dev/null; then
true
else
echo "$0: Invalid MAC address \"$MAC\"" >&2; exit 1;
fi
## Selecting the running memmode
if [ "x$memmode" = "xdf" ]; then
df=1
elif [ "x$memmode" = "xnf" ]; then
nf=1
elif [ "x$memmode" = "xtest" ]; then
test=1
else
df=1
nf=1
fi
# build flasher itself
if CC=cc make -s -C usb-loader; then true; else
echo "$0: Error compiling usb-loader" >&2; exit 1;
## Flashing DataFlash
if [ $df ]; then
checkExit $at91bs
checkExit $barebox
Tbarebox=$(mktemp /tmp/barebox.XXXXXX)
modifyMAC ${barebox} ${Tbarebox}
./usb-loader/mch_flasher -m df $FLAGS $DEV ${at91bs} 0 ${Tbarebox} 33792
fi
# cat binaries to temp file. Increase size of at91boot (0x8400)
T=$(mktemp /tmp/wrs-flash.XXXXXX)
cat binaries/at91bootstrap.bin /dev/zero | dd bs=1 count=33792 > $T \
2> /dev/null
cat binaries/barebox.bin >> $T
## Flashing NANDFlash
if [ $nf ]; then
checkExit $kernel
checkExit $rootfs
./usb-loader/mch_flasher -m nand $FLAGS $DEV ${kernel} 0x00100000 ${rootfs} 0x04000000
fi
## Loading in DDR
if [ $test ]; then
checkExit $barebox
checkExit $kernel
checkExit $rootfs
Tbarebox=$(mktemp /tmp/barebox.XXXXXX)
modifyMAC ${barebox} ${Tbarebox}
# change the mac address if so requested
if [ "$MAC" != "x$MAC" ]; then
sed -i "s/02:0B:AD:C0:FF:EE/$MAC/" $T
./usb-loader/mch_flasher -m ddr $FLAGS $DEV ${Tbarebox} 0x0 ${kernel} 0x1000000 ${rootfs} 0x2000000
fi
# flash it (msc...)
(cd usb-loader && ./mch_flasher $T $DEV)
#rm -f $T
\ No newline at end of file
From f87ac48aaf4ec7726391b87577fceede1b561228 Mon Sep 17 00:00:00 2001
From 6c56f4f07d953d33a90584dd15360f8d572483a4 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Thu, 15 Sep 2011 23:41:14 +0200
Subject: [PATCH 1/6] board 9g45ek: fix ddr config for WRS-V3
Subject: [PATCH 01/19] board 9g45ek: fix ddr config for WRS-V3
---
board/at91sam9g45ek/at91sam9g45ek.c | 2 +-
......@@ -81,5 +81,5 @@ index 550aea4..a4a168f 100644
#define AT91C_DDRC2_NR_12 (0x1 << 2) // (HDDRSDRC2) 12 Bits
#define AT91C_DDRC2_NR_13 (0x2 << 2) // (HDDRSDRC2) 13 Bits
--
1.7.7.2
1.7.9.5
From c27eea873f4a7dd9bea3da51b8e4aba27b9e52fc Mon Sep 17 00:00:00 2001
From b257bbfacdfa9475ca0a812a64d6ab59de9ea440 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 10:18:59 +0100
Subject: [PATCH 2/6] printf: added files from pptp, unchanged
Subject: [PATCH 02/19] printf: added files from pptp, unchanged
---
lib/diag-printf.c | 34 ++++++++++++++++++++++++++
lib/printf-mini.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+), 0 deletions(-)
2 files changed, 103 insertions(+)
create mode 100644 lib/diag-printf.c
create mode 100644 lib/printf-mini.c
......@@ -126,5 +126,5 @@ index 0000000..d68c848
+ return str - buf;
+}
--
1.7.7.2
1.7.9.5
From 3ebc7c415750ffcd7cf4241010027773609e6919 Mon Sep 17 00:00:00 2001
From dc2e9ac1fcca99e6c4924714f26cf85a87e3259c Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 10:37:27 +0100
Subject: [PATCH 3/6] printf: fixes and addition to makefile
Subject: [PATCH 03/19] printf: fixes and addition to makefile
---
include/pp_printf.h | 9 +++++++++
......@@ -78,5 +78,5 @@ index 2a46204..8810324 100644
#include "main.h"
#include "dbgu.h"
--
1.7.7.2
1.7.9.5
From 391890df3ca410003b51bf45a4b17a5a8e22a588 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Fri, 23 Mar 2012 13:42:57 +0100
Subject: [PATCH 04/19] version: add tmpconfig to ignore list
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index d78652e..a973a59 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,4 @@ binaries
*.o
tags
*.swp
+.tmpconfig*
--
1.7.9.5
From c28fc11363fb86c25b447817a6554874ad65f09a Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 28 Mar 2012 18:54:06 +0200
Subject: [PATCH 05/19] version: Improve tracking bin versions adding git
version in Makefile
---
.gitignore | 1 +
Makefile | 25 ++++++++++++++++++++++++-
main.c | 6 ++++++
3 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index a973a59..8b91fe5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ binaries
tags
*.swp
.tmpconfig*
+version.c
diff --git a/Makefile b/Makefile
index 6216632..c61ee3e 100644
--- a/Makefile
+++ b/Makefile
@@ -220,7 +220,7 @@ include driver/driver.mk
SRCS := $(COBJS-y:.o=.c)
-OBJS := $(SOBJS-y) $(COBJS-y)
+OBJS := $(SOBJS-y) $(COBJS-y) version.o
INCL=board/$(BOARD)
@@ -273,6 +273,29 @@ PHONY:=all gen_bin
all: PrintFlags gen_bin ChkFileSize
+## If not git is found
+ifeq ($(shell git status -s | grep -v "fatal*"),)
+version.c: $(SOBJS-y) $(COBJS-y)
+ @echo "/**" > $@
+ @echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
+ @echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
+ @echo "**/" >> $@
+ @echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
+ @echo "const char git_user[] = \"$(shell id -nu)\";" >> $@
+ @echo "const char git_revision[] = \"\";" >> $@
+ @echo "" >> $@
+else
+version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index
+ @echo "/**" > $@
+ @echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
+ @echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
+ @echo "**/" >> $@
+ @echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
+ @echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git rev-parse HEAD)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
+ @echo "" >> $@
+endif
+
PrintFlags:
@echo as FLAGS
@echo ========
diff --git a/main.c b/main.c
index 8810324..0ea1716 100644
--- a/main.c
+++ b/main.c
@@ -83,6 +83,10 @@ void Wait(unsigned int count)
/*------------------------------------------------------------------------------*/
int main(void)
{
+ extern const char build_time[];
+ extern const char git_user[];
+ extern const char git_revision[];
+
/*
* ================== 1st step: Hardware Initialization =================
*
@@ -92,6 +96,8 @@ int main(void)
hw_init();
#endif
+ pp_printf("Compiled by %s (%s)\r\ngit rev:%s\r\n\r\n",git_user,build_time,git_revision);
+
#ifdef CONFIG_USER_HW_INIT
user_hw_init();
#endif
--
1.7.9.5
From 4a94ffdd4e78d50d24669f2646b3648bc93a51c4 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 28 Mar 2012 19:19:46 +0200
Subject: [PATCH 06/19] leds: Correct FPGA LED problems, and add CPU LED
during booting
---
board/at91sam9g45ek/at91sam9g45ek.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/board/at91sam9g45ek/at91sam9g45ek.c b/board/at91sam9g45ek/at91sam9g45ek.c
index 8569231..83c2c29 100644
--- a/board/at91sam9g45ek/at91sam9g45ek.c
+++ b/board/at91sam9g45ek/at91sam9g45ek.c
@@ -80,6 +80,17 @@ void hw_init(void)
};
/*
+ * Configure LED GPIOs
+ */
+ const struct pio_desc led_gpio[] = {
+ {"D11", AT91C_PIN_PA(0), 0, PIO_OPENDRAIN, PIO_OUTPUT}, //Switch on D11 when booting start.
+ {"D12", AT91C_PIN_PA(1), 1, PIO_OPENDRAIN, PIO_OUTPUT}, //Setup D12 such to use when the programs end loading.
+ {"DDone", AT91C_PIN_PA(2), 0, PIO_DEFAULT, PIO_INPUT}, //Setup FPGA LED Done in read mode
+ {"DInit", AT91C_PIN_PA(3), 0, PIO_DEFAULT, PIO_INPUT} //Setup FPGA LED Init in read mode
+ };
+ pio_setup(led_gpio);
+
+ /*
* Disable watchdog
*/
writel(AT91C_WDTC_WDDIS, AT91C_BASE_WDTC + WDTC_WDMR);
--
1.7.9.5
From e5b1d890e842647f0a70af8381d5114a7ca8635d Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Mon, 19 Mar 2012 17:49:43 +0100
Subject: [PATCH 07/19] ddr: Fix ba offset bug and improve configuration
---
board/at91sam9g45ek/at91sam9g45ek.c | 34 ++++++++++++++++++----------------
driver/ddramc.c | 20 +++++++++++++-------
include/AT91SAM9G45_inc.h | 5 ++++-
include/DDR2_MT47H_inc.h | 35 +++++++++++++++++++++++++++++++++++
include/ddramc.h | 2 +-
5 files changed, 71 insertions(+), 25 deletions(-)
create mode 100644 include/DDR2_MT47H_inc.h
diff --git a/board/at91sam9g45ek/at91sam9g45ek.c b/board/at91sam9g45ek/at91sam9g45ek.c
index 83c2c29..e6b8f9c 100644
--- a/board/at91sam9g45ek/at91sam9g45ek.c
+++ b/board/at91sam9g45ek/at91sam9g45ek.c
@@ -151,7 +151,7 @@ void hw_init(void)
/*
* Configure DDRAM Controller
*/
- ddramc_hw_init();
+ ddramc_hw_init();
#endif /* CONFIG_DDR2 */
}
#endif /* CONFIG_HW_INIT */
@@ -163,36 +163,38 @@ static SDdramConfig ddram_config;
/* \fn ddramc_hw_init */
/* \brief This function performs DDRAMC HW initialization */
/*------------------------------------------------------------------------------*/
-void ddramc_hw_init(void)
+
+
+void ddramc_hw_init()
{
ddram_config.ddramc_mdr =
(AT91C_DDRC2_DBW_16_BITS | AT91C_DDRC2_MD_DDR2_SDRAM);
- ddram_config.ddramc_cr = (AT91C_DDRC2_NC_DDR10_SDR9 | // 10 column bits (1K)
- AT91C_DDRC2_NR_13 | // 13 row bits (8K)
+ ddram_config.ddramc_cr = (AT91C_DDRC2_NC_XX | // see include/DDR2_MT47H_inc.h
+ AT91C_DDRC2_NR_XX | // see include/DDR2_MT47H_inc.h
AT91C_DDRC2_CAS_3 | // CAS Latency 3
AT91C_DDRC2_DLL_RESET_DISABLED); // DLL not reset
ddram_config.ddramc_rtr = 0x24B;
- ddram_config.ddramc_t0pr = (AT91C_DDRC2_TRAS_6 | // 6 * 7.5 = 45 ns
- AT91C_DDRC2_TRCD_2 | // 2 * 7.5 = 22.5 ns
- AT91C_DDRC2_TWR_2 | // 2 * 7.5 = 15 ns
- AT91C_DDRC2_TRC_8 | // 8 * 7.5 = 75 ns
- AT91C_DDRC2_TRP_2 | // 2 * 7.5 = 22.5 ns
- AT91C_DDRC2_TRRD_1 | // 1 * 7.5 = 7.5 ns
- AT91C_DDRC2_TWTR_1 | // 1 clock cycle
- AT91C_DDRC2_TMRD_2); // 2 clock cycles
+ ddram_config.ddramc_t0pr = (AT91C_DDRC2_TRAS_6 | // 6 * 7.5 = 45 ns
+ AT91C_DDRC2_TRCD_2 | // 2 * 7.5 = 15 ns
+ AT91C_DDRC2_TWR_2 | // 2 * 7.5 = 15 ns
+ AT91C_DDRC2_TRC_8 | // 8 * 7.5 = 75 ns
+ AT91C_DDRC2_TRP_2 | // 2 * 7.5 = 22.5 ns
+ AT91C_DDRC2_TRRD_XX | // see include/DDR2_MT47H_inc.h
+ AT91C_DDRC2_TWTR_1 | // 1 clock cycle
+ AT91C_DDRC2_TMRD_2); // 2 clock cycles
ddram_config.ddramc_t1pr = (AT91C_DDRC2_TXP_2 | // 2 * 7.5 = 15 ns
200 << 16 | // 200 clock cycles, TXSRD: Exit self refresh delay to Read command
16 << 8 | // 16 * 7.5 = 120 ns TXSNR: Exit self refresh delay to non read command
AT91C_DDRC2_TRFC_14 << 0); // 14 * 7.5 = 142 ns (must be 140 ns for 1Gb DDR)
- ddram_config.ddramc_t2pr = (AT91C_DDRC2_TRTP_1 | // 1 * 7.5 = 7.5 ns
- AT91C_DDRC2_TRPA_0 | // 0 * 7.5 = 0 ns
- AT91C_DDRC2_TXARDS_7 | // 7 clock cycles
- AT91C_DDRC2_TXARD_2); // 2 clock cycles
+ ddram_config.ddramc_t2pr = (AT91C_DDRC2_TRTP_1 | // 1 * 7.5 = 7.5 ns
+ AT91C_DDRC2_TRPA_XX | // see include/DDR2_MT47H_inc.h
+ AT91C_DDRC2_TXARDS_XX | // see include/DDR2_MT47H_inc.h
+ AT91C_DDRC2_TXARD_2); // 2 clock cycles
// ENABLE DDR2 clock
writel(AT91C_PMC_DDR, AT91C_BASE_PMC + PMC_SCER);
diff --git a/driver/ddramc.c b/driver/ddramc.c
index e2824ff..f6fdfe8 100644
--- a/driver/ddramc.c
+++ b/driver/ddramc.c
@@ -75,10 +75,16 @@ int ddram_init(unsigned int ddram_controller_address,
ba_offset = (ddram_config->ddramc_cr & AT91C_DDRC2_NC) + 9; // number of column bits for DDR
if (ddram_decod_seq(ddram_config->ddramc_cr))
ba_offset += ((ddram_config->ddramc_cr & AT91C_DDRC2_NR) >> 2) + 11; // number of row bits
- ba_offset += (ddram_config->ddramc_mdr & AT91C_DDRC2_DBW) ? 1 : 2; // bus width
-
- dbg_log(3, " ba_offset = %x ... ", ba_offset);
-
+ ba_offset += (ddram_config->ddramc_mdr & AT91C_DDRC2_DBW) ? 1 : 2; // bus width
+
+ dbg_log(1,"DDR2 Config: %x (NC=%d, NR=%d, CAS=%d, ba_offset = %x)\n\r",
+ ddram_config->ddramc_cr ,
+ (ddram_config->ddramc_cr & AT91C_DDRC2_NC) + 9,
+ ((ddram_config->ddramc_cr & AT91C_DDRC2_NR) >> 2) + 11,
+ (ddram_config->ddramc_cr & AT91C_DDRC2_CAS) >> 4,
+ ba_offset
+ );
+
// Step 1: Program the memory device type
write_ddramc(ddram_controller_address, HDDRSDRC2_MDR,
ddram_config->ddramc_mdr);
@@ -126,7 +132,7 @@ int ddram_init(unsigned int ddram_controller_address,
write_ddramc(ddram_controller_address, HDDRSDRC2_MR,
AT91C_DDRC2_MODE_EXT_LMR_CMD);
/* Perform a write access to DDR address so that BA[1] is set to 1 and BA[0] is set to 0. */
- *((unsigned int *)(ddram_address + 0x4000000 /* (0x2 << ba_offset) */)) = 0;
+ *((unsigned int *)(ddram_address + (0x2 << ba_offset))) = 0;
// wait 2 cycles min (of tCK) = 15 ns min
Wait(2);
@@ -135,7 +141,7 @@ int ddram_init(unsigned int ddram_controller_address,
/* Perform a write access to DDR address so that BA[1] is set to 1 and BA[0] is set to 1. */
write_ddramc(ddram_controller_address, HDDRSDRC2_MR,
AT91C_DDRC2_MODE_EXT_LMR_CMD);
- *((unsigned int *)(ddram_address + 0x6000000 /* (0x3 << ba_offset) */)) = 0;
+ *((unsigned int *)(ddram_address + (0x3 << ba_offset))) = 0;
// wait 2 cycles min (of tCK) = 15 ns min
Wait(2);
@@ -144,7 +150,7 @@ int ddram_init(unsigned int ddram_controller_address,
/* Perform a write access to DDR address so that BA[1] is set to 0 and BA[0] is set to 1. */
write_ddramc(ddram_controller_address, HDDRSDRC2_MR,
AT91C_DDRC2_MODE_EXT_LMR_CMD);
- *((unsigned int *)(ddram_address + 0x2000000 /* (0x1 << ba_offset) */)) = 0;
+ *((unsigned int *)(ddram_address + (0x1 << ba_offset))) = 0;
// wait 200 cycles min (of tCK) = 1500 ns min
Wait(100);
diff --git a/include/AT91SAM9G45_inc.h b/include/AT91SAM9G45_inc.h
index a4a168f..a73fcd3 100644
--- a/include/AT91SAM9G45_inc.h
+++ b/include/AT91SAM9G45_inc.h
@@ -267,7 +267,7 @@
#define AT91C_DDRC2_NC_DDR10_SDR9 (0x1) // (HDDRSDRC2) DDR 10 Bits | SDR 9 Bits
#define AT91C_DDRC2_NC_DDR11_SDR10 (0x2) // (HDDRSDRC2) DDR 11 Bits | SDR 10 Bits
#define AT91C_DDRC2_NC_DDR12_SDR11 (0x3) // (HDDRSDRC2) DDR 12 Bits | SDR 11 Bits
-#define AT91C_DDRC2_NR AT91C_DDRC2_NR_13 // (HDDRSDRC2) Number of Row Bits
+#define AT91C_DDRC2_NR (0x3 << 2) // (HDDRSDRC2) Number of Row Bits (MASK)
#define AT91C_DDRC2_NR_11 (0x0 << 2) // (HDDRSDRC2) 11 Bits
#define AT91C_DDRC2_NR_12 (0x1 << 2) // (HDDRSDRC2) 12 Bits
#define AT91C_DDRC2_NR_13 (0x2 << 2) // (HDDRSDRC2) 13 Bits
@@ -6350,3 +6350,6 @@
#define BOARD_SD_MCI_ID_USE 0
#define CHIP_SRAM0_BASEADDR 0x300000
+
+//Hacks to include our DDR without modifying the whole board
+#include "DDR2_MT47H_inc.h"
\ No newline at end of file
diff --git a/include/DDR2_MT47H_inc.h b/include/DDR2_MT47H_inc.h
new file mode 100644
index 0000000..75b3af3
--- /dev/null
+++ b/include/DDR2_MT47H_inc.h
@@ -0,0 +1,35 @@
+/**
+* Small hacks to make the at91bootstrap works with our DDR memories
+*
+* Author: Benoit RAT
+*
+**/
+#ifndef WRS318V3
+#define WRS318V3 1 //Version 3.1
+
+#define MT47H32M16HR 0x025E
+#ifdef MT47H32M16HR
+ //Then define new value
+ #define AT91C_DDRC2_NC_XX AT91C_DDRC2_NC_DDR10_SDR9 // 10 column bits (1K)
+ #define AT91C_DDRC2_NR_XX AT91C_DDRC2_NR_13 // 13 row bits (8K)
+ #define AT91C_DDRC2_TRRD_XX AT91C_DDRC2_TRRD_2 // 2 * 7.5 > 10 ns
+
+ #if MT47H32M16HR == 0x025E //for -25E
+ #define AT91C_DDRC2_TRPA_XX AT91C_DDRC2_TRPA_2 // 2 * 7.5 = 15 ns
+ #define AT91C_DDRC2_TXARDS_XX AT91C_DDRC2_TXARDS_8 //
+ #endif
+
+ #if MT47H32M16HR == 0x0030 //for -3
+ #define AT91C_DDRC2_TRPA_XX AT91C_DDRC2_TRPA_3 // 3 * 7.5 = 22.5 ns
+ #define AT91C_DDRC2_TXARDS_XX AT91C_DDRC2_TXARDS_7 //
+ #endif
+#else //Original values for AT
+ #define AT91C_DDRC2_NC_XX AT91C_DDRC2_NC_DDR10_SDR9 // 10 column bits (1K)
+ #define AT91C_DDRC2_NR_XX AT91C_DDRC2_NR_13
+ #define AT91C_DDRC2_TRPA_XX AT91C_DDRC2_TRPA_0
+ #define AT91C_DDRC2_TXARDS_XX AT91C_DDRC2_TXARDS_7
+ #define AT91C_DDRC2_TRRD_XX AT91C_DDRC2_TRRD_1
+#endif
+
+
+#endif
\ No newline at end of file
diff --git a/include/ddramc.h b/include/ddramc.h
index 3e7a30a..527436f 100644
--- a/include/ddramc.h
+++ b/include/ddramc.h
@@ -45,6 +45,6 @@ typedef struct SDdramConfig {
extern int ddram_init(unsigned int ddram_controller_address,
unsigned int ddram_address,
struct SDdramConfig *ddram_config);
-extern void ddramc_hw_init(void);
+extern void ddramc_hw_init();
#endif /*SDRAMC_H_ */
--
1.7.9.5
From 3c96273023f759800c3cb3309ac1ef8a83fe7f04 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 10 Apr 2012 13:00:22 +0200
Subject: [PATCH 08/19] boot: disable watchdog asap
---
crt0_gnu.S | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/crt0_gnu.S b/crt0_gnu.S
index c00b717..0a9079b 100644
--- a/crt0_gnu.S
+++ b/crt0_gnu.S
@@ -105,6 +105,11 @@ _relocate_to_sram:
ldr pc, =_setup_clocks
#endif /* CONFIG_FLASH */
+ /* disable watchdog */
+ ldr r1, =0xFFFFFD44
+ mov r2, #0x00008000
+ str r2, [r1]
+
ldr r4, = lowlevel_clock_init
mov lr, pc
bx r4
--
1.7.9.5
From a6f38ea81c99fca8ad2c67b0b03d97c16fe97d94 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 10 Apr 2012 13:04:09 +0200
Subject: [PATCH 09/19] boot: added flip_leds(count) in assembler
---
crt0_gnu.S | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/crt0_gnu.S b/crt0_gnu.S
index 0a9079b..784c9ce 100644
--- a/crt0_gnu.S
+++ b/crt0_gnu.S
@@ -74,6 +74,35 @@ irq_vector:
b irq_vector
fiq_vector:
b fiq_vector
+
+/*
+ * First of all, write a procedure, that can be called from C or asm,
+ * to flip leds a number of times, after a small delay
+ */
+
+flip_leds: /* input: r0 is the count of flips */
+
+ /* a delay */
+ ldr r1, =200
+1: subs r1, r1, #1
+ bne 1b
+
+ ldr r1, =0xfffff200 /* PIOA */
+ mov r2, #3 /* bit 0 and 1: both leds */
+
+ str r2, [r1] /* enable */
+ str r2, [r1, #0x10] /* output enable */
+ cmp r0, #0
+ beq 2f
+0: str r2, [r1, #0x34] /* output clear (led on) */
+ str r2, [r1, #0x30] /* output set (led off) */
+ subs r0, r0, #1
+ bne 0b
+
+2: bx lr
+
+.ltorg
+
reset_vector:
/* Init the stack */
--
1.7.9.5
From b24256ae1eab66b12e361dc0e7873d081275ac24 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 10 Apr 2012 13:40:59 +0200
Subject: [PATCH 10/19] boot: Run a test pattern between clock configuration
---
crt0_gnu.S | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/crt0_gnu.S b/crt0_gnu.S
index 784c9ce..bc54989 100644
--- a/crt0_gnu.S
+++ b/crt0_gnu.S
@@ -79,7 +79,6 @@ fiq_vector:
* First of all, write a procedure, that can be called from C or asm,
* to flip leds a number of times, after a small delay
*/
-
flip_leds: /* input: r0 is the count of flips */
/* a delay */
@@ -139,10 +138,20 @@ _relocate_to_sram:
mov r2, #0x00008000
str r2, [r1]
+ /* test 4x the flip_leds procedure */
+ mov r0, #0x4
+ bl flip_leds
+
+ /* Call the lowlevel clock init function in ./driver/pmc.c */
ldr r4, = lowlevel_clock_init
mov lr, pc
bx r4
+ /* test 8x the flip_leds procedure */
+ mov r0, #0x8
+ bl flip_leds
+
+
#if 0
_setup_clocks:
/* Test if main oscillator is enabled */
--
1.7.9.5
From 00b15b66a2bde319a0e4ba592a26f921d542cfca Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 11 Apr 2012 17:25:28 +0200
Subject: [PATCH 11/19] boot: Correct crash due to an Atmel bug during boot
when PLL clock is already used as master clock
---
driver/pmc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/driver/pmc.c b/driver/pmc.c
index 1a09b9c..189d1c9 100644
--- a/driver/pmc.c
+++ b/driver/pmc.c
@@ -96,7 +96,7 @@ void lowlevel_clock_init()
/*
* After stablization, switch to 12MHz Main Oscillator
*/
- if ((read_pmc(PMC_MCKR) & AT91C_PMC_CSS) != AT91C_PMC_CSS_SLOW_CLK) {
+ if ((read_pmc(PMC_MCKR) & AT91C_PMC_CSS) == AT91C_PMC_CSS_SLOW_CLK) {
write_pmc(PMC_MCKR, AT91C_PMC_CSS_MAIN_CLK | AT91C_PMC_PRES_CLK);
while (!(read_pmc(PMC_SR) & AT91C_PMC_MCKRDY))
;
--
1.7.9.5
From 8083ba2049c07ce9f939819ce3016912d256019f Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Wed, 11 Apr 2012 17:25:28 +0200
Subject: [PATCH 12/19] Improve makefile to only take the gitversion of
current directory
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index c61ee3e..fd7f16e 100644
--- a/Makefile
+++ b/Makefile
@@ -292,7 +292,7 @@ version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index
@echo "**/" >> $@
@echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
@echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
- @echo "const char git_revision[] = \"$(shell git rev-parse HEAD)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
@echo "" >> $@
endif
--
1.7.9.5
From eaa9bd4511b69b6097726b68957fa7da5a44323f Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Fri, 11 May 2012 12:36:25 +0200
Subject: [PATCH 13/19] add simple script to compile for DF and NF
---
build.sh | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100755 build.sh
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..a9711d9
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+showhelp()
+{
+ echo "Usage: $0 [options]"
+ echo "options:"
+ echo " --help: show this little help"
+ echo " --df: compile only for dataflash"
+ echo " --nf: compile only for nandflash"
+}
+
+
+
+case "$1" in
+ --help) showhelp;;
+ --nf) yes "" | make at91sam9g45nf_defconfig > /dev/null; make;;
+ --df) yes "" | make at91sam9g45df_defconfig > /dev/null; make;;
+ *) yes "" | make at91sam9g45df_defconfig > /dev/null; make; yes "" | make at91sam9g45nf_defconfig > /dev/null; make;;
+esac
+
+
--
1.7.9.5
From 5006567aeb801664a861ffe05337943c89dcae60 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Fri, 11 May 2012 12:48:13 +0200
Subject: [PATCH 14/19] Correct a bug in makefile
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index fd7f16e..88dfffc 100644
--- a/Makefile
+++ b/Makefile
@@ -285,14 +285,14 @@ version.c: $(SOBJS-y) $(COBJS-y)
@echo "const char git_revision[] = \"\";" >> $@
@echo "" >> $@
else
-version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index
+version.c: $(SOBJS-y) $(COBJS-y) .git/HEAD .git/index Makefile
@echo "/**" > $@
@echo " * File automatically generated by Makefile (DO NOT MODIFIED)\n *\n * To use this you in a c code just add the following lines:\n * " >> $@
@echo "\textern const char build_time[];\n\textern const char git_user[];\n\textren const char git_revision[];\n * " >> $@
@echo "**/" >> $@
@echo 'const char build_time[] = __DATE__ " @ " __TIME__ ;' >> $@
@echo "const char git_user[] = \"$(shell git config --get user.name)\";" >> $@
- @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; fi;)\";" >> $@
+ @echo "const char git_revision[] = \"$(shell git log --abbrev-commit --pretty=oneline -1 . | cut -d" " -f1)$(shell if git status -s > /dev/null; then echo '+'; else echo ''; fi;)\";" >> $@
@echo "" >> $@
endif
--
1.7.9.5
From 425ef2fa1550b9e480167f8b125adb897f281798 Mon Sep 17 00:00:00 2001
From 80b81d783772a87000356f126cb47dc429a95f3d Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 10:42:17 +0100
Subject: [PATCH 4/6] memtest.c: copied from barebox (our version)
Subject: [PATCH 15/19] memtest: copied from barebox (our version)
---
lib/memtest.c | 355 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 355 insertions(+), 0 deletions(-)
1 file changed, 355 insertions(+)
create mode 100644 lib/memtest.c
diff --git a/lib/memtest.c b/lib/memtest.c
......@@ -370,5 +370,5 @@ index 0000000..d9c8b3d
+BAREBOX_CMD_END
+
--
1.7.7.2
1.7.9.5
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment