Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Sunxi Tools
Commits
aff86a5e
Commit
aff86a5e
authored
May 28, 2016
by
NiteHawk
Browse files
Merge pull request #52 from n1tehawk/20165227_issue48
fel-sdboot: Fix header corruption workaround
parents
ce9cf336
17164d8d
Changes
3
Show whitespace changes
Inline
Side-by-side
Makefile
View file @
aff86a5e
...
...
@@ -135,7 +135,7 @@ fel-pio.nm: fel-pio.elf
jtag-loop.elf
:
jtag-loop.c jtag-loop.lds
$(CROSS_COMPILE)
gcc
-g
$(ARM_ELF_FLAGS)
$<
-nostdlib
-o
$@
-T
jtag-loop.lds
-Wl
,-N
fel-sdboot.elf
:
fel-sdboot.
c
fel-sdboot.lds
fel-sdboot.elf
:
fel-sdboot.
S
fel-sdboot.lds
$(CROSS_COMPILE)
gcc
-g
$(ARM_ELF_FLAGS)
$<
-nostdlib
-o
$@
-T
fel-sdboot.lds
-Wl
,-N
boot_head_sun3i.elf
:
boot_head.S boot_head.lds
...
...
bin/fel-sdboot.sunxi
View file @
aff86a5e
No preview for this file type
fel-sdboot.
c
→
fel-sdboot.
S
View file @
aff86a5e
/*
* (C) Copyright 2011 Henrik Nordstrom <henrik@henriknordstrom.net>
*
Copyright
(
C
)
2016
Bernhard
Nortmann
<
bernhard
.
nortmann
@
web
.
de
>
*
*
Based
on
previous
works
*
Copyright
(
C
)
2016
Siarhei
Siamashka
<
siarhei
.
siamashka
@
gmail
.
com
>
*
Copyright
(
C
)
2012
Henrik
Nordstrom
<
henrik
@
henriknordstrom
.
net
>
*
*
This
program
is
free
software
; you can redistribute it and/or
*
modify
it
under
the
terms
of
the
GNU
General
Public
License
as
...
...
@@ -15,45 +19,51 @@
*
along
with
this
program
; if not, write to the Free Software
*
Foundation
,
Inc
.
,
59
Temple
Place
,
Suite
330
,
Boston
,
*
MA
02111
-
1307
USA
*
*/
/*
*
This
file
is
a
utility
stub
(
bootloader
code
)
to
force
the
device
into
*
FEL
mode
,
by
jumping
directly
to
the
corresponding
(
N
-)
BROM
entry
point
.
*
*
Build
instructions
:
*
make
fel
-
sdboot
.
sunxi
*
*
If
needed
,
adjust
CROSS_COMPILE
and
MKSUNXIBOOT
according
to
your
*
toolchain
,
e
.
g
.
*
make
fel
-
sdboot
.
sunxi
CROSS_COMPILE
=
armv7a
-
hardfloat
-
linux
-
gnueabi
-
\
*
MKSUNXIBOOT
=/
usr
/
local
/
bin
/
mksunxiboot
*
*
*
Install
instructions
:
*
dd
if
=
fel
-
sdboot
.
sunxi
of
=/
dev
/
sdX
bs
=
1024
seek
=
8
*/
Build instructions:
arm-none-linux-gnueabi-gcc -g -Os -fno-common -ffixed-r8 -msoft-float -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder fel-boot.c -c
arm-none-linux-gnueabi-objcopy -O binary fel-boot.o fel-boot.bin
mksunxiboot fel-boot.bin fel-boot.sunxi
Install instructions:
dd if=fel-boot.sunxi of=/dev/sdX bs=1024 seek=8
*/
SCTRL
.
req
r0
.
equ
V_BIT
,
(
1
<<
13
)
void
_start
(
void
)
{
unsigned
int
sctlr
;
.
equ
BROM_ENTRY_LOW
,
0x00000020
.
equ
BROM_ENTRY_HIGH
,
0xFFFF0020
/*
*
FEL mode fails to activate in an unpredictable way without
*
this NOP padding. Minor changes in the code, such as checking
*
the PC register (PC >= 0x10000) instead of SCTLR.V or doing
*
jump instead of call to the FEL handler in the BROM sometimes
*
break on A64 and sometimes break on A10/A13/A20. Trying to
*
add DSB & ISB instructions and/or invalidating caches and
*
BTB do not seem to make any difference. Only adding a bunch
*
of NOP instructions in the beginning help
s.
/*
*
In
cases
where
insufficient
padding
is
added
by
an
old
mksunxiboot
,
*
_start
may
be
0x20
,
which
means
that
the
instruction
at
0x28
could
get
*
corrupted
by
the
BROM
-
see
https
:
//
patchwork
.
ozlabs
.
org
/
patch
/
622173
/
*
*
Apply
a
workaround
to
avoid
(=
skip
over
)
that
memory
location
.
*
_main
would
be
at
0x30
in
that
particular
case
.
With
newer
(
properly
*
fixed
)
versions
of
mksunxiboot
,
this
code
ends
up
at
higher
addresses
*
and
will
be
moot
,
but
harmles
s
.
*/
asm
volatile
(
".rept 32
\n
nop
\n
.endr"
);
asm
volatile
(
"mrc p15, 0, %0, c1, c0, 0"
:
"=r"
(
sctlr
));
_start
:
b
_main
nop
nop
nop
if
(
sctlr
&
(
1
<<
13
))
/* SCTLR.V */
((
void
(
*
)(
void
))
0xffff0020
)();
else
((
void
(
*
)(
void
))
0x00000020
)();
}
_main
:
mrc
p15
,
0
,
SCTRL
,
c1
,
c0
,
0
tst
SCTRL
,
#
V_BIT
@
test
SCTRL
.
V
moveq
lr
,
#
BROM_ENTRY_LOW
ldrne
lr
,
=
BROM_ENTRY_HIGH
bx
lr
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment