Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U-Boot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fork
U-Boot
Commits
4f8ba5a6
Commit
4f8ba5a6
authored
7 years ago
by
Ke Hu
Browse files
Options
Downloads
Patches
Plain Diff
reset button switch startup bank
press reset button for 1 second in rescue mode to switch startup bank.
parent
38f17024
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
board/inteno/common/board.c
+9
-1
9 additions, 1 deletion
board/inteno/common/board.c
board/inteno/common/lwip_start.c
+137
-3
137 additions, 3 deletions
board/inteno/common/lwip_start.c
with
146 additions
and
4 deletions
board/inteno/common/board.c
+
9
−
1
View file @
4f8ba5a6
...
@@ -278,7 +278,7 @@ int board_late_init(void)
...
@@ -278,7 +278,7 @@ int board_late_init(void)
#define RT2880_PRGIO_ADDR (RALINK_SYSCTL_BASE + 0x600) // Programmable I/O
#define RT2880_PRGIO_ADDR (RALINK_SYSCTL_BASE + 0x600) // Programmable I/O
#define RT2880_REG_PIODIR (RT2880_PRGIO_ADDR + 0x00)
#define RT2880_REG_PIODIR (RT2880_PRGIO_ADDR + 0x00)
#define RT2880_REG_PIODATA (RT2880_PRGIO_ADDR + 0x20)
#define RT2880_REG_PIODATA (RT2880_PRGIO_ADDR + 0x20)
extern
int
first_press_check
;
static
int
do_rescue
(
cmd_tbl_t
*
cmdtp
,
int
flag
,
int
argc
,
char
*
const
argv
[])
static
int
do_rescue
(
cmd_tbl_t
*
cmdtp
,
int
flag
,
int
argc
,
char
*
const
argv
[])
{
{
int
opt
;
int
opt
;
...
@@ -297,6 +297,7 @@ static int do_rescue(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
...
@@ -297,6 +297,7 @@ static int do_rescue(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return
1
;
return
1
;
}
}
}
}
if
(
do_button
){
if
(
do_button
){
//set GPIO18 as input, this is the factory default button
//set GPIO18 as input, this is the factory default button
RALINK_REG
(
RT2880_REG_PIODIR
)
&=
~
(
1
<<
18
);
//input mode
RALINK_REG
(
RT2880_REG_PIODIR
)
&=
~
(
1
<<
18
);
//input mode
...
@@ -309,11 +310,18 @@ static int do_rescue(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
...
@@ -309,11 +310,18 @@ static int do_rescue(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
set_led
(
LED_WPS
,
LED_STATE_ON
);
set_led
(
LED_WPS
,
LED_STATE_ON
);
run_command
(
"net_init"
,
0
);
run_command
(
"net_init"
,
0
);
printf
(
"Entering rescue mode
\n
"
);
printf
(
"Entering rescue mode
\n
"
);
first_press_check
=
1
;
run_command
(
"httpd"
,
0
);
run_command
(
"httpd"
,
0
);
return
0
;
return
0
;
}
}
int
reset_button_is_pressed
(
void
)
{
RALINK_REG
(
RT2880_REG_PIODIR
)
&=
~
(
1
<<
18
);
//input mode
return
(
RALINK_REG
(
RT2880_REG_PIODATA
)
&
1
<<
18
)
?
0
:
1
;
}
U_BOOT_CMD
(
U_BOOT_CMD
(
rescue
,
2
,
0
,
do_rescue
,
rescue
,
2
,
0
,
do_rescue
,
...
...
This diff is collapsed.
Click to expand it.
board/inteno/common/lwip_start.c
+
137
−
3
View file @
4f8ba5a6
...
@@ -18,8 +18,11 @@
...
@@ -18,8 +18,11 @@
#include
"lwip_start.h"
#include
"lwip_start.h"
#include
"led.h"
u32_t
sys_now
(
void
);
u32_t
sys_now
(
void
);
static
void
lwip_periodic_handle
(
void
);
static
void
lwip_periodic_handle
(
void
);
extern
int
reset_button_is_pressed
();
/* from net.h but its hard to include that one. here */
/* from net.h but its hard to include that one. here */
void
net_init
(
void
);
void
net_init
(
void
);
...
@@ -31,6 +34,7 @@ void eth_halt(void);
...
@@ -31,6 +34,7 @@ void eth_halt(void);
int
eth_send
(
void
*
packet
,
int
length
);
int
eth_send
(
void
*
packet
,
int
length
);
#define ETHERNET_MTU 1500
#define ETHERNET_MTU 1500
#define GPIO_RESET_BUTTON 41
extern
u8
net_ethaddr
[
6
];
extern
u8
net_ethaddr
[
6
];
extern
int
lwip_redirect
;
extern
int
lwip_redirect
;
...
@@ -42,11 +46,128 @@ struct netif netif;
...
@@ -42,11 +46,128 @@ struct netif netif;
static
int
loop_active
;
static
int
loop_active
;
static
int
delay_start
;
static
int
delay_start
;
enum
reset_btn_status
{
reset_btn_release
,
reset_btn_hold
,
reset_btn_handle
};
static
int
reset_btn_state
=
reset_btn_release
;
static
int
reset_count
=
0
;
static
int
current_lit
=
1
;
// switching sucessful change led
static
int
rec_pkt_cnt
=
0
;
static
int
null_pkt_cnt
=
0
;
int
first_press_check
=
0
;
// =0 null, =1 rec
#define REC_PACKET_INC() (rec_pkt_cnt++)
#define NULL_PACKET_INC() (null_pkt_cnt++)
u32_t
sys_now
(
void
)
u32_t
sys_now
(
void
)
{
{
//printf("%s not implemented\n",__func__);
//printf("%s not implemented\n",__func__);
return
0
;
return
0
;
}
}
static
void
check_reset_button
(
int
sleep_time
)
{
int
btn
=
0
;
btn
=
reset_button_is_pressed
();
if
(
first_press_check
)
{
if
(
!
btn
)
//first enter button has released
{
first_press_check
=
0
;
}
return
;
}
if
(
reset_btn_state
!=
reset_btn_release
&&
sleep_time
)
mdelay
(
sleep_time
);
if
(
reset_btn_state
==
reset_btn_release
)
{
if
(
btn
)
//button is pressed
{
if
(
++
reset_count
>
5
)
//confirm btn pressed
{
reset_btn_state
=
reset_btn_hold
;
reset_count
=
0
;
}
}
else
{
reset_count
=
0
;
}
}
else
if
(
reset_btn_state
==
reset_btn_hold
)
{
if
(
btn
)
{
if
(
++
reset_count
>
5
)
//confirm btn pressed
{
reset_btn_state
=
reset_btn_handle
;
reset_count
=
0
;
}
}
else
{
reset_btn_state
=
reset_btn_release
;
reset_count
=
0
;
}
}
else
if
(
reset_btn_state
==
reset_btn_handle
)
{
if
(
!
btn
)
{
if
(
++
reset_count
>
5
)
//stay in button handle state for 5 times
{
int
next_vol
=
0
;
unsigned
long
cur_vol
=
0
;
char
*
s
;
char
*
fs_name
[]
=
{
"rootfs_0"
,
"rootfs_1"
};
char
*
root_name
=
"root_vol"
;
//get current ubi_fs
s
=
getenv
(
root_name
);
//switch ubi_fs
//next_vol = (strcmp(s,fs_name[0]))?0:1;
cur_vol
=
simple_strtoul
(
s
+
strlen
(
"rootfs_"
),
NULL
,
10
);
next_vol
=
!
cur_vol
;
setenv
(
root_name
,
fs_name
[
next_vol
]);
printf
(
"bootfs set to %s volume
\n
"
,
fs_name
[
next_vol
]);
reset_btn_state
=
reset_btn_release
;
reset_count
=
0
;
if
(
current_lit
)
set_led
(
LED_WPS
,
LED_STATE_OFF
);
else
set_led
(
LED_WPS
,
LED_STATE_ON
);
current_lit
=
!
current_lit
;
loop_active
=
0
;
}
}
else
{
reset_count
=
0
;
}
}
}
static
void
do_btn_handle
(
int
tick_time
)
{
int
need_check
=
0
;
if
(
null_pkt_cnt
>
tick_time
)
{
check_reset_button
(
100
);
null_pkt_cnt
=
0
;
}
else
if
(
rec_pkt_cnt
>
tick_time
)
{
check_reset_button
(
10
);
rec_pkt_cnt
=
0
;
}
}
/*
/*
called from net_process_received_packet() in net/net.c when a new packet is received.
called from net_process_received_packet() in net/net.c when a new packet is received.
...
@@ -189,9 +310,12 @@ void lwip_break( int delay)
...
@@ -189,9 +310,12 @@ void lwip_break( int delay)
}
}
}
}
//set_led
//add a new feature to check pressbutton
err_t
lwip_loop
(
int
timeout
)
err_t
lwip_loop
(
int
timeout
)
{
{
int
is_rec
=
0
;
loop_active
=
1
;
loop_active
=
1
;
timeout_active
=
0
;
timeout_active
=
0
;
delay_start
=
0
;
delay_start
=
0
;
...
@@ -209,8 +333,15 @@ err_t lwip_loop( int timeout)
...
@@ -209,8 +333,15 @@ err_t lwip_loop( int timeout)
/* if something has been received process it */
/* if something has been received process it */
if
(
eth_rx
()
>
0
)
if
(
eth_rx
()
>
0
)
{
{
lwip_periodic_handle
();
lwip_periodic_handle
();
}
//LOCK_BTN();
REC_PACKET_INC
();
}
else
{
NULL_PACKET_INC
();
}
/* exit on ctrl-c */
/* exit on ctrl-c */
if
(
ctrlc
()){
if
(
ctrlc
()){
printf
(
"
\n
lwip stop. due to ctrlc
\n\n
"
);
printf
(
"
\n
lwip stop. due to ctrlc
\n\n
"
);
...
@@ -218,7 +349,10 @@ err_t lwip_loop( int timeout)
...
@@ -218,7 +349,10 @@ err_t lwip_loop( int timeout)
loop_active
=
0
;
loop_active
=
0
;
return
ERR_IF
;
return
ERR_IF
;
}
}
/*do reset button check*/
//if(LOCK_VALID())
do_btn_handle
(
100
);
/* do we have a delayed shutdown ? */
/* do we have a delayed shutdown ? */
if
(
loop_active
<
0
){
if
(
loop_active
<
0
){
if
((
-
1
*
loop_active
)
<
get_timer
(
delay_start
)){
if
((
-
1
*
loop_active
)
<
get_timer
(
delay_start
)){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment