can't interrupt when printing T T T T T

2019-08-30 Thread duhuanpeng
Hello, I boot my barebox by barebox from tftpserver. I poweroff my
switcher. and barebox began to print
- - - -
Booting entry 'net'
T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T 
IP 192.168.1.88 is not reachable
- - - -
I try to hit ctrl-c and some other keys. but I can't stop it printing 'T'.
so I added some piece of code to test it

fs/tftp.c
   static int tftp_poll(struct file_priv *priv)
 {
+
+   if(tstc()) {
+   printf("%s", __func__);
+   putchar(getchar());
+   }
+
if (ctrlc()) {

net/net.c
 
 void net_poll(void)
 {
+   if(tstc()) {
+   printf("%s", __func__);
+   putchar(getchar());
+   }
+


net/eth.c

static int __eth_rx(struct eth_device *edev)
{
int ret;

+   if(tstc()) {
+   putchar(getchar());
+   printf("|-_-|");
+   }
+
- - - - - - - -
the result:

Booting entry 'net'
T net_pollknet_polljnet_pollknet_polljk|-_-|net_polljT 
n|-_-|net_pollkj|-_-|net_pollsnet_pollknet_pollfnet_pollanet_polljT 
|-_-|net_poll|-_-||-_-|net_pollnet_
pollT T T T T net_pollfnet_pollfT 
net_pollff|-_-|f|-_-|net_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfT
 f|-_-|net_polldnet_pollfnet_pollsnet_p
olldnet_pollkf|-_-|net_polljnet_pollknet_pollsnet_polljd|-_-|net_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljT
 net_polljnet_polljnet_polljnet_p
olljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljj|-_-|net_polljT
 T T T T T T T net_pollfnet_po
llfnet_pollfT 
net_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollff|-_-|T
 net_pollfnet_polldnet_polldd|-_-|d|-_
-|T T T T T T T T T T T T T T T T T T T IP 192.168.1.88 is not reachable

I found it the routine (tftp_poll) didn't catch the key input.
mostly the input is catched by net_poll().
could anyone help to move the ctrlc() dection into the right place?

duhuanpeng.








___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: can't interrupt when printing T T T T T

2019-08-30 Thread Ahmad Fatoum
Hello Duhuan (?),

On 8/29/19 6:53 PM, duhuanpeng wrote:
> Hello, I boot my barebox by barebox from tftpserver. I poweroff my
> switcher. and barebox began to print
> - - - -
> Booting entry 'net'
> T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T T 
> T IP 192.168.1.88 is not reachable
> - - - -
> I try to hit ctrl-c and some other keys. but I can't stop it printing 'T'.
> so I added some piece of code to test it
> 
> fs/tftp.c
>static int tftp_poll(struct file_priv *priv)
>  {
> +
> +   if(tstc()) {
> +   printf("%s", __func__);
> +   putchar(getchar());
> +   }
> +
> if (ctrlc()) {
> 
> net/net.c
>  
>  void net_poll(void)
>  {
> +   if(tstc()) {
> +   printf("%s", __func__);
> +   putchar(getchar());
> +   }
> +
> 
> 
> net/eth.c
> 
> static int __eth_rx(struct eth_device *edev)
> {
>   int ret;
> 
> +   if(tstc()) {
> +   putchar(getchar());
> +   printf("|-_-|");
> +   }
> +
> - - - - - - - -
> the result:
> 
> Booting entry 'net'
> T net_pollknet_polljnet_pollknet_polljk|-_-|net_polljT 
> n|-_-|net_pollkj|-_-|net_pollsnet_pollknet_pollfnet_pollanet_polljT 
> |-_-|net_poll|-_-||-_-|net_pollnet_
> pollT T T T T net_pollfnet_pollfT 
> net_pollff|-_-|f|-_-|net_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfT
>  f|-_-|net_polldnet_pollfnet_pollsnet_p
> olldnet_pollkf|-_-|net_polljnet_pollknet_pollsnet_polljd|-_-|net_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljT
>  net_polljnet_polljnet_polljnet_p
> olljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljnet_polljj|-_-|net_polljT
>  T T T T T T T net_pollfnet_po
> llfnet_pollfT 
> net_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollfnet_pollff|-_-|T
>  net_pollfnet_polldnet_polldd|-_-|d|-_
> -|T T T T T T T T T T T T T T T T T T T IP 192.168.1.88 is not reachable
> 
> I found it the routine (tftp_poll) didn't catch the key input.
> mostly the input is catched by net_poll().
> could anyone help to move the ctrlc() dection into the right place?

"startup: allow ctrl+c abort during boot sequence" on the barebox next branch
should fix this for you.

Cheers
Ahmad

> 
> duhuanpeng.
> 
> 
> 
> 
> 
> 
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] gpio: iopoll: implement gpio_poll_timeout_us

2019-08-30 Thread Ahmad Fatoum
Hello Oleksij,

On 8/30/19 6:18 AM, Oleksij Rempel wrote:
> On Thu, Aug 29, 2019 at 02:43:18PM +0200, Ahmad Fatoum wrote:
>> Sometimes we need to wait for state change on a GPIO,
>> provide a helper to do this.
>>
>> Signed-off-by: Ahmad Fatoum 
>> ---
>>  include/gpio.h | 10 ++
>>  1 file changed, 10 insertions(+)
>>
>> diff --git a/include/gpio.h b/include/gpio.h
>> index 1926edeca757..89cb306a195c 100644
>> --- a/include/gpio.h
>> +++ b/include/gpio.h
>> @@ -3,6 +3,7 @@
>>  
>>  #include 
>>  #include 
>> +#include 
>>  
>>  #ifdef CONFIG_GENERIC_GPIO
>>  void gpio_set_value(unsigned gpio, int value);
>> @@ -31,6 +32,13 @@ static inline int gpio_direction_input(unsigned gpio)
>>  void gpio_set_active(unsigned gpio, bool state);
>>  int gpio_is_active(unsigned gpio);
>>  int gpio_direction_active(unsigned gpio, bool state);
>> +
>> +#define gpio_poll_timeout_us(gpio, active, timeout_us)  
>> \
>> +({  \
>> +int __state;\
>> +readx_poll_timeout(gpio_is_active, gpio, __state,   \
>> +   __state == (active), timeout_us);\
>> +})
>>  #else
>>  static inline void gpio_set_active(unsigned gpio, int value)
>>  {
>> @@ -43,6 +51,8 @@ static inline int gpio_direction_active(unsigned gpio, int 
>> value)
>>  {
>>  return -EINVAL;
>>  }
>> +
>> +#define gpio_poll_timeout_us(gpio, val, timeout_us) (-ENOSYS)
>>  #endif
>>  
>>  #if defined(CONFIG_ARCH_NR_GPIO) && CONFIG_ARCH_NR_GPIO > 0
> 
> Do we already have some thing using this function?

Just stuff sitting on my own branches, but I figured it's useful
enough to have in the header.

> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] input: add handler for reset and power key input events

2019-08-30 Thread Ahmad Fatoum
Hello,

On 8/29/19 1:26 PM, duhuanpeng wrote:
> Hello, I merged this patch to my barebox. and test on my own board.
> 
> 1. Abort barebox booting and enter the console.
>the board reboots immediately when I press the button without release.
>here is my .dts about this button:
> 
> net {
> label = "board:LED1:system";
> gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
> default-state = "off";
> barebox,default-trigger = "net";
> };

Copy-paste mistake?

> 
> 2. Panic.
>type 'go 888' make barebox panic. now I really need a 'reset' key.
>I press and releaes the key, and try to hold this key several seconds.
>no reaction.
> 
> Is the 'reset' key designed for reset the board when something goes wrong?

That's the watchdog's job. If your hardware features a hardware watchdog, you 
can
have it started on bootm or configure barebox' poller to feed it continuously.
If barebox panics or anything else happens before Linux starts feeding the 
watchdog,
your system will then automatically reset.

You could have barebox panic loop on a gpio, but it would only help if barebox
actually calls panic. If you run into an infinite loop, or the exception vectors
are overwritten, there's nothing barebox can do (short of evolving to barebOS 
and
implementing preemption and privilege separation).

Cheers
Ahmad

> 
> Regards,
> duhuanpeng
> 
> 
> On Thu, Aug 29, 2019 at 07:28:08AM +0200, Ahmad Fatoum wrote:
>> Kernel device trees may indicate linux,code = KEY_POWER or KEY_RESTART,
>> mostly for gpio-keys. Make barebox able to act on them by registering an
>> appropriate input notifier.
>>
>> Suggested-by: Oleksij Rempel 
>> Signed-off-by: Ahmad Fatoum 
>> ---
>>  drivers/input/Kconfig   |  6 ++
>>  drivers/input/Makefile  |  1 +
>>  drivers/input/specialkeys.c | 36 
>>  3 files changed, 43 insertions(+)
>>  create mode 100644 drivers/input/specialkeys.c
>>
>> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
>> index 1f89ae3892dc..be061683fb0a 100644
>> --- a/drivers/input/Kconfig
>> +++ b/drivers/input/Kconfig
>> @@ -64,4 +64,10 @@ config KEYBOARD_USB
>>  help
>>This driver implements support for usb keyboard.
>>  
>> +config INPUT_SPECIALKEYS
>> +bool "Special keys handler"
>> +select INPUT
>> +help
>> +  Say Y here to handle key events like KEY_RESTART and KEY_POWER.
>> +
>>  endmenu
>> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
>> index e694a98d1087..36a4204d5308 100644
>> --- a/drivers/input/Makefile
>> +++ b/drivers/input/Makefile
>> @@ -5,3 +5,4 @@ obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
>>  obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o
>>  obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
>>  obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
>> +obj-$(CONFIG_INPUT_SPECIALKEYS) += specialkeys.o
>> diff --git a/drivers/input/specialkeys.c b/drivers/input/specialkeys.c
>> new file mode 100644
>> index ..51ee43218192
>> --- /dev/null
>> +++ b/drivers/input/specialkeys.c
>> @@ -0,0 +1,36 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +// Copyright (c) 2019 Ahmad Fatoum, Pengutronix
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +static void input_specialkeys_notify(struct input_notifier *in,
>> + struct input_event *ev)
>> +{
>> +switch (ev->code) {
>> +case KEY_RESTART:
>> +pr_debug("code: %d. Triggering reset.\n", ev->code);
>> +restart_machine();
>> +break;
>> +
>> +case KEY_POWER:
>> +pr_debug("code: %d. Triggering poweroff.\n", ev->code);
>> +poweroff_machine();
>> +break;
>> +}
>> +
>> +pr_debug("ignoring code: %d\n", ev->code);
>> +}
>> +
>> +static struct input_notifier notifier;
>> +
>> +static int input_specialkeys_init(void)
>> +{
>> +notifier.notify = input_specialkeys_notify;
>> +return input_register_notfier(¬ifier);
>> +}
>> +late_initcall(input_specialkeys_init);
>> -- 
>> 2.23.0
>>
>>
>> ___
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>>
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] input: add handler for reset and power key input events

2019-08-30 Thread Oleksij Rempel

Am 30.08.19 um 11:02 schrieb Ahmad Fatoum:

Hello,

On 8/29/19 1:26 PM, duhuanpeng wrote:

Hello, I merged this patch to my barebox. and test on my own board.

1. Abort barebox booting and enter the console.
the board reboots immediately when I press the button without release.
here is my .dts about this button:

 net {
 label = "board:LED1:system";
 gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
 default-state = "off";
 barebox,default-trigger = "net";
 };


Copy-paste mistake?



2. Panic.
type 'go 888' make barebox panic. now I really need a 'reset' key.
I press and releaes the key, and try to hold this key several seconds.
no reaction.

Is the 'reset' key designed for reset the board when something goes wrong?


That's the watchdog's job. If your hardware features a hardware watchdog, you 
can
have it started on bootm or configure barebox' poller to feed it continuously.
If barebox panics or anything else happens before Linux starts feeding the 
watchdog,
your system will then automatically reset.

You could have barebox panic loop on a gpio, but it would only help if barebox
actually calls panic. If you run into an infinite loop, or the exception vectors
are overwritten, there's nothing barebox can do (short of evolving to barebOS 
and
implementing preemption and privilege separation).


May be it would make sense to have an option simila to the kernel, to reboot on 
panic.

--
Regards,
Oleksij

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] input: add handler for reset and power key input events

2019-08-30 Thread Ahmad Fatoum


On 8/29/19 8:41 AM, Oleksij Rempel wrote:
> Hi
> 
> On 29.08.19 07:28, Ahmad Fatoum wrote:
>> Kernel device trees may indicate linux,code = KEY_POWER or KEY_RESTART,
>> mostly for gpio-keys. Make barebox able to act on them by registering an
>> appropriate input notifier.
>>
>> Suggested-by: Oleksij Rempel 
>> Signed-off-by: Ahmad Fatoum 
>> ---
>>   drivers/input/Kconfig   |  6 ++
>>   drivers/input/Makefile  |  1 +
>>   drivers/input/specialkeys.c | 36 
>>   3 files changed, 43 insertions(+)
>>   create mode 100644 drivers/input/specialkeys.c
>>
>> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
>> index 1f89ae3892dc..be061683fb0a 100644
>> --- a/drivers/input/Kconfig
>> +++ b/drivers/input/Kconfig
>> @@ -64,4 +64,10 @@ config KEYBOARD_USB
>>   help
>>     This driver implements support for usb keyboard.
>>   +config INPUT_SPECIALKEYS
>> +    bool "Special keys handler"
>> +    select INPUT
>> +    help
>> +  Say Y here to handle key events like KEY_RESTART and KEY_POWER.
>> +
>>   endmenu
>> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
>> index e694a98d1087..36a4204d5308 100644
>> --- a/drivers/input/Makefile
>> +++ b/drivers/input/Makefile
>> @@ -5,3 +5,4 @@ obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
>>   obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o
>>   obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
>>   obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
>> +obj-$(CONFIG_INPUT_SPECIALKEYS)    += specialkeys.o
>> diff --git a/drivers/input/specialkeys.c b/drivers/input/specialkeys.c
>> new file mode 100644
>> index ..51ee43218192
>> --- /dev/null
>> +++ b/drivers/input/specialkeys.c
>> @@ -0,0 +1,36 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +// Copyright (c) 2019 Ahmad Fatoum, Pengutronix
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +static void input_specialkeys_notify(struct input_notifier *in,
>> + struct input_event *ev)
>> +{
>> +    switch (ev->code) {
>> +    case KEY_RESTART:
>> +    pr_debug("code: %d. Triggering reset.\n", ev->code);
> 
> May be it is better to increase the pr_ level, for example to pr_info? In 
> case we have some buggy KEY (wrong active level, or floating input gpio) we 
> can easily detect it.

Will do.

> 
>> +    restart_machine();
>> +    break;
>> +
>> +    case KEY_POWER:
>> +    pr_debug("code: %d. Triggering poweroff.\n", ev->code);
> 
> same here.
> 
>> +    poweroff_machine();
>> +    break;
>> +    }
>> +
>> +    pr_debug("ignoring code: %d\n", ev->code);
>> +}
>> +
>> +static struct input_notifier notifier;
>> +
>> +static int input_specialkeys_init(void)
>> +{
>> +    notifier.notify = input_specialkeys_notify;
>> +    return input_register_notfier(¬ifier);
>> +}
>> +late_initcall(input_specialkeys_init);
>>
> 
> Kind regards,
> Oleksij Rempel
> 

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] Documentation: efi: fix typos

2019-08-30 Thread Ahmad Fatoum
Signed-off-by: Ahmad Fatoum 
---
 Documentation/boards/efi.rst | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Documentation/boards/efi.rst b/Documentation/boards/efi.rst
index 3da2daac99ef..2178c9ab4293 100644
--- a/Documentation/boards/efi.rst
+++ b/Documentation/boards/efi.rst
@@ -43,7 +43,7 @@ name it ``BOOTx64.EFI`` on 64bit architectures and 
``BOOTIA32.EFI`` on 32bit
 architectures. Switching to USB boot in the BIOS should then be enough to
 start barebox via USB. Some BIOSes allow to specify a path to a binary to
 be executed, others have a "start UEFI shell" entry which executes
-EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary aswell.
+EFI/Shellx64.efi on the :term:`ESP`. This can be a barebox binary as well.
 To use the :ref:`state_framework`, the describing devicetree file ``state.dtb``
 has to be put into the ``EFI/barebox/`` directory.
 Supported backends for EFI are raw partitions that can be discovered via a
@@ -200,7 +200,7 @@ EFI device paths
 
 In EFI each device can be pointed to using a device path. Device paths have 
multiple
 components. The toplevel component on X86 systems will be the PCI root 
complex, on
-other systems this can be the physical memory space. Each component will now 
descrive
+other systems this can be the physical memory space. Each component will now 
describe
 how to find the child component on the parent bus. Additional device path 
nodes can
 describe network addresses or filenames on partitions. Device paths have a 
binary
 representation and a clearly defined string representation. These 
characteristics make
@@ -274,7 +274,7 @@ Network Protocol GUID:
 EFI_GUID( 0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 
0xC1, 0x4D )
 
 Matching between EFI devices and drivers is done based on the Protocol GUIDs, 
so
-whenever a driver GUID matches one of the GUIDs a device imeplements the 
drivers
+whenever a driver GUID matches one of the GUIDs a device implements the drivers
 probe function is called.
 
 .. _efi_building_edk2:
-- 
2.23.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox