This is something before 0.2.6 from SVN (which does not exist anymore)
This commit is contained in:
parent
f041330b60
commit
68e3e60100
36
ChangeLog
36
ChangeLog
|
@ -1,6 +1,36 @@
|
|||
|
||||
2009-03-20 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Removed DSP power application for Mini-DAS
|
||||
|
||||
2009-03-09 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Enabled ASP pinmux for SFFSDR to fix audio
|
||||
playback and recording bug
|
||||
|
||||
2009-02-25 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Simplified gpio functions.
|
||||
* Allocate DDR memory for uart rx and inflate buffers
|
||||
semi-dynamically based on free DDR memory.
|
||||
* Configure pinmux based on board
|
||||
|
||||
2009-02-23 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Fixed problem with DM644x and large page NAND devices
|
||||
|
||||
2009-02-23 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Added linkerscript to dependency list for all objects.
|
||||
* Fixed problem for gunzip() caused by too much stack usage
|
||||
|
||||
2009-02-22 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Added automatic dependencies generation for Makefile
|
||||
|
||||
2009-02-21 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Fixed NAND layout problem in big block devices for DM35x RBL
|
||||
|
||||
2009-02-20 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Removed static CRC table
|
||||
* Added GZIP support and CRC checking for UBL
|
||||
|
||||
2009-02-16 Hugo Villeneuve <hugo@hugovil.com>
|
||||
* Added DDR test command line option
|
||||
|
||||
2008-12-03 Hugo Villeneuve <hugo@hugovil.com>
|
||||
|
||||
* First version.
|
||||
|
||||
|
||||
|
|
11
Makefile.am
11
Makefile.am
|
@ -4,8 +4,7 @@ AUTOMAKE_OPTIONS = gnu
|
|||
|
||||
SUBDIRS = doc src
|
||||
|
||||
EXTRA_DIST = \
|
||||
autogen.sh
|
||||
EXTRA_DIST = autogen.sh ubl
|
||||
|
||||
ACLOCAL = aclocal -I $(ac_aux_dir)
|
||||
|
||||
|
@ -18,3 +17,11 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \
|
|||
$(ac_aux_dir)/install-sh $(ac_aux_dir)/missing \
|
||||
$(ac_aux_dir)/mkinstalldirs $(ac_aux_dir)/config.guess \
|
||||
$(ac_aux_dir)/config.sub $(ac_aux_dir)/ltmain.sh
|
||||
|
||||
dist-hook:
|
||||
rm -rf $$(find $(distdir)/ubl -name config.h)
|
||||
rm -rf $$(find $(distdir)/ubl -name \*.o)
|
||||
rm -rf $$(find $(distdir)/ubl -name .svn)
|
||||
rm -rf $$(find $(distdir)/ubl -name .deps)
|
||||
rm -rf $$(find $(distdir)/ubl -name ubl.map)
|
||||
rm -rf $$(find $(distdir)/ubl -name ubl.elf)
|
||||
|
|
205
Makefile.in
205
Makefile.in
|
@ -1,8 +1,9 @@
|
|||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -15,8 +16,9 @@
|
|||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
|
@ -43,6 +45,7 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
|||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
||||
|
@ -54,6 +57,9 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
|||
ps-recursive uninstall-recursive
|
||||
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
distclean-recursive maintainer-clean-recursive
|
||||
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
|
||||
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
|
||||
distdir dist dist-all distcheck
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
|
@ -61,9 +67,34 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
|||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
{ test ! -d $(distdir) \
|
||||
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -fr $(distdir); }; }
|
||||
{ test ! -d "$(distdir)" \
|
||||
|| { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -fr "$(distdir)"; }; }
|
||||
am__relativize = \
|
||||
dir0=`pwd`; \
|
||||
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
|
||||
sed_rest='s,^[^/]*/*,,'; \
|
||||
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
|
||||
sed_butlast='s,/*[^/]*$$,,'; \
|
||||
while test -n "$$dir1"; do \
|
||||
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
|
||||
if test "$$first" != "."; then \
|
||||
if test "$$first" = ".."; then \
|
||||
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
|
||||
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
|
||||
else \
|
||||
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
|
||||
if test "$$first2" = "$$first"; then \
|
||||
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
|
||||
else \
|
||||
dir2="../$$dir2"; \
|
||||
fi; \
|
||||
dir0="$$dir0"/"$$first"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
|
||||
done; \
|
||||
reldir="$$dir2"
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
|
@ -157,9 +188,7 @@ top_builddir = @top_builddir@
|
|||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = gnu
|
||||
SUBDIRS = doc src
|
||||
EXTRA_DIST = \
|
||||
autogen.sh
|
||||
|
||||
EXTRA_DIST = autogen.sh ubl
|
||||
CLEANFILES = *~
|
||||
DISTCLEANFILES = .deps/*.P
|
||||
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure config.h.in \
|
||||
|
@ -178,14 +207,14 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
|
||||
cd $(srcdir) && $(AUTOMAKE) --gnu \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
|
@ -202,9 +231,10 @@ $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENC
|
|||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(srcdir) && $(AUTOCONF)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
config.h: stamp-h1
|
||||
@if test ! -f $@; then \
|
||||
|
@ -216,7 +246,7 @@ stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
|
|||
@rm -f stamp-h1
|
||||
cd $(top_builddir) && $(SHELL) ./config.status config.h
|
||||
$(srcdir)/config.h.in: $(am__configure_deps)
|
||||
cd $(top_srcdir) && $(AUTOHEADER)
|
||||
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
|
||||
rm -f stamp-h1
|
||||
touch $@
|
||||
|
||||
|
@ -247,7 +277,7 @@ $(RECURSIVE_TARGETS):
|
|||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
|
@ -281,16 +311,16 @@ $(RECURSIVE_CLEAN_TARGETS):
|
|||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
ctags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
done
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
|
@ -298,14 +328,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
include_option=--etags-include; \
|
||||
|
@ -317,7 +347,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
|||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test ! -f $$subdir/TAGS || \
|
||||
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
|
||||
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
|
@ -326,36 +356,41 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
|||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d $(distdir) || mkdir $(distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
|
@ -371,38 +406,57 @@ distdir: $(DISTFILES)
|
|||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d "$(distdir)/$$subdir" \
|
||||
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|
||||
|| exit 1; \
|
||||
distdir=`$(am__cd) $(distdir) && pwd`; \
|
||||
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
|
||||
(cd $$subdir && \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
|
||||
$(am__relativize); \
|
||||
new_distdir=$$reldir; \
|
||||
dir1=$$subdir; dir2="$(top_distdir)"; \
|
||||
$(am__relativize); \
|
||||
new_top_distdir=$$reldir; \
|
||||
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
|
||||
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
|
||||
($(am__cd) $$subdir && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$$top_distdir" \
|
||||
distdir="$$distdir/$$subdir" \
|
||||
top_distdir="$$new_top_distdir" \
|
||||
distdir="$$new_distdir" \
|
||||
am__remove_distdir=: \
|
||||
am__skip_length_check=: \
|
||||
am__skip_mode_fix=: \
|
||||
distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$(top_distdir)" distdir="$(distdir)" \
|
||||
dist-hook
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r $(distdir)
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
@ -415,6 +469,10 @@ dist-lzma: distdir
|
|||
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__remove_distdir)
|
||||
|
@ -443,6 +501,8 @@ distcheck: dist
|
|||
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lzma*) \
|
||||
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
|
@ -454,9 +514,11 @@ distcheck: dist
|
|||
mkdir $(distdir)/_build
|
||||
mkdir $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& cd $(distdir)/_build \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
|
@ -478,13 +540,15 @@ distcheck: dist
|
|||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@cd $(distuninstallcheck_dir) \
|
||||
@$(am__cd) '$(distuninstallcheck_dir)' \
|
||||
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
|
@ -527,6 +591,7 @@ clean-generic:
|
|||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
|
@ -548,6 +613,8 @@ dvi-am:
|
|||
|
||||
html: html-recursive
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-recursive
|
||||
|
||||
info-am:
|
||||
|
@ -556,18 +623,28 @@ install-data-am:
|
|||
|
||||
install-dvi: install-dvi-recursive
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-recursive
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-recursive
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-recursive
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-recursive
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
|
@ -590,23 +667,33 @@ ps-am:
|
|||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
|
||||
install-strip
|
||||
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
|
||||
ctags-recursive install-am install-strip tags-recursive
|
||||
|
||||
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
|
||||
all all-am am--refresh check check-am clean clean-generic \
|
||||
ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \
|
||||
dist-lzma dist-shar dist-tarZ dist-zip distcheck distclean \
|
||||
distclean-generic distclean-hdr distclean-tags distcleancheck \
|
||||
distdir distuninstallcheck dvi dvi-am html html-am info \
|
||||
info-am install install-am install-data install-data-am \
|
||||
install-dvi install-dvi-am install-exec install-exec-am \
|
||||
install-html install-html-am install-info install-info-am \
|
||||
install-man install-pdf install-pdf-am install-ps \
|
||||
install-ps-am install-strip installcheck installcheck-am \
|
||||
installdirs installdirs-am maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
|
||||
pdf-am ps ps-am tags tags-recursive uninstall uninstall-am
|
||||
dist-hook dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
|
||||
distcheck distclean distclean-generic distclean-hdr \
|
||||
distclean-tags distcleancheck distdir distuninstallcheck dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs installdirs-am \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \
|
||||
uninstall uninstall-am
|
||||
|
||||
|
||||
dist-hook:
|
||||
rm -rf $$(find $(distdir)/ubl -name config.h)
|
||||
rm -rf $$(find $(distdir)/ubl -name \*.o)
|
||||
rm -rf $$(find $(distdir)/ubl -name .svn)
|
||||
rm -rf $$(find $(distdir)/ubl -name .deps)
|
||||
rm -rf $$(find $(distdir)/ubl -name ubl.map)
|
||||
rm -rf $$(find $(distdir)/ubl -name ubl.elf)
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
|
4
NEWS
4
NEWS
|
@ -1,3 +1,7 @@
|
|||
|
||||
2009-04-20 dvnixload-0.2.6 has been released.
|
||||
New UBL with board-specific configuration
|
||||
and better DDR timings.
|
||||
|
||||
2008-12-03: dvnixload-0.1 has been released.
|
||||
Initial release
|
||||
|
|
7
README
7
README
|
@ -4,6 +4,13 @@
|
|||
Utility to program a UBL (first stage bootloader) and an application
|
||||
(2nd stage bootloader, ex. U-Boot) in NAND flash memory over the serial port.
|
||||
|
||||
I created this utility to fix the ridiculous situation in which
|
||||
you need to rely on MONO and crappy Windows application to program
|
||||
a UBL and U-Boot on DaVinci boards.
|
||||
|
||||
dvnixload is also faster than the original DVFlasher program because it
|
||||
uses compression to transmit U-Boot over the serial port.
|
||||
|
||||
Project website:
|
||||
http://www.hugovil.com/en/dvnixload
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.11 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -13,13 +13,13 @@
|
|||
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
m4_if(AC_AUTOCONF_VERSION, [2.63],,
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
|
||||
[m4_warning([this file was generated for autoconf 2.63.
|
||||
You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically `autoreconf'.])])
|
||||
|
||||
# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -31,10 +31,10 @@ To do so, use the procedure documented by the package, typically `autoreconf'.])
|
|||
# generated from the m4 files accompanying Automake X.Y.
|
||||
# (This private macro should not be called outside this file.)
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.10'
|
||||
[am__api_version='1.11'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.10.1], [],
|
||||
m4_if([$1], [1.11], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
|
@ -48,12 +48,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
|
|||
# AM_SET_CURRENT_AUTOMAKE_VERSION
|
||||
# -------------------------------
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.10.1])dnl
|
||||
[AM_AUTOMAKE_VERSION([1.11])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
|
@ -110,14 +110,14 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
|
|||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
|
||||
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 8
|
||||
# serial 9
|
||||
|
||||
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
|
||||
# -------------------------------------
|
||||
|
@ -130,6 +130,7 @@ AC_SUBST([$1_TRUE])dnl
|
|||
AC_SUBST([$1_FALSE])dnl
|
||||
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
|
||||
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
|
||||
m4_define([_AM_COND_VALUE_$1], [$2])dnl
|
||||
if $2; then
|
||||
$1_TRUE=
|
||||
$1_FALSE='#'
|
||||
|
@ -143,14 +144,14 @@ AC_CONFIG_COMMANDS_PRE(
|
|||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 9
|
||||
# serial 10
|
||||
|
||||
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
|
||||
# written in clear, in which case automake, when reading aclocal.m4,
|
||||
|
@ -207,6 +208,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
|
|||
if test "$am_compiler_list" = ""; then
|
||||
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
|
||||
fi
|
||||
am__universal=false
|
||||
m4_case([$1], [CC],
|
||||
[case " $depcc " in #(
|
||||
*\ -arch\ *\ -arch\ *) am__universal=true ;;
|
||||
esac],
|
||||
[CXX],
|
||||
[case " $depcc " in #(
|
||||
*\ -arch\ *\ -arch\ *) am__universal=true ;;
|
||||
esac])
|
||||
|
||||
for depmode in $am_compiler_list; do
|
||||
# Setup a source with many dependencies, because some compilers
|
||||
# like to wrap large dependency lists on column 80 (with \), and
|
||||
|
@ -224,7 +235,17 @@ AC_CACHE_CHECK([dependency style of $depcc],
|
|||
done
|
||||
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
|
||||
|
||||
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||
# handle `-M -o', and we need to detect this. Also, some Intel
|
||||
# versions had trouble with output in subdirs
|
||||
am__obj=sub/conftest.${OBJEXT-o}
|
||||
am__minus_obj="-o $am__obj"
|
||||
case $depmode in
|
||||
gcc)
|
||||
# This depmode causes a compiler race in universal mode.
|
||||
test "$am__universal" = false || continue
|
||||
;;
|
||||
nosideeffect)
|
||||
# after this tag, mechanisms are not by side-effect, so they'll
|
||||
# only be used when explicitly requested
|
||||
|
@ -234,19 +255,23 @@ AC_CACHE_CHECK([dependency style of $depcc],
|
|||
break
|
||||
fi
|
||||
;;
|
||||
msvisualcpp | msvcmsys)
|
||||
# This compiler won't grok `-c -o', but also, the minuso test has
|
||||
# not run yet. These depmodes are late enough in the game, and
|
||||
# so weak that their functioning should not be impacted.
|
||||
am__obj=conftest.${OBJEXT-o}
|
||||
am__minus_obj=
|
||||
;;
|
||||
none) break ;;
|
||||
esac
|
||||
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||
# handle `-M -o', and we need to detect this.
|
||||
if depmode=$depmode \
|
||||
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
|
||||
source=sub/conftest.c object=$am__obj \
|
||||
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
|
||||
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
|
||||
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
|
||||
>/dev/null 2>conftest.err &&
|
||||
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
|
||||
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
|
||||
# icc doesn't choke on unknown options, it will just issue warnings
|
||||
# or remarks (even with -Werror). So we grep stderr for any message
|
||||
|
@ -303,19 +328,29 @@ _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
|
|||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
#serial 3
|
||||
#serial 5
|
||||
|
||||
# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
# ------------------------------
|
||||
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
[for mf in $CONFIG_FILES; do
|
||||
[{
|
||||
# Autoconf 2.62 quotes --file arguments for eval, but not when files
|
||||
# are listed without --file. Let's play safe and only enable the eval
|
||||
# if we detect the quoting.
|
||||
case $CONFIG_FILES in
|
||||
*\'*) eval set x "$CONFIG_FILES" ;;
|
||||
*) set x $CONFIG_FILES ;;
|
||||
esac
|
||||
shift
|
||||
for mf
|
||||
do
|
||||
# Strip MF so we end up with the name of the file.
|
||||
mf=`echo "$mf" | sed -e 's/:.*$//'`
|
||||
# Check whether this is an Automake generated Makefile or not.
|
||||
|
@ -353,7 +388,8 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
|||
# echo "creating $dirpart/$file"
|
||||
echo '# dummy' > "$dirpart/$file"
|
||||
done
|
||||
done
|
||||
done
|
||||
}
|
||||
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
|
||||
|
||||
|
||||
|
@ -373,13 +409,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
|||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006, 2008 Free Software Foundation, Inc.
|
||||
# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 13
|
||||
# serial 16
|
||||
|
||||
# This macro actually does too much. Some checks are only needed if
|
||||
# your package does certain things. But this isn't really a big deal.
|
||||
|
@ -396,7 +432,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
|||
# arguments mandatory, and then we can depend on a new Autoconf
|
||||
# release and drop the old call support.
|
||||
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||
[AC_PREREQ([2.60])dnl
|
||||
[AC_PREREQ([2.62])dnl
|
||||
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||
dnl the ones we care about.
|
||||
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||
|
@ -447,8 +483,8 @@ AM_MISSING_PROG(AUTOCONF, autoconf)
|
|||
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
|
||||
AM_MISSING_PROG(AUTOHEADER, autoheader)
|
||||
AM_MISSING_PROG(MAKEINFO, makeinfo)
|
||||
AM_PROG_INSTALL_SH
|
||||
AM_PROG_INSTALL_STRIP
|
||||
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
|
||||
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
|
||||
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
|
@ -472,8 +508,21 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC],
|
|||
[define([AC_PROG_OBJC],
|
||||
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
|
||||
])
|
||||
_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
|
||||
dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
|
||||
dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro
|
||||
dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
|
||||
AC_CONFIG_COMMANDS_PRE(dnl
|
||||
[m4_provide_if([_AM_COMPILER_EXEEXT],
|
||||
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
|
||||
])
|
||||
|
||||
dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
|
||||
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
|
||||
dnl mangled by Autoconf and run in a shell conditional statement.
|
||||
m4_define([_AC_COMPILER_EXEEXT],
|
||||
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
|
||||
|
||||
|
||||
# When config.status generates a header, we must update the stamp-h file.
|
||||
# This file resides in the same directory as the config header
|
||||
|
@ -496,7 +545,7 @@ for _am_header in $config_headers :; do
|
|||
done
|
||||
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -507,7 +556,14 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
|
|||
# Define $install_sh.
|
||||
AC_DEFUN([AM_PROG_INSTALL_SH],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
|
||||
if test x"${install_sh}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||
*)
|
||||
install_sh="\${SHELL} $am_aux_dir/install-sh"
|
||||
esac
|
||||
fi
|
||||
AC_SUBST(install_sh)])
|
||||
|
||||
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
|
||||
|
@ -533,13 +589,13 @@ AC_SUBST([am__leading_dot])])
|
|||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 3
|
||||
# serial 4
|
||||
|
||||
# AM_MAKE_INCLUDE()
|
||||
# -----------------
|
||||
|
@ -548,7 +604,7 @@ AC_DEFUN([AM_MAKE_INCLUDE],
|
|||
[am_make=${MAKE-make}
|
||||
cat > confinc << 'END'
|
||||
am__doit:
|
||||
@echo done
|
||||
@echo this is the am__doit target
|
||||
.PHONY: am__doit
|
||||
END
|
||||
# If we don't find an include directive, just comment out the code.
|
||||
|
@ -558,24 +614,24 @@ am__quote=
|
|||
_am_result=none
|
||||
# First try GNU make style include.
|
||||
echo "include confinc" > confmf
|
||||
# We grep out `Entering directory' and `Leaving directory'
|
||||
# messages which can occur if `w' ends up in MAKEFLAGS.
|
||||
# In particular we don't look at `^make:' because GNU make might
|
||||
# be invoked under some other name (usually "gmake"), in which
|
||||
# case it prints its new name instead of `make'.
|
||||
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
|
||||
# Ignore all kinds of additional output from `make'.
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=include
|
||||
am__quote=
|
||||
_am_result=GNU
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# Now try BSD make style include.
|
||||
if test "$am__include" = "#"; then
|
||||
echo '.include "confinc"' > confmf
|
||||
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=.include
|
||||
am__quote="\""
|
||||
_am_result=BSD
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_SUBST([am__include])
|
||||
AC_SUBST([am__quote])
|
||||
|
@ -585,14 +641,14 @@ rm -f confinc confmf
|
|||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
|
||||
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 5
|
||||
# serial 6
|
||||
|
||||
# AM_MISSING_PROG(NAME, PROGRAM)
|
||||
# ------------------------------
|
||||
|
@ -609,7 +665,14 @@ AC_SUBST($1)])
|
|||
AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
|
||||
if test x"${MISSING+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
|
||||
*)
|
||||
MISSING="\${SHELL} $am_aux_dir/missing" ;;
|
||||
esac
|
||||
fi
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --run true"; then
|
||||
am_missing_run="$MISSING --run "
|
||||
|
@ -647,13 +710,13 @@ esac
|
|||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 3
|
||||
# serial 4
|
||||
|
||||
# _AM_MANGLE_OPTION(NAME)
|
||||
# -----------------------
|
||||
|
@ -670,7 +733,7 @@ AC_DEFUN([_AM_SET_OPTION],
|
|||
# ----------------------------------
|
||||
# OPTIONS is a space-separated list of Automake options.
|
||||
AC_DEFUN([_AM_SET_OPTIONS],
|
||||
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
|
||||
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
|
||||
|
||||
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
|
||||
# -------------------------------------------
|
||||
|
@ -680,14 +743,14 @@ AC_DEFUN([_AM_IF_OPTION],
|
|||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
|
||||
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
|
||||
# Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 4
|
||||
# serial 5
|
||||
|
||||
# AM_SANITY_CHECK
|
||||
# ---------------
|
||||
|
@ -696,16 +759,29 @@ AC_DEFUN([AM_SANITY_CHECK],
|
|||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftest.file
|
||||
# Reject unsafe characters in $srcdir or the absolute working directory
|
||||
# name. Accept space and tab only in the latter.
|
||||
am_lf='
|
||||
'
|
||||
case `pwd` in
|
||||
*[[\\\"\#\$\&\'\`$am_lf]]*)
|
||||
AC_MSG_ERROR([unsafe absolute working directory name]);;
|
||||
esac
|
||||
case $srcdir in
|
||||
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
|
||||
AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
|
||||
esac
|
||||
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
|
||||
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
|
||||
if test "$[*]" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftest.file`
|
||||
set X `ls -t "$srcdir/configure" conftest.file`
|
||||
fi
|
||||
rm -f conftest.file
|
||||
if test "$[*]" != "X $srcdir/configure conftest.file" \
|
||||
|
@ -758,18 +834,25 @@ fi
|
|||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 2
|
||||
|
||||
# _AM_SUBST_NOTMAKE(VARIABLE)
|
||||
# ---------------------------
|
||||
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
|
||||
# This macro is traced by Automake.
|
||||
AC_DEFUN([_AM_SUBST_NOTMAKE])
|
||||
|
||||
# AM_SUBST_NOTMAKE(VARIABLE)
|
||||
# ---------------------------
|
||||
# Public sister of _AM_SUBST_NOTMAKE.
|
||||
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.63 for dvnixload 0.1.0.
|
||||
# Generated by GNU Autoconf 2.63 for dvnixload 0.2.6.
|
||||
#
|
||||
# Report bugs to <bug@hugovil.com>.
|
||||
#
|
||||
|
@ -596,8 +596,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
|
|||
# Identity of this package.
|
||||
PACKAGE_NAME='dvnixload'
|
||||
PACKAGE_TARNAME='dvnixload'
|
||||
PACKAGE_VERSION='0.1.0'
|
||||
PACKAGE_STRING='dvnixload 0.1.0'
|
||||
PACKAGE_VERSION='0.2.6'
|
||||
PACKAGE_STRING='dvnixload 0.2.6'
|
||||
PACKAGE_BUGREPORT='bug@hugovil.com'
|
||||
|
||||
ac_unique_file="config.h.in"
|
||||
|
@ -637,7 +637,9 @@ ac_includes_default="\
|
|||
# include <unistd.h>
|
||||
#endif"
|
||||
|
||||
ac_subst_vars='LTLIBOBJS
|
||||
ac_subst_vars='am__EXEEXT_FALSE
|
||||
am__EXEEXT_TRUE
|
||||
LTLIBOBJS
|
||||
LIBOBJS
|
||||
ac_aux_dir
|
||||
EGREP
|
||||
|
@ -1286,7 +1288,7 @@ if test "$ac_init_help" = "long"; then
|
|||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures dvnixload 0.1.0 to adapt to many kinds of systems.
|
||||
\`configure' configures dvnixload 0.2.6 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
|
@ -1352,7 +1354,7 @@ fi
|
|||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of dvnixload 0.1.0:";;
|
||||
short | recursive ) echo "Configuration of dvnixload 0.2.6:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
|
@ -1439,7 +1441,7 @@ fi
|
|||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
dvnixload configure 0.1.0
|
||||
dvnixload configure 0.2.6
|
||||
generated by GNU Autoconf 2.63
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
|
||||
|
@ -1453,7 +1455,7 @@ cat >config.log <<_ACEOF
|
|||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by dvnixload $as_me 0.1.0, which was
|
||||
It was created by dvnixload $as_me 0.2.6, which was
|
||||
generated by GNU Autoconf 2.63. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
|
@ -1821,7 +1823,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
|
|||
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
|
||||
am__api_version='1.10'
|
||||
am__api_version='1.11'
|
||||
|
||||
ac_aux_dir=
|
||||
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
|
||||
|
@ -1952,16 +1954,33 @@ $as_echo_n "checking whether build environment is sane... " >&6; }
|
|||
# Just in case
|
||||
sleep 1
|
||||
echo timestamp > conftest.file
|
||||
# Reject unsafe characters in $srcdir or the absolute working directory
|
||||
# name. Accept space and tab only in the latter.
|
||||
am_lf='
|
||||
'
|
||||
case `pwd` in
|
||||
*[\\\"\#\$\&\'\`$am_lf]*)
|
||||
{ { $as_echo "$as_me:$LINENO: error: unsafe absolute working directory name" >&5
|
||||
$as_echo "$as_me: error: unsafe absolute working directory name" >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
esac
|
||||
case $srcdir in
|
||||
*[\\\"\#\$\&\'\`$am_lf\ \ ]*)
|
||||
{ { $as_echo "$as_me:$LINENO: error: unsafe srcdir value: \`$srcdir'" >&5
|
||||
$as_echo "$as_me: error: unsafe srcdir value: \`$srcdir'" >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
esac
|
||||
|
||||
# Do `set' in a subshell so we don't clobber the current shell's
|
||||
# arguments. Must try -L first in case configure is actually a
|
||||
# symlink; some systems play weird games with the mod time of symlinks
|
||||
# (eg FreeBSD returns the mod time of the symlink's containing
|
||||
# directory).
|
||||
if (
|
||||
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
|
||||
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
|
||||
if test "$*" = "X"; then
|
||||
# -L didn't work.
|
||||
set X `ls -t $srcdir/configure conftest.file`
|
||||
set X `ls -t "$srcdir/configure" conftest.file`
|
||||
fi
|
||||
rm -f conftest.file
|
||||
if test "$*" != "X $srcdir/configure conftest.file" \
|
||||
|
@ -2005,7 +2024,14 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
|
|||
# expand $ac_aux_dir to an absolute path
|
||||
am_aux_dir=`cd $ac_aux_dir && pwd`
|
||||
|
||||
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
|
||||
if test x"${MISSING+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
|
||||
*)
|
||||
MISSING="\${SHELL} $am_aux_dir/missing" ;;
|
||||
esac
|
||||
fi
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --run true"; then
|
||||
am_missing_run="$MISSING --run "
|
||||
|
@ -2015,6 +2041,115 @@ else
|
|||
$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
|
||||
fi
|
||||
|
||||
if test x"${install_sh}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
|
||||
*)
|
||||
install_sh="\${SHELL} $am_aux_dir/install-sh"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Installed binaries are usually stripped using `strip' when the user
|
||||
# run `make install-strip'. However `strip' might not be the right
|
||||
# tool to use in cross-compilation environments, therefore Automake
|
||||
# will honor the `STRIP' environment variable to overrule this program.
|
||||
if test "$cross_compiling" != no; then
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}strip; ac_word=$2
|
||||
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if test "${ac_cv_prog_STRIP+set}" = set; then
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test -n "$STRIP"; then
|
||||
ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
|
||||
else
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_prog_STRIP="${ac_tool_prefix}strip"
|
||||
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
fi
|
||||
fi
|
||||
STRIP=$ac_cv_prog_STRIP
|
||||
if test -n "$STRIP"; then
|
||||
{ $as_echo "$as_me:$LINENO: result: $STRIP" >&5
|
||||
$as_echo "$STRIP" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:$LINENO: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
if test -z "$ac_cv_prog_STRIP"; then
|
||||
ac_ct_STRIP=$STRIP
|
||||
# Extract the first word of "strip", so it can be a program name with args.
|
||||
set dummy strip; ac_word=$2
|
||||
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test -n "$ac_ct_STRIP"; then
|
||||
ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
|
||||
else
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_prog_ac_ct_STRIP="strip"
|
||||
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
fi
|
||||
fi
|
||||
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
|
||||
if test -n "$ac_ct_STRIP"; then
|
||||
{ $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
|
||||
$as_echo "$ac_ct_STRIP" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:$LINENO: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
if test "x$ac_ct_STRIP" = x; then
|
||||
STRIP=":"
|
||||
else
|
||||
case $cross_compiling:$ac_tool_warned in
|
||||
yes:)
|
||||
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
|
||||
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
|
||||
ac_tool_warned=yes ;;
|
||||
esac
|
||||
STRIP=$ac_ct_STRIP
|
||||
fi
|
||||
else
|
||||
STRIP="$ac_cv_prog_STRIP"
|
||||
fi
|
||||
|
||||
fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
|
||||
{ $as_echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5
|
||||
$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
|
||||
if test -z "$MKDIR_P"; then
|
||||
|
@ -2197,108 +2332,6 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
|
|||
|
||||
MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
|
||||
|
||||
install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
|
||||
|
||||
# Installed binaries are usually stripped using `strip' when the user
|
||||
# run `make install-strip'. However `strip' might not be the right
|
||||
# tool to use in cross-compilation environments, therefore Automake
|
||||
# will honor the `STRIP' environment variable to overrule this program.
|
||||
if test "$cross_compiling" != no; then
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
|
||||
set dummy ${ac_tool_prefix}strip; ac_word=$2
|
||||
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if test "${ac_cv_prog_STRIP+set}" = set; then
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test -n "$STRIP"; then
|
||||
ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
|
||||
else
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_prog_STRIP="${ac_tool_prefix}strip"
|
||||
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
fi
|
||||
fi
|
||||
STRIP=$ac_cv_prog_STRIP
|
||||
if test -n "$STRIP"; then
|
||||
{ $as_echo "$as_me:$LINENO: result: $STRIP" >&5
|
||||
$as_echo "$STRIP" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:$LINENO: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
if test -z "$ac_cv_prog_STRIP"; then
|
||||
ac_ct_STRIP=$STRIP
|
||||
# Extract the first word of "strip", so it can be a program name with args.
|
||||
set dummy strip; ac_word=$2
|
||||
{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test -n "$ac_ct_STRIP"; then
|
||||
ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
|
||||
else
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
|
||||
ac_cv_prog_ac_ct_STRIP="strip"
|
||||
$as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
fi
|
||||
fi
|
||||
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
|
||||
if test -n "$ac_ct_STRIP"; then
|
||||
{ $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5
|
||||
$as_echo "$ac_ct_STRIP" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:$LINENO: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
if test "x$ac_ct_STRIP" = x; then
|
||||
STRIP=":"
|
||||
else
|
||||
case $cross_compiling:$ac_tool_warned in
|
||||
yes:)
|
||||
{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5
|
||||
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
|
||||
ac_tool_warned=yes ;;
|
||||
esac
|
||||
STRIP=$ac_ct_STRIP
|
||||
fi
|
||||
else
|
||||
STRIP="$ac_cv_prog_STRIP"
|
||||
fi
|
||||
|
||||
fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
|
||||
# We need awk for the "check" target. The system "awk" is bad on
|
||||
# some platforms.
|
||||
# Always define AMTAR for backward compatibility.
|
||||
|
@ -3257,7 +3290,7 @@ ac_config_commands="$ac_config_commands depfiles"
|
|||
am_make=${MAKE-make}
|
||||
cat > confinc << 'END'
|
||||
am__doit:
|
||||
@echo done
|
||||
@echo this is the am__doit target
|
||||
.PHONY: am__doit
|
||||
END
|
||||
# If we don't find an include directive, just comment out the code.
|
||||
|
@ -3268,24 +3301,24 @@ am__quote=
|
|||
_am_result=none
|
||||
# First try GNU make style include.
|
||||
echo "include confinc" > confmf
|
||||
# We grep out `Entering directory' and `Leaving directory'
|
||||
# messages which can occur if `w' ends up in MAKEFLAGS.
|
||||
# In particular we don't look at `^make:' because GNU make might
|
||||
# be invoked under some other name (usually "gmake"), in which
|
||||
# case it prints its new name instead of `make'.
|
||||
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
|
||||
# Ignore all kinds of additional output from `make'.
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=include
|
||||
am__quote=
|
||||
_am_result=GNU
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
# Now try BSD make style include.
|
||||
if test "$am__include" = "#"; then
|
||||
echo '.include "confinc"' > confmf
|
||||
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
|
||||
case `$am_make -s -f confmf 2> /dev/null` in #(
|
||||
*the\ am__doit\ target*)
|
||||
am__include=.include
|
||||
am__quote="\""
|
||||
_am_result=BSD
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
|
@ -3342,6 +3375,11 @@ else
|
|||
if test "$am_compiler_list" = ""; then
|
||||
am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
|
||||
fi
|
||||
am__universal=false
|
||||
case " $depcc " in #(
|
||||
*\ -arch\ *\ -arch\ *) am__universal=true ;;
|
||||
esac
|
||||
|
||||
for depmode in $am_compiler_list; do
|
||||
# Setup a source with many dependencies, because some compilers
|
||||
# like to wrap large dependency lists on column 80 (with \), and
|
||||
|
@ -3359,7 +3397,17 @@ else
|
|||
done
|
||||
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
|
||||
|
||||
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||
# handle `-M -o', and we need to detect this. Also, some Intel
|
||||
# versions had trouble with output in subdirs
|
||||
am__obj=sub/conftest.${OBJEXT-o}
|
||||
am__minus_obj="-o $am__obj"
|
||||
case $depmode in
|
||||
gcc)
|
||||
# This depmode causes a compiler race in universal mode.
|
||||
test "$am__universal" = false || continue
|
||||
;;
|
||||
nosideeffect)
|
||||
# after this tag, mechanisms are not by side-effect, so they'll
|
||||
# only be used when explicitly requested
|
||||
|
@ -3369,19 +3417,23 @@ else
|
|||
break
|
||||
fi
|
||||
;;
|
||||
msvisualcpp | msvcmsys)
|
||||
# This compiler won't grok `-c -o', but also, the minuso test has
|
||||
# not run yet. These depmodes are late enough in the game, and
|
||||
# so weak that their functioning should not be impacted.
|
||||
am__obj=conftest.${OBJEXT-o}
|
||||
am__minus_obj=
|
||||
;;
|
||||
none) break ;;
|
||||
esac
|
||||
# We check with `-c' and `-o' for the sake of the "dashmstdout"
|
||||
# mode. It turns out that the SunPro C++ compiler does not properly
|
||||
# handle `-M -o', and we need to detect this.
|
||||
if depmode=$depmode \
|
||||
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
|
||||
source=sub/conftest.c object=$am__obj \
|
||||
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
|
||||
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
|
||||
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
|
||||
>/dev/null 2>conftest.err &&
|
||||
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
|
||||
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
|
||||
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
|
||||
# icc doesn't choke on unknown options, it will just issue warnings
|
||||
# or remarks (even with -Werror). So we grep stderr for any message
|
||||
|
@ -4562,6 +4614,14 @@ LIBOBJS=$ac_libobjs
|
|||
LTLIBOBJS=$ac_ltlibobjs
|
||||
|
||||
|
||||
if test -n "$EXEEXT"; then
|
||||
am__EXEEXT_TRUE=
|
||||
am__EXEEXT_FALSE='#'
|
||||
else
|
||||
am__EXEEXT_TRUE='#'
|
||||
am__EXEEXT_FALSE=
|
||||
fi
|
||||
|
||||
if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
|
||||
{ { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." >&5
|
||||
|
@ -4898,7 +4958,7 @@ exec 6>&1
|
|||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by dvnixload $as_me 0.1.0, which was
|
||||
This file was extended by dvnixload $as_me 0.2.6, which was
|
||||
generated by GNU Autoconf 2.63. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
|
@ -4961,7 +5021,7 @@ Report bugs to <bug-autoconf@gnu.org>."
|
|||
_ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_version="\\
|
||||
dvnixload config.status 0.1.0
|
||||
dvnixload config.status 0.2.6
|
||||
configured by $0, generated by GNU Autoconf 2.63,
|
||||
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
|
||||
|
||||
|
@ -5743,7 +5803,17 @@ $as_echo "$as_me: executing $ac_file commands" >&6;}
|
|||
|
||||
|
||||
case $ac_file$ac_mode in
|
||||
"depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do
|
||||
"depfiles":C) test x"$AMDEP_TRUE" != x"" || {
|
||||
# Autoconf 2.62 quotes --file arguments for eval, but not when files
|
||||
# are listed without --file. Let's play safe and only enable the eval
|
||||
# if we detect the quoting.
|
||||
case $CONFIG_FILES in
|
||||
*\'*) eval set x "$CONFIG_FILES" ;;
|
||||
*) set x $CONFIG_FILES ;;
|
||||
esac
|
||||
shift
|
||||
for mf
|
||||
do
|
||||
# Strip MF so we end up with the name of the file.
|
||||
mf=`echo "$mf" | sed -e 's/:.*$//'`
|
||||
# Check whether this is an Automake generated Makefile or not.
|
||||
|
@ -5865,7 +5935,8 @@ $as_echo "$as_me: error: cannot create directory $as_dir" >&2;}
|
|||
# echo "creating $dirpart/$file"
|
||||
echo '# dummy' > "$dirpart/$file"
|
||||
done
|
||||
done
|
||||
done
|
||||
}
|
||||
;;
|
||||
|
||||
esac
|
||||
|
@ -5908,3 +5979,8 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
|
|||
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
|
||||
fi
|
||||
|
||||
|
||||
echo
|
||||
echo "Configure finished."
|
||||
echo " Type 'make' to build dvnixload."
|
||||
echo " Type 'make -C ubl BOARD=<boardname>' to build HVUBL."
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# configure.in -- Process this file with autoconf to produce configure
|
||||
|
||||
# Initialization stuff
|
||||
AC_INIT(dvnixload, 0.1.0, [bug@hugovil.com])
|
||||
AC_INIT(dvnixload, 0.2.6, [bug@hugovil.com])
|
||||
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
|
||||
# AC_CONFIG_AUX_DIR(config)
|
||||
AC_CONFIG_SRCDIR([config.h.in])
|
||||
|
@ -37,3 +37,8 @@ AC_SUBST(ac_aux_dir)
|
|||
# Creating output file(s)
|
||||
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile])
|
||||
AC_OUTPUT
|
||||
|
||||
echo
|
||||
echo "Configure finished."
|
||||
echo " Type 'make' to build dvnixload."
|
||||
echo " Type 'make -C ubl BOARD=<boardname>' to build HVUBL."
|
||||
|
|
87
depcomp
87
depcomp
|
@ -1,10 +1,10 @@
|
|||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2007-03-29.01
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
|
||||
# Foundation, Inc.
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
|
||||
# Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -17,9 +17,7 @@ scriptversion=2007-03-29.01
|
|||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
|
@ -87,6 +85,15 @@ if test "$depmode" = dashXmstdout; then
|
|||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u="sed s,\\\\\\\\,/,g"
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
|
@ -192,14 +199,14 @@ sgi)
|
|||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
' ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
|
@ -328,7 +335,12 @@ hp2)
|
|||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
|
@ -404,7 +416,7 @@ dashmstdout)
|
|||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
@ -455,32 +467,39 @@ makedepend)
|
|||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
|
@ -500,7 +519,7 @@ cpp)
|
|||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
|
@ -538,13 +557,27 @@ cpp)
|
|||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
|
@ -557,16 +590,23 @@ msvisualcpp)
|
|||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
@ -585,5 +625,6 @@ exit 0
|
|||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
|
147
doc/Makefile.in
147
doc/Makefile.in
|
@ -1,8 +1,9 @@
|
|||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -15,8 +16,9 @@
|
|||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
|
@ -38,8 +40,30 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
|||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
man1dir = $(mandir)/man1
|
||||
am__installdirs = "$(DESTDIR)$(man1dir)"
|
||||
NROFF = nroff
|
||||
|
@ -143,13 +167,13 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu doc/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
|
@ -168,51 +192,41 @@ $(top_srcdir)/configure: $(am__configure_deps)
|
|||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
install-man1: $(man1_MANS) $(man_MANS)
|
||||
$(am__aclocal_m4_deps):
|
||||
install-man1: $(man1_MANS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
|
||||
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
|
||||
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
|
||||
for i in $$l2; do \
|
||||
case "$$i" in \
|
||||
*.1*) list="$$list $$i" ;; \
|
||||
esac; \
|
||||
done; \
|
||||
for i in $$list; do \
|
||||
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
|
||||
else file=$$i; fi; \
|
||||
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
|
||||
case "$$ext" in \
|
||||
1*) ;; \
|
||||
*) ext='1' ;; \
|
||||
esac; \
|
||||
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
|
||||
inst=`echo $$inst | sed -e 's/^.*\///'`; \
|
||||
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
|
||||
@list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
|
||||
{ for i in $$list; do echo "$$i"; done; \
|
||||
} | while read p; do \
|
||||
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; echo "$$p"; \
|
||||
done | \
|
||||
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
|
||||
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
|
||||
sed 'N;N;s,\n, ,g' | { \
|
||||
list=; while read file base inst; do \
|
||||
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
|
||||
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
|
||||
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
|
||||
done
|
||||
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
|
||||
fi; \
|
||||
done; \
|
||||
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
|
||||
$(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
|
||||
done; }
|
||||
|
||||
uninstall-man1:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
|
||||
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
|
||||
for i in $$l2; do \
|
||||
case "$$i" in \
|
||||
*.1*) list="$$list $$i" ;; \
|
||||
esac; \
|
||||
done; \
|
||||
for i in $$list; do \
|
||||
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
|
||||
case "$$ext" in \
|
||||
1*) ;; \
|
||||
*) ext='1' ;; \
|
||||
esac; \
|
||||
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
|
||||
inst=`echo $$inst | sed -e 's/^.*\///'`; \
|
||||
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
|
||||
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
|
||||
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
|
||||
done
|
||||
@list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
|
||||
files=`{ for i in $$list; do echo "$$i"; done; \
|
||||
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
|
||||
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
|
||||
test -z "$$files" || { \
|
||||
echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
|
||||
tags: TAGS
|
||||
TAGS:
|
||||
|
||||
|
@ -221,6 +235,19 @@ CTAGS:
|
|||
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@list='$(MANS)'; if test -n "$$list"; then \
|
||||
list=`for p in $$list; do \
|
||||
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
|
||||
if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
|
||||
if test -n "$$list" && \
|
||||
grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
|
||||
echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
|
||||
grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
|
||||
echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
|
||||
echo " typically \`make maintainer-clean' will remove them" >&2; \
|
||||
exit 1; \
|
||||
else :; fi; \
|
||||
else :; fi
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
|
@ -236,13 +263,17 @@ distdir: $(DISTFILES)
|
|||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
|
@ -274,6 +305,7 @@ clean-generic:
|
|||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
|
@ -293,6 +325,8 @@ dvi-am:
|
|||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
@ -301,18 +335,28 @@ install-data-am: install-man
|
|||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man: install-man1
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
@ -348,6 +392,7 @@ uninstall-man: uninstall-man1
|
|||
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
|
||||
uninstall-am uninstall-man uninstall-man1
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2006-12-25.00
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
|
@ -515,5 +515,6 @@ done
|
|||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
|
49
missing
49
missing
|
@ -1,10 +1,10 @@
|
|||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2006-05-10.23
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
|
||||
# Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
|
@ -18,9 +18,7 @@ scriptversion=2006-05-10.23
|
|||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
|
@ -89,6 +87,9 @@ Supported PROGRAM values:
|
|||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
|
||||
\`g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
@ -106,15 +107,22 @@ Send bug reports to <bug-automake@gnu.org>."
|
|||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program).
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex|yacc)
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar)
|
||||
tar*)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
|
@ -138,7 +146,7 @@ esac
|
|||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case $1 in
|
||||
case $program in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
|
@ -148,7 +156,7 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
autoconf*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
|
@ -157,7 +165,7 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
autoheader*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
|
@ -187,7 +195,7 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te)
|
||||
autom4te*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
|
@ -210,7 +218,7 @@ WARNING: \`$1' is needed, but is $msg.
|
|||
fi
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
bison*|yacc*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
|
@ -240,7 +248,7 @@ WARNING: \`$1' $msg. You should only need it if
|
|||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
lex*|flex*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
|
@ -263,7 +271,7 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
fi
|
||||
;;
|
||||
|
||||
help2man)
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
|
@ -277,11 +285,11 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit 1
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
makeinfo*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
|
@ -310,7 +318,7 @@ WARNING: \`$1' is $msg. You should only need it if
|
|||
touch $file
|
||||
;;
|
||||
|
||||
tar)
|
||||
tar*)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
|
@ -363,5 +371,6 @@ exit 0
|
|||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
|
115
src/Makefile.in
115
src/Makefile.in
|
@ -1,8 +1,9 @@
|
|||
# Makefile.in generated by automake 1.10.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
@ -19,8 +20,9 @@
|
|||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
|
@ -36,7 +38,7 @@ POST_UNINSTALL = :
|
|||
bin_PROGRAMS = dvnixload$(EXEEXT)
|
||||
subdir = src
|
||||
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
$(srcdir)/Makefile.in TODO
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
|
@ -44,8 +46,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
|||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_dvnixload_OBJECTS = main.$(OBJEXT) options.$(OBJEXT) \
|
||||
utils.$(OBJEXT) serial.$(OBJEXT) cmd.$(OBJEXT) crc.$(OBJEXT)
|
||||
|
@ -54,6 +56,7 @@ dvnixload_LDADD = $(LDADD)
|
|||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
|
@ -170,13 +173,13 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
|
@ -195,26 +198,41 @@ $(top_srcdir)/configure: $(am__configure_deps)
|
|||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
if test -f $$p \
|
||||
; then \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed 's/$(EXEEXT)$$//' | \
|
||||
while read p p1; do if test -f $$p; \
|
||||
then echo "$$p"; echo "$$p"; else :; fi; \
|
||||
done | \
|
||||
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
|
||||
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
|
||||
sed 'N;N;N;s,\n, ,g' | \
|
||||
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
|
||||
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
|
||||
if ($$2 == $$4) files[d] = files[d] " " $$1; \
|
||||
else { print "f", $$3 "/" $$4, $$1; } } \
|
||||
END { for (d in files) print "f", d, files[d] }' | \
|
||||
while read type dir files; do \
|
||||
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
|
||||
} \
|
||||
; done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
|
||||
rm -f "$(DESTDIR)$(bindir)/$$f"; \
|
||||
done
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
files=`for p in $$list; do echo "$$p"; done | \
|
||||
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
|
||||
-e 's/$$/$(EXEEXT)/' `; \
|
||||
test -n "$$list" || exit 0; \
|
||||
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(bindir)" && rm -f $$files
|
||||
|
||||
clean-binPROGRAMS:
|
||||
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
||||
|
@ -237,7 +255,7 @@ distclean-compile:
|
|||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
@ -247,14 +265,14 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
|
@ -262,29 +280,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
|||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
@ -305,13 +328,17 @@ distdir: $(DISTFILES)
|
|||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
|
@ -343,6 +370,7 @@ clean-generic:
|
|||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
|
@ -365,6 +393,8 @@ dvi-am:
|
|||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
@ -373,18 +403,28 @@ install-data-am:
|
|||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-binPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
@ -431,6 +471,7 @@ uninstall-am: uninstall-binPROGRAMS
|
|||
# gcc -DHAVE_CONFIG_H -I. -I. -I.. -c `test -f 'main.c' || echo './'`main.c
|
||||
.c.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
TODO
|
||||
|
||||
-Remove serial.h dependency in crc.c.
|
||||
-Compute CRC table dynamically.
|
||||
-Remove requirement for APP filename when doing DDR memory testing.
|
46
src/cmd.c
46
src/cmd.c
|
@ -116,7 +116,30 @@ int run_cmd_get_string(char *cmd, char *output, ssize_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int remove_file(char *filename)
|
||||
int copy_file(const char *src, const char *dst)
|
||||
{
|
||||
int count;
|
||||
char cmd[MAX_CMD_LENGTH];
|
||||
char *slines[MAX_LINES];
|
||||
char sbuf[MAX_CHARS];
|
||||
int k;
|
||||
|
||||
sprintf(cmd, "cp %s %s 2>&1", src, dst);
|
||||
count = run_popen(slines, sbuf, cmd);
|
||||
log_debug2("count is %d\n", count);
|
||||
|
||||
for (k = 0; k < count; k++)
|
||||
log_debug2("[%s]\n", slines[k]);
|
||||
|
||||
if (count != 0) {
|
||||
log_fail("Error copying file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int remove_file(const char *filename)
|
||||
{
|
||||
int count;
|
||||
char cmd[MAX_CMD_LENGTH];
|
||||
|
@ -132,7 +155,7 @@ int remove_file(char *filename)
|
|||
log_debug2("[%s]\n", slines[k]);
|
||||
|
||||
if (count != 0) {
|
||||
log_fail("Error removing temporary file");
|
||||
log_fail("Error removing file %s", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -164,7 +187,7 @@ test_file_elf(const char *filename)
|
|||
}
|
||||
|
||||
int
|
||||
check_source_files(const char *ubl, const char *app)
|
||||
check_source_files(int app_elf_format, const char *ubl, const char *app)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -174,23 +197,26 @@ check_source_files(const char *ubl, const char *app)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = test_file_presence(app);
|
||||
if (ret) {
|
||||
log_fail("Application file \"%s\" not found", app);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = test_file_elf(ubl);
|
||||
if (ret) {
|
||||
log_fail("UBL file \"%s\" not in ELF format", ubl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = test_file_presence(app);
|
||||
if (ret) {
|
||||
log_fail("Application file \"%s\" not found", app);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (app_elf_format) {
|
||||
ret = test_file_elf(app);
|
||||
if (ret) {
|
||||
log_fail("Application file \"%s\" not in ELF format", app);
|
||||
log_fail("Application file \"%s\" not in ELF format",
|
||||
app);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -25,8 +25,10 @@ int run_popen(char *lineptr[], char *buffer, char *exe_str);
|
|||
|
||||
int run_cmd_get_string(char *cmd, char *output, ssize_t size);
|
||||
|
||||
int remove_file(char *filename);
|
||||
int copy_file(const char *src, const char *dst);
|
||||
|
||||
int check_source_files(const char *ubl, const char *app);
|
||||
int remove_file(const char *filename);
|
||||
|
||||
int check_source_files(int app_elf_format, const char *ubl, const char *app);
|
||||
|
||||
#endif /* CMD_H */
|
||||
|
|
108
src/crc.c
108
src/crc.c
|
@ -33,59 +33,59 @@
|
|||
|
||||
#define CRC_TABLE_ELEMENTS 256
|
||||
|
||||
const u_int32_t crc32_table[CRC_TABLE_ELEMENTS] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
static const u_int32_t crc32_table[CRC_TABLE_ELEMENTS] = {
|
||||
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
|
||||
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
|
||||
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
|
||||
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
|
||||
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
|
||||
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
|
||||
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
|
||||
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
|
||||
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
|
||||
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
|
||||
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
|
||||
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
|
||||
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
|
||||
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
|
||||
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
|
||||
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
|
||||
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
|
||||
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
|
||||
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
|
||||
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
|
||||
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
|
||||
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
|
||||
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
|
||||
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
|
||||
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
|
||||
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
|
||||
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
|
||||
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
|
||||
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
|
||||
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
|
||||
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
|
||||
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
|
||||
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
|
||||
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
|
||||
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
|
||||
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
|
||||
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
|
||||
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
|
||||
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
|
||||
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
|
||||
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
|
||||
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
|
||||
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
|
||||
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
|
||||
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
|
||||
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
|
||||
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
|
||||
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
|
||||
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
|
||||
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
|
||||
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
|
||||
0x2d02ef8d
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -97,7 +97,7 @@ crc_send_table(void)
|
|||
send_number(crc32_table[k], 8);
|
||||
}
|
||||
|
||||
/* Compute CRC32 checksum */
|
||||
/* Compute CRC32 checksum for a data buffer. */
|
||||
u_int32_t
|
||||
crc32_dv_compute(u_int8_t *data, ssize_t size)
|
||||
{
|
||||
|
|
470
src/main.c
470
src/main.c
|
@ -35,20 +35,30 @@
|
|||
#include "cmd.h"
|
||||
#include "crc.h"
|
||||
|
||||
#define UBL_BIN_MAX_SIZE 0x3800
|
||||
#define SREC_MAX_SIZE 600000
|
||||
#define BINAPP_MAX_SIZE (15 * 1024 * 1024) /* 15 Mbytes */
|
||||
|
||||
#define UBL_MAGIC_SAFE 0xA1ACED00
|
||||
#define UBL_MAGIC_NAND_FLASH 0xA1ACEDCC /* Download via UART & Flash NAND
|
||||
* with UBL and U-Boot */
|
||||
#define UBL_MAGIC_BIN_IMG 0xA1ACED66 /* Describes the application image
|
||||
* in Flash - indicates that it is
|
||||
* binary */
|
||||
/* RBL & UBL magic numbers */
|
||||
#define RBL_MAGIC_SAFE 0xA1ACED00 /* Describes UBL flash image type for
|
||||
* RBL. */
|
||||
#define UBL_MAGIC_BIN_IMG 0xA1ACED66 /* Describes binary flash image type
|
||||
* for UBL. */
|
||||
#define UBL_MAGIC_GZIP_IMG 0xA1ACED77 /* Describes gzipped binary flash
|
||||
* image type for UBL. */
|
||||
/* UBL commands */
|
||||
#define UBL_CMD_FLASH_UBL_APP 0xA1ACEDCC /* Download UBL & application via
|
||||
* UART and burn in flash. */
|
||||
#define UBL_CMD_FLASH_DATA 0xA1ACEDCD /* Download data via UART and
|
||||
* burn in flash (no header in flash). */
|
||||
#define UBL_CMD_FLASH_ERASE 0xA1ACEDCE /* Erase the whole flash. */
|
||||
#define UBL_CMD_RUN_APP 0xA1ACEDDD /* Load and run application via UART. */
|
||||
#define UBL_CMD_DDR_TEST 0xA1ACEDEE /* Test DDR2 memory. */
|
||||
|
||||
#define DEFAULT_CROSS_COMPILE "arm-linux-"
|
||||
|
||||
static char cross_compile[MAX_ENV_VAR_LENGTH];
|
||||
|
||||
static struct options_t *options;
|
||||
|
||||
static int
|
||||
parse_environment_variables(void)
|
||||
{
|
||||
|
@ -96,67 +106,26 @@ error:
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* size_in_bytes must be initialized with the size of the buffer.
|
||||
* it will be written with the actual buffer size. */
|
||||
static int
|
||||
convert_elf_to_srec(const char *elf_file, const char *temp_file, u_int8_t *data,
|
||||
ssize_t *size_in_bytes, u_int32_t *entry_point)
|
||||
read_file_data(const char*file, u_int8_t *data, ssize_t *size_in_bytes)
|
||||
{
|
||||
ssize_t len;
|
||||
char cmd[MAX_CMD_LENGTH];
|
||||
FILE *fp;
|
||||
int ret;
|
||||
u_int32_t offset = 0;
|
||||
/*
|
||||
* OBJCOPY FLAGS:
|
||||
* -S
|
||||
* Do not copy relocation and symbol information from the source file
|
||||
* -R sectionname
|
||||
* Remove any section named sectionname from the output file
|
||||
* Get rid of the section .selfcopy (first 256 bytes) because
|
||||
* it contains self-copy stuff. This will remove 256 from bytes
|
||||
* the application size. The entry point is not modified.
|
||||
*/
|
||||
char *objcopy_flags = "-R .ddrram -R .ddrram2 -R .selfcopy " \
|
||||
"--gap-fill 0xFF --srec-forceS3 -S";
|
||||
ssize_t len;
|
||||
FILE *fp;
|
||||
|
||||
/* Find application entry point */
|
||||
ret = get_app_entry_point(entry_point, elf_file);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (*entry_point < 0x80000000) {
|
||||
log_info("Adding offset to SREC file");
|
||||
/* We must add offset starting at 0x81070000 because the UBL
|
||||
* first allocate a buffer in RAM between 0x80000000 and
|
||||
* 0x81070000 */
|
||||
offset = 0x81070000;
|
||||
*entry_point += offset;
|
||||
}
|
||||
|
||||
if (*size_in_bytes == 0) {
|
||||
log_fail("buffer size not specified");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sprintf(cmd,
|
||||
"%sobjcopy %s --change-addresses=0x%08X -O srec %s %s 2>&1",
|
||||
cross_compile, objcopy_flags, offset, elf_file, temp_file);
|
||||
|
||||
ret = system(cmd);
|
||||
if (ret) {
|
||||
log_fail("Error converting ELF to srec file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fp = fopen(temp_file, "r");
|
||||
fp = fopen(file, "r");
|
||||
if (!fp) {
|
||||
log_fail("Error opening temporary file %s", temp_file);
|
||||
log_fail("Error opening file %s", file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Copy temporary srec file data inside our buffer */
|
||||
/* Copy compressed file data inside our buffer */
|
||||
len = fread(data, 1, *size_in_bytes, fp);
|
||||
if (len == *size_in_bytes) {
|
||||
log_fail("Size of file data exceeds our buffer size (%d kbytes)",
|
||||
*size_in_bytes / 1024);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check that size is u32 aligned. */
|
||||
*size_in_bytes = len;
|
||||
|
@ -165,14 +134,16 @@ convert_elf_to_srec(const char *elf_file, const char *temp_file, u_int8_t *data,
|
|||
|
||||
#ifdef REMOVE_TEMP_FILES
|
||||
/* Remove temporary file. */
|
||||
ret = remove_file(temp_file);
|
||||
ret = remove_file(gz_file);
|
||||
if (ret) {
|
||||
log_fail("Error removing temporary file");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* size_in_bytes must be initialized with the size of the buffer.
|
||||
|
@ -182,9 +153,7 @@ convert_elf_to_binary(const char *elf_file, const char *temp_file,
|
|||
u_int8_t *data, ssize_t *size_in_bytes,
|
||||
u_int32_t *entry_point)
|
||||
{
|
||||
ssize_t len;
|
||||
char cmd[MAX_CMD_LENGTH];
|
||||
FILE *fp;
|
||||
int ret;
|
||||
/*
|
||||
* OBJCOPY FLAGS:
|
||||
|
@ -193,11 +162,10 @@ convert_elf_to_binary(const char *elf_file, const char *temp_file,
|
|||
* -R sectionname
|
||||
* Remove any section named sectionname from the output file
|
||||
* Get rid of the section .selfcopy (first 256 bytes) because
|
||||
* it contains self-copy stuff. This will remove 256 from bytes
|
||||
* it contains self-copy stuff. This will remove 256 bytes from
|
||||
* the application size. The entry point is not modified.
|
||||
*/
|
||||
char *objcopy_flags = "-R .ddrram -R .ddrram2 -R .selfcopy " \
|
||||
"--gap-fill 0xFF -S";
|
||||
char *objcopy_flags = "-R .ddrram -R .selfcopy --gap-fill 0xFF -S";
|
||||
|
||||
if (*size_in_bytes == 0) {
|
||||
log_fail("buffer size not specified");
|
||||
|
@ -207,34 +175,18 @@ convert_elf_to_binary(const char *elf_file, const char *temp_file,
|
|||
sprintf(cmd, "%sobjcopy %s -O binary %s %s 2>&1",
|
||||
cross_compile, objcopy_flags, elf_file, temp_file);
|
||||
|
||||
log_debug1("Running command: %s", cmd);
|
||||
ret = system(cmd);
|
||||
if (ret) {
|
||||
log_fail("Error converting ELF to binary file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fp = fopen(temp_file, "r");
|
||||
if (!fp) {
|
||||
log_fail("Error opening temporary file %s", temp_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Copy temporary binary file data inside our buffer */
|
||||
len = fread(data, 1, *size_in_bytes, fp);
|
||||
|
||||
/* Check that size is u32 aligned. */
|
||||
*size_in_bytes = len;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
#ifdef REMOVE_TEMP_FILES
|
||||
/* Remove temporary file. */
|
||||
ret = remove_file(temp_file);
|
||||
ret = read_file_data(temp_file, data, size_in_bytes);
|
||||
if (ret) {
|
||||
log_fail("Error removing temporary file");
|
||||
log_fail("Error reading file data");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Find application entry point */
|
||||
ret = get_app_entry_point(entry_point, elf_file);
|
||||
|
@ -244,191 +196,185 @@ convert_elf_to_binary(const char *elf_file, const char *temp_file,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* size_in_bytes must be initialized with the size of the buffer.
|
||||
* it will be written with the actual buffer size. */
|
||||
static int
|
||||
send_ubl_binary(const char *elf_file)
|
||||
compress_binary(const char *bin_file, const char *gz_file,
|
||||
u_int8_t *data, ssize_t *size_in_bytes)
|
||||
{
|
||||
char cmd[MAX_CMD_LENGTH];
|
||||
int ret;
|
||||
/*
|
||||
* OBJCOPY FLAGS:
|
||||
* -9
|
||||
* best compression
|
||||
* -f
|
||||
* overwrite existing file
|
||||
* --no-name
|
||||
* do not save the original file name and time stamp
|
||||
*
|
||||
*/
|
||||
char *gzip_flags = "-9 -f --no-name";
|
||||
|
||||
if (*size_in_bytes == 0) {
|
||||
log_fail("buffer size not specified");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sprintf(cmd, "gzip %s %s 2>&1", gzip_flags, bin_file);
|
||||
|
||||
log_debug1("Running command: %s", cmd);
|
||||
ret = system(cmd);
|
||||
if (ret) {
|
||||
log_fail("Error compressing binary file");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = read_file_data(gz_file, data, size_in_bytes);
|
||||
if (ret) {
|
||||
log_fail("Error reading file data");
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SEND_UBL 0
|
||||
#define SEND_APP_ELF 1
|
||||
#define SEND_APP_BIN 2
|
||||
|
||||
static int
|
||||
send_binary(const char *orig_file, const char *tmp_file, int format,
|
||||
u_int32_t magic_number, int blocknum)
|
||||
{
|
||||
int found;
|
||||
int ret;
|
||||
ssize_t size;
|
||||
u_int8_t data[UBL_BIN_MAX_SIZE];
|
||||
u_int32_t entry_point;
|
||||
ssize_t size;
|
||||
u_int8_t *data;
|
||||
u_int32_t crc;
|
||||
int size_len = 4; /* RBL format is default */
|
||||
int entry_point_len = 4; /* RBL format is default */
|
||||
char gz_file[128];
|
||||
|
||||
|
||||
data = malloc(BINAPP_MAX_SIZE);
|
||||
if (!data) {
|
||||
log_fail("Memory allocation error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Specify max size of our buffers */
|
||||
size = sizeof(data);
|
||||
size = BINAPP_MAX_SIZE;
|
||||
|
||||
/* Convert UBL ELF to binary and get the resulting binary file size and
|
||||
if (format == SEND_APP_BIN) {
|
||||
ret = copy_file(orig_file, tmp_file);
|
||||
if (ret)
|
||||
goto error_handled;
|
||||
|
||||
entry_point = blocknum;
|
||||
}
|
||||
else {
|
||||
/* Convert source ELF to binary and get the resulting file size and
|
||||
* entry point. */
|
||||
ret = convert_elf_to_binary(elf_file, "/tmp/ubl.bin", data, &size,
|
||||
ret = convert_elf_to_binary(orig_file, tmp_file, data, &size,
|
||||
&entry_point);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto error_handled;
|
||||
}
|
||||
|
||||
/* Wait for the device to send the BOOTME sequence.
|
||||
* If the UBL is already running, it will send BOOTPSP. */
|
||||
found = wait_for_message("BOOTME", "BOOTPSP", NULL);
|
||||
if (found == 0)
|
||||
goto error;
|
||||
else if (found == 2)
|
||||
/* The UBL is already loaded and running. Don't reload it. */
|
||||
goto bootpsp_received;
|
||||
if (format != SEND_UBL) {
|
||||
/* Compress for UBL format */
|
||||
sprintf(gz_file, "%s.gz", tmp_file);
|
||||
|
||||
/* No need to reset size, compressed file will be smaller. */
|
||||
ret = compress_binary(tmp_file, gz_file, data, &size);
|
||||
if (ret)
|
||||
goto error_handled;
|
||||
}
|
||||
|
||||
log_info("Sending ACK sequence");
|
||||
send_message(" ACK\n");
|
||||
|
||||
crc = crc32_dv_compute(data, size);
|
||||
if (format != SEND_UBL) {
|
||||
/* Configure for UBL format. */
|
||||
size_len = 8;
|
||||
entry_point_len = 8;
|
||||
|
||||
log_info("Sending UBL CRC ($%08X)", crc);
|
||||
log_info("Sending magic number ($%08X)", magic_number);
|
||||
send_number(magic_number, 8);
|
||||
}
|
||||
|
||||
crc = crc32_dv_compute(data, size);
|
||||
log_info("Sending CRC ($%08X)", crc);
|
||||
send_number(crc, 8);
|
||||
|
||||
log_info("Sending UBL size ($%04X bytes)", size);
|
||||
send_number(size, 4);
|
||||
log_info("Sending size ($%08X bytes)", size);
|
||||
send_number(size, size_len);
|
||||
|
||||
log_info("Sending UBL entry point ($%08X)", entry_point);
|
||||
send_number(entry_point, 4);
|
||||
log_info("Sending entry point ($%08X)", entry_point);
|
||||
send_number(entry_point, entry_point_len);
|
||||
|
||||
log_info("Sending termination sequence");
|
||||
send_number(0x0000, 4);
|
||||
|
||||
found = wait_for_message("BEGIN", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
goto error_unhandled;
|
||||
|
||||
if (format != SEND_UBL) {
|
||||
/* UBL format */
|
||||
log_info("Sending binary data");
|
||||
send_buffer_bin(data, size);
|
||||
|
||||
/* First DONE message indicates UBL received all data. */
|
||||
found = wait_for_message("DONE", NULL, NULL);
|
||||
if (!found)
|
||||
goto error_unhandled;
|
||||
|
||||
/* Second DONE message indicates UBL validated data. */
|
||||
found = wait_for_message("DONE", "BADCRC", "GZIPERR");
|
||||
if (found != 1)
|
||||
goto error_unhandled;
|
||||
|
||||
/* The third DONE message indicates successfull programming in flash. */
|
||||
found = wait_for_message("DONE", "BOOTME", NULL);
|
||||
if (found != 1)
|
||||
goto error_unhandled;
|
||||
} else {
|
||||
/* RBL format */
|
||||
log_info("Sending CRC table");
|
||||
crc_send_table();
|
||||
|
||||
found = wait_for_message("DONE", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
goto error_unhandled;
|
||||
|
||||
log_info("Sending UBL data");
|
||||
send_buffer(data, size);
|
||||
|
||||
found = wait_for_message("DONE", "CORRUPT", NULL);
|
||||
if (found != 1)
|
||||
goto error;
|
||||
goto error_unhandled;
|
||||
|
||||
found = wait_for_message("PSPBootMode = UART", NULL, NULL);
|
||||
found = wait_for_message("BootMode = UART", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
goto error_unhandled;
|
||||
|
||||
found = wait_for_message("BOOTPSP", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
|
||||
bootpsp_received:
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
send_srec(const char *elf_file, const char *temp_file, u_int32_t magic_number)
|
||||
{
|
||||
int found;
|
||||
int ret;
|
||||
u_int32_t entry_point;
|
||||
ssize_t size;
|
||||
u_int8_t data[SREC_MAX_SIZE];
|
||||
|
||||
/* Specify max size of our buffers */
|
||||
size = sizeof(data);
|
||||
|
||||
/* Convert UBL ELF to srec and get the resulting srec file size and
|
||||
* entry point. */
|
||||
ret = convert_elf_to_srec(elf_file, temp_file, data, &size,
|
||||
&entry_point);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
log_info("Sending ACK sequence");
|
||||
send_message(" ACK\n");
|
||||
|
||||
log_info("Sending magic number ($%08X)", magic_number);
|
||||
send_number(magic_number, 8);
|
||||
|
||||
log_info("Sending application entry point ($%08X)", entry_point);
|
||||
send_number(entry_point, 8);
|
||||
|
||||
log_info("Sending application size ($%08X bytes)", size);
|
||||
send_number(size, 8);
|
||||
|
||||
log_info("Sending termination sequence");
|
||||
send_number(0x0000, 4);
|
||||
|
||||
/* We can also receive BADCNT if the size is invalid. */
|
||||
found = wait_for_message("BEGIN", "BADADDR", "BADCNT");
|
||||
if (found != 1)
|
||||
goto error;
|
||||
|
||||
log_info("Sending SREC data");
|
||||
send_ascii_data(data, size);
|
||||
|
||||
/* First DONE message indicates UBL received all data. */
|
||||
found = wait_for_message("DONE", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
|
||||
/* The second DONE message indicates the S-record was decoded
|
||||
* successfully. */
|
||||
found = wait_for_message("DONE", "BOOTME", NULL);
|
||||
if (found != 1)
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
send_ubl_srec(char *elf_file)
|
||||
{
|
||||
int found;
|
||||
int ret;
|
||||
|
||||
log_info("Sending CMD sequence");
|
||||
send_message(" CMD\n");
|
||||
|
||||
log_info("Sending magic number ($%08X)", UBL_MAGIC_NAND_FLASH);
|
||||
send_number(UBL_MAGIC_NAND_FLASH, 8);
|
||||
|
||||
found = wait_for_message("SENDUBL", NULL, NULL);
|
||||
if (!found)
|
||||
return 1;
|
||||
|
||||
ret = send_srec(elf_file, "/tmp/ubl.srec", UBL_MAGIC_SAFE);
|
||||
if (ret) {
|
||||
log_info("Error sending UBL for flashing");
|
||||
return ret;
|
||||
goto error_unhandled;
|
||||
}
|
||||
|
||||
found = wait_for_message("SENDAPP", NULL, NULL);
|
||||
if (!found)
|
||||
return 1;
|
||||
ret = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
send_app_srec(char *elf_file)
|
||||
{
|
||||
int found;
|
||||
int ret;
|
||||
|
||||
ret = send_srec(elf_file, "/tmp/app.srec", UBL_MAGIC_BIN_IMG);
|
||||
if (ret) {
|
||||
log_info("Error sending application for flashing");
|
||||
error_handled:
|
||||
free(data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Wait for third DONE message that indicates booting */
|
||||
found = wait_for_message("DONE", NULL, NULL);
|
||||
if (!found)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
error_unhandled:
|
||||
ret = 1;
|
||||
goto error_handled;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -438,13 +384,15 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
struct options_t *options;
|
||||
int found;
|
||||
u_int32_t cmd;
|
||||
|
||||
options = parse_command_line_options(argc, argv);
|
||||
|
||||
parse_environment_variables();
|
||||
|
||||
ret = check_source_files(options->ubl, options->app);
|
||||
ret = check_source_files(options->app_header, options->ubl,
|
||||
options->app);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -452,28 +400,82 @@ main(int argc, char *argv[])
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Send UBL in binary format for RBL */
|
||||
ret = send_ubl_binary(options->ubl);
|
||||
/* Wait for the device to send the BOOTME sequence.
|
||||
* If the UBL is already running, it will send BOOTPSP. */
|
||||
found = wait_for_message("BOOTME", "BOOTPSP", NULL);
|
||||
if (found == 0)
|
||||
goto error;
|
||||
else if (found == 1) {
|
||||
/* Send UBL in binary format for RBL.
|
||||
* Magic and block numbers are not used. */
|
||||
ret = send_binary(options->ubl, "/tmp/ubl.bin", SEND_UBL, 0, 0);
|
||||
if (ret)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* UBL is now running. Send command */
|
||||
if (options->ddr_test)
|
||||
cmd = UBL_CMD_DDR_TEST;
|
||||
else if (options->app_header == 0)
|
||||
cmd = UBL_CMD_FLASH_DATA;
|
||||
else
|
||||
cmd = UBL_CMD_FLASH_UBL_APP;
|
||||
|
||||
log_info("Sending command to UBL ($%08X)", cmd);
|
||||
send_message(" CMD\n");
|
||||
send_number(cmd, 8);
|
||||
|
||||
if (options->ddr_test) {
|
||||
found = wait_for_message("DDRTEST_SUCCESS", "DDRTEST_FAILURE", NULL);
|
||||
if (found != 1)
|
||||
goto error;
|
||||
} else if (options->app_header == 0) {
|
||||
found = wait_for_message("SENDDATA", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
|
||||
/* UBL is now running.
|
||||
* Send UBL for flashing in srec format. */
|
||||
ret = send_ubl_srec(options->ubl);
|
||||
if (ret)
|
||||
/* Send DATA in binary format for flashing.
|
||||
* Magic number is not used. */
|
||||
ret = send_binary(options->app, "/tmp/data.bin", SEND_APP_BIN, 0,
|
||||
options->blocknum);
|
||||
if (ret) {
|
||||
log_info("Error sending DATA for flashing");
|
||||
goto error;
|
||||
}
|
||||
|
||||
} else {
|
||||
found = wait_for_message("SENDUBL", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
|
||||
/* Send application for flashing in srec format. */
|
||||
ret = send_app_srec(options->app);
|
||||
if (ret)
|
||||
/* Send UBL in binary format for flashing.
|
||||
* Block number is not used. */
|
||||
ret = send_binary(options->ubl, "/tmp/ubl.bin", SEND_APP_ELF,
|
||||
RBL_MAGIC_SAFE, 0);
|
||||
if (ret) {
|
||||
log_info("Error sending UBL for flashing");
|
||||
goto error;
|
||||
}
|
||||
|
||||
found = wait_for_message("SENDAPP", NULL, NULL);
|
||||
if (!found)
|
||||
goto error;
|
||||
|
||||
/* Send application in binary format for flashing.
|
||||
* Block number is not used. */
|
||||
ret = send_binary(options->app, "/tmp/app.bin", SEND_APP_ELF,
|
||||
UBL_MAGIC_GZIP_IMG, 0);
|
||||
if (ret) {
|
||||
log_info("Error sending application for flashing");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
/* Close serial port. */
|
||||
serial_port_close();
|
||||
|
||||
return ret;
|
||||
|
||||
error:
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "serial.h"
|
||||
#include "options.h"
|
||||
|
||||
#define START_APP_BLOCK_NUM 6
|
||||
|
||||
static struct options_t options;
|
||||
|
||||
/* Global variables needed by libcommon debug functions. */
|
||||
|
@ -57,8 +59,14 @@ static struct argp_option my_options[] = {
|
|||
{"debug", 'd', "LEVEL", 0,
|
||||
"Set verbosity level of messages. Valid levels are 0 (errors only)" \
|
||||
" to 5 (full debug)" },
|
||||
{"no-header", 'n', NULL, 0,
|
||||
"Don't write application header" },
|
||||
{"port", 'p', "PORT", 0, "Serial port device. Default is" \
|
||||
" /dev/ttyS0." },
|
||||
{"test", 't', NULL, 0,
|
||||
"Perform DDR2 memory testing" },
|
||||
{"writeblock", 'w', "BLOCKNUM", 0,
|
||||
"Write application at block BLOCKNUM in flash memory. Default is 6" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
@ -76,9 +84,18 @@ parse_opt(int key, char *arg, struct argp_state *state)
|
|||
if (decode_debug_option(arg) < 0)
|
||||
argp_error(state, "unsupported debug level `%s'", arg);
|
||||
break;
|
||||
case 'n':
|
||||
options.app_header = 0; /* Don't write app. header. */
|
||||
break;
|
||||
case 'p':
|
||||
hv_strncpy(options.port_string, arg, MAX_FILENAME_LENGTH);
|
||||
break;
|
||||
case 't':
|
||||
options.ddr_test = 1;
|
||||
break;
|
||||
case 'w':
|
||||
options.blocknum = atoi(arg);
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
if (state->arg_num == 0)
|
||||
hv_strncpy(options.ubl, arg, MAX_FILENAME_LENGTH);
|
||||
|
@ -91,10 +108,10 @@ parse_opt(int key, char *arg, struct argp_state *state)
|
|||
switch (state->arg_num) {
|
||||
case 0:
|
||||
argp_error(state,
|
||||
"missing UBL and application filenames");
|
||||
"Missing UBL and application filenames");
|
||||
break;
|
||||
case 1:
|
||||
argp_error(state, "missing application filename");
|
||||
argp_error(state, "Missing application filename");
|
||||
break;
|
||||
default:
|
||||
/* Ok */
|
||||
|
@ -124,6 +141,9 @@ parse_command_line_options(int argc, char *argv[])
|
|||
{
|
||||
/* Setting default values. */
|
||||
debug_level = LEVEL_INFO;
|
||||
options.ddr_test = 0;
|
||||
options.blocknum = START_APP_BLOCK_NUM;
|
||||
options.app_header = 1; /* Write application header */
|
||||
options.ubl[0] = '\0';
|
||||
options.app[0] = '\0';
|
||||
hv_strncpy(options.port_string, DEFAULT_UART_PORT, MAX_FILENAME_LENGTH);
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
|
||||
struct options_t {
|
||||
int baud_rate_index;
|
||||
int ddr_test;
|
||||
int blocknum;
|
||||
int app_header;
|
||||
char port_string[MAX_FILENAME_LENGTH];
|
||||
char ubl[MAX_FILENAME_LENGTH];
|
||||
char app[MAX_FILENAME_LENGTH];
|
||||
|
|
|
@ -258,6 +258,15 @@ send_buffer(u_int8_t *data, ssize_t size_in_bytes)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
send_buffer_bin(u_int8_t *data, ssize_t size_in_bytes)
|
||||
{
|
||||
for (; size_in_bytes > 0; size_in_bytes--, data++)
|
||||
write(serial_port.fd, data, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
send_ascii_data(u_int8_t *data, ssize_t size)
|
||||
{
|
||||
|
|
|
@ -39,6 +39,9 @@ send_number(u_int32_t number, int digits);
|
|||
int
|
||||
send_buffer(u_int8_t *data, ssize_t size_in_bytes);
|
||||
|
||||
int
|
||||
send_buffer_bin(u_int8_t *data, ssize_t size_in_bytes);
|
||||
|
||||
int
|
||||
send_ascii_data(u_int8_t *data, ssize_t size_in_bytes);
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
v0.2.3
|
||||
Mini-DAS: Enable DSP1 & DSP2 power.
|
||||
|
||||
v0.2.4
|
||||
Mini-DAS: Enable DSP1 & DSP2 power.
|
||||
Deactivate DSP1 & DSP2 reset lines.
|
||||
|
||||
|
||||
v0.2.5
|
||||
Mini-DAS: Enable all power supplys and deactivate
|
||||
all peripheral reset lines.
|
||||
|
||||
v0.2.6
|
||||
Mini-DAS: Add delay after applying DSP power and
|
||||
before releasing DSP reset lines.
|
||||
|
||||
v0.2.7
|
||||
Mini-DAS: Open-drain output for CAMERA RESET.
|
|
@ -0,0 +1,201 @@
|
|||
#
|
||||
# Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
ifndef CROSS_COMPILE
|
||||
CROSS_COMPILE=arm-linux-
|
||||
endif
|
||||
|
||||
.PHONY : clean check
|
||||
|
||||
CC=$(CROSS_COMPILE)gcc
|
||||
LD=$(CROSS_COMPILE)ld
|
||||
|
||||
CFLAGS := -c -Os -Wall
|
||||
LDFLAGS := -Map ubl.map -nostdlib
|
||||
|
||||
SOURCES := davinci.c uart.c uartboot.c ubl.c util.c gpio.c crc.c gunzip.c
|
||||
|
||||
# Boards setup
|
||||
ifeq ($(BOARD),dvevm)
|
||||
# EVM for DM6446
|
||||
PLATFORM := DM644x
|
||||
FLASH_TYPE := FLASH_TYPE_NAND
|
||||
DDR_TYPE := MICRON_MT47H64M16BT_3_162MHZ
|
||||
DDR_SIZE := 0x10000000 # 256MB
|
||||
endif
|
||||
ifeq ($(BOARD),sffsdr)
|
||||
PLATFORM := DM644x
|
||||
FLASH_TYPE := FLASH_TYPE_NAND
|
||||
DDR_TYPE := MICRON_MT47H32M16BN_3_162MHZ
|
||||
DDR_SIZE := 0x08000000 # 128MB
|
||||
endif
|
||||
ifeq ($(BOARD),das)
|
||||
PLATFORM := DM644x
|
||||
FLASH_TYPE := FLASH_TYPE_NAND
|
||||
DDR_TYPE := MICRON_MT47H64M16HR_3_162MHZ
|
||||
DDR_SIZE := 0x10000000 # 256MB
|
||||
endif
|
||||
ifeq ($(BOARD),minidas)
|
||||
PLATFORM := DM35x
|
||||
FLASH_TYPE := FLASH_TYPE_NAND
|
||||
DDR_TYPE := MICRON_MT47H128M16HG_3IT_171MHZ
|
||||
DDR_SIZE := 0x10000000 # 256MB
|
||||
endif
|
||||
ifeq ($(BOARD),afeusb)
|
||||
PLATFORM := DM35x
|
||||
FLASH_TYPE := FLASH_TYPE_NAND
|
||||
DDR_TYPE := MICRON_MT47H32M16BN_3_171MHZ
|
||||
DDR_SIZE := 0x04000000 # 64MB
|
||||
endif
|
||||
ifeq ($(BOARD),dm355evm)
|
||||
PLATFORM := DM35x
|
||||
FLASH_TYPE := FLASH_TYPE_NAND
|
||||
DDR_TYPE := MICRON_MT47H64M16BT_37E_171MHZ
|
||||
DDR_SIZE := 0x08000000 # 128MB
|
||||
endif
|
||||
ifeq ($(BOARD),nor)
|
||||
# Only for testing NOR flash compilation
|
||||
PLATFORM := DM35x
|
||||
FLASH_TYPE := FLASH_TYPE_NOR
|
||||
DDR_TYPE := MICRON_MT47H64M16BT_37E_171MHZ
|
||||
DDR_SIZE := 0x08000000 # 128MB
|
||||
endif
|
||||
|
||||
# Generate a config.h file based on the board selected.
|
||||
# Only update this file if the selected board is different.
|
||||
OLDBOARD = $(shell cat config.h 2> /dev/null | grep "$(BOARD)")
|
||||
ifneq ($(OLDBOARD),$(BOARD))
|
||||
$(shell echo "$(BOARD)" > config.h)
|
||||
endif
|
||||
|
||||
CFLAGS += -D${PLATFORM} -D${FLASH_TYPE} -D$(DDR_TYPE) -Dboard_$(BOARD)
|
||||
|
||||
# Processor type setup
|
||||
# The Instruction and Data accesses are differentiated via accessing different
|
||||
# memory map regions. The instruction region at 0x0000 and data region at
|
||||
# 0x8000 (0x10000 for DM35x) map to the same physical TCM RAM.
|
||||
ifeq ($(PLATFORM),DM644x)
|
||||
SOURCES += dm644x.c
|
||||
IRAM_SIZE := 0x00004000
|
||||
DRAM_START := 0x00008000
|
||||
DRAM_SIZE := 0x00004000
|
||||
endif
|
||||
ifeq ($(PLATFORM),DM35x)
|
||||
SOURCES += dm35x.c
|
||||
IRAM_SIZE := 0x00008000
|
||||
DRAM_START := 0x00010000
|
||||
DRAM_SIZE := 0x00008000
|
||||
endif
|
||||
|
||||
LDFLAGS += --defsym __DDR_SIZE=$(DDR_SIZE) \
|
||||
--defsym __IRAM_SIZE=$(IRAM_SIZE) \
|
||||
--defsym __DRAM_START=$(DRAM_START) \
|
||||
--defsym __DRAM_SIZE=$(DRAM_SIZE) \
|
||||
-T ubl.lds
|
||||
|
||||
# NAND flash setup
|
||||
ifeq ($(FLASH_TYPE),FLASH_TYPE_NAND)
|
||||
SOURCES += nandboot.c nand.c
|
||||
endif
|
||||
ifeq ($(FLASH_TYPE),FLASH_TYPE_NOR)
|
||||
SOURCES += norboot.c nor.c
|
||||
endif
|
||||
|
||||
OBJECTS := $(patsubst %.c,%.o,$(SOURCES))
|
||||
EXECUTABLE := ubl.elf
|
||||
BINARY := $(EXECUTABLE)
|
||||
|
||||
DEPS_DIR := .deps
|
||||
# Creation of the dependencies directory
|
||||
$(shell mkdir -p $(DEPS_DIR))
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifndef BOARD
|
||||
all:
|
||||
@echo "You must select a board."
|
||||
@echo "List of supported boards: evmdm6446 sffsdr das minidas afeusb evmdm355"
|
||||
@echo "Example:"
|
||||
@echo " make BOARD=sffsdr"; exit 1
|
||||
else
|
||||
ifndef PLATFORM
|
||||
all:
|
||||
@echo "Invalid board"; exit 1
|
||||
else
|
||||
all: $(BINARY)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Including the dependency files (except during clean rules, so Make won't
|
||||
# create them only to immediately remove them again). Each one of them will
|
||||
# become a target in this Makefile (that is why the 'include' command must be
|
||||
# placed after the 'all' target). If a dependency file is not found or is out
|
||||
# of date, it is built or updated.
|
||||
# If any have actually been changed, Make restarts with a clean state and
|
||||
# reads all the dependency makefiles over again.
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq "$(SOURCES)" ""
|
||||
ifdef BOARD
|
||||
-include $(patsubst %.c,$(DEPS_DIR)/%.d,$(SOURCES))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
clean:
|
||||
-@rm -f -v *.o $(EXECUTABLE)
|
||||
-@rm -f -v *.map
|
||||
-@rm -f -v *~
|
||||
-@rm -f -v config.h
|
||||
-@rm -f -r $(DEPS_DIR)
|
||||
|
||||
check:
|
||||
-@checkpatch.pl --no-tree --file *.c *.h | more
|
||||
|
||||
$(EXECUTABLE): $(OBJECTS)
|
||||
$(LD) $(LDFLAGS) $(OBJECTS) -o $@
|
||||
|
||||
# Any source files depend on automatically generated config.h.
|
||||
# This is necessary to recompile everything when we change boards.
|
||||
*.o: config.h $(LINKERSCRIPT)
|
||||
|
||||
# The preprocessor of the compiler is used to generate a string representing
|
||||
# the dependencies of the input file. This is done invoking the compiler with
|
||||
# the -MM option (like -M but omit system header files). The purpose of the
|
||||
# sed script is to add the name of the dependency file (.d) to the string
|
||||
# returned by the preprocessor, like in the following example:
|
||||
# "main.o: main.c main.h" would become "main.o main.d: main.c main.h"
|
||||
# The MAKE '$*' automatic variable represents the stem with which an implicit
|
||||
# rule match. This would be 'main' in the above example.
|
||||
#
|
||||
# Use of the $(SHELL) function: Double quotes must be used to surround the
|
||||
# command.
|
||||
#
|
||||
# In MAKE, using '$$' will produce a single dollar sign. When using only '$',
|
||||
# MAKE tries to expand the variable following the dollar sign. Additionally,
|
||||
# and for an obscure reason, '$1' must be preceded by a backslash on the
|
||||
# command line. This is why '\$$1' is used in the command line of the shell to
|
||||
# be seen as '$1' by the PERL script.
|
||||
#
|
||||
# The `-e' flag to the shell makes it exit immediately if the $(CC) command
|
||||
# fails (exits with a nonzero status). Normally the shell exits with the
|
||||
# status of the last command in the pipeline (sed in this case), so make would
|
||||
# not notice a nonzero status from the compiler.
|
||||
$(DEPS_DIR)/%.d: %.c
|
||||
@echo "Generating dependencies for $<"
|
||||
@$(SHELL) -ec '$(CC) -MM $(CPPFLAGS) $< | \
|
||||
sed '\''s/\($*\)\.o[ :]*/\1.o $(DEPS_DIR)\/$*.d : /g'\'' > $@; \
|
||||
[ -s $@ ] || rm -f $@'
|
|
@ -0,0 +1,21 @@
|
|||
README for HVUBL
|
||||
|
||||
This UBL can be used for flashing itself and a 2nd stage bootloader (usually
|
||||
U-boot) in flash memory.
|
||||
|
||||
It can also be used to flash an arbitrary data image into flash, without
|
||||
a header.
|
||||
|
||||
It can also be used to run DDR RAM memory testing.
|
||||
|
||||
To compile HVUBL for the sffsdr board, for example, run:
|
||||
$> make BOARD=sffsdr
|
||||
|
||||
The Makefile honors the CROSS_COMPILE environment variable to specify the prefix
|
||||
of your ARM gcc toolchain. If it is not set, it defaults to:
|
||||
CROSS_COMPILE=arm-linux-
|
||||
|
||||
You can override it like this, for example:
|
||||
$> make CROSS_COMPILE=arm-angstrom-linux-gnueabi- BOARD=sffsdr
|
||||
|
||||
The output file, in ARM ELF format, will be named <ubl.elf>
|
|
@ -0,0 +1,7 @@
|
|||
TODO
|
||||
|
||||
-Define DDR bus width and number of banks for each board.
|
||||
-NAND write & read page: do bound checking on
|
||||
block number < maximum number of blocks.
|
||||
-When writing something other than UBL, use
|
||||
Linux and U-Boot standard ECC layout.
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* board.h - board definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _BOARD_H_
|
||||
#define _BOARD_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
|
||||
#if defined(board_dvevm)
|
||||
# define PINMUX1_DEFAULT PINMUX1_UART0
|
||||
|
||||
#elif defined(board_sffsdr)
|
||||
# define PINMUX1_DEFAULT PINMUX1_UART0 | PINMUX1_UART1 | PINMUX1_I2C | \
|
||||
PINMUX1_ASP
|
||||
|
||||
#elif defined(board_das)
|
||||
# define PINMUX0_DEFAULT PINMUX0_VLYNQEN | VLYNQ_WIDTH_4
|
||||
# define PINMUX1_DEFAULT PINMUX1_UART0 | PINMUX1_UART2 | PINMUX1_I2C | \
|
||||
PINMUX1_SPI
|
||||
|
||||
#elif defined(board_dm355evm)
|
||||
# define PINMUX0_DEFAULT 0x00007F55 /* All Video Inputs */
|
||||
# define PINMUX1_DEFAULT 0x00145555 /* All Video Outputs */
|
||||
# define PINMUX2_DEFAULT 0x00000004 /* EMIFA */
|
||||
# define PINMUX3_DEFAULT 0x1BFF55FF /* SPI0, SPI1, UART1, I2C, SD0, SD1,
|
||||
* ASP0, CLKOUTs */
|
||||
# define PINMUX4_DEFAULT 0x00000000 /* MMC/SD0 instead of MS, SPI0 */
|
||||
|
||||
#elif defined(board_minidas)
|
||||
# define PINMUX0_DEFAULT 0x00005C00 /* 8-bits video input, rest is GPIOs. */
|
||||
# define PINMUX1_DEFAULT 0x00430000 /* All GPIOs (temporary: no PWM1 for buzzer) */
|
||||
# define PINMUX2_DEFAULT 0x00000C0A /* EMIF A3:13, CE0 & CE1. */
|
||||
# define PINMUX3_DEFAULT 0x0B7BAAC0 /* SPI0, SPI1, UART1, UART2, I2C, SD0,
|
||||
* CLKOUT1, CLKOUT2 */
|
||||
# define PINMUX4_DEFAULT 0x00000001 /* MMC/SD0 + SPI0_SDI */
|
||||
|
||||
/* Optional GPIO used as a status LED. Make sure to enable the corresponding
|
||||
* PINMUX bit. */
|
||||
#define STATUS_LED GPIO(71)
|
||||
#define DSP1_PWR_ENA GPIO(95)
|
||||
#define DSP2_PWR_ENA GPIO(94)
|
||||
#define HDD_ENA GPIO(96)
|
||||
#define FULL_ENA GPIO(68)
|
||||
#define ALCOHOL_ENA GPIO(73)
|
||||
#define CAMERA_RESETn GPIO(72)
|
||||
#define FAN GPIO(81)
|
||||
#define BUZZER GPIO(80)
|
||||
#define WIFI_RESETn GPIO(79)
|
||||
#define GPS_RESETn GPIO(78)
|
||||
#define CAN_RESETn GPIO(77)
|
||||
#define ATA_RESETn GPIO(76)
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _BOARD_H_ */
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* common.h - common definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h> /* For size_t */
|
||||
|
||||
#include "board.h"
|
||||
|
||||
/* Return types */
|
||||
#define E_PASS 0
|
||||
#define E_FAIL 1
|
||||
#define E_TIMEOUT 2
|
||||
|
||||
/* Define this to have more verbose NAND debug messages */
|
||||
/* #define NAND_DEBUG 1 */
|
||||
|
||||
/* Define this to write a RAMP into NAND for debugging. */
|
||||
/* #define NAND_DEBUG_WRITE_RAMP 1 */
|
||||
|
||||
#define UBL_VERSION_STR "HV-UBL v0.2.11"
|
||||
|
||||
/* Define this for bypassing the ECC check when reading from the NAND.
|
||||
* This is useful for debugging or during development. */
|
||||
#define NAND_BYPASS_READ_PAGE_ECC_CHECK 1
|
||||
|
||||
#define MAGIC_NUMBER_MASK 0xFFFFFF00
|
||||
#define MAGIC_NUMBER_VALID 0xA1ACED00
|
||||
|
||||
/* RBL magic numbers */
|
||||
#define RBL_MAGIC_SAFE 0xA1ACED00 /* Describes UBL flash image type for
|
||||
* RBL. */
|
||||
|
||||
/* UBL magic numbers */
|
||||
#define UBL_MAGIC_BIN_IMG 0xA1ACED66 /* Describes binary flash image type
|
||||
* for UBL. */
|
||||
#define UBL_MAGIC_GZIP_IMG 0xA1ACED77 /* Describes gzipped binary flash
|
||||
* image type for UBL. */
|
||||
|
||||
/* UBL commands */
|
||||
#define UBL_CMD_FLASH_UBL_APP 0xA1ACEDCC /* Download UBL & application via
|
||||
* UART and burn in flash. */
|
||||
#define UBL_CMD_FLASH_DATA 0xA1ACEDCD /* Download data via UART and
|
||||
* burn in flash (no header in flash). */
|
||||
#define UBL_CMD_FLASH_ERASE 0xA1ACEDCE /* Erase the whole flash. */
|
||||
#define UBL_CMD_RUN_APP 0xA1ACEDDD /* Load and run application via UART. */
|
||||
#define UBL_CMD_DDR_TEST 0xA1ACEDEE /* Test DDR2 memory. */
|
||||
|
||||
/* Define maximum downloadable image size */
|
||||
#define MAX_IMAGE_SIZE 0xC00000 /* 12 Mbytes */
|
||||
|
||||
struct nor_boot_t {
|
||||
uint32_t magicNum;
|
||||
uint32_t entryPoint;
|
||||
uint32_t appSize;
|
||||
uint32_t ldAddress; /* Starting RAM address where image is to copied - XIP Mode */
|
||||
};
|
||||
|
||||
enum bootmode_t {
|
||||
NON_SECURE_NAND = 0, /* Non-secure NAND mode */
|
||||
NON_SECURE_NOR, /* Non-secure NOR mode */
|
||||
UNKNOWN_MODE, /* Unknown mode */
|
||||
NON_SECURE_UART /* Non-secure UART mode */
|
||||
};
|
||||
|
||||
#define ENDIAN_SWAP(a) (((a&0xFF)<<24)|((a&0xFF0000)>>8)|((a&0xFF00)<<8)|((a&0xFF000000)>>24))
|
||||
|
||||
/* Log functions */
|
||||
#define log_fail(_x_) uart_send_str_lf(_x_)
|
||||
#define log_info(_x_) uart_send_str_lf(_x_)
|
||||
#define log_debug(_x_) uart_send_str_lf(_x_)
|
||||
|
||||
#define host_msg(_x_) uart_send_str_lf(_x_)
|
||||
|
||||
#endif /* _COMMON_H_ */
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* crc.h -- CRC routines
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on dv-boot, original copyright follows:
|
||||
* Copyright (c) 2007 Sergey Kubushin <ksi@koi8.net>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h> /* For size_t */
|
||||
|
||||
#define CRC_TABLE_ELEMENTS 256
|
||||
#define DAVINCI_CRC_POLY 0x04C11DB7
|
||||
|
||||
static uint32_t crc32_table[CRC_TABLE_ELEMENTS];
|
||||
|
||||
static uint32_t
|
||||
reflect_num(uint32_t in_val, uint32_t num)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t out_val = 0x0;
|
||||
|
||||
for (i = 1; i < (num + 1); i++) {
|
||||
out_val |= (uint32_t)(((in_val & 0x1)) << (num - i));
|
||||
in_val >>= 1;
|
||||
}
|
||||
|
||||
return out_val;
|
||||
}
|
||||
|
||||
/* Build a reflected CRC-32 table (for standard CRC-32 algorithm) */
|
||||
void
|
||||
crc32_dv_build_table(void)
|
||||
{
|
||||
uint32_t i, j, crc_accum;
|
||||
|
||||
for (i = 0; i < CRC_TABLE_ELEMENTS; i++) {
|
||||
crc_accum = reflect_num(i, 8) << (32 - 8);
|
||||
for (j = 0; j < 8; j++) {
|
||||
if ((crc_accum & 0x80000000) != 0x00000000)
|
||||
crc_accum = (crc_accum << 1) ^ DAVINCI_CRC_POLY;
|
||||
else
|
||||
crc_accum = (crc_accum << 1);
|
||||
|
||||
crc32_table[i] = reflect_num(crc_accum, 32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Compute CRC32 checksum */
|
||||
uint32_t
|
||||
crc32_dv_compute(uint8_t *data, size_t size)
|
||||
{
|
||||
uint32_t crc32 = 0xFFFFFFFF;
|
||||
|
||||
while (size-- > 0)
|
||||
crc32 = crc32_table[(crc32 ^ *data++) & 0xFF] ^ (crc32 >> 8);
|
||||
|
||||
return crc32;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* crc.h -- CRC definitions.
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef CRC_H
|
||||
#define CRC_H 1
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h> /* For size_t, memcpy, memset */
|
||||
|
||||
/* Build a reflected CRC-32 table (for standard CRC-32 algorithm) */
|
||||
void crc32_dv_build_table(void);
|
||||
|
||||
/* Compute non-standard CRC32 */
|
||||
uint32_t
|
||||
crc32_dv_compute(uint8_t *data, size_t size);
|
||||
|
||||
#endif /* CRC_H */
|
|
@ -0,0 +1,528 @@
|
|||
/*
|
||||
* davinci.c - common DaVinci platform initialization
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
#include "ddr.h"
|
||||
#include "util.h"
|
||||
#include "uart.h"
|
||||
#include "gpio.h"
|
||||
|
||||
extern enum bootmode_t bootmode;
|
||||
extern const int8_t lpsc_en_list[];
|
||||
extern const int8_t lpsc_emurstie_list[];
|
||||
extern const size_t lpsc_en_list_len;
|
||||
extern const size_t lpsc_emurstie_list_len;
|
||||
|
||||
/* Symbol from linker script */
|
||||
extern uint32_t __DDR_START;
|
||||
|
||||
static void
|
||||
pinmuxControl(uint32_t regOffset, uint32_t mask, uint32_t value)
|
||||
{
|
||||
SYSTEM->PINMUX[regOffset] &= ~mask;
|
||||
SYSTEM->PINMUX[regOffset] |= (mask & value);
|
||||
}
|
||||
|
||||
static void
|
||||
lpsc_tansition(uint8_t module, uint8_t domain, uint8_t state)
|
||||
{
|
||||
/* Wait for any outstanding transition to complete */
|
||||
while ((PSC->PTSTAT) & (0x00000001 << domain))
|
||||
;
|
||||
|
||||
/* If we are already in that state, just return */
|
||||
if (((PSC->MDSTAT[module]) & 0x1F) == state)
|
||||
return;
|
||||
|
||||
/* Perform transition */
|
||||
PSC->MDCTL[module] = ((PSC->MDCTL[module]) & (0xFFFFFFE0)) | (state);
|
||||
PSC->PTCMD |= (0x00000001 << domain);
|
||||
|
||||
/* Wait for transition to complete */
|
||||
while ((PSC->PTSTAT) & (0x00000001 << domain))
|
||||
;
|
||||
|
||||
/* Wait and verify the state */
|
||||
while (((PSC->MDSTAT[module]) & 0x1F) != state)
|
||||
;
|
||||
}
|
||||
|
||||
static void
|
||||
ivt_init(void)
|
||||
{
|
||||
volatile uint32_t *ivect;
|
||||
extern uint32_t __IVT;
|
||||
|
||||
if (bootmode == NON_SECURE_NOR) {
|
||||
ivect = &(__IVT);
|
||||
*ivect++ = 0xEAFFFFFE; /* Reset @ 0x00*/
|
||||
} else
|
||||
ivect = &(__IVT) + 4;
|
||||
|
||||
*ivect++ = 0xEAFFFFFE; /* Undefined Address @ 0x04 */
|
||||
*ivect++ = 0xEAFFFFFE; /* Software Interrupt @0x08 */
|
||||
*ivect++ = 0xEAFFFFFE; /* Pre-Fetch Abort @ 0x0C */
|
||||
*ivect++ = 0xEAFFFFFE; /* Data Abort @ 0x10 */
|
||||
*ivect++ = 0xEAFFFFFE; /* Reserved @ 0x14 */
|
||||
*ivect++ = 0xEAFFFFFE; /* IRQ @ 0x18 */
|
||||
*ivect = 0xEAFFFFFE; /* FIQ @ 0x1C */
|
||||
}
|
||||
|
||||
static int
|
||||
timer0_init(void)
|
||||
{
|
||||
TIMER0->TGCR = 0x00000000; /* Reset timer */
|
||||
TIMER0->TCR = 0x00000000; /* Disable timer */
|
||||
TIMER0->TIM12 = 0x00000000; /* Reset timer count to zero */
|
||||
|
||||
/* Set timer period (5 seconds timeout) */
|
||||
TIMER0->PRD12 = SYSTEM_CLK_HZ * 5;
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
void
|
||||
timer0_start(void)
|
||||
{
|
||||
AINTC->IRQ1 |= 0x00000001; /* Clear interrupt */
|
||||
TIMER0->TGCR = 0x00000000; /* Reset timer */
|
||||
TIMER0->TIM12 = 0x00000000; /* Reset timer count to zero */
|
||||
TIMER0->TCR = 0x00000040; /* Setup for one-shot mode */
|
||||
TIMER0->TGCR = 0x00000005; /* Start TIMER12 in 32-bits mode. */
|
||||
}
|
||||
|
||||
uint32_t
|
||||
timer0_status(void)
|
||||
{
|
||||
return AINTC->IRQ1 & 0x1;
|
||||
}
|
||||
|
||||
static int
|
||||
uart0_init(void)
|
||||
{
|
||||
UART0->PWREMU_MGNT = 0; /* Reset UART TX & RX components */
|
||||
waitloop(100);
|
||||
|
||||
/* Set DLAB bit - allows setting of clock divisors */
|
||||
UART0->LCR |= 0x80;
|
||||
|
||||
/*
|
||||
* Compute divisor value. Normally, we should simply return:
|
||||
* SYSTEM_CLK_HZ / (16 * baudrate)
|
||||
* but we need to round that value by adding 0.5.
|
||||
* Rounding is especially important at high baud rates.
|
||||
*/
|
||||
UART0->DLL = (SYSTEM_CLK_HZ + (UART_BAUDRATE * (UART_BCLK_RATIO / 2))) /
|
||||
(UART_BCLK_RATIO * UART_BAUDRATE);
|
||||
UART0->DLH = 0x00;
|
||||
|
||||
UART0->FCR = 0x0007; /* Clear UART TX & RX FIFOs */
|
||||
UART0->MCR = 0x0000; /* RTS & CTS disabled,
|
||||
* Loopback mode disabled,
|
||||
* Autoflow disabled
|
||||
*/
|
||||
|
||||
UART0->LCR = 0x0003; /* Clear DLAB bit
|
||||
* 8-bit words,
|
||||
* 1 STOP bit generated,
|
||||
* No Parity, No Stick paritiy,
|
||||
* No Break control
|
||||
*/
|
||||
|
||||
/* Enable receiver, transmitter, set to run. */
|
||||
UART0->PWREMU_MGNT |= 0x6001;
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
static int
|
||||
pll_init(volatile struct pll_regs_t *pll, int pll_mult, int plldiv_ratio[5])
|
||||
{
|
||||
int k;
|
||||
volatile uint32_t *plldiv_reg[5];
|
||||
int pll_is_powered_up =
|
||||
(pll->PLLCTL & DEVICE_PLLCTL_PLLPWRDN_MASK) >> 1;
|
||||
|
||||
plldiv_reg[0] = &pll->PLLDIV1;
|
||||
plldiv_reg[1] = &pll->PLLDIV2;
|
||||
plldiv_reg[2] = &pll->PLLDIV3;
|
||||
plldiv_reg[3] = &pll->PLLDIV4;
|
||||
plldiv_reg[4] = &pll->PLLDIV5;
|
||||
|
||||
/* Set PLL clock input to internal osc. */
|
||||
pll->PLLCTL &= ~(DEVICE_PLLCTL_CLKMODE_MASK);
|
||||
|
||||
/* Set PLL to bypass, then wait for PLL to stabilize */
|
||||
pll->PLLCTL &= ~(DEVICE_PLLCTL_PLLENSRC_MASK |
|
||||
DEVICE_PLLCTL_PLLEN_MASK);
|
||||
waitloop(150);
|
||||
|
||||
/* Reset PLL: Warning, bit state is inverted for DM644x vs DM35x. */
|
||||
#if defined(DM644x)
|
||||
pll->PLLCTL &= ~DEVICE_PLLCTL_PLLRST_MASK;
|
||||
#elif defined(DM35x)
|
||||
pll->PLLCTL |= DEVICE_PLLCTL_PLLRST_MASK;
|
||||
#endif
|
||||
|
||||
if (pll_is_powered_up) {
|
||||
/* Disable PLL */
|
||||
pll->PLLCTL |= DEVICE_PLLCTL_PLLDIS_MASK;
|
||||
|
||||
/* Powerup PLL */
|
||||
pll->PLLCTL &= ~(DEVICE_PLLCTL_PLLPWRDN_MASK);
|
||||
}
|
||||
|
||||
/* Enable PLL */
|
||||
pll->PLLCTL &= ~(DEVICE_PLLCTL_PLLDIS_MASK);
|
||||
|
||||
/* Wait for PLL to stabilize */
|
||||
waitloop(150);
|
||||
|
||||
/* Load PLL multiplier. */
|
||||
pll->PLLM = (pll_mult - 1) & 0xff;
|
||||
|
||||
/* Set and enable dividers as needed. */
|
||||
for (k = 0; k < 5; k++) {
|
||||
if (plldiv_ratio[k] > 0)
|
||||
*(plldiv_reg[k]) |= DEVICE_PLLDIV_EN_MASK |
|
||||
(plldiv_ratio[k] - 1);
|
||||
}
|
||||
|
||||
#if defined(DM35x)
|
||||
/* Set the processor AIM wait state and PLL1 post-divider to to 1 */
|
||||
SYSTEM->MISC &= ~(DEVICE_MISC_PLL1POSTDIV_MASK |
|
||||
DEVICE_MISC_AIMWAITST_MASK);
|
||||
#endif
|
||||
|
||||
/* Initiate a new divider transition. */
|
||||
pll->PLLCMD |= DEVICE_PLLCMD_GOSET_MASK;
|
||||
|
||||
/* Wait for completion of phase alignment. */
|
||||
while ((pll->PLLSTAT & DEVICE_PLLSTAT_GOSTAT_MASK))
|
||||
;
|
||||
|
||||
/* Wait for PLL to reset ( ~5 usec ) */
|
||||
waitloop(5000);
|
||||
|
||||
/* Release PLL from reset */
|
||||
|
||||
/* Reset PLL: Warning, bit state is inverted for DM644x vs DM35x. */
|
||||
#if defined(DM644x)
|
||||
pll->PLLCTL |= DEVICE_PLLCTL_PLLRST_MASK;
|
||||
#elif defined(DM35x)
|
||||
pll->PLLCTL &= ~DEVICE_PLLCTL_PLLRST_MASK;
|
||||
#endif
|
||||
|
||||
/* Wait for PLL to re-lock:
|
||||
* DM644z: 2000P
|
||||
* DM35x: 8000P
|
||||
*/
|
||||
waitloop(8000);
|
||||
|
||||
/* Switch out of BYPASS mode */
|
||||
pll->PLLCTL |= DEVICE_PLLCTL_PLLEN_MASK;
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
static int
|
||||
pll1_init(void)
|
||||
{
|
||||
int plldiv_ratio[5];
|
||||
|
||||
#if defined(DM644x)
|
||||
plldiv_ratio[0] = 1; /* PLLDIV1 fixed */
|
||||
plldiv_ratio[1] = 2; /* PLLDIV2 fixed */
|
||||
plldiv_ratio[2] = 3; /* PLLDIV3 fixed */
|
||||
plldiv_ratio[3] = -1; /* PLLDIV4 not used */
|
||||
plldiv_ratio[4] = 6; /* PLLDIV5 fixed */
|
||||
#elif defined(DM35x)
|
||||
plldiv_ratio[0] = 2; /* PLLDIV1 fixed */
|
||||
plldiv_ratio[1] = 4; /* PLLDIV2 fixed */
|
||||
|
||||
/* Calculate PLL divider ratio for divider 3 (feeds VPBE) */
|
||||
plldiv_ratio[2] = 0;
|
||||
while ((plldiv_ratio[2] * VPBE_CLK_HZ) <
|
||||
(SYSTEM_CLK_HZ * (PLL1_Mult >> 3)))
|
||||
plldiv_ratio[2]++;
|
||||
|
||||
/* Check to make sure we can supply accurate VPBE clock */
|
||||
if ((plldiv_ratio[2] * VPBE_CLK_HZ) !=
|
||||
(SYSTEM_CLK_HZ * (PLL1_Mult >> 3)))
|
||||
return E_FAIL;
|
||||
|
||||
/* See the device datasheet for more info (must be 2 or 4) */
|
||||
plldiv_ratio[3] = 4;
|
||||
plldiv_ratio[4] = -1; /* PLLDIV5 not used */
|
||||
#endif
|
||||
|
||||
return pll_init(PLL1, PLL1_Mult, plldiv_ratio);
|
||||
}
|
||||
|
||||
static int
|
||||
pll2_init(void)
|
||||
{
|
||||
int plldiv_ratio[5];
|
||||
|
||||
plldiv_ratio[0] = PLL2_Div1;
|
||||
plldiv_ratio[1] = PLL2_Div2;
|
||||
plldiv_ratio[2] = -1; /* PLLDIV3 not used */
|
||||
plldiv_ratio[3] = -1; /* PLLDIV4 not used */
|
||||
plldiv_ratio[4] = -1; /* PLLDIV5 not used */
|
||||
|
||||
return pll_init(PLL2, PLL2_Mult, plldiv_ratio);
|
||||
}
|
||||
|
||||
static void
|
||||
ddr_timing_setup(void)
|
||||
{
|
||||
/* The configuration of DDRPHYCR is not dependent on the DDR2 device
|
||||
* specification but rather on the board layout.
|
||||
* Setup the read latency and clear DLLPWRDN */
|
||||
DDR->DDRPHYCR = DDRPHYCR_DEFAULT |
|
||||
(DDR_READ_Latency & DDRPHYCR_READLAT_MASK);
|
||||
|
||||
/*
|
||||
* Set the PR_OLD_COUNT bits in the Bus Burst Priority Register (PBBPR)
|
||||
* as suggested in TMS320DM6446 errata 2.1.2:
|
||||
*
|
||||
* On DM6446 Silicon Revision 2.1 and earlier, under certain conditions
|
||||
* low priority modules can occupy the bus and prevent high priority
|
||||
* modules like the VPSS from getting the required DDR2 throughput.
|
||||
*/
|
||||
DDR->PBBPR = DDR_PBBPR_PR_OLD_COUNT;
|
||||
|
||||
/* TIMUNLOCK (unlocked), CAS Latency, number of banks and page size */
|
||||
DDR->SDBCR = SDBCR_DEFAULT |
|
||||
SDBCR_TIMUNLOCK |
|
||||
(DDR_NM << 14) |
|
||||
(DDR_CL << 9) |
|
||||
(DDR_IBANK << 4) |
|
||||
(DDR_PAGESIZE << 0);
|
||||
|
||||
/* Program timing registers */
|
||||
DDR->SDTIMR = (DDR_T_RFC << 25) |
|
||||
(DDR_T_RP << 22) |
|
||||
(DDR_T_RCD << 19) |
|
||||
(DDR_T_WR << 16) |
|
||||
(DDR_T_RAS << 11) |
|
||||
(DDR_T_RC << 6) |
|
||||
(DDR_T_RRD << 3) |
|
||||
(DDR_T_WTR << 0);
|
||||
|
||||
DDR->SDTIMR2 = (DDR_T_XSNR << 16) |
|
||||
(DDR_T_XSRD << 8) |
|
||||
(DDR_T_RTP << 5) |
|
||||
(DDR_T_CKE << 0);
|
||||
#if defined(DM35x)
|
||||
DDR->SDTIMR2 |= (DDR_T_RASMAX << 27) |
|
||||
(DDR_T_XP << 25);
|
||||
#endif
|
||||
|
||||
/* Clear the TIMUNLOCK bit (locked) */
|
||||
DDR->SDBCR &= ~SDBCR_TIMUNLOCK;
|
||||
|
||||
/* Set the refresh rate */
|
||||
DDR->SDRCR = DDR_RR;
|
||||
}
|
||||
|
||||
static void
|
||||
ddr_reset(void)
|
||||
{
|
||||
/* Perform a soft reset to the DDR2 memory controller:
|
||||
* Put in SYNCRESET and enable it again. */
|
||||
lpsc_tansition(LPSC_DDR2, PD0, PSC_SYNCRESET);
|
||||
lpsc_tansition(LPSC_DDR2, PD0, PSC_ENABLE);
|
||||
}
|
||||
|
||||
static int
|
||||
ddr_init(void)
|
||||
{
|
||||
volatile uint32_t *ddr_start = &__DDR_START;
|
||||
/* For reading/writing dummy value in order to apply timing settings */
|
||||
volatile uint32_t ddr_dummy_read;
|
||||
|
||||
/* Enable DDR2 module. */
|
||||
lpsc_tansition(LPSC_DDR2, PD0, PSC_ENABLE);
|
||||
|
||||
#if defined(DM35x)
|
||||
ddr_vtp_calibration();
|
||||
ddr_reset();
|
||||
#endif
|
||||
|
||||
ddr_timing_setup();
|
||||
|
||||
/* Dummy read to apply timing settings */
|
||||
ddr_dummy_read = ddr_start[0];
|
||||
|
||||
#if defined(DM644x)
|
||||
ddr_reset();
|
||||
ddr_vtp_calibration();
|
||||
#endif
|
||||
|
||||
/* Verify correct initialization. */
|
||||
ddr_start[0] = DDR_TEST_PATTERN;
|
||||
if (ddr_start[0] != DDR_TEST_PATTERN) {
|
||||
log_fail("DDR init failed");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
static void
|
||||
psc_init(void)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
#if defined(DM35x)
|
||||
/* Do always on power domain transitions */
|
||||
while ((PSC->PTSTAT) & 0x00000001);
|
||||
#elif defined(DM644x)
|
||||
/*
|
||||
* Workaround for TMS320DM6446 errata 1.3.22
|
||||
* (Revision(s) Affected: 1.3 and earlier):
|
||||
* PSC: PTSTAT Register Does Not Clear After Warm/Maximum Reset.
|
||||
* Clear the reserved location at address 0x01C41A20
|
||||
*/
|
||||
PSC_PTSTAT_WORKAROUND_REG = 0;
|
||||
|
||||
/* Put the C64x+ Core into reset (if it's on) */
|
||||
PSC->MDCTL[LPSC_DSP] &= (~0x00000100);
|
||||
PSC->PTCMD |= 0x00000002;
|
||||
while ((PSC->PTSTAT) & (0x00000002));
|
||||
while ((PSC->MDSTAT[LPSC_DSP]) & (0x00000100));
|
||||
#endif
|
||||
|
||||
/* Enable selected modules */
|
||||
for (i = 0; i < lpsc_en_list_len; i++) {
|
||||
int8_t k = lpsc_en_list[i];
|
||||
|
||||
PSC->MDCTL[k] = (PSC->MDCTL[k] & 0xFFFFFFE0) | PSC_ENABLE;
|
||||
}
|
||||
|
||||
/* Set EMURSTIE on selected modules */
|
||||
for (i = 0; i < lpsc_emurstie_list_len; i++) {
|
||||
int8_t k = lpsc_emurstie_list[i];
|
||||
|
||||
PSC->MDCTL[k] |= EMURSTIE_MASK;
|
||||
}
|
||||
|
||||
/* Do Always-On Power Domain Transitions */
|
||||
PSC->PTCMD |= 0x00000001;
|
||||
while ((PSC->PTSTAT) & 0x00000001);
|
||||
|
||||
#if defined(DM644x)
|
||||
/* DO DSP Power Domain Transitions */
|
||||
PSC->PTCMD |= 0x00000002;
|
||||
while ((PSC->PTSTAT) & (0x00000002));
|
||||
#endif
|
||||
|
||||
/* Clear EMURSTIE on selected modules */
|
||||
for (i = 0; i < lpsc_emurstie_list_len; i++) {
|
||||
int8_t k = lpsc_emurstie_list[i];
|
||||
|
||||
PSC->MDCTL[k] &= (~EMURSTIE_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
davinci_platform_init(char *version)
|
||||
{
|
||||
int status = E_PASS;
|
||||
|
||||
psc_init();
|
||||
|
||||
/* Disable ARM interrupts */
|
||||
AINTC->INTCTL = 0x4;
|
||||
AINTC->EABASE = 0x0;
|
||||
AINTC->EINT0 = 0x0;
|
||||
AINTC->EINT1 = 0x0;
|
||||
|
||||
AINTC->FIQ0 = 0xFFFFFFFF;
|
||||
AINTC->FIQ1 = 0xFFFFFFFF;
|
||||
AINTC->IRQ0 = 0xFFFFFFFF;
|
||||
AINTC->IRQ1 = 0xFFFFFFFF;
|
||||
|
||||
#ifdef PINMUX0_DEFAULT
|
||||
pinmuxControl(0, 0xFFFFFFFF, PINMUX0_DEFAULT);
|
||||
#endif
|
||||
#ifdef PINMUX1_DEFAULT
|
||||
pinmuxControl(1, 0xFFFFFFFF, PINMUX1_DEFAULT);
|
||||
#endif
|
||||
/* The folowing are only available on DM35x */
|
||||
#ifdef PINMUX2_DEFAULT
|
||||
pinmuxControl(2, 0xFFFFFFFF, PINMUX2_DEFAULT);
|
||||
#endif
|
||||
#ifdef PINMUX3_DEFAULT
|
||||
pinmuxControl(3, 0xFFFFFFFF, PINMUX3_DEFAULT);
|
||||
#endif
|
||||
#ifdef PINMUX4_DEFAULT
|
||||
pinmuxControl(4, 0xFFFFFFFF, PINMUX4_DEFAULT);
|
||||
#endif
|
||||
|
||||
if (status == E_PASS)
|
||||
status |= pll1_init();
|
||||
|
||||
if (status == E_PASS)
|
||||
status |= uart0_init();
|
||||
|
||||
if (status == E_PASS)
|
||||
status |= timer0_init();
|
||||
|
||||
uart_send_lf();
|
||||
log_info(version);
|
||||
|
||||
if (status == E_PASS)
|
||||
status |= pll2_init();
|
||||
|
||||
if (status == E_PASS)
|
||||
status |= ddr_init();
|
||||
|
||||
#ifdef STATUS_LED
|
||||
gpio_direction_out(STATUS_LED, 1);
|
||||
#endif /* STATUS_LED */
|
||||
|
||||
#ifdef board_minidas
|
||||
gpio_direction_out(FAN, 0);
|
||||
gpio_direction_out(BUZZER, 0);
|
||||
|
||||
/* Put all peripherals in RESET state */
|
||||
gpio_direction_out(DSP1_PWR_ENA, 0);
|
||||
gpio_direction_out(DSP2_PWR_ENA, 0);
|
||||
gpio_direction_out(WIFI_RESETn, 0);
|
||||
gpio_direction_out(GPS_RESETn, 0);
|
||||
gpio_direction_out(CAN_RESETn, 0);
|
||||
gpio_direction_out(ATA_RESETn, 0);
|
||||
gpio_direction_out(CAMERA_RESETn, 0);
|
||||
|
||||
/* Enable power for hard disk */
|
||||
gpio_direction_out(HDD_ENA, 1);
|
||||
#endif
|
||||
|
||||
/* IRQ Vector Table Setup */
|
||||
ivt_init();
|
||||
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,463 @@
|
|||
/*
|
||||
* davinci.h - common DaVinci platform definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DAVINCI_H_
|
||||
#define _DAVINCI_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#if defined(DM644x)
|
||||
#include "dm644x.h"
|
||||
#elif defined(DM35x)
|
||||
#include "dm35x.h"
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* System Control Module register structure - See sprue14.pdf, Chapter 10 *
|
||||
* for more details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct sys_module_regs_t {
|
||||
#if defined(DM644x)
|
||||
uint32_t PINMUX[2]; //0x00
|
||||
uint32_t DSPBOOTADDR; //0x08
|
||||
uint32_t SUSPSRC; //0x0C
|
||||
uint32_t INTGEN; //0x10
|
||||
#elif defined(DM35x)
|
||||
uint32_t PINMUX[5]; //0x00
|
||||
#endif
|
||||
uint32_t BOOTCFG; //0x14
|
||||
uint32_t ARM_INTMUX; //0x18 - ONLY ON DM35x
|
||||
uint32_t EDMA_EVTMUX; //0x1C - ONLY ON DM35x
|
||||
uint32_t DDR_SLEW; //0x20 - ONLY ON DM35x
|
||||
uint32_t CLKOUT; //0x24 - ONLY ON DM35x
|
||||
uint32_t DEVICE_ID; //0x28
|
||||
uint32_t VDAC_CONFIG; //0x2C - ONLY ON DM35x
|
||||
uint32_t TIMER64_CTL; //0x30 - ONLY ON DM35x
|
||||
uint32_t USBPHY_CTL; //0x34
|
||||
#if defined(DM644x)
|
||||
uint32_t CHP_SHRTSW; //0x38
|
||||
#elif defined(DM35x)
|
||||
uint32_t MISC; //0x38
|
||||
#endif
|
||||
uint32_t MSTPRI[2]; //0x3C
|
||||
uint32_t VPSS_CLKCTL; //0x44
|
||||
#if defined(DM644x)
|
||||
uint32_t VDD3P3V_PWDN; //0x48
|
||||
uint32_t DDRVTPER; //0x4C
|
||||
uint32_t RSVD2[8]; //0x50
|
||||
#elif defined(DM35x)
|
||||
uint32_t DEEPSLEEP; //0x48
|
||||
uint32_t RSVD0; //0x4C
|
||||
uint32_t DEBOUNCE[8]; //0x50
|
||||
uint32_t VTPIOCR; //0x70
|
||||
#endif
|
||||
};
|
||||
|
||||
#define SYSTEM ((volatile struct sys_module_regs_t *) 0x01C40000)
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* ARM Interrupt Controller register structure - See sprue26.pdf for more *
|
||||
* details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct aintc_regs_t {
|
||||
uint32_t FIQ0;
|
||||
uint32_t FIQ1;
|
||||
uint32_t IRQ0;
|
||||
uint32_t IRQ1;
|
||||
uint32_t FIQENTRY;
|
||||
uint32_t IRQENTRY;
|
||||
uint32_t EINT0;
|
||||
uint32_t EINT1;
|
||||
uint32_t INTCTL;
|
||||
uint32_t EABASE;
|
||||
uint32_t RSVD0[2];
|
||||
uint32_t INTPRI0;
|
||||
uint32_t INTPRI1;
|
||||
uint32_t INTPRI2;
|
||||
uint32_t INTPRI3;
|
||||
uint32_t INTPRI4;
|
||||
uint32_t INTPRI5;
|
||||
uint32_t INTPRI6;
|
||||
uint32_t INTPRI7;
|
||||
};
|
||||
|
||||
#define AINTC ((volatile struct aintc_regs_t *) 0x01C48000)
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* PLL Register structure - See sprue14.pdf, Chapter 6 for more details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct pll_regs_t {
|
||||
uint32_t PID;
|
||||
uint32_t RSVD0[56];
|
||||
uint32_t RSTYPE; /* 0x0E4 */
|
||||
uint32_t RSVD1[6];
|
||||
uint32_t PLLCTL; /* 0x100 */
|
||||
uint32_t RSVD2[3];
|
||||
uint32_t PLLM; /* 0x110 */
|
||||
uint32_t RSVD3;
|
||||
uint32_t PLLDIV1; /* 0x118 */
|
||||
uint32_t PLLDIV2;
|
||||
uint32_t PLLDIV3;
|
||||
uint32_t RSVD4;
|
||||
uint32_t POSTDIV; /* 0x128 */
|
||||
uint32_t BPDIV;
|
||||
uint32_t RSVD5[2];
|
||||
uint32_t PLLCMD; /* 0x138 */
|
||||
uint32_t PLLSTAT;
|
||||
uint32_t ALNCTL;
|
||||
uint32_t DCHANGE;
|
||||
uint32_t CKEN;
|
||||
uint32_t CKSTAT;
|
||||
uint32_t SYSTAT;
|
||||
uint32_t RSVD6[3];
|
||||
uint32_t PLLDIV4; /* 0x160 - Only on DM35x */
|
||||
uint32_t PLLDIV5; /* 0x164 - Only on DM644x */
|
||||
};
|
||||
|
||||
#define PLL1 ((volatile struct pll_regs_t *) 0x01C40800)
|
||||
#define PLL2 ((volatile struct pll_regs_t *) 0x01C40C00)
|
||||
|
||||
#define DEVICE_PLLCTL_CLKMODE_MASK 0x00000100
|
||||
#define DEVICE_PLLCTL_PLLEN_MASK 0x00000001
|
||||
#define DEVICE_PLLCTL_PLLPWRDN_MASK 0x00000002
|
||||
#define DEVICE_PLLCTL_PLLRST_MASK 0x00000008
|
||||
#define DEVICE_PLLCTL_PLLDIS_MASK 0x00000010
|
||||
#define DEVICE_PLLCTL_PLLENSRC_MASK 0x00000020
|
||||
|
||||
#define DEVICE_PLLCMD_GOSET_MASK 0x00000001
|
||||
#define DEVICE_PLLSTAT_GOSTAT_MASK 0x00000001
|
||||
#define DEVICE_PLLDIV_EN_MASK 0x00008000
|
||||
#define DEVICE_PLLSTAT_LOCK_MASK 0x00000002
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* Power/Sleep Ctrl Register structure - See sprue14.pdf, Chapter 7 *
|
||||
* for more details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct psc_regs_t {
|
||||
uint32_t PID; // 0x000
|
||||
uint32_t RSVD0[3]; // 0x004
|
||||
uint32_t GBLCTL; // 0x010 - NOT ON DM35x
|
||||
uint32_t RSVD1; // 0x014
|
||||
uint32_t INTEVAL; // 0x018
|
||||
uint32_t RSVD2[9]; // 0x01C
|
||||
uint32_t MERRPR0; // 0x040
|
||||
uint32_t MERRPR1; // 0x044
|
||||
uint32_t RSVD3[2]; // 0x048
|
||||
uint32_t MERRCR0; // 0x050
|
||||
uint32_t MERRCR1; // 0x054
|
||||
uint32_t RSVD4[2]; // 0x058
|
||||
uint32_t PERRPR; // 0x060
|
||||
uint32_t RSVD5; // 0x064
|
||||
uint32_t PERRCR; // 0x068
|
||||
uint32_t RSVD6; // 0x06C
|
||||
uint32_t EPCPR; // 0x070
|
||||
uint32_t RSVD7; // 0x074
|
||||
uint32_t EPCCR; // 0x078
|
||||
uint32_t RSVD8[33]; // 0x07C
|
||||
uint32_t RAILSTAT; // 0x100 - NOT ON DM35x
|
||||
uint32_t RAILCTL; // 0x104 - NOT ON DM35x
|
||||
uint32_t RAILSEL; // 0x108 - NOT ON DM35x
|
||||
uint32_t RSVD9[5]; // 0x10C
|
||||
uint32_t PTCMD; // 0x120
|
||||
uint32_t RSVD10; // 0x124
|
||||
uint32_t PTSTAT; // 0x128
|
||||
uint32_t RSVD11[53]; // 0x12C
|
||||
uint32_t PDSTAT0; // 0x200
|
||||
uint32_t PDSTAT1; // 0x204
|
||||
uint32_t RSVD12[62]; // 0x208
|
||||
uint32_t PDCTL0; // 0x300
|
||||
uint32_t PDCTL1; // 0x304
|
||||
uint32_t RSVD13[134]; // 0x308
|
||||
uint32_t MCKOUT0; // 0x520
|
||||
uint32_t MCKOUT1; // 0x524
|
||||
uint32_t RSVD14[182]; // 0x528
|
||||
uint32_t MDSTAT[41]; // 0x800
|
||||
uint32_t RSVD15[87]; // 0x8A4
|
||||
uint32_t MDCTL[41]; // 0xA00
|
||||
};
|
||||
|
||||
#define PSC ((volatile struct psc_regs_t*) 0x01C41000)
|
||||
|
||||
#if defined(DM644x)
|
||||
/* See TMS320DM6446 errata 1.3.22 */
|
||||
#define PSC_PTSTAT_WORKAROUND_REG (*((volatile uint32_t*) 0x01C41A20))
|
||||
#endif
|
||||
|
||||
#define PD0 0
|
||||
|
||||
/* PSC constants */
|
||||
#define LPSC_VPSS_MAST 0
|
||||
#define LPSC_VPSS_SLV 1
|
||||
#define LPSC_EDMACC 2
|
||||
#define LPSC_EDMATC0 3
|
||||
#define LPSC_EDMATC1 4
|
||||
#if defined(DM644x)
|
||||
#define LPSC_EMAC 5
|
||||
#define LPSC_EMAC_MEM_CTL 6
|
||||
#define LPSC_MDIO 7
|
||||
#define LPSC_RESERVED0 8
|
||||
#elif defined(DM35x)
|
||||
#define LPSC_TIMER3 5
|
||||
#define LPSC_SPI1 6
|
||||
#define LPSC_MMC_SD1 7
|
||||
#define LPSC_ASP1 8
|
||||
#endif
|
||||
#define LPSC_USB 9
|
||||
#if defined(DM644x)
|
||||
#define LPSC_ATA 10
|
||||
#define LPSC_VLYNQ 11
|
||||
#define LPSC_HPI 12
|
||||
#elif defined(DM35x)
|
||||
#define LPSC_PWM3 10
|
||||
#define LPSC_SPI2 11
|
||||
#define LPSC_RTO 12
|
||||
#endif
|
||||
#define LPSC_DDR2 13
|
||||
#define LPSC_AEMIF 14
|
||||
#define LPSC_MMC_SD0 15
|
||||
#if defined(DM644x)
|
||||
#define LPSC_RESERVED1 16
|
||||
#elif defined(DM35x)
|
||||
#define LPSC_MEMSTK 16
|
||||
#endif
|
||||
#define LPSC_ASP0 17
|
||||
#define LPSC_I2C 18
|
||||
#define LPSC_UART0 19
|
||||
#if defined(DM35x)
|
||||
#define LPSC_UART1 20
|
||||
#define LPSC_UART2 21
|
||||
#define LPSC_SPIO 22
|
||||
#define LPSC_PWM0 23
|
||||
#define LPSC_PWM1 24
|
||||
#define LPSC_PWM2 25
|
||||
#endif
|
||||
#define LPSC_GPIO 26
|
||||
#define LPSC_TIMER0 27
|
||||
#define LPSC_TIMER1 28
|
||||
#if defined(DM35x)
|
||||
#define LPSC_TIMER2 29
|
||||
#define LPSC_SYSMOD 30
|
||||
#endif
|
||||
#define LPSC_ARM 31
|
||||
#if defined(DM644x)
|
||||
#define LPSC_DSP 39
|
||||
#define LPSC_IMCOP 40
|
||||
#elif defined(DM35x)
|
||||
#define LPSC_VPSS_DAC 40
|
||||
#endif
|
||||
|
||||
#define EMURSTIE_MASK 0x00000200
|
||||
|
||||
#define PSC_ENABLE 0x3
|
||||
#define PSC_DISABLE 0x2
|
||||
#define PSC_SYNCRESET 0x1
|
||||
#define PSC_SWRSTDISABLE 0x0
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* DDR2 Memory Ctrl Register structure - See sprue22b.pdf for more details.*
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct ddr_mem_ctl_regs_t {
|
||||
uint32_t RSVD0;
|
||||
uint32_t SDRSTAT;
|
||||
uint32_t SDBCR;
|
||||
uint32_t SDRCR;
|
||||
uint32_t SDTIMR;
|
||||
uint32_t SDTIMR2;
|
||||
#if defined(DM644x)
|
||||
uint32_t RSVD1[2];
|
||||
#elif defined(DM35x)
|
||||
uint32_t RSVD1;
|
||||
uint32_t SDBCR2;
|
||||
#endif
|
||||
uint32_t PBBPR; /* 0x20 */
|
||||
uint32_t RSVD2[39];
|
||||
uint32_t IRR; /* 0xC0 */
|
||||
uint32_t IMR;
|
||||
uint32_t IMSR;
|
||||
uint32_t IMCR;
|
||||
uint32_t RSVD3[5];
|
||||
uint32_t DDRPHYCR;
|
||||
uint32_t RSVD4[2];
|
||||
#if defined(DM644x)
|
||||
uint32_t VTPIOCR; /* 0xF0 - In system control module for DM35x */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define DDR ((volatile struct ddr_mem_ctl_regs_t *) 0x20000000)
|
||||
|
||||
#define DDR_TEST_PATTERN 0xA55AA55A
|
||||
|
||||
#define SDBCR_TIMUNLOCK (1 << 15)
|
||||
|
||||
#if defined(DM644x)
|
||||
|
||||
#define DDRVTPR (*((volatile uint32_t*) 0x01C42030))
|
||||
|
||||
#define DDRPHYCR_DEFAULT 0x50006400 /* Default value with reserved fields */
|
||||
#define DDRPHYCR_READLAT_MASK (0x7 << 0)
|
||||
#define SDBCR_DEFAULT 0x00130000 /* Default value with reserved fields */
|
||||
|
||||
#elif defined(DM35x)
|
||||
#define DDRPHYCR_DEFAULT 0x28006400 /* Default value with reserved fields */
|
||||
#define DDRPHYCR_READLAT_MASK (0xF << 0)
|
||||
#define SDBCR_DEFAULT 0x00170000 /* Default value with reserved fields */
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* AEMIF Register structure - See sprue20a.pdf for more details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct emif_regs_t {
|
||||
uint32_t ERCSR; // 0x00
|
||||
uint32_t AWCCR; // 0x04
|
||||
uint32_t SDBCR; // 0x08 - NOT ON DM35x
|
||||
uint32_t SDRCR; // 0x0C - NOT ON DM35x
|
||||
uint32_t A1CR; // 0x10
|
||||
uint32_t A2CR; // 0x14
|
||||
uint32_t A3CR; // 0x18 - NOT ON DM35x
|
||||
uint32_t A4CR; // 0x1C - NOT ON DM35x
|
||||
uint32_t SDTIMR; // 0x20 - NOT ON DM35x
|
||||
uint32_t DDRSR; // 0x24 - NOT ON DM35x
|
||||
uint32_t DDRPHYCR; // 0x28 - NOT ON DM35x
|
||||
uint32_t DDRPHYSR; // 0x2C - NOT ON DM35x
|
||||
uint32_t TOTAR; // 0x30 - NOT ON DM35x
|
||||
uint32_t TOTACTR; // 0x34 - NOT ON DM35x
|
||||
uint32_t DDRPHYID_REV; // 0x38 - NOT ON DM35x
|
||||
uint32_t SDSRETR; // 0x3C - NOT ON DM35x
|
||||
uint32_t EIRR; // 0x40
|
||||
uint32_t EIMR;
|
||||
uint32_t EIMSR;
|
||||
uint32_t EIMCR;
|
||||
uint32_t IOCTRLR; // 0x50 - NOT ON DM35x
|
||||
uint32_t IOSTATR; // 0x54 - NOT ON DM35x
|
||||
uint32_t RSVD0;
|
||||
uint32_t ONENANDCTL; // 0x5C - ONLY ON DM35x
|
||||
uint32_t NANDFCR; // 0x60
|
||||
uint32_t NANDFSR; // 0x64
|
||||
uint32_t RSVD1[2];
|
||||
uint32_t NANDF1ECC; // 0x70
|
||||
uint32_t NANDF2ECC; // 0x74
|
||||
uint32_t NANDF3ECC; // 0x78 - NOT ON DM35x
|
||||
uint32_t NANDF4ECC; // 0x7C - NOT ON DM35x
|
||||
uint32_t RSVD2; // 0x80
|
||||
uint32_t IODFTECR;
|
||||
uint32_t IODFTGCR;
|
||||
uint32_t RSVD3;
|
||||
uint32_t IODFTMRLR; // 0x90
|
||||
uint32_t IODFTMRMR; // 0x94
|
||||
uint32_t IODFTMRMSBR; // 0x98
|
||||
uint32_t RSVD4[5];
|
||||
uint32_t MODRNR; // 0xB0
|
||||
uint32_t RSVD5[2];
|
||||
uint32_t NAND4BITECCLOAD; // 0xBC - ONLY ON DM35x
|
||||
uint32_t NAND4BITECC1; // 0xC0 - ONLY ON DM35x
|
||||
uint32_t NAND4BITECC2; // 0xC4 - ONLY ON DM35x
|
||||
uint32_t NAND4BITECC3; // 0xC8 - ONLY ON DM35x
|
||||
uint32_t NAND4BITECC4; // 0xCC - ONLY ON DM35x
|
||||
uint32_t NANDERRADD1; // 0xD0 - ONLY ON DM35x
|
||||
uint32_t NANDERRADD2; // 0xD4 - ONLY ON DM35x
|
||||
uint32_t NANDERRVAL1; // 0xD8 - ONLY ON DM35x
|
||||
uint32_t NANDERRVAL2; // 0xDC - ONLY ON DM35x
|
||||
};
|
||||
|
||||
#if defined(DM644x)
|
||||
#define AEMIF ((volatile struct emif_regs_t *) 0x01E00000)
|
||||
#elif defined(DM35x)
|
||||
#define AEMIF ((volatile struct emif_regs_t *) 0x01E10000)
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* UART Register structure - See sprue33.pdf for more details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct uart_regs_t {
|
||||
uint32_t RBR;
|
||||
uint32_t IER;
|
||||
uint32_t IIR;
|
||||
uint32_t LCR;
|
||||
uint32_t MCR;
|
||||
uint32_t LSR;
|
||||
uint32_t MSR; /* NOT ON DM35x */
|
||||
uint32_t SCR; /* NOT ON DM35x */
|
||||
uint32_t DLL;
|
||||
uint32_t DLH;
|
||||
uint32_t PID1;
|
||||
uint32_t PID2;
|
||||
uint32_t PWREMU_MGNT;
|
||||
};
|
||||
|
||||
#define THR RBR
|
||||
#define FCR IIR
|
||||
|
||||
#define UART0 ((volatile struct uart_regs_t *) 0x01C20000)
|
||||
|
||||
#define UART_BCLK_RATIO 16 /* BCLK is 16 times the baudrate */
|
||||
#define UART_BAUDRATE 115200
|
||||
|
||||
/* -------------------------------------------------------------------------- *
|
||||
* Timer Register structure - See sprue26.pdf for more details. *
|
||||
* -------------------------------------------------------------------------- */
|
||||
struct timer_regs_t {
|
||||
uint32_t PID12;
|
||||
uint32_t EMUMGT_CLKSPD;
|
||||
uint32_t GPINT_GPEN; // NOT ON DM35x
|
||||
uint32_t GPTDAT_GPDIR; // NOT ON DM35x
|
||||
uint32_t TIM12;
|
||||
uint32_t TIM34;
|
||||
uint32_t PRD12;
|
||||
uint32_t PRD34;
|
||||
uint32_t TCR;
|
||||
uint32_t TGCR;
|
||||
uint32_t WDTCR;
|
||||
uint32_t RSVD1[3]; // 0x2C - ONLY ON DM35x
|
||||
uint32_t REL12; // 0x34 - ONLY ON DM35x
|
||||
uint32_t REL34; // 0x38 - ONLY ON DM35x
|
||||
uint32_t CAP12; // 0x3C - ONLY ON DM35x
|
||||
uint32_t CAP34; // 0x40 - ONLY ON DM35x
|
||||
uint32_t INTCTL_STAT; // 0x44 - ONLY ON DM35x
|
||||
};
|
||||
|
||||
#define TIMER0 ((volatile struct timer_regs_t *) 0x01C21400)
|
||||
|
||||
struct gpio_controller {
|
||||
uint32_t dir;
|
||||
uint32_t out_data;
|
||||
uint32_t set_data;
|
||||
uint32_t clr_data;
|
||||
uint32_t in_data;
|
||||
uint32_t set_rising;
|
||||
uint32_t clr_rising;
|
||||
uint32_t set_falling;
|
||||
uint32_t clr_falling;
|
||||
uint32_t intstat;
|
||||
};
|
||||
|
||||
#define DAVINCI_GPIO_BASE 0x01C67000
|
||||
|
||||
#define GPIOC ((volatile struct gpio_controller *) DAVINCI_GPIO_BASE)
|
||||
|
||||
int davinci_platform_init(char *version);
|
||||
void ddr_vtp_calibration(void);
|
||||
|
||||
void timer0_start(void);
|
||||
uint32_t timer0_status(void);
|
||||
|
||||
#endif /* _DAVINCI_H_ */
|
|
@ -0,0 +1,364 @@
|
|||
/*
|
||||
* ddr.h - DDR devices parameters
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DDDR_H_
|
||||
#define _DDDR_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(MICRON_MT47H32M16BN_3_171MHZ)
|
||||
/* Micron MT47H32M16BN-3 @ 171 MHz settings:
|
||||
* TCK = 5.85 nS -> 1 / 171MHz
|
||||
* T_REF = 7.8 uS (varies with commercial vs industrial)
|
||||
* T_RFC = 105 nS (varies with capacity)
|
||||
* T_RP = 15 nS
|
||||
* T_RCD = 15 nS
|
||||
* T_WR = 15 nS
|
||||
* T_RAS = 40 nS
|
||||
* T_RASMAX = 70 uS
|
||||
* T_RTP = 7.5 nS
|
||||
* T_RC = 55 nS
|
||||
* T_RRD = 10 nS
|
||||
* T_WTR = 7.5 nS
|
||||
* T_XSRD = 200 nS
|
||||
* T_XSNR = 115 nS -> T_RFC(MIN) + 10
|
||||
* T_CKE = 3 TCK
|
||||
* T_XP = 2 TCK
|
||||
*/
|
||||
static const uint8_t DDR_IBANK = 2; /* 4 banks. */
|
||||
static const uint16_t DDR_RR = 1336; /* DDRCLK * T_REF */
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 17; /* (T_RFC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RP = 2; /* (T_RP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RCD = 2; /* (T_RCD * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_WR = 2; /* (T_WR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RAS = 6; /* (T_RAS * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RC = 9; /* (T_RC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RRD = 1; /* [((4 * T_RRD) + (2 * TCK)) / (4 * TCK)] - 1 */
|
||||
/*
|
||||
* Only for 8 bank DDR2/mDDR memories. When interfacing to DDR2/mDDR memories
|
||||
* with less than 8 banks the T_RRD field should be calculated using:
|
||||
* (T_RRD * DDRCLK) - 1.
|
||||
*/
|
||||
static const uint8_t DDR_T_WTR = 1; /* (T_WTR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RASMAX = 8; /*
|
||||
* (T_RASMAX(uS) / T_REF) - 1
|
||||
* Should be 17 but max. value
|
||||
* is 15 (4 bits)
|
||||
*/
|
||||
static const uint8_t DDR_T_XP = 2; /*
|
||||
* If T_XP > T_CKE then
|
||||
* T_XP = T_XP - 1
|
||||
* else
|
||||
* T_XP = T_CKE - 1
|
||||
*/
|
||||
static const uint8_t DDR_T_XSNR = 19; /* (T_XSNR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_XSRD = 199; /* T_XSRD - 1 */
|
||||
static const uint8_t DDR_T_RTP = 1; /* (T_RTP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_CKE = 2; /* T_CKE - 1 */
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#elif defined(MICRON_MT47H32M16BN_3_162MHZ) /* SFFSDR */
|
||||
/* Micron MT47H32M16BN-3 @ 162 MHz settings:
|
||||
* TCK = 6.17 nS -> 1 / 162 MHz
|
||||
* T_REF = 7.8 uS (varies with commercial vs industrial)
|
||||
* T_RFC = 105 nS (varies with capacity)
|
||||
* T_RP = 15 nS
|
||||
* T_RCD = 15 nS
|
||||
* T_WR = 15 nS
|
||||
* T_RAS = 40 nS
|
||||
* T_RASMAX = 70 uS
|
||||
* T_RTP = 7.5 nS
|
||||
* T_RC = 55 nS
|
||||
* T_RRD = 10 nS
|
||||
* T_WTR = 7.5 nS
|
||||
* T_XSRD = 200 nS
|
||||
* T_XSNR = 115 nS -> T_RFC(MIN) + 10
|
||||
* T_CKE = 3 TCK
|
||||
* T_XP = 2 TCK
|
||||
*/
|
||||
static const uint8_t DDR_IBANK = 2; /* 4 banks. */
|
||||
static const uint16_t DDR_RR = 1265; /* DDRCLK * T_REF */
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 16; /* (T_RFC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RP = 2; /* (T_RP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RCD = 2; /* (T_RCD * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_WR = 2; /* (T_WR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RAS = 6; /* (T_RAS * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RC = 8; /* (T_RC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RRD = 1; /* [((4 * T_RRD) + (2 * TCK)) / (4 * TCK)] - 1 */
|
||||
/*
|
||||
* Only for 8 bank DDR2/mDDR memories. When interfacing to DDR2/mDDR memories
|
||||
* with less than 8 banks the T_RRD field should be calculated using:
|
||||
* (T_RRD * DDRCLK) - 1.
|
||||
*/
|
||||
static const uint8_t DDR_T_WTR = 1; /* (T_WTR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RASMAX = 8; /*
|
||||
* (T_RASMAX(uS) / T_REF) - 1
|
||||
* Should be 17 but max. value
|
||||
* is 15 (4 bits)
|
||||
*/
|
||||
static const uint8_t DDR_T_XP = 2; /*
|
||||
* If T_XP > T_CKE then
|
||||
* T_XP = T_XP - 1
|
||||
* else
|
||||
* T_XP = T_CKE - 1
|
||||
*/
|
||||
static const uint8_t DDR_T_XSNR = 18; /* (T_XSNR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_XSRD = 199; /* T_XSRD - 1 */
|
||||
static const uint8_t DDR_T_RTP = 1; /* (T_RTP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_CKE = 2; /* T_CKE - 1 */
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#elif defined(MICRON_MT47H64M16BT_37E_171MHZ) /* EVM DM355 */
|
||||
/* Micron MT47H64M16BT-37E @ 171 MHz */
|
||||
static const uint8_t DDR_IBANK = 3; /* 8 banks. */
|
||||
static const uint16_t DDR_RR = 1336;
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 21;
|
||||
static const uint8_t DDR_T_RP = 2;
|
||||
static const uint8_t DDR_T_RCD = 2;
|
||||
static const uint8_t DDR_T_WR = 2;
|
||||
static const uint8_t DDR_T_RAS = 6;
|
||||
static const uint8_t DDR_T_RC = 9;
|
||||
static const uint8_t DDR_T_RRD = 1;
|
||||
static const uint8_t DDR_T_WTR = 1;
|
||||
static const uint8_t DDR_T_RASMAX = 7;
|
||||
static const uint8_t DDR_T_XP = 2;
|
||||
static const uint8_t DDR_T_XSNR = 23;
|
||||
static const uint8_t DDR_T_XSRD = 199;
|
||||
static const uint8_t DDR_T_RTP = 3;
|
||||
static const uint8_t DDR_T_CKE = 3;
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#elif defined(MICRON_MT47H64M16HR_3_162MHZ) /* DAS Commercial */
|
||||
/* Micron MT47H64M16HR-3 @ 162 MHz settings:
|
||||
* TCK = 6.17 nS -> 1 / 162 MHz
|
||||
* T_REF = 7.8 uS (varies with commercial vs industrial)
|
||||
* T_RFC = 127.5 nS (varies with capacity)
|
||||
* T_RP = 15 nS
|
||||
* T_RCD = 15 nS
|
||||
* T_WR = 15 nS
|
||||
* T_RAS = 40 nS
|
||||
* T_RASMAX = 70 uS
|
||||
* T_RTP = 7.5 nS
|
||||
* T_RC = 55 nS
|
||||
* T_RRD = 10 nS
|
||||
* T_WTR = 7.5 nS
|
||||
* T_XSRD = 200 nS
|
||||
* T_XSNR = 138 nS -> T_RFC(MIN) + 10
|
||||
* T_CKE = 3 TCK
|
||||
* T_XP = 2 TCK
|
||||
*/
|
||||
static const uint8_t DDR_IBANK = 3; /* 8 banks. */
|
||||
static const uint16_t DDR_RR = 1265; /* DDRCLK * T_REF */
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 20; /* (T_RFC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RP = 2; /* (T_RP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RCD = 2; /* (T_RCD * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_WR = 2; /* (T_WR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RAS = 6; /* (T_RAS * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RC = 8; /* (T_RC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RRD = 2; /* [((4 * T_RRD) + (2 * TCK)) / (4 * TCK)] - 1 */
|
||||
/*
|
||||
* Only for 8 bank DDR2/mDDR memories. When interfacing to DDR2/mDDR memories
|
||||
* with less than 8 banks the T_RRD field should be calculated using:
|
||||
* (T_RRD * DDRCLK) - 1.
|
||||
*/
|
||||
static const uint8_t DDR_T_WTR = 1; /* (T_WTR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RASMAX = 8; /*
|
||||
* (T_RASMAX(uS) / T_REF) - 1
|
||||
* Should be 17 but max. value
|
||||
* is 15 (4 bits)
|
||||
*/
|
||||
static const uint8_t DDR_T_XP = 2; /*
|
||||
* If T_XP > T_CKE then
|
||||
* T_XP = T_XP - 1
|
||||
* else
|
||||
* T_XP = T_CKE - 1
|
||||
*/
|
||||
static const uint8_t DDR_T_XSNR = 21; /* (T_XSNR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_XSRD = 199; /* T_XSRD - 1 */
|
||||
static const uint8_t DDR_T_RTP = 1; /* (T_RTP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_CKE = 2; /* T_CKE - 1 */
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#elif defined(MICRON_MT47H64M16HR_3IT_162MHZ) /* DAS industrial */
|
||||
/* Micron MT47H64M16HR-3IT @ 162 MHz settings:
|
||||
* TCK = 6.17 nS -> 1 / 162 MHz
|
||||
* T_REF = 3.9 uS (varies with commercial vs industrial)
|
||||
* T_RFC = 127.5 nS (varies with capacity)
|
||||
* T_RP = 15 nS
|
||||
* T_RCD = 15 nS
|
||||
* T_WR = 15 nS
|
||||
* T_RAS = 40 nS
|
||||
* T_RASMAX = 70 uS
|
||||
* T_RTP = 7.5 nS
|
||||
* T_RC = 55 nS
|
||||
* T_RRD = 10 nS
|
||||
* T_WTR = 7.5 nS
|
||||
* T_XSRD = 200 nS
|
||||
* T_XSNR = 138 nS -> T_RFC(MIN) + 10
|
||||
* T_CKE = 3 TCK
|
||||
* T_XP = 2 TCK
|
||||
*/
|
||||
static const uint8_t DDR_IBANK = 3; /* 8 banks. */
|
||||
static const uint16_t DDR_RR = 635; /* DDRCLK * T_REF */
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 20; /* (T_RFC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RP = 2; /* (T_RP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RCD = 2; /* (T_RCD * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_WR = 2; /* (T_WR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RAS = 6; /* (T_RAS * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RC = 8; /* (T_RC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RRD = 2; /* [((4 * T_RRD) + (2 * TCK)) / (4 * TCK)] - 1 */
|
||||
/*
|
||||
* Only for 8 bank DDR2/mDDR memories. When interfacing to DDR2/mDDR memories
|
||||
* with less than 8 banks the T_RRD field should be calculated using:
|
||||
* (T_RRD * DDRCLK) - 1.
|
||||
*/
|
||||
static const uint8_t DDR_T_WTR = 1; /* (T_WTR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RASMAX = 15; /*
|
||||
* (T_RASMAX(uS) / T_REF) - 1
|
||||
* Should be 17 but max. value
|
||||
* is 15 (4 bits)
|
||||
*/
|
||||
static const uint8_t DDR_T_XP = 2; /*
|
||||
* If T_XP > T_CKE then
|
||||
* T_XP = T_XP - 1
|
||||
* else
|
||||
* T_XP = T_CKE - 1
|
||||
*/
|
||||
static const uint8_t DDR_T_XSNR = 21; /* (T_XSNR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_XSRD = 199; /* T_XSRD - 1 */
|
||||
static const uint8_t DDR_T_RTP = 1; /* (T_RTP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_CKE = 2; /* T_CKE - 1 */
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#elif defined(MICRON_MT47H64M16BT_3_162MHZ)
|
||||
/* Micron MT47H64M16HR-3IT @ 162 MHz settings:
|
||||
* TCK = 5.85 nS -> 1 / 162 MHz
|
||||
* T_REF = 3.9 uS (varies with commercial vs industrial)
|
||||
* T_RFC = 198 nS (varies with capacity)
|
||||
* T_RP = 15 nS
|
||||
* T_RCD = 15 nS
|
||||
* T_WR = 15 nS
|
||||
* T_RAS = 40 nS
|
||||
* T_RASMAX = 70 uS
|
||||
* T_RTP = 7.5 nS
|
||||
* T_RC = 55 nS
|
||||
* T_RRD = 10 nS
|
||||
* T_WTR = 7.5 nS
|
||||
* T_XSRD = 200 nS
|
||||
* T_XSNR = 208 nS -> T_RFC(MIN) + 10
|
||||
* T_CKE = 3 TCK
|
||||
* T_XP = 2 TCK
|
||||
*/
|
||||
static const uint8_t DDR_IBANK = 3; /* 8 banks. */
|
||||
static const uint16_t DDR_RR = 667; /* DDRCLK * T_REF */
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 33; /* (T_RFC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RP = 2; /* (T_RP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RCD = 2; /* (T_RCD * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_WR = 2; /* (T_WR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RAS = 6; /* (T_RAS * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RC = 9; /* (T_RC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RRD = 1; /* [((4 * T_RRD) + (2 * TCK)) / (4 * TCK)] - 1 */
|
||||
/*
|
||||
* Only for 8 bank DDR2/mDDR memories. When interfacing to DDR2/mDDR memories
|
||||
* with less than 8 banks the T_RRD field should be calculated using:
|
||||
* (T_RRD * DDRCLK) - 1.
|
||||
*/
|
||||
static const uint8_t DDR_T_WTR = 1; /* (T_WTR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RASMAX = 15; /*
|
||||
* (T_RASMAX(uS) / T_REF) - 1
|
||||
* Should be 17 but max. value
|
||||
* is 15 (4 bits)
|
||||
*/
|
||||
static const uint8_t DDR_T_XP = 2; /*
|
||||
* If T_XP > T_CKE then
|
||||
* T_XP = T_XP - 1
|
||||
* else
|
||||
* T_XP = T_CKE - 1
|
||||
*/
|
||||
static const uint8_t DDR_T_XSNR = 34; /* (T_XSNR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_XSRD = 199; /* T_XSRD - 1 */
|
||||
static const uint8_t DDR_T_RTP = 1; /* (T_RTP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_CKE = 2; /* T_CKE - 1 */
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#elif defined(MICRON_MT47H128M16HG_3IT_171MHZ)
|
||||
/* Micron MT47H128M16HG-3IT @ 171 MHz settings:
|
||||
* TCK = 5.85 nS -> 1 / 171MHz
|
||||
* T_REF = 3.9 uS (varies with commercial vs industrial)
|
||||
* T_RFC = 198 nS (varies with capacity)
|
||||
* T_RP = 15 nS
|
||||
* T_RCD = 15 nS
|
||||
* T_WR = 15 nS
|
||||
* T_RAS = 40 nS
|
||||
* T_RASMAX = 70 uS
|
||||
* T_RTP = 7.5 nS
|
||||
* T_RC = 55 nS
|
||||
* T_RRD = 10 nS
|
||||
* T_WTR = 7.5 nS
|
||||
* T_XSRD = 200 nS
|
||||
* T_XSNR = 208 nS -> T_RFC(MIN) + 10
|
||||
* T_CKE = 3 TCK
|
||||
* T_XP = 2 TCK
|
||||
*/
|
||||
static const uint8_t DDR_IBANK = 3; /* 8 banks. */
|
||||
static const uint16_t DDR_RR = 667; /* DDRCLK * T_REF */
|
||||
static const uint8_t DDR_CL = 3;
|
||||
static const uint8_t DDR_T_RFC = 33; /* (T_RFC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RP = 2; /* (T_RP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RCD = 2; /* (T_RCD * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_WR = 2; /* (T_WR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RAS = 6; /* (T_RAS * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RC = 9; /* (T_RC * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RRD = 1; /* [((4 * T_RRD) + (2 * TCK)) / (4 * TCK)] - 1 */
|
||||
/*
|
||||
* Only for 8 bank DDR2/mDDR memories. When interfacing to DDR2/mDDR memories
|
||||
* with less than 8 banks the T_RRD field should be calculated using:
|
||||
* (T_RRD * DDRCLK) - 1.
|
||||
*/
|
||||
static const uint8_t DDR_T_WTR = 1; /* (T_WTR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_RASMAX = 15; /*
|
||||
* (T_RASMAX(uS) / T_REF) - 1
|
||||
* Should be 17 but max. value
|
||||
* is 15 (4 bits)
|
||||
*/
|
||||
static const uint8_t DDR_T_XP = 2; /*
|
||||
* If T_XP > T_CKE then
|
||||
* T_XP = T_XP - 1
|
||||
* else
|
||||
* T_XP = T_CKE - 1
|
||||
*/
|
||||
static const uint8_t DDR_T_XSNR = 34; /* (T_XSNR * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_XSRD = 199; /* T_XSRD - 1 */
|
||||
static const uint8_t DDR_T_RTP = 1; /* (T_RTP * DDRCLK) - 1 */
|
||||
static const uint8_t DDR_T_CKE = 2; /* T_CKE - 1 */
|
||||
static const uint8_t DDR_READ_Latency = 4; /* Board specific */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _DDDR_H_ */
|
|
@ -0,0 +1,121 @@
|
|||
/*
|
||||
* dm35x.c - DM35x specific platform initialization
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "davinci.h"
|
||||
#include "util.h"
|
||||
|
||||
#define DEVICE_VTPIOCR_PWRDN_MASK (0x00000040)
|
||||
#define DEVICE_VTPIOCR_LOCK_MASK (0x00000080)
|
||||
#define DEVICE_VTPIOCR_PWRSAVE_MASK (0x00000100)
|
||||
#define DEVICE_VTPIOCR_CLR_MASK (0x00002000)
|
||||
#define DEVICE_VTPIOCR_VTPIOREADY_MASK (0x00004000)
|
||||
#define DEVICE_VTPIOCR_READY_MASK (0x00008000)
|
||||
|
||||
/* List of modules to enable in the PSC */
|
||||
const int8_t lpsc_en_list[] = {
|
||||
LPSC_VPSS_MAST,
|
||||
LPSC_VPSS_SLV,
|
||||
LPSC_EDMACC,
|
||||
LPSC_EDMATC0,
|
||||
LPSC_EDMATC1,
|
||||
LPSC_TIMER3,
|
||||
LPSC_SPI1,
|
||||
LPSC_MMC_SD1,
|
||||
LPSC_ASP1,
|
||||
LPSC_USB,
|
||||
LPSC_PWM3,
|
||||
LPSC_SPI2,
|
||||
LPSC_RTO,
|
||||
LPSC_DDR2,
|
||||
LPSC_AEMIF,
|
||||
LPSC_MMC_SD0,
|
||||
LPSC_MEMSTK,
|
||||
LPSC_ASP0,
|
||||
LPSC_I2C,
|
||||
LPSC_UART0,
|
||||
LPSC_UART1,
|
||||
LPSC_UART2,
|
||||
LPSC_SPIO,
|
||||
LPSC_PWM0,
|
||||
LPSC_PWM1,
|
||||
LPSC_PWM2,
|
||||
LPSC_GPIO,
|
||||
LPSC_TIMER0,
|
||||
LPSC_TIMER1,
|
||||
LPSC_TIMER2,
|
||||
LPSC_SYSMOD,
|
||||
LPSC_ARM,
|
||||
LPSC_VPSS_DAC,
|
||||
};
|
||||
|
||||
const size_t lpsc_en_list_len = sizeof(lpsc_en_list) /
|
||||
sizeof(lpsc_en_list[0]);
|
||||
|
||||
/* List of modules for which to control EMURSTIE */
|
||||
const int8_t lpsc_emurstie_list[] = {
|
||||
LPSC_VPSS_MAST,
|
||||
LPSC_VPSS_SLV,
|
||||
LPSC_TIMER3,
|
||||
LPSC_SPI1,
|
||||
LPSC_USB,
|
||||
LPSC_PWM3,
|
||||
LPSC_DDR2,
|
||||
LPSC_AEMIF,
|
||||
LPSC_MMC_SD0,
|
||||
LPSC_ASP0,
|
||||
LPSC_GPIO,
|
||||
LPSC_VPSS_DAC,
|
||||
};
|
||||
|
||||
const size_t lpsc_emurstie_list_len = sizeof(lpsc_emurstie_list) /
|
||||
sizeof(lpsc_emurstie_list[0]);
|
||||
|
||||
/* DDR2 VTP Calibration */
|
||||
void
|
||||
ddr_vtp_calibration(void)
|
||||
{
|
||||
/* DO VTP calibration:
|
||||
* Clear CLR & PWRDN & LOCK bits */
|
||||
SYSTEM->VTPIOCR &= ~(DEVICE_VTPIOCR_PWRDN_MASK |
|
||||
DEVICE_VTPIOCR_LOCK_MASK |
|
||||
DEVICE_VTPIOCR_CLR_MASK);
|
||||
|
||||
/* Un-clear VTP */
|
||||
SYSTEM->VTPIOCR |= DEVICE_VTPIOCR_CLR_MASK;
|
||||
|
||||
/* Wait for ready */
|
||||
while (!(SYSTEM->VTPIOCR & DEVICE_VTPIOCR_READY_MASK));
|
||||
|
||||
/* Set bit VTP_IO_READY */
|
||||
SYSTEM->VTPIOCR |= DEVICE_VTPIOCR_VTPIOREADY_MASK;
|
||||
|
||||
/* Enable power save mode and lock impedance */
|
||||
SYSTEM->VTPIOCR |= (DEVICE_VTPIOCR_PWRSAVE_MASK |
|
||||
DEVICE_VTPIOCR_LOCK_MASK);
|
||||
|
||||
/* Powerdown VTP as it is locked */
|
||||
SYSTEM->VTPIOCR |= DEVICE_VTPIOCR_PWRDN_MASK;
|
||||
|
||||
/* Wait for calibration to complete */
|
||||
waitloop(150);
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* dm35x.h - DM35x specific platform definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DM35X_H_
|
||||
#define _DM35X_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define SYSTEM_CLK_HZ 24000000
|
||||
|
||||
#define VPBE_CLK_HZ 27000000
|
||||
|
||||
#define PLL1_Mult 144 /* 216 MHz */
|
||||
|
||||
#define PLL2_Mult 114
|
||||
#define PLL2_Div1 2 /* Fixed */
|
||||
#define PLL2_Div2 -1 /* PLLDIV2 not used */
|
||||
|
||||
#define DEVICE_MISC_PLL1POSTDIV_MASK 0x00000002
|
||||
#define DEVICE_MISC_AIMWAITST_MASK 0x00000001
|
||||
#define DEVICE_MISC_TIMER2WDT_MASK 0x00000010
|
||||
|
||||
#define UBL_IMAGE_SIZE 0x7800 /* 30 kB UBL (2Kb reserved for RBL stack) */
|
||||
|
||||
/* Global Memory Timing and PLL Settings */
|
||||
static const uint8_t DDR_NM = 1; /* 16-bit bus width only on DM35x. */
|
||||
static const uint8_t DDR_PAGESIZE = 2; /* 1024-word page size. */
|
||||
|
||||
#define DDR_PBBPR_PR_OLD_COUNT 0x000000FE;
|
||||
|
||||
/* PINMUX2 register bit values */
|
||||
#define PINMUX2_EM_CLK (1 << 11)
|
||||
#define PINMUX2_EM_AVD (1 << 10)
|
||||
#define PINMUX2_EM_WAIT (1 << 9)
|
||||
#define PINMUX2_EM_WE_OE (1 << 8)
|
||||
#define PINMUX2_EM_CE1 (1 << 7)
|
||||
#define PINMUX2_EM_CE0 (1 << 6)
|
||||
#define PINMUX2_EM_D7_0 (1 << 5)
|
||||
#define PINMUX2_EM_D15_8 (1 << 4)
|
||||
#define PINMUX2_EM_BA0 (1 << 2)
|
||||
#define PINMUX2_EM_A0_BA1 (1 << 1)
|
||||
#define PINMUX2_EM_A13_3 (1 << 0)
|
||||
|
||||
#endif /* _DM35X_H_ */
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* dm644x.c - DM644x specific platform initialization
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "davinci.h"
|
||||
#include "util.h"
|
||||
|
||||
#define VTPIOCR_EN_MASK (1 << 13)
|
||||
#define VTPIOCR_RECAL_MASK (1 << 15)
|
||||
|
||||
#define DDRVTPER_EN_MASK (1 << 0)
|
||||
|
||||
#define DDRVTPR_CAL_DATA_MASK 0x03FF
|
||||
|
||||
/* List of modules to enable in the PSC */
|
||||
const int8_t lpsc_en_list[] = {
|
||||
LPSC_VPSS_MAST,
|
||||
LPSC_VPSS_SLV,
|
||||
LPSC_EDMACC,
|
||||
LPSC_EDMATC0,
|
||||
LPSC_EDMATC1,
|
||||
LPSC_EMAC,
|
||||
LPSC_EMAC_MEM_CTL,
|
||||
LPSC_MDIO,
|
||||
LPSC_USB,
|
||||
LPSC_ATA,
|
||||
LPSC_VLYNQ,
|
||||
LPSC_HPI,
|
||||
LPSC_DDR2,
|
||||
LPSC_AEMIF,
|
||||
LPSC_MMC_SD0,
|
||||
LPSC_ASP0,
|
||||
LPSC_I2C,
|
||||
LPSC_UART0,
|
||||
LPSC_GPIO,
|
||||
LPSC_TIMER0,
|
||||
LPSC_ARM,
|
||||
LPSC_IMCOP,
|
||||
};
|
||||
|
||||
const size_t lpsc_en_list_len = sizeof(lpsc_en_list) /
|
||||
sizeof(lpsc_en_list[0]);
|
||||
|
||||
/* List of modules for which to control EMURSTIE */
|
||||
const int8_t lpsc_emurstie_list[] = {
|
||||
LPSC_VPSS_SLV,
|
||||
LPSC_EMAC,
|
||||
LPSC_EMAC_MEM_CTL,
|
||||
LPSC_MDIO,
|
||||
LPSC_USB,
|
||||
LPSC_ATA,
|
||||
LPSC_VLYNQ,
|
||||
LPSC_HPI,
|
||||
LPSC_DDR2,
|
||||
LPSC_AEMIF,
|
||||
LPSC_MMC_SD0,
|
||||
LPSC_ASP0,
|
||||
LPSC_GPIO,
|
||||
LPSC_IMCOP,
|
||||
};
|
||||
|
||||
const size_t lpsc_emurstie_list_len = sizeof(lpsc_emurstie_list) /
|
||||
sizeof(lpsc_emurstie_list[0]);
|
||||
|
||||
/* DDR2 VTP Calibration */
|
||||
void
|
||||
ddr_vtp_calibration(void)
|
||||
{
|
||||
int32_t cal_data;
|
||||
|
||||
/* Enable VTP IO calibration bit (not started) */
|
||||
DDR->VTPIOCR = 0x0000001F | VTPIOCR_EN_MASK;
|
||||
|
||||
/* Start VTP IO calibration */
|
||||
DDR->VTPIOCR |= VTPIOCR_RECAL_MASK;
|
||||
|
||||
/* Wait for calibration to complete */
|
||||
waitloop(11*33);
|
||||
|
||||
/* Enable access to DDRVTPR */
|
||||
SYSTEM->DDRVTPER = DDRVTPER_EN_MASK;
|
||||
|
||||
cal_data = DDRVTPR & DDRVTPR_CAL_DATA_MASK; /* Read calibration data */
|
||||
|
||||
/* Write calibration data to VTP Control register */
|
||||
DDR->VTPIOCR &= ~DDRVTPR_CAL_DATA_MASK;
|
||||
DDR->VTPIOCR |= cal_data;
|
||||
|
||||
/* Disable VTP IO calibration bit */
|
||||
DDR->VTPIOCR &= ~VTPIOCR_EN_MASK;
|
||||
|
||||
/* Disable access to DDRVTPR */
|
||||
SYSTEM->DDRVTPER = 0;
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* dm644x.h - DM644x specific platform definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DM644X_H_
|
||||
#define _DM644X_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define SYSTEM_CLK_HZ 27000000
|
||||
|
||||
#define PLL1_Mult 22 /* DSP=594 MHz ARM=297 MHz */
|
||||
|
||||
#define PLL2_Mult 24 /* DDRPHY=324 MHz DDRCLK=162 MHz */
|
||||
#define PLL2_Div1 12
|
||||
#define PLL2_Div2 2
|
||||
|
||||
#define UBL_IMAGE_SIZE 0x3800 /* 14 kB UBL (2Kb reserved for RBL stack) */
|
||||
|
||||
/* Global Memory Timing and PLL Settings */
|
||||
static const uint8_t DDR_NM = 0; /* 32-bit bus width by default. */
|
||||
static const uint8_t DDR_PAGESIZE = 2; /* 1024-word page size. */
|
||||
|
||||
/*
|
||||
* See TMS320DM6446 errata 2.1.2:
|
||||
* A value of $20 should provide a good ARM (cache enabled)
|
||||
* performance and still allow good utilization by the VPSS or other
|
||||
* modules.
|
||||
*/
|
||||
#define DDR_PBBPR_PR_OLD_COUNT 0x00000020;
|
||||
|
||||
/* PINMUX0 register bit values */
|
||||
#define PINMUX0_EMACEN (1 << 31)
|
||||
#define PINMUX0_HPIEN (1 << 29)
|
||||
#define PINMUX0_CFLDEN (1 << 27)
|
||||
#define PINMUX0_CWE (1 << 26)
|
||||
#define PINMUX0_LFLDEN (1 << 25)
|
||||
#define PINMUX0_LOEEN (1 << 24)
|
||||
#define PINMUX0_RGB888 (1 << 23)
|
||||
#define PINMUX0_RGB666 (1 << 22)
|
||||
#define PINMUX0_ATAEN (1 << 17)
|
||||
#define PINMUX0_HDIREN (1 << 16)
|
||||
#define PINMUX0_VLYNQEN (1 << 15)
|
||||
#define PINMUX0_VLSCREN (1 << 14)
|
||||
#define PINMUX0_VLYNQWD1 (1 << 13)
|
||||
#define PINMUX0_VLYNQWD0 (1 << 12)
|
||||
|
||||
#define VLYNQ_WIDTH_1 (0 << 12)
|
||||
#define VLYNQ_WIDTH_2 (1 << 12)
|
||||
#define VLYNQ_WIDTH_3 (3 << 12) /* See TI SPRUE26A document. */
|
||||
#define VLYNQ_WIDTH_4 (2 << 12) /* See TI SPRUE26A document. */
|
||||
|
||||
/* PINMUX1 register bit values */
|
||||
#define PINMUX1_TIMIN (1 << 18)
|
||||
#define PINMUX1_CLK1 (1 << 17)
|
||||
#define PINMUX1_CLK0 (1 << 16)
|
||||
#define PINMUX1_ASP (1 << 10)
|
||||
#define PINMUX1_SPI (1 << 8)
|
||||
#define PINMUX1_I2C (1 << 7)
|
||||
#define PINMUX1_PWM2 (1 << 6)
|
||||
#define PINMUX1_PWM1 (1 << 5)
|
||||
#define PINMUX1_PWM0 (1 << 4)
|
||||
#define PINMUX1_U2FLO (1 << 3)
|
||||
#define PINMUX1_UART2 (1 << 2)
|
||||
#define PINMUX1_UART1 (1 << 1)
|
||||
#define PINMUX1_UART0 (1 << 0)
|
||||
|
||||
#endif /* _DM644X_H_ */
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* gpio.c - GPIO handling
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on davinci gpio code from the Linux kernel, original copyright follows:
|
||||
* Copyright (c) 2006-2007 David Brownell
|
||||
* Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
#include "gpio.h"
|
||||
|
||||
static struct gpio_controller *
|
||||
gpio_to_controller(unsigned gpio)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (gpio < 32 * 1)
|
||||
ptr = (void *) DAVINCI_GPIO_BASE + 0x10;
|
||||
else if (gpio < 32 * 2)
|
||||
ptr = (void *) DAVINCI_GPIO_BASE + 0x38;
|
||||
else if (gpio < 32 * 3)
|
||||
ptr = (void *) DAVINCI_GPIO_BASE + 0x60;
|
||||
else if (gpio < 32 * 4)
|
||||
ptr = (void *) DAVINCI_GPIO_BASE + 0x88;
|
||||
else
|
||||
ptr = NULL;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
gpio_mask(unsigned gpio)
|
||||
{
|
||||
return 1 << (gpio % 32);
|
||||
}
|
||||
|
||||
int
|
||||
gpio_direction_in(unsigned gpio)
|
||||
{
|
||||
volatile struct gpio_controller *g = gpio_to_controller(gpio);
|
||||
uint32_t mask = gpio_mask(gpio);
|
||||
|
||||
g->dir |= mask;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gpio_direction_out(unsigned gpio, int initial_value)
|
||||
{
|
||||
volatile struct gpio_controller *g = gpio_to_controller(gpio);
|
||||
uint32_t mask = gpio_mask(gpio);
|
||||
|
||||
if (initial_value)
|
||||
g->set_data = mask;
|
||||
else
|
||||
g->clr_data = mask;
|
||||
|
||||
g->dir &= ~mask;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
gpio_set(unsigned gpio, int state)
|
||||
{
|
||||
volatile struct gpio_controller *g = gpio_to_controller(gpio);
|
||||
uint32_t mask = gpio_mask(gpio);
|
||||
|
||||
if (state)
|
||||
g->set_data = mask;
|
||||
else
|
||||
g->clr_data = mask;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* gpio.h - Gpio specific platform definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _GPIO_H_
|
||||
#define _GPIO_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define GPIO(X) (X) /* 0 <= X <= (DAVINCI_N_GPIO - 1) */
|
||||
|
||||
int
|
||||
gpio_direction_in(unsigned gpio);
|
||||
|
||||
int
|
||||
gpio_direction_out(unsigned gpio, int initial_value);
|
||||
|
||||
void
|
||||
gpio_set(unsigned gpio, int state);
|
||||
|
||||
#endif /* _GPIO_H_ */
|
|
@ -0,0 +1,868 @@
|
|||
/* gunzip.c - puff implementation
|
||||
*
|
||||
* Copyright (C) 2002-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in puff.h
|
||||
* version 1.8, 9 Jan 2004
|
||||
*
|
||||
* puff.c is a simple inflate written to be an unambiguous way to specify the
|
||||
* deflate format. It is not written for speed but rather simplicity. As a
|
||||
* side benefit, this code might actually be useful when small code is more
|
||||
* important than speed, such as bootstrap applications. For typical deflate
|
||||
* data, zlib's inflate() is about four times as fast as puff(). zlib's
|
||||
* inflate compiles to around 20K on my machine, whereas puff.c compiles to
|
||||
* around 4K on my machine (a PowerPC using GNU cc). If the faster decode()
|
||||
* function here is used, then puff() is only twice as slow as zlib's
|
||||
* inflate().
|
||||
*
|
||||
* All dynamically allocated memory comes from the stack. The stack required
|
||||
* is less than 2K bytes. This code is compatible with 16-bit int's and
|
||||
* assumes that long's are at least 32 bits. puff.c uses the short data type,
|
||||
* assumed to be 16 bits, for arrays in order to to conserve memory. The code
|
||||
* works whether integers are stored big endian or little endian.
|
||||
*
|
||||
* In the comments below are "Format notes" that describe the inflate process
|
||||
* and document some of the less obvious aspects of the format. This source
|
||||
* code is meant to supplement RFC 1951, which formally describes the deflate
|
||||
* format:
|
||||
*
|
||||
* http://www.zlib.org/rfc-deflate.html
|
||||
*/
|
||||
|
||||
/*
|
||||
* Change history:
|
||||
*
|
||||
* 1.0 10 Feb 2002 - First version
|
||||
* 1.1 17 Feb 2002 - Clarifications of some comments and notes
|
||||
* - Update puff() dest and source pointers on negative
|
||||
* errors to facilitate debugging deflators
|
||||
* - Remove longest from struct huffman -- not needed
|
||||
* - Simplify offs[] index in construct()
|
||||
* - Add input size and checking, using longjmp() to
|
||||
* maintain easy readability
|
||||
* - Use short data type for large arrays
|
||||
* - Use pointers instead of long to specify source and
|
||||
* destination sizes to avoid arbitrary 4 GB limits
|
||||
* 1.2 17 Mar 2002 - Add faster version of decode(), doubles speed (!),
|
||||
* but leave simple version for readabilty
|
||||
* - Make sure invalid distances detected if pointers
|
||||
* are 16 bits
|
||||
* - Fix fixed codes table error
|
||||
* - Provide a scanning mode for determining size of
|
||||
* uncompressed data
|
||||
* 1.3 20 Mar 2002 - Go back to lengths for puff() parameters [Jean-loup]
|
||||
* - Add a puff.h file for the interface
|
||||
* - Add braces in puff() for else do [Jean-loup]
|
||||
* - Use indexes instead of pointers for readability
|
||||
* 1.4 31 Mar 2002 - Simplify construct() code set check
|
||||
* - Fix some comments
|
||||
* - Add FIXLCODES #define
|
||||
* 1.5 6 Apr 2002 - Minor comment fixes
|
||||
* 1.6 7 Aug 2002 - Minor format changes
|
||||
* 1.7 3 Mar 2003 - Added test code for distribution
|
||||
* - Added zlib-like license
|
||||
* 1.8 9 Jan 2004 - Added some comments on no distance codes case
|
||||
* 1.9 20 Feb 2009 - Hugo villeneuve: changed puff function name to gunzip
|
||||
*/
|
||||
|
||||
#include "uart.h"
|
||||
|
||||
#define NIL ((unsigned char *)0) /* for no output option */
|
||||
|
||||
/*
|
||||
* Maximums for allocations and loops. It is not useful to change these --
|
||||
* they are fixed by the deflate format.
|
||||
*/
|
||||
#define MAXBITS 15 /* maximum bits in a code */
|
||||
#define MAXLCODES 286 /* maximum number of literal/length codes */
|
||||
#define MAXDCODES 30 /* maximum number of distance codes */
|
||||
#define MAXCODES (MAXLCODES+MAXDCODES) /* maximum codes lengths to read */
|
||||
#define FIXLCODES 288 /* number of fixed literal/length codes */
|
||||
|
||||
/* input and output state */
|
||||
struct state {
|
||||
/* output state */
|
||||
unsigned char *out; /* output buffer */
|
||||
unsigned long outlen; /* available space at out */
|
||||
unsigned long outcnt; /* bytes written to out so far */
|
||||
|
||||
/* input state */
|
||||
unsigned char *in; /* input buffer */
|
||||
unsigned long inlen; /* available input at in */
|
||||
unsigned long incnt; /* bytes read so far */
|
||||
int bitbuf; /* bit buffer */
|
||||
int bitcnt; /* number of bits in bit buffer */
|
||||
};
|
||||
|
||||
static int pufferror;
|
||||
|
||||
/*
|
||||
* Moved those variables from internal stack to DDR.
|
||||
* They were using too much internal stack and corrupted data.
|
||||
*/
|
||||
short distcnt[MAXBITS+1] __attribute__((section(".ddrram"))); /* distcode memory */
|
||||
short distsym[MAXDCODES] __attribute__((section(".ddrram"))); /* distcode memory */
|
||||
short lencnt[MAXBITS+1] __attribute__((section(".ddrram"))); /* lencode memory */
|
||||
short dyn_lengths[MAXCODES] __attribute__((section(".ddrram"))); /* descriptor code lengths */
|
||||
short lensym[FIXLCODES] __attribute__((section(".ddrram")));
|
||||
|
||||
/*
|
||||
* Return need bits from the input stream. This always leaves less than
|
||||
* eight bits in the buffer. bits() works properly for need == 0.
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - Bits are stored in bytes from the least significant bit to the most
|
||||
* significant bit. Therefore bits are dropped from the bottom of the bit
|
||||
* buffer, using shift right, and new bytes are appended to the top of the
|
||||
* bit buffer, using shift left.
|
||||
*/
|
||||
static int
|
||||
bits(struct state *s, int need)
|
||||
{
|
||||
long val; /* bit accumulator (can use up to 20 bits) */
|
||||
|
||||
/* load at least need bits into val */
|
||||
val = s->bitbuf;
|
||||
|
||||
while (s->bitcnt < need) {
|
||||
if (s->incnt == s->inlen) {
|
||||
pufferror = -1;
|
||||
return 0; /* out of input */
|
||||
}
|
||||
|
||||
/* load eight bits */
|
||||
val |= (long)(s->in[s->incnt++]) << s->bitcnt;
|
||||
s->bitcnt += 8;
|
||||
}
|
||||
|
||||
/* drop need bits and update buffer, always zero to seven bits left */
|
||||
s->bitbuf = (int)(val >> need);
|
||||
|
||||
s->bitcnt -= need;
|
||||
|
||||
/* return need bits, zeroing the bits above that */
|
||||
return (int)(val & ((1L << need) - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a stored block.
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - After the two-bit stored block type (00), the stored block length and
|
||||
* stored bytes are byte-aligned for fast copying. Therefore any leftover
|
||||
* bits in the byte that has the last bit of the type, as many as seven, are
|
||||
* discarded. The value of the discarded bits are not defined and should not
|
||||
* be checked against any expectation.
|
||||
*
|
||||
* - The second inverted copy of the stored block length does not have to be
|
||||
* checked, but it's probably a good idea to do so anyway.
|
||||
*
|
||||
* - A stored block can have zero length. This is sometimes used to byte-align
|
||||
* subsets of the compressed data for random access or partial recovery.
|
||||
*/
|
||||
static int
|
||||
stored(struct state *s)
|
||||
{
|
||||
unsigned len; /* length of stored block */
|
||||
|
||||
/* discard leftover bits from current byte (assumes s->bitcnt < 8) */
|
||||
s->bitbuf = 0;
|
||||
s->bitcnt = 0;
|
||||
|
||||
/* get length and check against its one's complement */
|
||||
if (s->incnt + 4 > s->inlen)
|
||||
return 2; /* not enough input */
|
||||
len = s->in[s->incnt++];
|
||||
len |= s->in[s->incnt++] << 8;
|
||||
if (s->in[s->incnt++] != (~len & 0xff) ||
|
||||
s->in[s->incnt++] != ((~len >> 8) & 0xff))
|
||||
return -2; /* didn't match complement! */
|
||||
|
||||
/* copy len bytes from in to out */
|
||||
if (s->incnt + len > s->inlen)
|
||||
return 2; /* not enough input */
|
||||
if (s->out != NIL) {
|
||||
if (s->outcnt + len > s->outlen)
|
||||
return 1; /* not enough output space */
|
||||
while (len--)
|
||||
s->out[s->outcnt++] = s->in[s->incnt++];
|
||||
} else { /* just scanning */
|
||||
s->outcnt += len;
|
||||
s->incnt += len;
|
||||
}
|
||||
|
||||
/* done with a valid stored block */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Huffman code decoding tables. count[1..MAXBITS] is the number of symbols of
|
||||
* each length, which for a canonical code are stepped through in order.
|
||||
* symbol[] are the symbol values in canonical order, where the number of
|
||||
* entries is the sum of the counts in count[]. The decoding process can be
|
||||
* seen in the function decode() below.
|
||||
*/
|
||||
struct huffman {
|
||||
short *count; /* number of symbols of each length */
|
||||
short *symbol; /* canonically ordered symbols */
|
||||
};
|
||||
|
||||
/*
|
||||
* Decode a code from the stream s using huffman table h. Return the symbol or
|
||||
* a negative value if there is an error. If all of the lengths are zero, i.e.
|
||||
* an empty code, or if the code is incomplete and an invalid code is received,
|
||||
* then -9 is returned after reading MAXBITS bits.
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - The codes as stored in the compressed data are bit-reversed relative to
|
||||
* a simple integer ordering of codes of the same lengths. Hence below the
|
||||
* bits are pulled from the compressed data one at a time and used to
|
||||
* build the code value reversed from what is in the stream in order to
|
||||
* permit simple integer comparisons for decoding. A table-based decoding
|
||||
* scheme (as used in zlib) does not need to do this reversal.
|
||||
*
|
||||
* - The first code for the shortest length is all zeros. Subsequent codes of
|
||||
* the same length are simply integer increments of the previous code. When
|
||||
* moving up a length, a zero bit is appended to the code. For a complete
|
||||
* code, the last code of the longest length will be all ones.
|
||||
*
|
||||
* - Incomplete codes are handled by this decoder, since they are permitted
|
||||
* in the deflate format. See the format notes for fixed() and dynamic().
|
||||
*/
|
||||
#ifdef SLOW
|
||||
static int
|
||||
decode(struct state *s, struct huffman *h)
|
||||
{
|
||||
int len; /* current number of bits in code */
|
||||
int code; /* len bits being decoded */
|
||||
int first; /* first code of length len */
|
||||
int count; /* number of codes of length len */
|
||||
int index; /* index of first code of length len in symbol table */
|
||||
|
||||
code = first = index = 0;
|
||||
for (len = 1; len <= MAXBITS; len++) {
|
||||
code |= bits(s, 1); /* get next bit */
|
||||
if (pufferror)
|
||||
return -1;
|
||||
|
||||
count = h->count[len];
|
||||
if (code < first + count) /* if length len, return symbol */
|
||||
return h->symbol[index + (code - first)];
|
||||
index += count; /* else update for next length */
|
||||
first += count;
|
||||
first <<= 1;
|
||||
code <<= 1;
|
||||
}
|
||||
return -9; /* ran out of codes */
|
||||
}
|
||||
|
||||
/*
|
||||
* A faster version of decode() for real applications of this code. It's not
|
||||
* as readable, but it makes puff() twice as fast. And it only makes the code
|
||||
* a few percent larger.
|
||||
*/
|
||||
#else /* !SLOW */
|
||||
static int
|
||||
decode(struct state *s, struct huffman *h)
|
||||
{
|
||||
int len; /* current number of bits in code */
|
||||
int code; /* len bits being decoded */
|
||||
int first; /* first code of length len */
|
||||
int count; /* number of codes of length len */
|
||||
int index; /* index of first code of length len in symbol table */
|
||||
int bitbuf; /* bits from stream */
|
||||
int left; /* bits left in next or left to process */
|
||||
short *next; /* next number of codes */
|
||||
|
||||
bitbuf = s->bitbuf;
|
||||
left = s->bitcnt;
|
||||
code = first = index = 0;
|
||||
len = 1;
|
||||
next = h->count + 1;
|
||||
while (1) {
|
||||
while (left--) {
|
||||
code |= bitbuf & 1;
|
||||
bitbuf >>= 1;
|
||||
count = *next++;
|
||||
if (code < first + count) {
|
||||
/* if length len, return symbol */
|
||||
s->bitbuf = bitbuf;
|
||||
s->bitcnt = (s->bitcnt - len) & 7;
|
||||
return h->symbol[index + (code - first)];
|
||||
}
|
||||
index += count; /* else update for next length */
|
||||
first += count;
|
||||
first <<= 1;
|
||||
code <<= 1;
|
||||
len++;
|
||||
}
|
||||
left = (MAXBITS+1) - len;
|
||||
if (left == 0)
|
||||
break;
|
||||
if (s->incnt == s->inlen) {
|
||||
pufferror = -1; /* out of input */
|
||||
return -1;
|
||||
}
|
||||
|
||||
bitbuf = s->in[s->incnt++];
|
||||
if (left > 8)
|
||||
left = 8;
|
||||
}
|
||||
return -9; /* ran out of codes */
|
||||
}
|
||||
#endif /* SLOW */
|
||||
|
||||
/*
|
||||
* Given the list of code lengths length[0..n-1] representing a canonical
|
||||
* Huffman code for n symbols, construct the tables required to decode those
|
||||
* codes. Those tables are the number of codes of each length, and the symbols
|
||||
* sorted by length, retaining their original order within each length. The
|
||||
* return value is zero for a complete code set, negative for an over-
|
||||
* subscribed code set, and positive for an incomplete code set. The tables
|
||||
* can be used if the return value is zero or positive, but they cannot be used
|
||||
* if the return value is negative. If the return value is zero, it is not
|
||||
* possible for decode() using that table to return an error--any stream of
|
||||
* enough bits will resolve to a symbol. If the return value is positive, then
|
||||
* it is possible for decode() using that table to return an error for received
|
||||
* codes past the end of the incomplete lengths.
|
||||
*
|
||||
* Not used by decode(), but used for error checking, h->count[0] is the number
|
||||
* of the n symbols not in the code. So n - h->count[0] is the number of
|
||||
* codes. This is useful for checking for incomplete codes that have more than
|
||||
* one symbol, which is an error in a dynamic block.
|
||||
*
|
||||
* Assumption: for all i in 0..n-1, 0 <= length[i] <= MAXBITS
|
||||
* This is assured by the construction of the length arrays in dynamic() and
|
||||
* fixed() and is not verified by construct().
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - Permitted and expected examples of incomplete codes are one of the fixed
|
||||
* codes and any code with a single symbol which in deflate is coded as one
|
||||
* bit instead of zero bits. See the format notes for fixed() and dynamic().
|
||||
*
|
||||
* - Within a given code length, the symbols are kept in ascending order for
|
||||
* the code bits definition.
|
||||
*/
|
||||
static int
|
||||
construct(struct huffman *h, short *length, int n)
|
||||
{
|
||||
int symbol; /* current symbol when stepping through length[] */
|
||||
int len; /* current length when stepping through h->count[] */
|
||||
int left; /* number of possible codes left of current length */
|
||||
short offs[MAXBITS+1]; /* offsets in symbol table for each length */
|
||||
|
||||
/* count number of codes of each length */
|
||||
for (len = 0; len <= MAXBITS; len++)
|
||||
h->count[len] = 0;
|
||||
|
||||
/* assumes lengths are within bounds */
|
||||
for (symbol = 0; symbol < n; symbol++)
|
||||
(h->count[length[symbol]])++;
|
||||
if (h->count[0] == n) /* no codes! */
|
||||
return 0; /* complete, but decode() will fail */
|
||||
|
||||
/* check for an over-subscribed or incomplete set of lengths */
|
||||
left = 1; /* one possible code of zero length */
|
||||
for (len = 1; len <= MAXBITS; len++) {
|
||||
left <<= 1; /* one more bit, double codes left */
|
||||
left -= h->count[len]; /* deduct count from possible codes */
|
||||
if (left < 0)
|
||||
return left; /* over-subscribed--return negative */
|
||||
} /* left > 0 means incomplete */
|
||||
|
||||
/* generate offsets into symbol table for each length for sorting */
|
||||
offs[1] = 0;
|
||||
for (len = 1; len < MAXBITS; len++)
|
||||
offs[len + 1] = offs[len] + h->count[len];
|
||||
|
||||
/*
|
||||
* put symbols in table sorted by length, by symbol order within each
|
||||
* length
|
||||
*/
|
||||
for (symbol = 0; symbol < n; symbol++)
|
||||
if (length[symbol] != 0)
|
||||
h->symbol[offs[length[symbol]]++] = symbol;
|
||||
|
||||
/* return zero for complete set, positive for incomplete set */
|
||||
return left;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode literal/length and distance codes until an end-of-block code.
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - Compressed data that is after the block type if fixed or after the code
|
||||
* description if dynamic is a combination of literals and length/distance
|
||||
* pairs terminated by and end-of-block code. Literals are simply Huffman
|
||||
* coded bytes. A length/distance pair is a coded length followed by a
|
||||
* coded distance to represent a string that occurs earlier in the
|
||||
* uncompressed data that occurs again at the current location.
|
||||
*
|
||||
* - Literals, lengths, and the end-of-block code are combined into a single
|
||||
* code of up to 286 symbols. They are 256 literals (0..255), 29 length
|
||||
* symbols (257..285), and the end-of-block symbol (256).
|
||||
*
|
||||
* - There are 256 possible lengths (3..258), and so 29 symbols are not enough
|
||||
* to represent all of those. Lengths 3..10 and 258 are in fact represented
|
||||
* by just a length symbol. Lengths 11..257 are represented as a symbol and
|
||||
* some number of extra bits that are added as an integer to the base length
|
||||
* of the length symbol. The number of extra bits is determined by the base
|
||||
* length symbol. These are in the static arrays below, lens[] for the base
|
||||
* lengths and lext[] for the corresponding number of extra bits.
|
||||
*
|
||||
* - The reason that 258 gets its own symbol is that the longest length is used
|
||||
* often in highly redundant files. Note that 258 can also be coded as the
|
||||
* base value 227 plus the maximum extra value of 31. While a good deflate
|
||||
* should never do this, it is not an error, and should be decoded properly.
|
||||
*
|
||||
* - If a length is decoded, including its extra bits if any, then it is
|
||||
* followed a distance code. There are up to 30 distance symbols. Again
|
||||
* there are many more possible distances (1..32768), so extra bits are added
|
||||
* to a base value represented by the symbol. The distances 1..4 get their
|
||||
* own symbol, but the rest require extra bits. The base distances and
|
||||
* corresponding number of extra bits are below in the static arrays dist[]
|
||||
* and dext[].
|
||||
*
|
||||
* - Literal bytes are simply written to the output. A length/distance pair is
|
||||
* an instruction to copy previously uncompressed bytes to the output. The
|
||||
* copy is from distance bytes back in the output stream, copying for length
|
||||
* bytes.
|
||||
*
|
||||
* - Distances pointing before the beginning of the output data are not
|
||||
* permitted.
|
||||
*
|
||||
* - Overlapped copies, where the length is greater than the distance, are
|
||||
* allowed and common. For example, a distance of one and a length of 258
|
||||
* simply copies the last byte 258 times. A distance of four and a length of
|
||||
* twelve copies the last four bytes three times. A simple forward copy
|
||||
* ignoring whether the length is greater than the distance or not implements
|
||||
* this correctly. You should not use memcpy() since its behavior is not
|
||||
* defined for overlapped arrays. You should not use memmove() or bcopy()
|
||||
* since though their behavior -is- defined for overlapping arrays, it is
|
||||
* defined to do the wrong thing in this case.
|
||||
*/
|
||||
static int
|
||||
codes(struct state *s,
|
||||
struct huffman *lencode,
|
||||
struct huffman *distcode)
|
||||
{
|
||||
int symbol; /* decoded symbol */
|
||||
int len; /* length for copy */
|
||||
unsigned dist; /* distance for copy */
|
||||
/* Size base for length codes 257-285 */
|
||||
static const short lens[29] = {
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258};
|
||||
/* Extra bits for length codes 257-285 */
|
||||
static const short lext[29] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
|
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
|
||||
/* Offset base for distance codes 0-29 */
|
||||
static const short dists[30] = {
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577};
|
||||
/* Extra bits for distance codes 0-29 */
|
||||
static const short dext[30] = {
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
|
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
|
||||
12, 12, 13, 13};
|
||||
|
||||
/* decode literals and length/distance pairs */
|
||||
do {
|
||||
symbol = decode(s, lencode);
|
||||
if (symbol < 0)
|
||||
return symbol; /* invalid symbol */
|
||||
if (symbol < 256) { /* literal: symbol is the byte */
|
||||
/* write out the literal */
|
||||
if (s->out != NIL) {
|
||||
if (s->outcnt == s->outlen)
|
||||
return 1;
|
||||
s->out[s->outcnt] = symbol;
|
||||
}
|
||||
s->outcnt++;
|
||||
} else if (symbol > 256) { /* length */
|
||||
/* get and compute length */
|
||||
symbol -= 257;
|
||||
if (symbol >= 29)
|
||||
return -9; /* invalid fixed code */
|
||||
len = lens[symbol] + bits(s, lext[symbol]);
|
||||
if (pufferror)
|
||||
return -1;
|
||||
|
||||
/* get and check distance */
|
||||
symbol = decode(s, distcode);
|
||||
if (symbol < 0)
|
||||
return symbol; /* invalid symbol */
|
||||
dist = dists[symbol] + bits(s, dext[symbol]);
|
||||
if (pufferror)
|
||||
return -1;
|
||||
|
||||
if (dist > s->outcnt)
|
||||
return -10; /* distance too far back */
|
||||
|
||||
/* copy length bytes from distance bytes back */
|
||||
if (s->out != NIL) {
|
||||
if (s->outcnt + len > s->outlen)
|
||||
return 1;
|
||||
while (len--) {
|
||||
s->out[s->outcnt] =
|
||||
s->out[s->outcnt - dist];
|
||||
s->outcnt++;
|
||||
}
|
||||
} else
|
||||
s->outcnt += len;
|
||||
}
|
||||
} while (symbol != 256); /* end of block symbol */
|
||||
|
||||
/* done with a valid fixed or dynamic block */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a fixed codes block.
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - This block type can be useful for compressing small amounts of data for
|
||||
* which the size of the code descriptions in a dynamic block exceeds the
|
||||
* benefit of custom codes for that block. For fixed codes, no bits are
|
||||
* spent on code descriptions. Instead the code lengths for literal/length
|
||||
* codes and distance codes are fixed. The specific lengths for each symbol
|
||||
* can be seen in the "for" loops below.
|
||||
*
|
||||
* - The literal/length code is complete, but has two symbols that are invalid
|
||||
* and should result in an error if received. This cannot be implemented
|
||||
* simply as an incomplete code since those two symbols are in the "middle"
|
||||
* of the code. They are eight bits long and the longest literal/length\
|
||||
* code is nine bits. Therefore the code must be constructed with those
|
||||
* symbols, and the invalid symbols must be detected after decoding.
|
||||
*
|
||||
* - The fixed distance codes also have two invalid symbols that should result
|
||||
* in an error if received. Since all of the distance codes are the same
|
||||
* length, this can be implemented as an incomplete code. Then the invalid
|
||||
* codes are detected while decoding.
|
||||
*/
|
||||
static int
|
||||
fixed(struct state *s)
|
||||
{
|
||||
static int virgin = 1;
|
||||
//////////////static short lencnt[MAXBITS+1];
|
||||
//////static short lensym[FIXLCODES];
|
||||
///////////////////static short distcnt[MAXBITS+1], distsym[MAXDCODES];
|
||||
static struct huffman lencode = {lencnt, lensym};
|
||||
static struct huffman distcode = {distcnt, distsym};
|
||||
|
||||
/* build fixed huffman tables if first call (may not be thread safe) */
|
||||
if (virgin) {
|
||||
int symbol;
|
||||
short lengths[FIXLCODES];
|
||||
|
||||
/* literal/length table */
|
||||
for (symbol = 0; symbol < 144; symbol++)
|
||||
lengths[symbol] = 8;
|
||||
for (; symbol < 256; symbol++)
|
||||
lengths[symbol] = 9;
|
||||
for (; symbol < 280; symbol++)
|
||||
lengths[symbol] = 7;
|
||||
for (; symbol < FIXLCODES; symbol++)
|
||||
lengths[symbol] = 8;
|
||||
construct(&lencode, lengths, FIXLCODES);
|
||||
|
||||
/* distance table */
|
||||
for (symbol = 0; symbol < MAXDCODES; symbol++)
|
||||
lengths[symbol] = 5;
|
||||
construct(&distcode, lengths, MAXDCODES);
|
||||
|
||||
/* do this just once */
|
||||
virgin = 0;
|
||||
}
|
||||
|
||||
/* decode data until end-of-block code */
|
||||
return codes(s, &lencode, &distcode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a dynamic codes block.
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - A dynamic block starts with a description of the literal/length and
|
||||
* distance codes for that block. New dynamic blocks allow the compressor to
|
||||
* rapidly adapt to changing data with new codes optimized for that data.
|
||||
*
|
||||
* - The codes used by the deflate format are "canonical", which means that
|
||||
* the actual bits of the codes are generated in an unambiguous way simply
|
||||
* from the number of bits in each code. Therefore the code descriptions
|
||||
* are simply a list of code lengths for each symbol.
|
||||
*
|
||||
* - The code lengths are stored in order for the symbols, so lengths are
|
||||
* provided for each of the literal/length symbols, and for each of the
|
||||
* distance symbols.
|
||||
*
|
||||
* - If a symbol is not used in the block, this is represented by a zero as
|
||||
* as the code length. This does not mean a zero-length code, but rather
|
||||
* that no code should be created for this symbol. There is no way in the
|
||||
* deflate format to represent a zero-length code.
|
||||
*
|
||||
* - The maximum number of bits in a code is 15, so the possible lengths for
|
||||
* any code are 1..15.
|
||||
*
|
||||
* - The fact that a length of zero is not permitted for a code has an
|
||||
* interesting consequence. Normally if only one symbol is used for a given
|
||||
* code, then in fact that code could be represented with zero bits. However
|
||||
* in deflate, that code has to be at least one bit. So for example, if
|
||||
* only a single distance base symbol appears in a block, then it will be
|
||||
* represented by a single code of length one, in particular one 0 bit. This
|
||||
* is an incomplete code, since if a 1 bit is received, it has no meaning,
|
||||
* and should result in an error. So incomplete distance codes of one symbol
|
||||
* should be permitted, and the receipt of invalid codes should be handled.
|
||||
*
|
||||
* - It is also possible to have a single literal/length code, but that code
|
||||
* must be the end-of-block code, since every dynamic block has one. This
|
||||
* is not the most efficient way to create an empty block (an empty fixed
|
||||
* block is fewer bits), but it is allowed by the format. So incomplete
|
||||
* literal/length codes of one symbol should also be permitted.
|
||||
*
|
||||
* - If there are only literal codes and no lengths, then there are no distance
|
||||
* codes. This is represented by one distance code with zero bits.
|
||||
*
|
||||
* - The list of up to 286 length/literal lengths and up to 30 distance lengths
|
||||
* are themselves compressed using Huffman codes and run-length encoding. In
|
||||
* the list of code lengths, a 0 symbol means no code, a 1..15 symbol means
|
||||
* that length, and the symbols 16, 17, and 18 are run-length instructions.
|
||||
* Each of 16, 17, and 18 are follwed by extra bits to define the length of
|
||||
* the run. 16 copies the last length 3 to 6 times. 17 represents 3 to 10
|
||||
* zero lengths, and 18 represents 11 to 138 zero lengths. Unused symbols
|
||||
* are common, hence the special coding for zero lengths.
|
||||
*
|
||||
* - The symbols for 0..18 are Huffman coded, and so that code must be
|
||||
* described first. This is simply a sequence of up to 19 three-bit values
|
||||
* representing no code (0) or the code length for that symbol (1..7).
|
||||
*
|
||||
* - A dynamic block starts with three fixed-size counts from which is computed
|
||||
* the number of literal/length code lengths, the number of distance code
|
||||
* lengths, and the number of code length code lengths (ok, you come up with
|
||||
* a better name!) in the code descriptions. For the literal/length and
|
||||
* distance codes, lengths after those provided are considered zero, i.e. no
|
||||
* code. The code length code lengths are received in a permuted order (see
|
||||
* the order[] array below) to make a short code length code length list more
|
||||
* likely. As it turns out, very short and very long codes are less likely
|
||||
* to be seen in a dynamic code description, hence what may appear initially
|
||||
* to be a peculiar ordering.
|
||||
*
|
||||
* - Given the number of literal/length code lengths (nlen) and distance code
|
||||
* lengths (ndist), then they are treated as one long list of nlen + ndist
|
||||
* code lengths. Therefore run-length coding can and often does cross the
|
||||
* boundary between the two sets of lengths.
|
||||
*
|
||||
* - So to summarize, the code description at the start of a dynamic block is
|
||||
* three counts for the number of code lengths for the literal/length codes,
|
||||
* the distance codes, and the code length codes. This is followed by the
|
||||
* code length code lengths, three bits each. This is used to construct the
|
||||
* code length code which is used to read the remainder of the lengths. Then
|
||||
* the literal/length code lengths and distance lengths are read as a single
|
||||
* set of lengths using the code length codes. Codes are constructed from
|
||||
* the resulting two sets of lengths, and then finally you can start
|
||||
* decoding actual compressed data in the block.
|
||||
*
|
||||
* - For reference, a "typical" size for the code description in a dynamic
|
||||
* block is around 80 bytes.
|
||||
*/
|
||||
static int
|
||||
dynamic(struct state *s)
|
||||
{
|
||||
int nlen, ndist, ncode; /* number of dyn_lengths in descriptor */
|
||||
int index; /* index of dyn_lengths[] */
|
||||
int err; /* construct() return value */
|
||||
//////////////short lensym[MAXLCODES]; /* lencode memory */
|
||||
struct huffman lencode = {lencnt, lensym}; /* length code */
|
||||
struct huffman distcode = {distcnt, distsym}; /* distance code */
|
||||
static const short order[19] = /* permutation of code length codes */
|
||||
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14,
|
||||
1, 15};
|
||||
|
||||
/* get number of dyn_lengths in each table, check dyn_lengths */
|
||||
nlen = bits(s, 5) + 257;
|
||||
ndist = bits(s, 5) + 1;
|
||||
ncode = bits(s, 4) + 4;
|
||||
if (pufferror)
|
||||
return -1;
|
||||
|
||||
if (nlen > MAXLCODES || ndist > MAXDCODES)
|
||||
return -3; /* bad counts */
|
||||
|
||||
/* read code length code dyn_lengths (really), missing dyn_lengths are zero */
|
||||
for (index = 0; index < ncode; index++) {
|
||||
dyn_lengths[order[index]] = bits(s, 3);
|
||||
if (pufferror)
|
||||
return -1;
|
||||
}
|
||||
for (; index < 19; index++)
|
||||
dyn_lengths[order[index]] = 0;
|
||||
|
||||
/* build huffman table for code dyn_lengths codes (use lencode
|
||||
* temporarily) */
|
||||
err = construct(&lencode, dyn_lengths, 19);
|
||||
if (err != 0)
|
||||
return -4; /* require complete code set here */
|
||||
|
||||
/* read length/literal and distance code length tables */
|
||||
index = 0;
|
||||
while (index < nlen + ndist) {
|
||||
int symbol; /* decoded value */
|
||||
int len; /* last length to repeat */
|
||||
|
||||
symbol = decode(s, &lencode);
|
||||
if (symbol < 16) /* length in 0..15 */
|
||||
dyn_lengths[index++] = symbol;
|
||||
else { /* repeat instruction */
|
||||
len = 0; /* assume repeating zeros */
|
||||
if (symbol == 16) { /* repeat last length 3..6 times */
|
||||
if (index == 0)
|
||||
return -5; /* no last length! */
|
||||
len = dyn_lengths[index - 1]; /* last length */
|
||||
symbol = 3 + bits(s, 2);
|
||||
if (pufferror)
|
||||
return -1;
|
||||
} else if (symbol == 17) { /* repeat zero 3..10 times */
|
||||
symbol = 3 + bits(s, 3);
|
||||
if (pufferror)
|
||||
return -1;
|
||||
} else { /* == 18, repeat zero 11..138 times */
|
||||
symbol = 11 + bits(s, 7);
|
||||
if (pufferror)
|
||||
return -1;
|
||||
}
|
||||
if (index + symbol > nlen + ndist)
|
||||
return -6; /* too many dyn_lengths! */
|
||||
while (symbol--) /* repeat last or zero symbol times */
|
||||
dyn_lengths[index++] = len;
|
||||
}
|
||||
}
|
||||
|
||||
/* build huffman table for literal/length codes */
|
||||
err = construct(&lencode, dyn_lengths, nlen);
|
||||
if (err < 0 || (err > 0 && nlen - lencode.count[0] != 1))
|
||||
return -7; /* only allow incomplete codes if just one code */
|
||||
|
||||
/* build huffman table for distance codes */
|
||||
err = construct(&distcode, dyn_lengths + nlen, ndist);
|
||||
if (err < 0 || (err > 0 && ndist - distcode.count[0] != 1))
|
||||
return -8; /* only allow incomplete codes if just one code */
|
||||
|
||||
/* decode data until end-of-block code */
|
||||
return codes(s, &lencode, &distcode);
|
||||
}
|
||||
|
||||
/*
|
||||
* Inflate source to dest. On return, destlen and sourcelen are updated to the
|
||||
* size of the uncompressed data and the size of the deflate data respectively.
|
||||
* On success, the return value of puff() is zero. If there is an error in the
|
||||
* source data, i.e. it is not in the deflate format, then a negative value is
|
||||
* returned. If there is not enough input available or there is not enough
|
||||
* output space, then a positive error is returned. In that case, destlen and
|
||||
* sourcelen are not updated to facilitate retrying from the beginning with the
|
||||
* provision of more input data or more output space. In the case of invalid
|
||||
* inflate data (a negative error), the dest and source pointers are updated to
|
||||
* facilitate the debugging of deflators.
|
||||
*
|
||||
* puff() also has a mode to determine the size of the uncompressed output with
|
||||
* no output written. For this dest must be (unsigned char *)0. In this case,
|
||||
* the input value of *destlen is ignored, and on return *destlen is set to the
|
||||
* size of the uncompressed output.
|
||||
*
|
||||
* The return codes are:
|
||||
*
|
||||
* 2: available inflate data did not terminate
|
||||
* 1: output space exhausted before completing inflate
|
||||
* 0: successful inflate
|
||||
* -1: invalid block type (type == 3)
|
||||
* -2: stored block length did not match one's complement
|
||||
* -3: dynamic block code description: too many length or distance codes
|
||||
* -4: dynamic block code description: code lengths codes incomplete
|
||||
* -5: dynamic block code description: repeat lengths with no first length
|
||||
* -6: dynamic block code description: repeat more than specified lengths
|
||||
* -7: dynamic block code description: invalid literal/length code lengths
|
||||
* -8: dynamic block code description: invalid distance code lengths
|
||||
* -9: invalid literal/length or distance code in fixed or dynamic block
|
||||
* -10: distance is too far back in fixed or dynamic block
|
||||
*
|
||||
* Format notes:
|
||||
*
|
||||
* - Three bits are read for each block to determine the kind of block and
|
||||
* whether or not it is the last block. Then the block is decoded and the
|
||||
* process repeated if it was not the last block.
|
||||
*
|
||||
* - The leftover bits in the last byte of the deflate data after the last
|
||||
* block (if it was a fixed or dynamic block) are undefined and have no
|
||||
* expected values to check.
|
||||
*/
|
||||
int
|
||||
gunzip(unsigned char *dest, /* destination pointer */
|
||||
unsigned long *destlen, /* amount of output space */
|
||||
unsigned char *source, /* source data pointer */
|
||||
unsigned long *sourcelen) /* amount of input available */
|
||||
{
|
||||
struct state s; /* input/output state */
|
||||
int last, type; /* block information */
|
||||
int err; /* return value */
|
||||
|
||||
pufferror = 0;
|
||||
|
||||
/* initialize output state */
|
||||
s.out = dest;
|
||||
s.outlen = *destlen; /* ignored if dest is NIL */
|
||||
s.outcnt = 0;
|
||||
|
||||
/* initialize input state */
|
||||
s.in = source;
|
||||
s.inlen = *sourcelen;
|
||||
s.incnt = 0;
|
||||
s.bitbuf = 0;
|
||||
s.bitcnt = 0;
|
||||
|
||||
/* process blocks until last block or error */
|
||||
do {
|
||||
last = bits(&s, 1); /* one if last block */
|
||||
if (pufferror)
|
||||
return 2;
|
||||
|
||||
type = bits(&s, 2); /* block type 0..3 */
|
||||
if (pufferror)
|
||||
return 2;
|
||||
|
||||
switch (type) {
|
||||
case 0:
|
||||
err = stored(&s);
|
||||
break;
|
||||
case 1:
|
||||
err = fixed(&s);
|
||||
break;
|
||||
case 2:
|
||||
err = dynamic(&s);
|
||||
break;
|
||||
default:
|
||||
err = -1; /* Invalid */
|
||||
break;
|
||||
}
|
||||
|
||||
if (pufferror)
|
||||
return 2;
|
||||
|
||||
if (err != 0)
|
||||
break; /* return with error */
|
||||
} while (!last);
|
||||
|
||||
/* update the lengths and return */
|
||||
if (err <= 0) {
|
||||
*destlen = s.outcnt;
|
||||
*sourcelen = s.incnt;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/* gunzip.h
|
||||
Copyright (C) 2002, 2003 Mark Adler, all rights reserved
|
||||
version 1.7, 3 Mar 2002
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Mark Adler madler@alumni.caltech.edu
|
||||
*/
|
||||
|
||||
#define GUNZIP_COMP_BLOCK_OFFSET 0x0A /* Offset of compressed block when no
|
||||
* flags are set in the GZIP file. */
|
||||
|
||||
int gunzip(unsigned char *dest, /* destination pointer */
|
||||
unsigned long *destlen, /* amount of output space */
|
||||
unsigned char *source, /* source data pointer */
|
||||
unsigned long *sourcelen); /* amount of input available */
|
|
@ -0,0 +1,975 @@
|
|||
/*
|
||||
* nand.c - NAND flash functions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
#include "util.h"
|
||||
#include "uart.h"
|
||||
#include "nand.h"
|
||||
|
||||
/* BUS width defines */
|
||||
#define BUS_8BIT 0x01
|
||||
#define BUS_16BIT 0x02
|
||||
#define BUS_32BIT 0x04
|
||||
|
||||
/* NAND flash addresses */
|
||||
#define NAND_DATA_OFFSET 0x00
|
||||
#define NAND_ALE_OFFSET 0x08
|
||||
#define NAND_CLE_OFFSET 0x10
|
||||
|
||||
#define NAND_TIMEOUT 20480
|
||||
|
||||
/* NAND flash commands */
|
||||
#define NAND_LO_PAGE 0x00
|
||||
#define NAND_HI_PAGE 0x01
|
||||
#define NAND_LOCK 0x2A
|
||||
#define NAND_UNLOCK_START 0x23
|
||||
#define NAND_UNLOCK_END 0x24
|
||||
#define NAND_READ_30H 0x30
|
||||
#define NAND_EXTRA_PAGE 0x50
|
||||
#define NAND_RDID 0x90
|
||||
#define NAND_RDIDADD 0x00
|
||||
#define NAND_RESET 0xFF
|
||||
#define NAND_PGRM_START 0x80
|
||||
#define NAND_PGRM_END 0x10
|
||||
#define NAND_RDY 0x40
|
||||
#define NAND_PGM_FAIL 0x01
|
||||
#define NAND_BERASEC1 0x60
|
||||
#define NAND_BERASEC2 0xD0
|
||||
#define NAND_STATUS 0x70
|
||||
|
||||
/* Status output */
|
||||
#define NAND_NANDFSR_READY 0x01
|
||||
#define NAND_STATUS_WRITEREADY 0xC0
|
||||
#define NAND_STATUS_ERROR 0x01
|
||||
#define NAND_STATUS_BUSY 0x40
|
||||
|
||||
#define UNKNOWN_NAND 0xFF /* Unknown device id */
|
||||
|
||||
/* Gives the page size in bytes without the spare bytes */
|
||||
#define NANDFLASH_PAGESIZE(x) ((x >> 8) << 8)
|
||||
|
||||
union flash_data {
|
||||
uint8_t c;
|
||||
uint16_t w;
|
||||
uint32_t l;
|
||||
};
|
||||
|
||||
union flash_ptr {
|
||||
volatile uint8_t *cp;
|
||||
volatile uint16_t *wp;
|
||||
volatile uint32_t *lp;
|
||||
};
|
||||
|
||||
struct nand_dev_infos_t {
|
||||
uint8_t id; /* Device ID */
|
||||
uint16_t num_blocks; /* Number of blocks */
|
||||
uint8_t pages_per_block; /* Number of pages per block */
|
||||
uint16_t bytes_per_page; /* Number of bytes per page (with spare) */
|
||||
};
|
||||
|
||||
struct nand_info_t {
|
||||
uint32_t base_addr; /* Base address of NAND CS memory space. */
|
||||
int bus_width; /* Bus width: 0 = 8 bits, 1 = 16 bits */
|
||||
int id; /* Index into nand_dev_infos_t array. */
|
||||
int num_blocks; /* Number of blocks */
|
||||
int pages_per_block; /* Number of pages per block */
|
||||
int bytes_per_page; /* Number of bytes per page (with spare) */
|
||||
int num_cab; /* Number of Column address cycles */
|
||||
int num_rab; /* Number of Row address cycles */
|
||||
uint32_t ecc_mask; /* Mask for ECC register */
|
||||
int large_page; /* True if page size >= 2048 bytes */
|
||||
int ecc_index; /* ECC position is different for small and
|
||||
* large page devices. */
|
||||
int chunk_size; /* Always read/write in 512 bytes chunk max.
|
||||
* This will be set based on page size. */
|
||||
int spare_bytes; /* Number of spare area bytes per page. */
|
||||
int blk_addr_shift; /* Number of bits by which to shift block address */
|
||||
int page_addr_shift; /* Number of bits by which to shift page address */
|
||||
int cs_offset; /*
|
||||
* Chip-select offset:
|
||||
* 0 = CS2 space
|
||||
* 1 = CS3 space
|
||||
* 2 = CS4 space
|
||||
* 3 = CS5 space
|
||||
*/
|
||||
};
|
||||
|
||||
/* Buffer for storing data read from NAND flash */
|
||||
static uint8_t read_buf[MAX_PAGE_SIZE] __attribute__((section(".ddrram")));
|
||||
|
||||
/* Symbol from linker script */
|
||||
extern uint32_t __NANDFlash;
|
||||
|
||||
/* structure for holding details about the NAND device itself */
|
||||
static volatile struct nand_info_t nand_info;
|
||||
|
||||
/* Table of ROM supported NAND devices */
|
||||
static const struct nand_dev_infos_t nand_dev_infos[] = {
|
||||
/* id, num_blocks, pages_per_block, bytes_per_page */
|
||||
{0x6E, 256, 16, 256+8}, /* 1 MB */
|
||||
{0x68, 256, 16, 256+8}, /* 1 MB */
|
||||
{0xEC, 256, 16, 256+8}, /* 1 MB */
|
||||
{0xE8, 256, 16, 256+8}, /* 1 MB */
|
||||
{0xEA, 512, 16, 256+8}, /* 2 MB */
|
||||
{0xE3, 512, 16, 512+16}, /* 4 MB */
|
||||
{0xE5, 512, 16, 512+16}, /* 4 MB */
|
||||
{0xE6, 1024, 16, 512+16}, /* 8 MB */
|
||||
|
||||
{0x39, 1024, 16, 512+16}, /* 8 MB */
|
||||
{0x6B, 1024, 16, 512+16}, /* 8 MB */
|
||||
{0x73, 1024, 32, 512+16}, /* 16 MB */
|
||||
{0x33, 1024, 32, 512+16}, /* 16 MB */
|
||||
{0x75, 2048, 32, 512+16}, /* 32 MB */
|
||||
{0x35, 2048, 32, 512+16}, /* 32 MB */
|
||||
|
||||
{0x43, 1024, 32, 512+16}, /* 16 MB 0x1243 */
|
||||
{0x45, 2048, 32, 512+16}, /* 32 MB 0x1245 */
|
||||
{0x53, 1024, 32, 512+16}, /* 16 MB 0x1253 */
|
||||
{0x55, 2048, 32, 512+16}, /* 32 MB 0x1255 */
|
||||
{0x36, 4096, 32, 512+16}, /* 64 MB */
|
||||
{0x46, 4096, 32, 512+16}, /* 64 MB 0x1346 */
|
||||
{0x56, 4096, 32, 512+16}, /* 64 MB 0x1356 */
|
||||
|
||||
{0x76, 4096, 32, 512+16}, /* 64 MB */
|
||||
|
||||
{0x74, 8192, 32, 512+16}, /* 128 MB 0x1374 */
|
||||
{0x79, 8192, 32, 512+16}, /* 128 MB */
|
||||
{0x71, 16384, 32, 512+16}, /* 256 MB */
|
||||
{0xF1, 1024, 64, 2048+64}, /* 128 MB - Big Block */
|
||||
{0xA1, 1024, 64, 2048+64}, /* 128 MB - Big Block */
|
||||
{0xAA, 2048, 64, 2048+64}, /* 256 MB - Big Block */
|
||||
{0xDA, 2048, 64, 2048+64}, /* 256 MB - Big Block */
|
||||
{0xDC, 4096, 64, 2048+64}, /* 512 MB - Big Block */
|
||||
{0xAC, 4096, 64, 2048+64}, /* 512 MB - Big Block */
|
||||
{0xB1, 1024, 64, 2048+64}, /* 128 MB - Big Block */
|
||||
{0xC1, 1024, 64, 2048+64}, /* 128 MB - Big Block */
|
||||
{0xD3, 4096, 64, 2048+64}, /* 512 MB - Big Block */
|
||||
{0x00, 0, 0, 0} /* Indicate end of table */
|
||||
};
|
||||
|
||||
static volatile uint8_t *
|
||||
flash_make_addr(uint32_t baseAddr, uint32_t offset)
|
||||
{
|
||||
return (volatile uint8_t *) (baseAddr + offset);
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_data(uint32_t offset, uint32_t data)
|
||||
{
|
||||
volatile union flash_ptr addr;
|
||||
union flash_data dataword;
|
||||
dataword.l = data;
|
||||
|
||||
addr.cp = flash_make_addr(nand_info.base_addr, offset);
|
||||
switch (nand_info.bus_width) {
|
||||
case BUS_8BIT:
|
||||
*addr.cp = dataword.c;
|
||||
break;
|
||||
case BUS_16BIT:
|
||||
*addr.wp = dataword.w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_cmd(uint32_t cmd)
|
||||
{
|
||||
flash_write_data(NAND_CLE_OFFSET, cmd);
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_addr(uint32_t addr)
|
||||
{
|
||||
flash_write_data(NAND_ALE_OFFSET, addr);
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_bytes(const uint8_t *src, uint32_t numBytes)
|
||||
{
|
||||
volatile union flash_ptr destAddr, srcAddr;
|
||||
uint32_t i;
|
||||
|
||||
srcAddr.cp = (volatile uint8_t *) src;
|
||||
destAddr.cp = flash_make_addr(nand_info.base_addr, NAND_DATA_OFFSET);
|
||||
switch (nand_info.bus_width) {
|
||||
case BUS_8BIT:
|
||||
for (i = 0; i < numBytes; i++)
|
||||
*destAddr.cp = *srcAddr.cp++;
|
||||
break;
|
||||
case BUS_16BIT:
|
||||
for (i = 0; i < (numBytes >> 1); i++)
|
||||
*destAddr.wp = *srcAddr.wp++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_addr_bytes(uint32_t numAddrBytes, uint32_t addr)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0; i < numAddrBytes; i++)
|
||||
flash_write_addr((addr >> (8*i)) & 0xff);
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_row_addr_bytes(uint32_t block, uint32_t page)
|
||||
{
|
||||
uint32_t row_addr;
|
||||
row_addr =
|
||||
(block << (nand_info.blk_addr_shift - nand_info.page_addr_shift)) | page;
|
||||
flash_write_addr_bytes(nand_info.num_rab, row_addr);
|
||||
}
|
||||
|
||||
static void
|
||||
flash_write_addr_cycles(uint32_t block, uint32_t page)
|
||||
{
|
||||
flash_write_addr_bytes(nand_info.num_cab, 0x00000000);
|
||||
flash_write_row_addr_bytes(block, page);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
flash_read_data(void)
|
||||
{
|
||||
volatile union flash_ptr addr;
|
||||
union flash_data cmdword;
|
||||
|
||||
cmdword.l = 0x0;
|
||||
addr.cp = flash_make_addr(nand_info.base_addr, NAND_DATA_OFFSET);
|
||||
switch (nand_info.bus_width) {
|
||||
case BUS_8BIT:
|
||||
cmdword.c = *addr.cp;
|
||||
break;
|
||||
case BUS_16BIT:
|
||||
cmdword.w = *addr.wp;
|
||||
break;
|
||||
}
|
||||
return cmdword.l;
|
||||
}
|
||||
|
||||
static void
|
||||
flash_read_bytes(uint8_t *dest, uint32_t numBytes)
|
||||
{
|
||||
volatile union flash_ptr destAddr, srcAddr;
|
||||
uint32_t i;
|
||||
|
||||
destAddr.cp = (volatile uint8_t *) dest;
|
||||
srcAddr.cp = flash_make_addr(nand_info.base_addr, NAND_DATA_OFFSET);
|
||||
switch (nand_info.bus_width) {
|
||||
case BUS_8BIT:
|
||||
for (i = 0; i < numBytes; i++)
|
||||
*destAddr.cp++ = *srcAddr.cp;
|
||||
break;
|
||||
case BUS_16BIT:
|
||||
for (i = 0; i < (numBytes >> 1); i++)
|
||||
*destAddr.wp++ = *srcAddr.wp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Poll bit of NANDFSR to indicate ready */
|
||||
static int
|
||||
nand_wait_for_ready(uint32_t timeout)
|
||||
{
|
||||
volatile uint32_t cnt = timeout;
|
||||
uint32_t ready;
|
||||
|
||||
waitloop(200);
|
||||
|
||||
do {
|
||||
ready = AEMIF->NANDFSR & NAND_NANDFSR_READY;
|
||||
cnt--;
|
||||
} while ((cnt > 0) && !ready);
|
||||
|
||||
if (cnt == 0) {
|
||||
log_info("NAND busy timeout");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* Wait for the status to be ready in NAND register
|
||||
* There were some problems reported in DM320 with Ready/Busy pin
|
||||
* not working with all NANDs. So this check has also been added.
|
||||
*/
|
||||
static int
|
||||
nand_wait_for_status(uint32_t timeout)
|
||||
{
|
||||
volatile uint32_t cnt;
|
||||
uint32_t status;
|
||||
cnt = timeout;
|
||||
|
||||
do {
|
||||
flash_write_cmd(NAND_STATUS);
|
||||
status = flash_read_data() &
|
||||
(NAND_STATUS_ERROR | NAND_STATUS_BUSY);
|
||||
cnt--;
|
||||
} while ((cnt > 0) && !status);
|
||||
|
||||
if (cnt == 0) {
|
||||
log_info("NAND status timeout");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* Read the current ECC calculation and restart process */
|
||||
static uint32_t
|
||||
nand_read_ecc(void)
|
||||
{
|
||||
uint32_t retval;
|
||||
|
||||
/* Read and mask appropriate (based on CSn space flash is in)
|
||||
* ECC register */
|
||||
retval = ((uint32_t *)(&(AEMIF->NANDF1ECC)))[nand_info.cs_offset] &
|
||||
nand_info.ecc_mask;
|
||||
|
||||
waitloop(5);
|
||||
|
||||
#ifdef NAND_DEBUG
|
||||
uart_send_str("Value read from ECC register: ");
|
||||
uart_send_hexnum(retval, 8);
|
||||
uart_send_lf();
|
||||
#endif
|
||||
|
||||
/* Write appropriate bit to start ECC calculations */
|
||||
AEMIF->NANDFCR |= (1<<(8 + (nand_info.cs_offset)));
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Get details of the NAND flash used from the id and the table of NAND
|
||||
* devices. */
|
||||
static int
|
||||
nand_get_details(void)
|
||||
{
|
||||
uint32_t deviceID, i, j;
|
||||
|
||||
/* Issue device read ID command. */
|
||||
flash_write_cmd(NAND_RDID);
|
||||
flash_write_addr(NAND_RDIDADD);
|
||||
|
||||
/* Read ID bytes */
|
||||
j = flash_read_data() & 0xFF;
|
||||
deviceID = flash_read_data() & 0xFF;
|
||||
j = flash_read_data() & 0xFF;
|
||||
j = flash_read_data() & 0xFF;
|
||||
|
||||
uart_send_str(" ID:");
|
||||
uart_send_hexnum(deviceID, 2);
|
||||
if (nand_info.bus_width == BUS_16BIT)
|
||||
uart_send_str(", 16");
|
||||
else
|
||||
uart_send_str(", 8");
|
||||
|
||||
log_info("-bit bus");
|
||||
|
||||
i = 0;
|
||||
while (nand_dev_infos[i].id != 0x00) {
|
||||
if (deviceID == nand_dev_infos[i].id) {
|
||||
nand_info.id = (uint8_t) nand_dev_infos[i].id;
|
||||
nand_info.pages_per_block =
|
||||
nand_dev_infos[i].pages_per_block;
|
||||
nand_info.num_blocks = nand_dev_infos[i].num_blocks;
|
||||
nand_info.bytes_per_page = NANDFLASH_PAGESIZE(
|
||||
nand_dev_infos[i].bytes_per_page);
|
||||
|
||||
nand_info.spare_bytes = nand_dev_infos[i].bytes_per_page -
|
||||
nand_info.bytes_per_page;
|
||||
|
||||
/* Configure small or large page device. */
|
||||
if (nand_info.bytes_per_page >= 2048) {
|
||||
/* Set the large page flag */
|
||||
nand_info.large_page = true;
|
||||
nand_info.ecc_index = 2;
|
||||
nand_info.chunk_size = 512; /* Limit to 512 bytes */
|
||||
} else {
|
||||
/* Clear the large page flag */
|
||||
nand_info.large_page = false;
|
||||
nand_info.ecc_index = 0;
|
||||
nand_info.chunk_size = nand_info.bytes_per_page;
|
||||
}
|
||||
|
||||
/* Setup address shift values */
|
||||
j = 0;
|
||||
while ((nand_info.pages_per_block >> j) > 1)
|
||||
j++;
|
||||
|
||||
nand_info.blk_addr_shift = j;
|
||||
nand_info.page_addr_shift = (nand_info.large_page) ? 16 : 8;
|
||||
|
||||
nand_info.blk_addr_shift += nand_info.page_addr_shift;
|
||||
|
||||
/* Set number of column address bytes needed */
|
||||
nand_info.num_cab = nand_info.page_addr_shift >> 3;
|
||||
|
||||
j = 0;
|
||||
while ((nand_info.num_blocks >> j) > 1)
|
||||
j++;
|
||||
|
||||
/* Set number of row address bytes needed */
|
||||
if ((nand_info.blk_addr_shift + j) <= 24)
|
||||
nand_info.num_rab = 3 -
|
||||
nand_info.num_cab;
|
||||
else if ((nand_info.blk_addr_shift + j) <= 32)
|
||||
nand_info.num_rab = 4 -
|
||||
nand_info.num_cab;
|
||||
else
|
||||
nand_info.num_rab = 5 -
|
||||
nand_info.num_cab;
|
||||
|
||||
/* Set the ECC bit mask */
|
||||
if (nand_info.bytes_per_page < 512)
|
||||
nand_info.ecc_mask = 0x07FF07FF;
|
||||
else
|
||||
nand_info.ecc_mask = 0x0FFF0FFF;
|
||||
|
||||
/* Report informations */
|
||||
uart_send_str(" Blocks: ");
|
||||
uart_send_hexnum(nand_info.num_blocks, 5);
|
||||
uart_send_str(", Pages/block: ");
|
||||
uart_send_hexnum(nand_info.pages_per_block, 3);
|
||||
uart_send_str(", Bytes per page: ");
|
||||
uart_send_hexnum(nand_info.bytes_per_page, 4);
|
||||
uart_send_lf();
|
||||
|
||||
/* Report additional debug informations */
|
||||
#ifdef NAND_DEBUG
|
||||
uart_send_str(" Page shift: ");
|
||||
uart_send_hexnum(nand_info.page_addr_shift, 2);
|
||||
uart_send_lf();
|
||||
uart_send_str(" Block shift: ");
|
||||
uart_send_hexnum(nand_info.blk_addr_shift, 2);
|
||||
uart_send_lf();
|
||||
uart_send_str(" Column address bytes: ");
|
||||
uart_send_hexnum(nand_info.num_cab, 2);
|
||||
uart_send_lf();
|
||||
uart_send_str(" Row address bytes: ");
|
||||
uart_send_hexnum(nand_info.num_rab, 2);
|
||||
uart_send_lf();
|
||||
uart_send_str(" ECC mask: ");
|
||||
uart_send_hexnum(nand_info.ecc_mask, 8);
|
||||
uart_send_lf();
|
||||
#endif
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* No match was found for the device ID */
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
static void
|
||||
nand_write_spare(uint32_t eccvalue)
|
||||
{
|
||||
uint32_t spare_data[4] = {
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF,
|
||||
0xFFFFFFFF
|
||||
};
|
||||
|
||||
/* Place the ECC values where the RBL expects them */
|
||||
spare_data[nand_info.ecc_index] = eccvalue;
|
||||
|
||||
/* Write spare bytes infos */
|
||||
if (nand_info.bytes_per_page == 256)
|
||||
flash_write_bytes((uint8_t *) spare_data, 8);
|
||||
else
|
||||
flash_write_bytes((uint8_t *) spare_data, 16);
|
||||
}
|
||||
|
||||
/*
|
||||
* RBL-expected layout for large page NAND (ex: 2048 bytes/page):
|
||||
*
|
||||
* DM35x DM644x
|
||||
* -----------------------------
|
||||
* 512 DATA 2048 DATA
|
||||
* 16 SPARE 64 SPARE
|
||||
* 512 DATA
|
||||
* 16 SPARE
|
||||
* 512 DATA
|
||||
* 16 SPARE
|
||||
* 512 DATA
|
||||
* 16 SPARE
|
||||
*
|
||||
* So for big block NAND devices (bytes per page > 512) on the DM35x, we must
|
||||
* write 512 bytes and write the ECC immediately after that data, and repeat
|
||||
* until all the page is written.
|
||||
*/
|
||||
|
||||
/* Generic routine to write a page of data to NAND */
|
||||
static int
|
||||
nand_write_page(uint32_t block, uint32_t page, const uint8_t *src)
|
||||
{
|
||||
uint32_t hw_ecc[4]; /* Maximum of 2048 bytes/page (4 * 512 = 2048) */
|
||||
uint8_t numWrites, i;
|
||||
|
||||
numWrites = (nand_info.bytes_per_page >> 9); /* Divide by 512 */
|
||||
if (numWrites == 0)
|
||||
numWrites++;
|
||||
|
||||
/* Write program command */
|
||||
flash_write_cmd(NAND_PGRM_START);
|
||||
|
||||
/* Write address bytes */
|
||||
flash_write_addr_cycles(block, page);
|
||||
|
||||
/* Starting the ECC in the NANDFCR register for CS2 (bit no.8) */
|
||||
nand_read_ecc();
|
||||
|
||||
/* Write data */
|
||||
for (i = 0; i < numWrites; i++) {
|
||||
/* Write data to page */
|
||||
flash_write_bytes(src, nand_info.chunk_size);
|
||||
|
||||
/* Read the ECC value */
|
||||
hw_ecc[i] = nand_read_ecc();
|
||||
|
||||
/* Format ECC */
|
||||
endian_data(&(hw_ecc[i]));
|
||||
|
||||
#if defined(DM35x)
|
||||
/* Write spare area */
|
||||
nand_write_spare(hw_ecc[i]);
|
||||
#endif
|
||||
|
||||
/* Increment the pointer */
|
||||
src += nand_info.chunk_size;
|
||||
}
|
||||
|
||||
#if defined(DM644x)
|
||||
for (i = 0; i < numWrites; i++) {
|
||||
nand_write_spare(hw_ecc[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Write program end command */
|
||||
flash_write_cmd(NAND_PGRM_END);
|
||||
|
||||
/* Wait for the device to be ready */
|
||||
if (nand_wait_for_ready(NAND_TIMEOUT) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
/* Return status check result */
|
||||
return nand_wait_for_status(NAND_TIMEOUT);
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
nand_read_spare(void)
|
||||
{
|
||||
uint32_t spare_ecc[4], spare_ecc_temp;
|
||||
|
||||
/* Read the stored ECC value(s) */
|
||||
if (nand_info.bytes_per_page == 256)
|
||||
flash_read_bytes((uint8_t *) spare_ecc, 8);
|
||||
else
|
||||
flash_read_bytes((uint8_t *) spare_ecc, 16);
|
||||
|
||||
spare_ecc_temp = spare_ecc[nand_info.ecc_index];
|
||||
|
||||
/* Format ECC */
|
||||
endian_data(&spare_ecc_temp);
|
||||
|
||||
return spare_ecc_temp;
|
||||
}
|
||||
|
||||
/* Read a page from NAND */
|
||||
int
|
||||
nand_read_page(uint32_t block, uint32_t page, uint8_t *dest)
|
||||
{
|
||||
uint32_t hw_ecc[4];
|
||||
uint32_t spare_ecc[4];
|
||||
uint8_t numReads, i;
|
||||
|
||||
numReads = (nand_info.bytes_per_page >> 9); /* Divide by 512 */
|
||||
if (numReads == 0)
|
||||
numReads++;
|
||||
|
||||
/* Write read command */
|
||||
flash_write_cmd(NAND_LO_PAGE);
|
||||
|
||||
/* Write address bytes */
|
||||
flash_write_addr_cycles(block, page);
|
||||
|
||||
/* Additional confirm command for big_block devices */
|
||||
if (nand_info.large_page)
|
||||
flash_write_cmd(NAND_READ_30H);
|
||||
|
||||
/* Wait for data to be available */
|
||||
if (nand_wait_for_ready(NAND_TIMEOUT) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
/* Starting the ECC in the NANDFCR register for CS2(bit no.8) */
|
||||
nand_read_ecc();
|
||||
|
||||
/* Read the page data */
|
||||
for (i = 0; i < numReads; i++) {
|
||||
/* Read data bytes */
|
||||
flash_read_bytes(dest, nand_info.chunk_size);
|
||||
|
||||
/* Read hardware computed ECC */
|
||||
hw_ecc[i] = nand_read_ecc();
|
||||
|
||||
#if defined(DM35x)
|
||||
/* Read spare area ECC */
|
||||
spare_ecc[i] = nand_read_spare();
|
||||
#endif
|
||||
|
||||
/* Increment the pointer */
|
||||
dest += nand_info.chunk_size;
|
||||
}
|
||||
|
||||
#if defined(DM644x)
|
||||
for (i = 0; i < numReads; i++) {
|
||||
spare_ecc[i] = nand_read_spare();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NAND_BYPASS_READ_PAGE_ECC_CHECK
|
||||
for (i = 0; i < numReads; i++) {
|
||||
/* Verify ECC values */
|
||||
if (hw_ecc[i] != spare_ecc[i]) {
|
||||
log_info("NAND ECC failure:");
|
||||
uart_send_str("HW = ");
|
||||
uart_send_hexnum(hw_ecc[i], 8);
|
||||
uart_send_lf();
|
||||
uart_send_str("SPARE =");
|
||||
uart_send_hexnum(spare_ecc[i], 8);
|
||||
uart_send_lf();
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
#endif /* NAND_BYPASS_READ_PAGE_ECC_CHECK */
|
||||
|
||||
/* Return status check result */
|
||||
return nand_wait_for_status(NAND_TIMEOUT);
|
||||
}
|
||||
|
||||
/* Verify data written by reading and comparing byte for byte */
|
||||
static int
|
||||
nand_verify_page(int block, int page, const uint8_t *src)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (nand_read_page(block, page, read_buf) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
for (i = 0; i < nand_info.bytes_per_page; i++) {
|
||||
/* Check for data read errors */
|
||||
if (src[i] != read_buf[i]) {
|
||||
int k = i;
|
||||
|
||||
uart_send_str("NAND verify page failed at block ");
|
||||
uart_send_hexnum(block, 4);
|
||||
uart_send_str(", page ");
|
||||
uart_send_hexnum(page, 4);
|
||||
uart_send_str(", offset ");
|
||||
uart_send_hexnum(i, 4);
|
||||
uart_send_lf();
|
||||
|
||||
for (k = i - 8; k < (i + 20); k += 4) {
|
||||
uart_send_str("offset ");
|
||||
uart_send_hexnum(k, 4);
|
||||
uart_send_str(", ram=");
|
||||
uart_send_hexnum(*((uint32_t *) &src[k]), 8);
|
||||
uart_send_str(", nand=");
|
||||
uart_send_hexnum(*((uint32_t *) &read_buf[k]), 8);
|
||||
uart_send_lf();
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* NAND Flash unprotect command */
|
||||
static uint32_t
|
||||
nand_unprotect_blocks(uint32_t startBlkNum, uint32_t blkCnt)
|
||||
{
|
||||
uint32_t endBlkNum;
|
||||
endBlkNum = startBlkNum + blkCnt - 1;
|
||||
|
||||
uart_send_str("Unprotecting blocks ");
|
||||
uart_send_hexnum(startBlkNum, 4);
|
||||
uart_send_str(" to ");
|
||||
uart_send_hexnum(endBlkNum, 4);
|
||||
uart_send_lf();
|
||||
|
||||
/* Do bounds checking */
|
||||
if (endBlkNum >= nand_info.num_blocks) {
|
||||
log_fail("Invalid last block");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
flash_write_cmd(NAND_UNLOCK_START);
|
||||
flash_write_row_addr_bytes(startBlkNum, 0);
|
||||
|
||||
flash_write_cmd(NAND_UNLOCK_END);
|
||||
flash_write_row_addr_bytes(endBlkNum, 0);
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* NAND Flash protect command */
|
||||
static void
|
||||
nand_protect_blocks(void)
|
||||
{
|
||||
log_info("Protecting the entire NAND flash");
|
||||
flash_write_cmd(NAND_LOCK);
|
||||
}
|
||||
|
||||
/* NAND Flash erase block function */
|
||||
static uint32_t
|
||||
nand_erase_blocks(uint32_t startBlkNum, uint32_t blkCnt)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
/* Do bounds checking */
|
||||
if ((startBlkNum + blkCnt - 1) >= nand_info.num_blocks)
|
||||
return E_FAIL;
|
||||
|
||||
/* Output info about what we are doing */
|
||||
uart_send_str("Erasing blocks ");
|
||||
uart_send_hexnum(startBlkNum, 4);
|
||||
uart_send_str(" to ");
|
||||
uart_send_hexnum(startBlkNum + blkCnt - 1, 4);
|
||||
uart_send_lf();
|
||||
|
||||
for (i = 0; i < blkCnt; i++) {
|
||||
/* Start erase command */
|
||||
flash_write_cmd(NAND_BERASEC1);
|
||||
|
||||
/* Write the row addr bytes only */
|
||||
flash_write_row_addr_bytes(startBlkNum + i, 0);
|
||||
|
||||
/* Confirm erase command */
|
||||
flash_write_cmd(NAND_BERASEC2);
|
||||
|
||||
/* Wait for the device to be ready */
|
||||
if (nand_wait_for_ready(NAND_TIMEOUT) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
/* Verify the op succeeded by reading status from flash */
|
||||
if (nand_wait_for_status(NAND_TIMEOUT) != E_PASS)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* Initialize NAND interface and find the details of the NAND used */
|
||||
int
|
||||
nand_init(void)
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t *CSRegs;
|
||||
|
||||
log_info("Initializing NAND flash:");
|
||||
|
||||
#ifdef NAND_BYPASS_READ_PAGE_ECC_CHECK
|
||||
log_info(" Bypassing ECC checks");
|
||||
#endif /* NAND_BYPASS_READ_PAGE_ECC_CHECK */
|
||||
|
||||
/* Set NAND flash base address */
|
||||
nand_info.base_addr = (uint32_t) &__NANDFlash;
|
||||
|
||||
/* Get the cs_offset (can be 0 through 3 - corresponds with CS2 through
|
||||
* CS5) */
|
||||
nand_info.cs_offset = (nand_info.base_addr >> 25) - 1;
|
||||
|
||||
/* Setting the nand_width = 0(8 bit NAND) or 1(16 bit NAND). AEMIF CS2
|
||||
* bus Width is given by the BOOTCFG(bit no.5). */
|
||||
width = (((SYSTEM->BOOTCFG) & 0x20) >> 5);
|
||||
nand_info.bus_width = (width)?BUS_16BIT:BUS_8BIT;
|
||||
|
||||
/* Setup AEMIF registers for NAND */
|
||||
CSRegs = (uint32_t *) &(AEMIF->A1CR);
|
||||
|
||||
/* Set correct AxCR reg */
|
||||
CSRegs[nand_info.cs_offset] = 0x3FFFFFFC | width;
|
||||
|
||||
/* NAND enable for CSx. */
|
||||
AEMIF->NANDFCR |= (0x1 << (nand_info.cs_offset));
|
||||
nand_read_ecc();
|
||||
|
||||
/* Send reset command to NAND */
|
||||
flash_write_cmd(NAND_RESET);
|
||||
|
||||
if (nand_wait_for_ready(NAND_TIMEOUT) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
return nand_get_details();
|
||||
}
|
||||
|
||||
static int
|
||||
nand_write_verify_page(int block, int page, const uint8_t *src)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = nand_write_page(block, page, src);
|
||||
if (status != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
waitloop(200);
|
||||
|
||||
/* Verify the page just written */
|
||||
return nand_verify_page(block, page, src);
|
||||
}
|
||||
|
||||
int
|
||||
nand_write_prog(struct nand_image_descriptor_t *im_desc, const uint8_t *src,
|
||||
size_t size)
|
||||
{
|
||||
int num_blocks;
|
||||
int max_block_num;
|
||||
int page_num;
|
||||
uint32_t count_mask;
|
||||
|
||||
im_desc->page_num = 1; /* Always start data in page 1 */
|
||||
|
||||
/* Do some rounding based on data buffer size */
|
||||
im_desc->size_in_pages = 0;
|
||||
while ((im_desc->size_in_pages * nand_info.bytes_per_page) < size)
|
||||
im_desc->size_in_pages++;
|
||||
|
||||
/* Get total number of blocks needed */
|
||||
num_blocks = 0;
|
||||
while ((num_blocks * nand_info.pages_per_block) <
|
||||
(im_desc->size_in_pages + 1))
|
||||
num_blocks++;
|
||||
|
||||
uart_send_str("Needed blocks: ");
|
||||
uart_send_hexnum(num_blocks, 4);
|
||||
uart_send_lf();
|
||||
uart_send_str("Needed pages: ");
|
||||
uart_send_hexnum(im_desc->size_in_pages, 4);
|
||||
uart_send_lf();
|
||||
|
||||
/* Check whether writing UBL or APP (based on destination block) */
|
||||
if (im_desc->block_num == START_UBL_BLOCK_NUM)
|
||||
max_block_num = END_UBL_BLOCK_NUM;
|
||||
else
|
||||
max_block_num = nand_info.num_blocks - 1;
|
||||
|
||||
NAND_WRITE_RETRY:
|
||||
if (im_desc->block_num > max_block_num) {
|
||||
log_fail("Block > last block");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
uart_send_str("Trying block ");
|
||||
uart_send_hexnum(im_desc->block_num, 4);
|
||||
uart_send_lf();
|
||||
|
||||
/* Unprotect all needed blocks of the Flash */
|
||||
if (nand_unprotect_blocks(im_desc->block_num, num_blocks) != E_PASS) {
|
||||
im_desc->block_num++;
|
||||
log_info("Unprotect failed");
|
||||
goto NAND_WRITE_RETRY;
|
||||
}
|
||||
|
||||
/* Erase the block where the header goes and the data starts */
|
||||
if (nand_erase_blocks(im_desc->block_num, num_blocks) != E_PASS) {
|
||||
im_desc->block_num++;
|
||||
log_info("Erase failed");
|
||||
goto NAND_WRITE_RETRY;
|
||||
}
|
||||
|
||||
#ifdef NAND_DEBUG_WRITE_RAMP
|
||||
{
|
||||
int k;
|
||||
|
||||
/* Usefull for debugging NAND ECC and spare bytes errors. */
|
||||
for (k = 0; k < 512; k++)
|
||||
ptr[k] = 0xCAFE0000 | k;
|
||||
}
|
||||
#endif
|
||||
|
||||
page_num = 0; /* Start in page 0. */
|
||||
|
||||
if (im_desc->magic != UBL_CMD_FLASH_DATA) {
|
||||
/* Write the header to page 0. */
|
||||
log_info("Writing header");
|
||||
|
||||
if (nand_write_verify_page(im_desc->block_num, page_num,
|
||||
(uint8_t *) im_desc) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
/* Set starting page number for next data portion. */
|
||||
page_num = 1;
|
||||
}
|
||||
|
||||
/* The following assumes power of 2 page_cnt - *should* always be
|
||||
* valid. */
|
||||
count_mask = nand_info.pages_per_block - 1;
|
||||
log_info("Writing data");
|
||||
do {
|
||||
/* Write data on a per page basis */
|
||||
if (nand_write_verify_page(im_desc->block_num,
|
||||
page_num & count_mask, src)
|
||||
!= E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
page_num++;
|
||||
src += nand_info.bytes_per_page;
|
||||
if (!(page_num & count_mask))
|
||||
im_desc->block_num++;
|
||||
} while (page_num <= im_desc->size_in_pages);
|
||||
|
||||
nand_protect_blocks();
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
nand_erase_all(void)
|
||||
{
|
||||
/* Unprotect the NAND Flash */
|
||||
nand_unprotect_blocks(0, nand_info.num_blocks - 1);
|
||||
|
||||
/* Erase all the pages */
|
||||
if (nand_erase_blocks(0, nand_info.num_blocks - 1) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
/* Protect the device */
|
||||
nand_protect_blocks();
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
int
|
||||
nand_get_pages_per_block(void)
|
||||
{
|
||||
return nand_info.pages_per_block;
|
||||
}
|
||||
|
||||
int
|
||||
nand_get_bytes_per_page(void)
|
||||
{
|
||||
return nand_info.bytes_per_page;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* nand.h - NAND flash definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _NAND_H_
|
||||
#define _NAND_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
|
||||
/* Define which blocks are valid for writing UBL and APP data */
|
||||
#define START_UBL_BLOCK_NUM 1
|
||||
#define END_UBL_BLOCK_NUM 5
|
||||
#define START_APP_BLOCK_NUM 6
|
||||
|
||||
#define MAX_PAGE_SIZE (2048+64) /* Data bytes + spare area */
|
||||
|
||||
/* NAND descriptor expected by RBL when it loads UBL image. */
|
||||
struct nand_image_descriptor_t {
|
||||
uint32_t magic;
|
||||
uint32_t entry_point;
|
||||
uint32_t size_in_pages;
|
||||
uint32_t block_num;
|
||||
uint32_t page_num;
|
||||
uint32_t load_address; /* Not used by RBL */
|
||||
};
|
||||
|
||||
|
||||
int nand_init(void);
|
||||
|
||||
int nand_erase_all(void);
|
||||
|
||||
int nand_read_page(uint32_t block, uint32_t page, uint8_t *dest);
|
||||
|
||||
int nand_write_prog(struct nand_image_descriptor_t *im_desc,
|
||||
const uint8_t *src, size_t size);
|
||||
|
||||
/* Copy Application from NAND to RAM */
|
||||
int nand_copy(uint32_t *jump_entry_point);
|
||||
|
||||
int nand_get_pages_per_block(void);
|
||||
|
||||
int nand_get_bytes_per_page(void);
|
||||
|
||||
#endif /* _NAND_H_ */
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* nandboot.c - NAND boot mode functions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "nand.h"
|
||||
#include "util.h"
|
||||
#include "uart.h"
|
||||
|
||||
static uint8_t nand_header[MAX_PAGE_SIZE] __attribute__((section(".ddrram")));
|
||||
|
||||
/*
|
||||
* Find out where the application is and copy to RAM
|
||||
* jump_entry_point: Entry point for application we are decoding out of
|
||||
* flash
|
||||
*/
|
||||
int
|
||||
nand_copy(uint32_t *jump_entry_point)
|
||||
{
|
||||
uint32_t count, start_block;
|
||||
uint32_t i;
|
||||
uint32_t magicNum;
|
||||
uint32_t block, page;
|
||||
uint32_t readError = E_FAIL;
|
||||
int failedOnceAlready = false;
|
||||
uint8_t *rxBuf; /* Temporary buffer to load header in NAND */
|
||||
struct nand_image_descriptor_t im_desc;
|
||||
int last_header_block;
|
||||
|
||||
start_block = START_APP_BLOCK_NUM;
|
||||
last_header_block = start_block + 10;
|
||||
|
||||
NAND_startAgain:
|
||||
/* Read header about application starting at START_APP_BLOCK_NUM, Page 0
|
||||
* and try 10 blocks. */
|
||||
for (count = start_block; count <= last_header_block; count++) {
|
||||
if (nand_read_page(count, 0, nand_header) != E_PASS)
|
||||
continue;
|
||||
|
||||
magicNum = *((uint32_t *) nand_header);
|
||||
|
||||
/* Valid magic number found */
|
||||
if ((magicNum & MAGIC_NUMBER_MASK) == MAGIC_NUMBER_VALID) {
|
||||
start_block = count;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Never found valid header. */
|
||||
if (count > last_header_block)
|
||||
return E_FAIL;
|
||||
|
||||
memcpy((void *) &im_desc, nand_header, sizeof(im_desc));
|
||||
|
||||
uart_send_str("Image infos: Magic = ");
|
||||
uart_send_hexnum(im_desc.magic, 8);
|
||||
uart_send_str(", Entry = ");
|
||||
uart_send_hexnum(im_desc.entry_point, 8);
|
||||
uart_send_str(", Pages = ");
|
||||
uart_send_hexnum(im_desc.size_in_pages, 8);
|
||||
uart_send_str(", Load = ");
|
||||
uart_send_hexnum(im_desc.load_address, 8);
|
||||
uart_send_lf();
|
||||
|
||||
rxBuf = (uint8_t *) im_desc.load_address;
|
||||
|
||||
NAND_retry:
|
||||
/* initialize block and page number to be used for read */
|
||||
block = im_desc.block_num;
|
||||
page = im_desc.page_num;
|
||||
|
||||
/* Perform the actual copying of the application from NAND to RAM */
|
||||
for (i = 0; i < im_desc.size_in_pages; i++) {
|
||||
/* if page goes beyond max number of pages increment block
|
||||
* number and reset page number */
|
||||
if (page >= nand_get_pages_per_block()) {
|
||||
page = 0;
|
||||
block++;
|
||||
}
|
||||
|
||||
/* Copy the data */
|
||||
readError =
|
||||
nand_read_page(block, page++,
|
||||
&rxBuf[i * nand_get_bytes_per_page()]);
|
||||
|
||||
/*
|
||||
* We attempt to read the app data twice. If we fail twice then
|
||||
* we go look for a new application header in the NAND flash at
|
||||
* the next block.
|
||||
*/
|
||||
if (readError != E_PASS) {
|
||||
if (failedOnceAlready) {
|
||||
start_block++;
|
||||
goto NAND_startAgain;
|
||||
} else {
|
||||
failedOnceAlready = true;
|
||||
goto NAND_retry;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Application was read correctly, so set entrypoint */
|
||||
*jump_entry_point = im_desc.entry_point;
|
||||
|
||||
return E_PASS;
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* nor.h - NOR flash definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _NOR_H_
|
||||
#define _NOR_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
|
||||
/* Global NOR commands */
|
||||
uint32_t NOR_Init (void);
|
||||
|
||||
int nor_copy(uint32_t *jump_entry_point);
|
||||
|
||||
uint32_t NOR_WriteBytes(uint32_t writeAddress, uint32_t numBytes, uint32_t readAddress);
|
||||
uint32_t NOR_GlobalErase(void);
|
||||
uint32_t NOR_Erase(uint32_t start_address, uint32_t size);
|
||||
uint32_t DiscoverBlockInfo(uint32_t address,uint32_t* blockSize, uint32_t* blockAddr);
|
||||
|
||||
|
||||
uint32_t nor_get_flashbase(void);
|
||||
|
||||
|
||||
#endif /* _NOR_H_ */
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* norboot.c - NOR boot mode functions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "nor.h"
|
||||
#include "util.h"
|
||||
#include "uart.h"
|
||||
|
||||
extern NOR_INFO gNorInfo;
|
||||
|
||||
/* Function to find out where the Application is and copy to DRAM */
|
||||
int
|
||||
nor_copy(uint32_t *jump_entry_point)
|
||||
{
|
||||
volatile struct nor_boot_t *hdr = 0;
|
||||
volatile uint32_t *appStartAddr = 0;
|
||||
volatile uint32_t count = 0;
|
||||
volatile uint32_t *ramPtr = 0;
|
||||
uint32_t blkSize, blkAddress;
|
||||
|
||||
if (NOR_Init() != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
DiscoverBlockInfo((gNorInfo.flashBase + UBL_IMAGE_SIZE), &blkSize,
|
||||
&blkAddress);
|
||||
|
||||
hdr = (volatile struct nor_boot_t *) (blkAddress + blkSize);
|
||||
|
||||
/* Check for valid magic number. */
|
||||
if ((hdr->magicNum & 0xFFFFFF00) != MAGIC_NUMBER_VALID) {
|
||||
log_fail("No valid header found");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* Set the source address for copy */
|
||||
appStartAddr = (uint32_t *)(((uint8_t*) hdr) + sizeof(struct nor_boot_t));
|
||||
|
||||
if (hdr->magicNum == UBL_MAGIC_BIN_IMG) {
|
||||
log_fail("Unsupported image format");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ramPtr = (uint32_t *) hdr->ldAddress;
|
||||
|
||||
/* Copy data to RAM */
|
||||
memcpy(ramPtr, appStartAddr, hdr->appSize);
|
||||
|
||||
/* Application was read correctly, so set entrypoint */
|
||||
*jump_entry_point = hdr->entryPoint;
|
||||
|
||||
return E_PASS;
|
||||
}
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
* uart.c - UART Rx and Tx functions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
#include "uart.h"
|
||||
#include "util.h"
|
||||
#include "crc.h"
|
||||
#include "gunzip.h"
|
||||
|
||||
/* Symbol from linker script */
|
||||
extern uint32_t __DDR_FREE; /* Start of free DDR memory region. */
|
||||
extern uint32_t __DDR_END; /* Last DDR memory address. */
|
||||
|
||||
/* Receive data from UART */
|
||||
static int
|
||||
uart_recv_bytes(size_t count, uint8_t *dest)
|
||||
{
|
||||
uint32_t i, status = 0;
|
||||
uint32_t timerStatus = 1;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
/* Enable timer one time */
|
||||
timer0_start();
|
||||
do {
|
||||
status = (UART0->LSR)&(0x01);
|
||||
timerStatus = timer0_status();
|
||||
} while (!status && timerStatus);
|
||||
|
||||
if (timerStatus == 0) {
|
||||
host_msg("UART_TIMEOUT");
|
||||
return E_TIMEOUT;
|
||||
}
|
||||
|
||||
/* Receive byte */
|
||||
dest[i] = (UART0->RBR) & 0xFF;
|
||||
|
||||
/* Check status for errors */
|
||||
if ((UART0->LSR & 0x1C) != 0) {
|
||||
host_msg("UART_RXERR");
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* Send bytes with optional null terminating character. */
|
||||
static void
|
||||
uart_send_bytes(char *string)
|
||||
{
|
||||
uint32_t status = 0;
|
||||
int32_t i, count;
|
||||
uint32_t timerStatus = 1;
|
||||
|
||||
count = strlen(string);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
/* Enable Timer one time */
|
||||
timer0_start();
|
||||
do {
|
||||
status = (UART0->LSR)&(0x20);
|
||||
timerStatus = timer0_status();
|
||||
} while (!status && timerStatus);
|
||||
|
||||
if (timerStatus == 0)
|
||||
return; /* E_TIMEOUT */
|
||||
|
||||
/* Send byte */
|
||||
(UART0->THR) = string[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if the given string is received via UART */
|
||||
static int
|
||||
uart_check_string(char *string, int include_null)
|
||||
{
|
||||
int i, count;
|
||||
|
||||
count = strlen(string);
|
||||
if (include_null != false)
|
||||
count++;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
uint8_t recv;
|
||||
|
||||
/* Get one byte */
|
||||
if (uart_recv_bytes(1, &recv) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
if (recv != string[i])
|
||||
return E_FAIL;
|
||||
}
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* Receive a uint32 value in HEX form (8 bytes) */
|
||||
static int
|
||||
uart_recv_hex_uint32(uint32_t *data)
|
||||
{
|
||||
int k;
|
||||
uint8_t recv[8];
|
||||
uint32_t temp;
|
||||
int shift;
|
||||
const int num_ascii_char = 8;
|
||||
|
||||
/* Get 8 bytes from UART */
|
||||
if (uart_recv_bytes(num_ascii_char, recv) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
*data = 0;
|
||||
|
||||
/* Converting ascii to Hex */
|
||||
for (k = 0, shift = 28; k < num_ascii_char; k++, shift -= 4) {
|
||||
temp = recv[k] - 48;
|
||||
|
||||
if (temp > 22) /* Lower case a,b,c,d,e,f */
|
||||
temp -= 39;
|
||||
else if (temp > 9) /* Upper case A,B,C,D,E,F */
|
||||
temp -= 7;
|
||||
|
||||
*data |= temp << shift;
|
||||
}
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
/* Send line feed (\n) to UART. */
|
||||
void
|
||||
uart_send_lf(void)
|
||||
{
|
||||
uart_send_bytes("\r\n");
|
||||
}
|
||||
|
||||
/* Send a string to UART, without line feed. */
|
||||
void
|
||||
uart_send_str(char *string)
|
||||
{
|
||||
uart_send_bytes(string);
|
||||
}
|
||||
|
||||
/* Send a string to UART, with line feed. */
|
||||
void
|
||||
uart_send_str_lf(char *string)
|
||||
{
|
||||
uart_send_bytes(string);
|
||||
uart_send_lf();
|
||||
}
|
||||
|
||||
void
|
||||
uart_send_hexnum(uint32_t value, int digits)
|
||||
{
|
||||
char seq[9];
|
||||
uint32_t i, shift;
|
||||
uint8_t temp;
|
||||
|
||||
for (i = 0; i < digits; i++) {
|
||||
shift = ((digits - 1) - i) * 4;
|
||||
temp = (value >> shift) & 0x0F;
|
||||
if (temp > 9)
|
||||
temp += 7;
|
||||
seq[i] = temp + 48;
|
||||
}
|
||||
seq[digits] = 0;
|
||||
|
||||
uart_send_str("0x");
|
||||
uart_send_bytes(seq);
|
||||
}
|
||||
|
||||
int
|
||||
uart_get_cmd(uint32_t *boot_cmd)
|
||||
{
|
||||
if (uart_check_string(" CMD", true) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
if (uart_recv_hex_uint32(boot_cmd) != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
return E_PASS;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
uart_get_prog(struct uart_ack_header_t *uart_ack_header)
|
||||
{
|
||||
uint32_t error;
|
||||
uint32_t recv_crc, computed_crc;
|
||||
unsigned long inflate_dstbuf_len, inflate_srcbuf_len;
|
||||
uint8_t *ddr_free = (uint8_t *) &__DDR_FREE;
|
||||
|
||||
uart_ack_header->recv_buffer = ddr_free;
|
||||
uart_ack_header->inflate_dstbuf = ddr_free + MAX_IMAGE_SIZE;
|
||||
inflate_dstbuf_len = ((uint8_t *) &__DDR_END) + 1 - uart_ack_header->inflate_dstbuf;
|
||||
|
||||
/* Send ACK command */
|
||||
error = uart_check_string(" ACK", true);
|
||||
if (error != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
/* Get the ACK header elements */
|
||||
error = uart_recv_hex_uint32(&uart_ack_header->magic);
|
||||
error |= uart_recv_hex_uint32(&recv_crc);
|
||||
error |= uart_recv_hex_uint32(&uart_ack_header->size);
|
||||
error |= uart_recv_hex_uint32(&uart_ack_header->entry_point);
|
||||
error |= uart_check_string("0000", false);
|
||||
if (error != E_PASS)
|
||||
return E_FAIL;
|
||||
|
||||
uart_send_str("Magic = ");
|
||||
uart_send_hexnum(uart_ack_header->magic, 8);
|
||||
uart_send_str(", CRC = ");
|
||||
uart_send_hexnum(recv_crc, 8);
|
||||
uart_send_str(", Entry = ");
|
||||
uart_send_hexnum(uart_ack_header->entry_point, 8);
|
||||
uart_send_str(", Size = ");
|
||||
uart_send_hexnum(uart_ack_header->size, 8);
|
||||
uart_send_lf();
|
||||
|
||||
/* Verify that the file size is appropriate */
|
||||
if ((uart_ack_header->size == 0) ||
|
||||
(uart_ack_header->size > MAX_IMAGE_SIZE)) {
|
||||
host_msg("BADCNT");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* Send BEGIN command */
|
||||
host_msg("BEGIN");
|
||||
|
||||
/* Receive the data over UART */
|
||||
if (uart_recv_bytes(uart_ack_header->size,
|
||||
uart_ack_header->recv_buffer)
|
||||
!= E_PASS) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* Return first DONE when all data arrives */
|
||||
host_msg("DONE");
|
||||
|
||||
computed_crc = crc32_dv_compute(uart_ack_header->recv_buffer,
|
||||
uart_ack_header->size);
|
||||
if (computed_crc != recv_crc) {
|
||||
host_msg("BADCRC");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
inflate_srcbuf_len = uart_ack_header->size - GUNZIP_COMP_BLOCK_OFFSET;
|
||||
|
||||
error = gunzip(uart_ack_header->inflate_dstbuf, &inflate_dstbuf_len,
|
||||
&uart_ack_header->recv_buffer[GUNZIP_COMP_BLOCK_OFFSET],
|
||||
&inflate_srcbuf_len);
|
||||
if (error != 0) {
|
||||
uart_send_str("gzip error = ");
|
||||
uart_send_hexnum(error, 8);
|
||||
uart_send_lf();
|
||||
host_msg("GZIPERR");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
uart_send_str("Deflated data size = ");
|
||||
uart_send_hexnum(inflate_dstbuf_len, 8);
|
||||
uart_send_lf();
|
||||
|
||||
uart_ack_header->recv_buffer = uart_ack_header->inflate_dstbuf;
|
||||
uart_ack_header->size = inflate_dstbuf_len;
|
||||
|
||||
/* Return DONE when all data is validated */
|
||||
host_msg("DONE");
|
||||
|
||||
return E_PASS;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* uart.h - UART Rx and Tx definitions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _UART_H_
|
||||
#define _UART_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
struct uart_ack_header_t {
|
||||
uint32_t magic;
|
||||
uint32_t entry_point;
|
||||
uint32_t size;
|
||||
uint8_t *recv_buffer;
|
||||
uint8_t *inflate_dstbuf;
|
||||
};
|
||||
|
||||
void uart_boot(uint32_t *jump_entry_point);
|
||||
|
||||
void uart_send_lf(void);
|
||||
void uart_send_str(char *string);
|
||||
void uart_send_str_lf(char *string);
|
||||
void uart_send_hexnum(uint32_t value, int digits);
|
||||
|
||||
int uart_get_cmd(uint32_t *boot_cmd);
|
||||
|
||||
uint32_t uart_get_prog(struct uart_ack_header_t *uart_ack_header);
|
||||
|
||||
#endif /* _UART_H_ */
|
|
@ -0,0 +1,261 @@
|
|||
/*
|
||||
* uartboot.c - UART boot mode
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
#include "uart.h"
|
||||
#include "util.h"
|
||||
#include "crc.h"
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
#include "nor.h"
|
||||
#elif defined(FLASH_TYPE_NAND)
|
||||
#include "nand.h"
|
||||
#endif
|
||||
|
||||
/* Symbols from linker script */
|
||||
extern uint32_t __DDR_START;
|
||||
extern uint32_t __DDR_SIZE;
|
||||
|
||||
static int
|
||||
ddr_memory_test(void)
|
||||
{
|
||||
int k;
|
||||
volatile uint32_t *ddr_start = &__DDR_START;
|
||||
const uint32_t ddr_size32 = ((uint32_t) &__DDR_SIZE) / 4;
|
||||
uint32_t read32;
|
||||
|
||||
log_info("DDR tests");
|
||||
|
||||
log_info("1. RAMP test:");
|
||||
for (k = 0; k < ddr_size32; k++)
|
||||
ddr_start[k] = k; /* Write */
|
||||
|
||||
for (k = 0; k < ddr_size32; k++) {
|
||||
read32 = ddr_start[k]; /* Read */
|
||||
if (read32 != k)
|
||||
goto error;
|
||||
}
|
||||
log_info(" Success");
|
||||
|
||||
log_info("2. PATTERN test:");
|
||||
for (k = 0; k < ddr_size32; k++)
|
||||
ddr_start[k] = DDR_TEST_PATTERN; /* Write */
|
||||
|
||||
for (k = 0; k < ddr_size32; k++) {
|
||||
read32 = ddr_start[k]; /* Read */
|
||||
if (read32 != DDR_TEST_PATTERN)
|
||||
goto error;
|
||||
}
|
||||
log_info(" Success");
|
||||
|
||||
host_msg("DDRTEST_SUCCESS");
|
||||
return 0;
|
||||
|
||||
error:
|
||||
uart_send_str("Failed at address: ");
|
||||
uart_send_hexnum(k * 4, 8);
|
||||
uart_send_str(", Expected: ");
|
||||
uart_send_hexnum(k, 8);
|
||||
uart_send_str(", Read: ");
|
||||
uart_send_hexnum(read32, 8);
|
||||
uart_send_lf();
|
||||
host_msg("DDRTEST_FAILURE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
uart_boot(uint32_t *jump_entry_point)
|
||||
{
|
||||
#if defined(FLASH_TYPE_NAND)
|
||||
struct nand_image_descriptor_t im_desc;
|
||||
#elif defined(FLASH_TYPE_NOR)
|
||||
struct nor_boot_t norBoot;
|
||||
uint32_t blkAddress, blkSize, baseAddress;
|
||||
#endif
|
||||
struct uart_ack_header_t uart_ack_header;
|
||||
uint32_t boot_cmd;
|
||||
|
||||
crc32_dv_build_table();
|
||||
log_info("Starting UART Boot");
|
||||
host_msg("BOOTPSP");
|
||||
|
||||
/* Get the BOOT command */
|
||||
if (uart_get_cmd(&boot_cmd) != E_PASS)
|
||||
goto uartboot_error;
|
||||
|
||||
/* Set the entry point to reset by default */
|
||||
*jump_entry_point = 0x0;
|
||||
|
||||
switch (boot_cmd) {
|
||||
case UBL_CMD_DDR_TEST:
|
||||
/* Perform DDR memory testing. */
|
||||
ddr_memory_test();
|
||||
break;
|
||||
|
||||
/* Download via UART UBL and APP and burn to flash. */
|
||||
case UBL_CMD_FLASH_UBL_APP:
|
||||
host_msg("SENDUBL");
|
||||
|
||||
/* Download UBL into GZIP format */
|
||||
if (uart_get_prog(&uart_ack_header) != E_PASS)
|
||||
goto uartboot_error;
|
||||
|
||||
log_info("Writing UBL");
|
||||
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
NOR_Erase(nor_get_flashbase(), uart_ack_header.size);
|
||||
|
||||
/* Write binary UBL to NOR flash. */
|
||||
NOR_WriteBytes(nor_get_flashbase(), uart_ack_header.size,
|
||||
(uint32_t) uart_ack_header.recv_buffer);
|
||||
#elif defined(FLASH_TYPE_NAND)
|
||||
im_desc.magic = uart_ack_header.magic;
|
||||
im_desc.entry_point = uart_ack_header.entry_point;
|
||||
im_desc.block_num = START_UBL_BLOCK_NUM;
|
||||
im_desc.load_address = 0; /* Load address not used by RBL */
|
||||
|
||||
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer,
|
||||
uart_ack_header.size) != E_PASS)
|
||||
goto uartboot_error;
|
||||
#endif
|
||||
|
||||
/* Indicate that UBL flashing was successfull. */
|
||||
host_msg("DONE");
|
||||
|
||||
host_msg("SENDAPP");
|
||||
|
||||
/* Get the application header and data */
|
||||
if (uart_get_prog(&uart_ack_header) != E_PASS)
|
||||
goto uartboot_error;
|
||||
|
||||
log_info("Writing APP");
|
||||
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
/* Erase the NOR flash where header and data will go */
|
||||
DiscoverBlockInfo((nor_get_flashbase() + UBL_IMAGE_SIZE),
|
||||
&blkSize, &blkAddress);
|
||||
baseAddress = blkAddress + blkSize;
|
||||
NOR_Erase(baseAddress, uart_ack_header.size + sizeof(norBoot));
|
||||
|
||||
/* MagicFlag for Application (binary or safe) */
|
||||
norBoot.magicNum = uart_ack_header.magic;
|
||||
|
||||
/* Bytes of application (either srec or binary) */
|
||||
norBoot.appSize = uart_ack_header.size;
|
||||
|
||||
/* Value from ACK header */
|
||||
norBoot.entryPoint = uart_ack_header.entry_point;
|
||||
|
||||
/* Semi-hardcoded load address to entry point. FIXME */
|
||||
norBoot.ldAddress = uart_ack_header.entry_point;
|
||||
|
||||
/* Write the struct nor_boot_t header to the flash */
|
||||
NOR_WriteBytes(baseAddress, sizeof(norBoot),
|
||||
(uint32_t) &norBoot);
|
||||
|
||||
/* Write the application data to the flash */
|
||||
NOR_WriteBytes((baseAddress + sizeof(norBoot)),
|
||||
uart_ack_header.size,
|
||||
(uint32_t) uart_ack_header.recv_buffer);
|
||||
|
||||
/* Semi-hardcoded load address to entry point. FIXME */
|
||||
if (nor_write_prog(&nor_boot, uart_ack_header.recv_buffer,
|
||||
uart_ack_header.size,
|
||||
baseAddress + sizeof(norBoot),
|
||||
uart_ack_header.magic,
|
||||
uart_ack_header.entry_point,
|
||||
uart_ack_header.entry_point) != E_PASS)
|
||||
goto uartboot_error;
|
||||
#elif defined(FLASH_TYPE_NAND)
|
||||
im_desc.magic = uart_ack_header.magic;
|
||||
im_desc.entry_point = uart_ack_header.entry_point;
|
||||
im_desc.block_num = START_APP_BLOCK_NUM;
|
||||
/* Assuming load address is identical to entry point. */
|
||||
im_desc.load_address = uart_ack_header.entry_point;
|
||||
|
||||
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer,
|
||||
uart_ack_header.size) != E_PASS)
|
||||
goto uartboot_error;
|
||||
#endif
|
||||
|
||||
/* Indicate that APP flashing was successfull. */
|
||||
host_msg("DONE");
|
||||
|
||||
break;
|
||||
|
||||
case UBL_CMD_FLASH_DATA:
|
||||
host_msg("SENDDATA");
|
||||
|
||||
/* Get the data block infos and actual bytes */
|
||||
if (uart_get_prog(&uart_ack_header) != E_PASS)
|
||||
goto uartboot_error;
|
||||
|
||||
log_info("Writing DATA");
|
||||
|
||||
im_desc.magic = uart_ack_header.magic;
|
||||
im_desc.block_num = uart_ack_header.entry_point; /* Block in flash */
|
||||
|
||||
if (nand_write_prog(&im_desc, uart_ack_header.recv_buffer,
|
||||
uart_ack_header.size) != E_PASS)
|
||||
goto uartboot_error;
|
||||
|
||||
/* Indicate that APP flashing was successfull. */
|
||||
host_msg("DONE");
|
||||
|
||||
break;
|
||||
|
||||
case UBL_CMD_FLASH_ERASE:
|
||||
log_info("Erasing whole flash");
|
||||
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
if (NOR_GlobalErase() != E_PASS) {
|
||||
log_info("Erase failed");
|
||||
goto uartboot_error;
|
||||
}
|
||||
#elif defined(FLASH_TYPE_NAND)
|
||||
if (nand_erase_all() != E_PASS) {
|
||||
log_info("Erase failed");
|
||||
goto uartboot_error;
|
||||
}
|
||||
#endif
|
||||
|
||||
log_info("Erase successfull");
|
||||
|
||||
break;
|
||||
default:
|
||||
/* Load and run application */
|
||||
host_msg("SENDAPP");
|
||||
|
||||
if (uart_get_prog(&uart_ack_header) != E_PASS)
|
||||
goto uartboot_error;
|
||||
|
||||
*jump_entry_point = uart_ack_header.entry_point;
|
||||
break;
|
||||
} /* end switch statement */
|
||||
|
||||
return;
|
||||
|
||||
uartboot_error:
|
||||
/* Set the entry point to reset. */
|
||||
*jump_entry_point = 0x0;
|
||||
}
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* ubl.c - main file
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "davinci.h"
|
||||
#include "uart.h"
|
||||
#include "util.h"
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
#include "nor.h"
|
||||
#elif defined(FLASH_TYPE_NAND)
|
||||
#include "nand.h"
|
||||
#endif
|
||||
|
||||
#define C1_IC (1 << 12) /* icache off/on */
|
||||
|
||||
static uint32_t jump_entry_point;
|
||||
|
||||
enum bootmode_t bootmode;
|
||||
|
||||
/* read co-processor 15, register #1 (control register) */
|
||||
static uint32_t
|
||||
read_p15_c1(void)
|
||||
{
|
||||
uint32_t value;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"mrc p15, 0, %0, c1, c0, 0 @ read control reg\n"
|
||||
: "=r" (value)
|
||||
:
|
||||
: "memory");
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/* write to co-processor 15, register #1 (control register) */
|
||||
static void
|
||||
write_p15_c1(uint32_t value)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
"mcr p15, 0, %0, c1, c0, 0 @ write it back\n"
|
||||
:
|
||||
: "r" (value)
|
||||
: "memory");
|
||||
|
||||
read_p15_c1();
|
||||
}
|
||||
|
||||
static void
|
||||
cp_delay(void)
|
||||
{
|
||||
volatile int i;
|
||||
|
||||
/* copro seems to need some delay between reading and writing */
|
||||
for (i = 0; i < 100; i++)
|
||||
;
|
||||
}
|
||||
|
||||
static void
|
||||
icache_enable(void)
|
||||
{
|
||||
uint32_t reg;
|
||||
|
||||
reg = read_p15_c1(); /* get control reg. */
|
||||
cp_delay();
|
||||
write_p15_c1(reg | C1_IC);
|
||||
}
|
||||
|
||||
static int
|
||||
ubl_main(void)
|
||||
{
|
||||
int status;
|
||||
|
||||
/* Read boot mode */
|
||||
bootmode = (enum bootmode_t) (((SYSTEM->BOOTCFG) & 0xC0) >> 6);
|
||||
|
||||
/* Wait until the RBL is done using the UART. */
|
||||
if (bootmode == NON_SECURE_UART)
|
||||
while ((UART0->LSR & 0x40) == 0);
|
||||
|
||||
status = davinci_platform_init(UBL_VERSION_STR);
|
||||
if (status != E_PASS)
|
||||
goto error;
|
||||
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
status = NOR_Init();
|
||||
#elif defined(FLASH_TYPE_NAND)
|
||||
status = nand_init();
|
||||
#endif
|
||||
if (status != E_PASS) {
|
||||
uart_send_str("flash init failed");
|
||||
goto error;
|
||||
}
|
||||
|
||||
uart_send_str("BootMode = ");
|
||||
|
||||
/* Select Boot Mode */
|
||||
switch (bootmode) {
|
||||
#if defined(FLASH_TYPE_NAND)
|
||||
case NON_SECURE_NAND:
|
||||
log_info("NAND"); /* Report boot mode to host */
|
||||
|
||||
/* Copy binary application data from NAND to DDRAM */
|
||||
if (nand_copy(&jump_entry_point) != E_PASS) {
|
||||
log_info("Boot failed.");
|
||||
goto UARTBOOT;
|
||||
}
|
||||
break;
|
||||
#elif defined(FLASH_TYPE_NOR)
|
||||
case NON_SECURE_NOR:
|
||||
log_info("NOR"); /* Report boot mode to host */
|
||||
|
||||
/* Copy binary application data from NOR to DDRAM */
|
||||
if (nor_copy() != E_PASS) {
|
||||
log_info("Boot failed.");
|
||||
goto UARTBOOT;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case NON_SECURE_UART:
|
||||
log_info("UART"); /* Report boot mode to host */
|
||||
goto UARTBOOT;
|
||||
break;
|
||||
default:
|
||||
UARTBOOT:
|
||||
uart_boot(&jump_entry_point);
|
||||
break;
|
||||
}
|
||||
|
||||
waitloop(10000);
|
||||
|
||||
/* Disabling UART timeout timer */
|
||||
while ((UART0->LSR & 0x40) == 0)
|
||||
;
|
||||
TIMER0->TCR = 0x00000000;
|
||||
|
||||
return E_PASS;
|
||||
|
||||
error:
|
||||
jump_entry_point = 0; /* Reset */
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/*
|
||||
* boot() has naked attribute (doesn't save registers since it is the entry
|
||||
* point out of boot and it doesn't have an exit point). This setup requires
|
||||
* that the gnu compiler uses the -nostdlib option.
|
||||
*/
|
||||
__attribute__((naked, section(".boot"))) void boot(void);
|
||||
|
||||
void
|
||||
boot(void)
|
||||
{
|
||||
void (*app_entry_function)(void);
|
||||
extern uint32_t __topstack; /* symbol defined in linker script */
|
||||
register uint32_t *stackpointer asm("sp");
|
||||
|
||||
asm(" MRS r0, cpsr");
|
||||
asm(" BIC r0, r0, #0x1F"); /* Clear MODES */
|
||||
asm(" ORR r0, r0, #0x13"); /* Set SUPERVISOR mode */
|
||||
asm(" ORR r0, r0, #0xC0"); /* Disable FIQ and IRQ */
|
||||
asm(" MSR cpsr, r0");
|
||||
|
||||
/* Set the IVT to low memory, leave MMU & caches disabled */
|
||||
asm(" MRC p15, 0, r1, c1, c0, 0");
|
||||
asm(" BIC r0,r0,#0x00002000");
|
||||
asm(" MCR p15, 0, r1, c1, c0, 0");
|
||||
|
||||
/* Stack setup */
|
||||
stackpointer = &(__topstack);
|
||||
|
||||
icache_enable();
|
||||
|
||||
/* Call to main code */
|
||||
ubl_main();
|
||||
|
||||
uart_send_str("Starting app at: ");
|
||||
uart_send_hexnum((uint32_t) jump_entry_point, 8);
|
||||
uart_send_lf();
|
||||
|
||||
/* Jump to entry point */
|
||||
app_entry_function = (void *) jump_entry_point;
|
||||
(*app_entry_function)();
|
||||
}
|
||||
|
||||
/*
|
||||
* selfcopy() has naked attribute (doesn't save registers since it is the
|
||||
* entry point when the UBL is found at the base of the NOR Flash and then
|
||||
* goes directly to the the boot() function, which is also naked). This setup
|
||||
* requires that the gnu compiler uses the -nostdlib option.
|
||||
*/
|
||||
#if defined(FLASH_TYPE_NOR)
|
||||
__attribute__((naked, section(".selfcopy"))) void selfcopy(void);
|
||||
|
||||
void
|
||||
selfcopy(void)
|
||||
{
|
||||
volatile uint32_t *src = &(__selfcopysrc);
|
||||
volatile uint32_t *dest = &(__selfcopydest);
|
||||
volatile uint32_t *destend = &(__selfcopydestend);
|
||||
extern uint32_t __selfcopysrc, __selfcopydest, __selfcopydestend;
|
||||
|
||||
/* Enable ITCM */
|
||||
asm(" MRC p15, 0, r0, c9, c1, 1");
|
||||
asm(" MOV r0, #0x1");
|
||||
asm(" MCR p15, 0, r0, c9, c1, 1");
|
||||
|
||||
/* Enable DTCM */
|
||||
asm(" MRC p15, 0, r0, c9, c1, 0");
|
||||
asm(" MOV r0, #0x8000");
|
||||
asm(" ORR r0, r0, #0x1");
|
||||
asm(" MCR p15, 0, r0, c9, c1, 0");
|
||||
|
||||
/* Copy the words */
|
||||
while (dest < destend) {
|
||||
*dest = *src;
|
||||
dest++;
|
||||
src++;
|
||||
}
|
||||
|
||||
/* Jump to the normal entry point */
|
||||
boot();
|
||||
}
|
||||
|
||||
__attribute__ ((naked, section(".fakeentry"))) void fake_entry(void);
|
||||
|
||||
void
|
||||
fake_entry(void)
|
||||
{
|
||||
boot();
|
||||
}
|
||||
#endif /* FLASH_TYPE_NOR */
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* dm35x.lds - DM35x linker script file
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
ENTRY(boot)
|
||||
SECTIONS {
|
||||
/* Common definitions */
|
||||
__EMIF_START = 0x02000000;
|
||||
__EMIF_SIZE = 0x02000000;
|
||||
__IRAM_START = 0x00000000;
|
||||
__DDR_START = 0x80000000;
|
||||
|
||||
STACKStart = __DRAM_START + __DRAM_SIZE;
|
||||
__topstack = (__DRAM_START + __DRAM_SIZE) - 0x4;
|
||||
|
||||
. = __EMIF_START;
|
||||
|
||||
__CS2start = .;
|
||||
__NORFlash = .;
|
||||
__NANDFlash = .;
|
||||
|
||||
.selfcopy : AT (0x0)
|
||||
{
|
||||
*(.selfcopy)
|
||||
. = ALIGN(256);
|
||||
}
|
||||
|
||||
__selfcopysrc = .;
|
||||
__IVT = __DRAM_START;
|
||||
__selfcopydest = __DRAM_START + 0x00000020;
|
||||
|
||||
. = 0x20;
|
||||
.fakeentry : AT ( LOADADDR(.selfcopy) + SIZEOF(.selfcopy))
|
||||
{
|
||||
*(.fakeentry)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
.text : AT ( LOADADDR(.fakeentry) + SIZEOF(.fakeentry) )
|
||||
{
|
||||
*(.text)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
.boot : AT ( LOADADDR(.text) + SIZEOF(.text))
|
||||
{
|
||||
*(.boot)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
/* Move into DRAM for placing const and data sections */
|
||||
. += (__DRAM_START - __IRAM_START);
|
||||
|
||||
.rodata : AT ( LOADADDR(.boot) + SIZEOF(.boot) )
|
||||
{
|
||||
*(.rodata*)
|
||||
*(.rodata)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
.data : AT ( LOADADDR(.rodata) + SIZEOF(.rodata) )
|
||||
{
|
||||
*(.data)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
__selfcopydestend = __selfcopydest + SIZEOF(.fakeentry) +
|
||||
SIZEOF(.text) + SIZEOF(.boot) +
|
||||
SIZEOF(.data) + SIZEOF(.rodata);
|
||||
|
||||
.bss :
|
||||
{
|
||||
*(.bss) *(COMMON)
|
||||
. = ALIGN(4);
|
||||
}
|
||||
|
||||
/* DDR2 */
|
||||
. = __DDR_START;
|
||||
.ddrram (NOLOAD) :
|
||||
{
|
||||
*(.ddrram)
|
||||
}
|
||||
__DDR_FREE = .;
|
||||
__DDR_END = __DDR_START + __DDR_SIZE - 1;
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* util.c - miscellaneous functions
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define MAXSTRLEN 256
|
||||
|
||||
/* Endian swap */
|
||||
void
|
||||
endian_data(uint32_t *data)
|
||||
{
|
||||
uint32_t temp = *data;
|
||||
|
||||
*data = ENDIAN_SWAP(temp);
|
||||
}
|
||||
|
||||
void *
|
||||
memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
const uint8_t *src8 = src;
|
||||
uint8_t *dst8 = dest;
|
||||
|
||||
for (; n > 0; n--) {
|
||||
*dst8 = *src8;
|
||||
dst8++;
|
||||
src8++;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/* Get string length by finding null terminating char */
|
||||
size_t
|
||||
strlen(const char *s)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while ((s[i] != 0) && (i < MAXSTRLEN))
|
||||
i++;
|
||||
|
||||
if (i == MAXSTRLEN)
|
||||
return -1;
|
||||
else
|
||||
return i;
|
||||
}
|
||||
|
||||
/* Simple wait loop */
|
||||
void
|
||||
waitloop(int32_t loopcnt)
|
||||
{
|
||||
for (; loopcnt > 0; loopcnt--)
|
||||
asm(" NOP");
|
||||
}
|
||||
|
||||
void
|
||||
sleep_ms(int ms)
|
||||
{
|
||||
for (; ms > 0; ms--)
|
||||
waitloop(20000);
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* util.h - miscellaneous functions prototypes
|
||||
*
|
||||
* Copyright (C) 2008 Hugo Villeneuve <hugo@hugovil.com>
|
||||
*
|
||||
* Based on TI DaVinci Flash and Boot Utilities, original copyright follows:
|
||||
* Copyright 2008 Texas Instruments, Inc. <www.ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _UTIL_H_
|
||||
#define _UTIL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h> /* For memcpy & memset prototypes */
|
||||
|
||||
void endian_data(uint32_t *data);
|
||||
|
||||
void waitloop(int32_t loopcnt);
|
||||
void sleep_ms(int ms);
|
||||
|
||||
#endif /* _UTIL_H_ */
|
Loading…
Reference in New Issue