embedded - u-boot select boot partition based on GPIO state -


i'm developing recovery mechanism on embedded system. want boot recovery mode if user pressed gpio button. recovery mode means selecting different kernel , root partition usual. got stuck on using gpio value in conditional command. if write if gpio input 20; cmd; fi cmd run because gpio returns error status not value of gpio. how can value?

is feasible use u-boot commands implement boot selection (i need blink leds 15s , if user presses button @ least 5s switch recovery). easier implement logic in c code? if , there examples?

in general providing recovery system seems common task embedded engineer. best practices in scenario? common way of implementing this? not find or guidelines on web.

recovery may depend on system has available you, , how robust need be. remember keep can read-only , seperated stuff writeable. keep writeable stuff in different partition in nand or wherever. method described above , running if kernel/fs bad. may need. if ever plan on allowing updating of u-boot may want consider possibility of u-boot getting corrupt when rewritten , have way recover.

alot of embedded processor's have boot order defined pins pull 1 way or other on start. favorite method of mine connect button 1 of these user can hold on power change boot order (say nand sd) , boot device can restore system.

for situation above possible check gpio, flash led etc. u-boot. can use u-boot commands:

if gpio input 63;      gpio toggle 52; "     sleep 1;      gpio toggle 52;      sleep 1; fi; 

or can directly in u-boot c code somewhere if prefer, such in own u-boot command compiled u-boot:

gpio_request(gpio_led2, "ind_led2"); gpio_request(gpio_led3, "ind_led3"); while(1) {     gpio_direction_output(gpio_led1, 1);     gpio_direction_output(gpio_led2, 0);     gpio_direction_output(gpio_led3, 1);     udelay (500000);        //wait 500ms     gpio_direction_output(gpio_led1, 0);     gpio_direction_output(gpio_led2, 1);     gpio_direction_output(gpio_led3, 0);     udelay (500000);        //wait 500ms } 

if getting errors running gpio commands u-boot make sure have gpio command stuff enabled, following in config file:

#define config_cmd_gpio 

if still doesn't work make sure u-boot has drivers gpio on part (which can't imagine doesn't).


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -