Commit cabe6e89 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

Merge branch 'v3-sevensols' into v3-rc1

parents 8dfc70a1 5ca6e20c
......@@ -7,3 +7,6 @@
modules.order
.tmp_versions
Module.symvers
.cproject
.project
.settings
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 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
From 74e27efd703fbafab08c28c7f7d0eb1aaae7db8e Mon Sep 17 00:00:00 2001
From fa3b681d37c9787473f4ed8fc33205471696db8d Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 11:38:53 +0100
Subject: [PATCH 5/6] memtest: fix it and add to makefile
Subject: [PATCH 16/19] memtest: fix it and add to makefile
---
lib/libc.mk | 1 +
lib/memtest.c | 85 +++++++++++++++++++++++---------------------------------
lib/memtest.c | 85 ++++++++++++++++++++++++---------------------------------
2 files changed, 36 insertions(+), 50 deletions(-)
diff --git a/lib/libc.mk b/lib/libc.mk
......@@ -191,5 +191,5 @@ index d9c8b3d..52542c9 100644
-BAREBOX_CMD_END
-
--
1.7.7.2
1.7.9.5
From cf60a3a806e75315e39610d40607d76efcc5816c Mon Sep 17 00:00:00 2001
From 5f895df9f30230375cbbf2320a7c8af00d852fc2 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Tue, 6 Mar 2012 11:39:13 +0100
Subject: [PATCH 6/6] main: call memtest
Subject: [PATCH 17/19] main: call memtest
---
main.c | 92 +++-------------------------------------------------------------
1 files changed, 4 insertions(+), 88 deletions(-)
main.c | 93 ++++------------------------------------------------------------
1 file changed, 5 insertions(+), 88 deletions(-)
diff --git a/main.c b/main.c
index 8810324..e4a6956 100644
index 0ea1716..60f3fe7 100644
--- a/main.c
+++ b/main.c
@@ -83,6 +83,7 @@ void Wait(unsigned int count)
/*------------------------------------------------------------------------------*/
int main(void)
{
+ extern void mem_test(unsigned long ini, unsigned long end);
@@ -86,6 +86,8 @@ int main(void)
extern const char build_time[];
extern const char git_user[];
extern const char git_revision[];
+
+ extern void mem_test(unsigned long ini, unsigned long end);
/*
* ================== 1st step: Hardware Initialization =================
*
@@ -101,92 +102,7 @@ int main(void)
@@ -107,92 +109,7 @@ int main(void)
load_1wire_info();
#endif
......@@ -116,5 +117,5 @@ index 8810324..e4a6956 100644
+ return 0; /* not reached */
}
--
1.7.7.2
1.7.9.5
From 78f344309e4fa491efd1240f481d15c00f6d47b2 Mon Sep 17 00:00:00 2001
From: Benoit Rat <benoit@sevensols.com>
Date: Mon, 2 Apr 2012 15:43:17 +0200
Subject: [PATCH 19/19] memtest: Add CPU LED switching to memtest
---
lib/memtest.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/lib/memtest.c b/lib/memtest.c
index 4366171..20c5e45 100644
--- a/lib/memtest.c
+++ b/lib/memtest.c
@@ -26,6 +26,7 @@
#include <pp_printf.h>
#include <dbgu.h>
#include <debug.h>
+#include <gpio.h>
//#include <stdlib.h>
/* BEGIN HACKS - to compile barebox code out of barebox */
@@ -120,6 +121,8 @@ int mem_test_integrity(ulong _start, ulong _end, ulong pattern)
//Increment actual read value and decrement write value.
val += incr;
val_next -= incr;
+
+ if((*addr % (1024*100)) == 0) pio_set_value(AT91C_PIN_PA(0),*addr % (2048*100)); //Blinking light while testing
}
printf("\tOK\r\n");
@@ -401,6 +404,10 @@ int mem_test(ulong _start, ulong _end, ulong pattern_unused)
printf ("OK: bus line, address line and integrity are OK\n\r\n\r");
printf ("Now it will continue to check integrity with various patterns. (Ctrl+C to exit)...\n\r");
+ pio_set_value(AT91C_PIN_PA(0),1);
+ pio_set_value(AT91C_PIN_PA(1),0);
+
+
return mem_test_integrity(_start,_end,pattern_unused);
}
--
1.7.9.5
G45 memtest
============
The test is inspired from the one in barebox
It has been improved[^1] and now check:
* Data lines
* Address lines
* Memory integrity
* holding counters
* holding anti-counters
* Random patterns
You can find the source on my github: https://github.com/neub/wrs-sw-at91bootstrap/tree/memtest
[^1]: http://www.barrgroup.com/Embedded-Systems/How-To/Memory-Test-Suite-C
version.c
mch_flasher
samba_applets/isp-project/*/bin/
OBJS=mch_flasher.o serial_linux.o version.o
OUTPUT=mch_flasher
OBJS = mch_flasher.o serial_linux.o
FLASHER = mch_flasher
all: $(OBJS)
${CC} -o $(OUTPUT) $(OBJS)
all: $(FLASHER)
$(FLASHER): $(OBJS)
${CC} -o $@ $(OBJS)
version.c: ../.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)\";" >> $@
echo "" >> $@
clean:
rm -f $(OBJS) $(FLASHER) *~
rm -f version.c $(OBJS) $(OUTPUT):q:q
This diff is collapsed.
......@@ -38,6 +38,7 @@
#include <board.h>
#include <pio/pio.h>
#include "board_memories.h"
#include <utility/trace.h>
/*
Macros:
......@@ -49,6 +50,12 @@
#define READ(peripheral, register) (peripheral->register)
#define WRITE(peripheral, register, value) (peripheral->register = value)
//------------------------------------------------------------------------------
// External definitions
//------------------------------------------------------------------------------
#ifndef AT91C_DDRC2_NR_XX
#define AT91C_DDRC2_NR_XX AT91C_DDRC2_NR_13 /*This value should be 13 for WRS3-18*/
#endif
//------------------------------------------------------------------------------
// Internal functions
......@@ -78,20 +85,20 @@ void BOARD_RemapRam()
}
void BOARD_ConfigureVddMemSel(unsigned char VddMemSel)
{
if (VddMemSel == VDDMEMSEL_3V3) {
AT91C_BASE_MATRIX->MATRIX_EBICSA |= (1 << 16);
AT91C_BASE_MATRIX->MATRIX_EBICSA &= ~(1 << 17);
}
else {
AT91C_BASE_MATRIX->MATRIX_EBICSA &= ~(1 << 16);
AT91C_BASE_MATRIX->MATRIX_EBICSA &= ~(1 << 17);
}
}
void BOARD_ConfigureVddMemSel(unsigned char VddMemSel)
{
if (VddMemSel == VDDMEMSEL_3V3) {
AT91C_BASE_MATRIX->MATRIX_EBICSA |= (1 << 16);
AT91C_BASE_MATRIX->MATRIX_EBICSA &= ~(1 << 17);
}
else {
AT91C_BASE_MATRIX->MATRIX_EBICSA &= ~(1 << 16);
AT91C_BASE_MATRIX->MATRIX_EBICSA &= ~(1 << 17);
}
}
//------------------------------------------------------------------------------
/// Configure DDR
//------------------------------------------------------------------------------
......@@ -102,6 +109,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
int i;
volatile unsigned int cr = 0;
unsigned short ddrc_dbw = 0;
unsigned int ba_offset;
switch (busWidth) {
case 16:
......@@ -114,6 +122,9 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
break;
}
// Enable DDR2 clock x2 in PMC
WRITE(AT91C_BASE_PMC, PMC_SCER, AT91C_PMC_DDR);
......@@ -135,11 +146,28 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
// 4. Program the features of DDR2-SDRAM device into the Timing Register HDDRSDRC2_T2PR.
WRITE(pDdrc, HDDRSDRC2_CR, AT91C_DDRC2_NC_DDR10_SDR9 | // 10 column bits (1K)
AT91C_DDRC2_NR_14 | // 14 row bits (8K)
AT91C_DDRC2_NR_XX | // 13 row bits (8K)
AT91C_DDRC2_CAS_3 | // CAS Latency 3
AT91C_DDRC2_DLL_RESET_DISABLED
); // DLL not reset
/* compute BA[] offset according to CR configuration */
ba_offset = (READ(pDdrc, HDDRSDRC2_CR) & AT91C_DDRC2_NC) + 9; // number of column bits for DDR
ba_offset += ((READ(pDdrc, HDDRSDRC2_CR) & AT91C_DDRC2_NR) >> 2) + 11; // number of row bits
ba_offset += (ddrc_dbw & AT91C_DDRC2_DBW) ? 1 : 2; // bus width
TRACE_INFO("\tDDR2 Config: 0x%x (NC=%d, NR=%d, CAS=%d, ba_offset=%d) \n\r",
(READ(pDdrc, HDDRSDRC2_CR)),
(READ(pDdrc, HDDRSDRC2_CR) & AT91C_DDRC2_NC) + 9,
((READ(pDdrc, HDDRSDRC2_CR) & AT91C_DDRC2_NR) >> 2) + 11,
(READ(pDdrc, HDDRSDRC2_CR) & AT91C_DDRC2_CAS) >> 4,
ba_offset);
// assume timings for 7.5ns min clock period
WRITE(pDdrc, HDDRSDRC2_T0PR, AT91C_DDRC2_TRAS_6 | // 6 * 7.5 = 45 ns
AT91C_DDRC2_TRCD_2 | // 2 * 7.5 = 15 ns
......@@ -189,7 +217,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
// Step 6: An Extended Mode Register set (EMRS2) cycle is issued to chose between commercialor high temperature operations.
WRITE(pDdrc, HDDRSDRC2_MR, AT91C_DDRC2_MODE_EXT_LMR_CMD);
*((unsigned int *)((unsigned char *)pDdr + 0x4000000)) = 0;
*((unsigned int *)((unsigned char *)pDdr + (0x2 << ba_offset))) = 0;
// wait 2 cycles min
for (i = 0; i < 100; i++) {
......@@ -198,7 +226,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
// Step 7: An Extended Mode Register set (EMRS3) cycle is issued to set all registers to 0.
WRITE(pDdrc, HDDRSDRC2_MR, AT91C_DDRC2_MODE_EXT_LMR_CMD);
*((unsigned int *)((unsigned char *)pDdr + 0x6000000)) = 0;
*((unsigned int *)((unsigned char *)pDdr + (0x3 << ba_offset))) = 0;
// wait 2 cycles min
for (i = 0; i < 100; i++) {
......@@ -207,7 +235,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
// Step 8: An Extended Mode Register set (EMRS1) cycle is issued to enable DLL.
WRITE(pDdrc, HDDRSDRC2_MR, AT91C_DDRC2_MODE_EXT_LMR_CMD);
*((unsigned int *)((unsigned char *)pDdr + 0x2000000)) = 0;
*((unsigned int *)((unsigned char *)pDdr + (0x1 << ba_offset))) = 0;
// wait 200 cycles min
for (i = 0; i < 10000; i++) {
......@@ -267,7 +295,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
// Step 16: An Extended Mode Register set (EMRS1) cycle is issued to OCD default value.
WRITE(pDdrc, HDDRSDRC2_MR, AT91C_DDRC2_MODE_EXT_LMR_CMD);
*((unsigned int *)((unsigned char *)pDdr + 0x2000000)) = 0;
*((unsigned int *)((unsigned char *)pDdr + (0x1 << ba_offset))) = 0;
// wait 2 cycles min
for (i = 0; i < 100; i++) {
......@@ -280,7 +308,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
// Step 18: An Extended Mode Register set (EMRS1) cycle is issued to enable OCD exit.
WRITE(pDdrc, HDDRSDRC2_MR, AT91C_DDRC2_MODE_EXT_LMR_CMD);
*((unsigned int *)((unsigned char *)pDdr + 0x6000000)) = 0;
*((unsigned int *)((unsigned char *)pDdr + (0x1 << ba_offset))) = 0;
// wait 2 cycles min
for (i = 0; i < 100; i++) {
......@@ -292,7 +320,7 @@ void BOARD_ConfigureDdram(unsigned char ddrModel, unsigned char busWidth)
*(pDdr) = 0;
// Step 21: Write the refresh rate into the count field in the Refresh Timer register. The DDR2-SDRAM device requires a
// refresh every 15.625 ¦Ìs or 7.81 ¦Ìs. With a 100MHz frequency, the refresh timer count register must to be set with
// refresh every 15.625 ns or 7.81 ns. With a 100MHz frequency, the refresh timer count register must to be set with
// (15.625 /100 MHz) = 1562 i.e. 0x061A or (7.81 /100MHz) = 781 i.e. 0x030d.
// Set Refresh timer
......@@ -520,6 +548,22 @@ void BOARD_ConfigureSdram(unsigned char busWidth)
//------------------------------------------------------------------------------
void BOARD_ConfigureNandFlash(unsigned char busWidth)
{
AT91C_BASE_MATRIX->MATRIX_EBICSA |= AT91C_EBI_CS3A_SM;
// Configure SMC
AT91C_BASE_SMC->SMC_SETUP3 = 0x00020002;
AT91C_BASE_SMC->SMC_PULSE3 = 0x04040404;
AT91C_BASE_SMC->SMC_CYCLE3 = 0x00070007;
AT91C_BASE_SMC->SMC_CTRL3 = 0x00030003;
if (busWidth == 8) {
AT91C_BASE_SMC->SMC_CTRL3 |= AT91C_SMC_DBW_WIDTH_EIGTH_BITS;
}
else if (busWidth == 16) {
AT91C_BASE_SMC->SMC_CTRL3 |= AT91C_SMC_DBW_WIDTH_SIXTEEN_BITS;
}
}
//------------------------------------------------------------------------------
......
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \page "EccNandFlash"
///
/// !!!Purpose
///
/// EccNandFlash layer is called by SkipBlockNandFlash driver, it will call the bl driver (RawNandFlash)
/// to do write/read operations, and do ECC check to the write/read result, it then will feedback the
/// ecc check result to the upper SkipBlockNandFlash layer driver.
///
/// !!!Usage
///
/// -# EccNandFlash_Initialize is used to initializes an EccNandFlash instance.
/// -# EccNandFlash_WritePage is used to write a Nandflash page with ecc result, the function
/// will calculate ecc for the data that is going to be written, and write data and spare(with
/// calculated ecc) to Nandflash device.
/// -# EccNandFlash_ReadPage is uese to read a Nandflash page with ecc check, the function
/// will read out data and spare first, then it calculates ecc with data and then compare with
/// the readout ecc, and feedback the ecc check result to dl driver.
//------------------------------------------------------------------------------
#ifndef ECCNANDFLASH_H
#define ECCNANDFLASH_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "RawNandFlash.h"
#include <board.h>
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
struct EccNandFlash {
struct RawNandFlash raw;
};
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char EccNandFlash_Initialize(
struct EccNandFlash *ecc,
const struct NandFlashModel *model,
unsigned int commandAddress,
unsigned int addressAddress,
unsigned int dataAddress,
const Pin pinChipEnable,
const Pin pinReadyBusy);
extern unsigned char EccNandFlash_ReadPage(
const struct EccNandFlash *ecc,
unsigned short block,
unsigned short page,
void *data,
void *spare);
extern unsigned char EccNandFlash_WritePage(
const struct EccNandFlash *ecc,
unsigned short block,
unsigned short page,
void *data,
void *spare);
extern void EccNandlfash_SetNoECC(void);
extern void EccNandlfash_ClearNoECC(void);
extern unsigned char EccNandlfash_GetNoECC(void);
#endif //#ifndef ECCNANDFLASH_H
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \page "ManagedNandFlash"
///
/// !!!Purpose
///
/// The lower layer of nandflash block management, it is called by MappedNandFlash layer, and
/// it will call EccNandFlash layer.
//------------------------------------------------------------------------------
#ifndef MANAGEDNANDFLASH_H
#define MANAGEDNANDFLASH_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "NandCommon.h"
#include "EccNandFlash.h"
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
#define NandBlockStatus_DEFAULT 0xF
#define NandBlockStatus_FREE 0xE
#define NandBlockStatus_LIVE 0xC
#define NandBlockStatus_DIRTY 0x8
#define NandBlockStatus_BAD 0x0
#define NandEraseDIRTY 0 // Erase dirty blocks only
#define NandEraseDATA 1 // Erase all data, calculate count
#define NandEraseFULL 2 // Erase all, reset erase count
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
struct NandBlockStatus {
unsigned int status:4,
eraseCount:28;
};
struct ManagedNandFlash {
struct EccNandFlash ecc;
struct NandBlockStatus blockStatuses[NandCommon_MAXNUMBLOCKS];
unsigned short baseBlock;
unsigned short sizeInBlocks;
};
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char ManagedNandFlash_Initialize(
struct ManagedNandFlash *managed,
const struct NandFlashModel *model,
unsigned int commandAddress,
unsigned int addressAddress,
unsigned int dataAddress,
const Pin pinChipEnable,
const Pin pinReadyBusy,
unsigned short baseBlock,
unsigned short sizeInBlocks);
extern unsigned char ManagedNandFlash_AllocateBlock(
struct ManagedNandFlash *managed,
unsigned short block);
extern unsigned char ManagedNandFlash_ReleaseBlock(
struct ManagedNandFlash *managed,
unsigned short block);
extern unsigned char ManagedNandFlash_EraseBlock(
struct ManagedNandFlash *managed,
unsigned short block);
extern unsigned char ManagedNandFlash_ReadPage(
const struct ManagedNandFlash *managed,
unsigned short block,
unsigned short page,
void *data,
void *spare);
extern unsigned char ManagedNandFlash_WritePage(
const struct ManagedNandFlash *managed,
unsigned short block,
unsigned short page,
void *data,
void *spare);
extern unsigned char ManagedNandFlash_CopyPage(
const struct ManagedNandFlash *managed,
unsigned short sourceBlock,
unsigned short sourcePage,
unsigned short destBlock,
unsigned short destPage);
extern unsigned char ManagedNandFlash_CopyBlock(
const struct ManagedNandFlash *managed,
unsigned short sourceBlock,
unsigned short destBlock);
extern unsigned char ManagedNandFlash_EraseDirtyBlocks(
struct ManagedNandFlash *managed);
extern unsigned char ManagedNandFlash_FindYoungestBlock(
const struct ManagedNandFlash *managed,
unsigned char status,
unsigned short *block);
extern unsigned short ManagedNandFlash_CountBlocks(
const struct ManagedNandFlash *managed,
unsigned char status);
extern unsigned short ManagedNandFlash_GetDeviceSizeInBlocks(
const struct ManagedNandFlash *managed);
extern unsigned char ManagedNandFlash_EraseAll(
struct ManagedNandFlash *managed,
unsigned char level);
#endif //#ifndef MANAGEDNANDFLASH_H
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \page "MappedNandFlash"
///
/// !!!Purpose
///
/// MappedNandFlash layer will do operations on logical blocks of nandflash, it is called by
/// TranslatedNandFlash layer
//------------------------------------------------------------------------------
#ifndef MAPPEDNANDFLASH_H
#define MAPPEDNANDFLASH_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "ManagedNandFlash.h"
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
struct MappedNandFlash {
struct ManagedNandFlash managed;
signed short logicalMapping[NandCommon_MAXNUMBLOCKS];
signed short logicalMappingBlock;
unsigned char mappingModified;
unsigned char reserved;
};
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char MappedNandFlash_Initialize(
struct MappedNandFlash *mapped,
const struct NandFlashModel *model,
unsigned int commandAddress,
unsigned int addressAddress,
unsigned int dataAddress,
const Pin pinChipEnable,
const Pin pinReadyBusy,
unsigned short baseBlock,
unsigned short sizeInBlocks);
extern unsigned char MappedNandFlash_ReadPage(
const struct MappedNandFlash *mapped,
unsigned short block,
unsigned short page,
void *data,
void *spare);
extern unsigned char MappedNandFlash_WritePage(
const struct MappedNandFlash *mapped,
unsigned short block,
unsigned short page,
void *data,
void *spare);
extern unsigned char MappedNandFlash_Map(
struct MappedNandFlash *mapped,
unsigned short logicalBlock,
unsigned short physicalBlock);
extern unsigned char MappedNandFlash_Unmap(
struct MappedNandFlash *mapped,
unsigned short logicalBlock);
extern signed short MappedNandFlash_LogicalToPhysical(
const struct MappedNandFlash *mapped,
unsigned short logicalBlock);
extern signed short MappedNandFlash_PhysicalToLogical(
const struct MappedNandFlash *mapped,
unsigned short physicalBlock);
extern unsigned char MappedNandFlash_SaveLogicalMapping(
struct MappedNandFlash *mapped,
unsigned short physicalBlock);
extern unsigned char MappedNandFlash_EraseAll(
struct MappedNandFlash *mapped,
unsigned char level);
#endif //#ifndef MAPPEDNANDFLASH_H
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
#ifndef NANDCOMMON_H
#define NANDCOMMON_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
#if defined(at91sam3u1) || defined(at91sam3u2) || defined(at91sam7se32)
#define NF_MAXPAGESIZE_SUPPORT_2K
#endif
//------------------------------------------------------------------------------
/// \page "NandFlash Maximum Supported Values"
/// Since no memory allocation is available, limits have been set on various
/// characteristics of a NandFlash chip:
///
/// !Maximums
/// - NandCommon_MAXNUMBLOCKS
/// - NandCommon_MAXNUMPAGESPERBLOCK
/// - NandCommon_MAXPAGESIZE
/// Maximum number of blocks in a device
#define NandCommon_MAXNUMBLOCKS 1024 //2048
/// Maximum number of pages in one block
#define NandCommon_MAXNUMPAGESPERBLOCK 256 //64
/// Maximum size of the data area of one page, in bytes.
#if !defined(NF_MAXPAGESIZE_SUPPORT_2K)
#define NandCommon_MAXPAGEDATASIZE 4096 //2048
#else
#define NandCommon_MAXPAGEDATASIZE 2048
#endif
/// Maximum size of the spare area of one page, in bytes.
#define NandCommon_MAXPAGESPARESIZE 128 //64
/// Maximum number of ecc bytes stored in the spare for one single page.
#define NandCommon_MAXSPAREECCBYTES 48 //24
/// Maximum number of extra free bytes inside the spare area of a page.
#define NandCommon_MAXSPAREEXTRABYTES 78 //38
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "NandFlash Error Codes"
/// NandFlash API methods return either 0 (indicating that there was no error),
/// or one of the following error codes:
///
/// !Codes
/// - NandCommon_ERROR_NOMOREBLOCKS
/// - NandCommon_ERROR_BLOCKNOTMAPPED
/// - NandCommon_ERROR_OUTOFBOUNDS
/// - NandCommon_ERROR_MAPPINGNOTFOUND
/// - NandCommon_ERROR_CANNOTREAD
/// No more blocks can be allocated for a write operation.
#define NandCommon_ERROR_NOMOREBLOCKS 1
/// The desired logical block has no current physical mapping.
#define NandCommon_ERROR_BLOCKNOTMAPPED 2
/// Access if out-of-bounds.
#define NandCommon_ERROR_OUTOFBOUNDS 3
/// There are no block having the desired property.
#define NandCommon_ERROR_NOBLOCKFOUND 4
/// The nandflash device has no logical mapping information on it.
#define NandCommon_ERROR_MAPPINGNOTFOUND 5
/// A read operation cannot be carried out.
#define NandCommon_ERROR_CANNOTREAD 6
/// A write operation cannot be carried out.
#define NandCommon_ERROR_CANNOTWRITE 7
/// NandFlash chip model cannot be recognized.
#define NandCommon_ERROR_UNKNOWNMODEL 8
/// Page data is corrupted according to ECC
#define NandCommon_ERROR_CORRUPTEDDATA 9
/// Block is not in the required status.
#define NandCommon_ERROR_WRONGSTATUS 10
/// Device has no logical mapping stored in it
#define NandCommon_ERROR_NOMAPPING 11
/// The block being accessed is bad and must be replaced
#define NandCommon_ERROR_BADBLOCK 12
/// Failed to perform an erase operation
#define NandCommon_ERROR_CANNOTERASE 13
/// A hardware copyback operation failed.
#define NandCommon_ERROR_CANNOTCOPY 14
/// HW Ecc Not compatible with the Nand Model
#define NandCommon_ERROR_ECC_NOT_COMPATIBLE 15
//------------------------------------------------------------------------------
#endif //#ifndef NANDCOMMON_H
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
///
/// !!!Purpose
///
/// This directory contains nandflash drivers
///
/// !!!Description
/// - Nandflash drivers: SkipBlockNandFlash layer, EccNandFlash and NandSpareScheme layer,
/// RawNandflash layer.
/// - Nandflash parameter interface : NandFlashModel.
/// - Supported Nandflash device list : NandFlashModelList.
/// - Nandflash block management drivers : TranslatedNandFlash layer, MappedNandFlash layer,
/// ManagedNandFlash layer.
//------------------------------------------------------------------------------
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
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