Re: [yocto] #yocto bootchooser: Cannot get state 'state'

2020-01-21 Thread Ahmad Fatoum
Hi,

On 1/21/20 6:51 PM, Hans-Ulrich Schlieben wrote:
> Hi Ahmad,
> 
> thank you for the great help. There's a lot to learn for me here.
>> Does it come from the phytec git directly? Upstream barebox has this:
> The zeus image I build here includes layer meta-phytec branch zeus and a 
> custom layer from phytec called meta-ksp0663.
> On the custom layer I created a new branch zeus and just renamed the barebox 
> and barebox-targettools bbappend files from 2017 to 2019.
> 
> You are right about the missing state in barebox2019.01. 
> for barebox 2019 drvinfo just contains:
> state
> 
> drvinfo for barebox 2017 says:
> state 
> imx6qdl_phytec_boot_state.19
> Does that mean that the driver is not loaded?

This means you have a state driver, but there was no device to bind to.

> At the barebox2019 version of_dump returns: Cannot find nodepath state
> At the barebox2017 version of_dump returns a full subtree for 
> imx6qdl_phytec_boot_state and the eeprom entry for state.
> 
> Looking into the 2017 barebox sources using  find ./ -iname 
> "imx6qdl-phytec*.dtsi"  it finds imx6qdl-phytec-state.dtsi:
> This file does not exist in the 2019 barebox sources. There is only 
> imx6ul-phytec-state.dtsi available.

Ha! That's it. The file is in upstream barebox, so no idea why Phytec dropped 
it.
That's probably a question for Phytec support.

Cheers
Ahmad

> 
> Now I will try the upstream version.
> 
> Thank you very much for your help.
> 
> Best Regards
> 
> hu
> 
>> -Original Message-
>> From: Ahmad Fatoum  
>> Sent: Monday, 20 January 2020 16:23
>> To: Hans-Ulrich Schlieben ; Enrico Joerns 
>> ; yo...@lists.yoctoproject.org
>> Cc: barebox@lists.infradead.org
>> Subject: Re: [yocto] #yocto bootchooser: Cannot get state 'state'
>>
>> Hello,
>>
>> On 1/16/20 4:09 PM, Hans-Ulrich Schlieben wrote:
>>> Hi Ahmad,
>>>
>>> Thanks to your Mail I tested with barebox_2017.12.0-phy6.bb (thud used 
>>> barebox_2017.12.0-phy4.bb) and this works in zeus too. 
>>>
 According to the state command output under thud, your state is stored on 
 the EEPROM, not the NAND. Look for update-eeprom in your device tree.
 There should also be an /dev/eeprom0.update-eeprom in barebox.
>>> That seems right, when working the eeprom is written to on each boot.
>>> But I could not find any references to *eep* inside barebox in any layer.
>>
>> Does it come from the phytec git directly? Upstream barebox has this:
>> https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.pengutronix.de%2Fcgit%2Fbarebox%2Ftree%2Farch%2Farm%2Fdts%2Fimx6qdl-phytec-state.dtsi%3Fh%3Dnextdata=01%7C01%7Chu.schlieben%40codewrights.de%7Cfd604ff2646c497fbb3508d79dbca678%7C0974af9b352b437cb606e9f242c0c227%7C0sdata=fXOQB7awFhPhxJmDAyN5ipLxe3W8IbAw3vp03GL1Y10%3Dreserved=0
>>
>> I would imagine, yours does to. You can check in the yocto build directory.
>> (If you have rm_work enabled, you might need RM_WORK_EXCLUDE += 
>> "your-barebox-recipe"
>> in your local.conf)
>>
>> Also try of_dump /state inside of barebox to see the device tree node.
>>
>> The reason, you haven't found it in the deploy/ device tree is that barebox 
>> modifies the kernel device tree on loading and adds the state nodes to it.
>>
 if not, try executing the drvinfo command and see if the driver has probed 
 the EEPROM.
>> Looks like the state node is missing in your device tree.
>>
>> Do you have the state driver enabled? drvinfo should tell you that.
>>
>> Cheers
>> Ahmad
>>
>> -- 
>> Pengutronix e.K.   | |
>> Steuerwalder Str. 21   | 
>> https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pengutronix.de%2Fdata=01%7C01%7Chu.schlieben%40codewrights.de%7Cfd604ff2646c497fbb3508d79dbca678%7C0974af9b352b437cb606e9f242c0c227%7C0sdata=Edh9RArsjllc2C5LSvixIndwBoKZfMY0dnbLT2NdE1w%3Dreserved=0
>>   |
>> 31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
>> Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
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: [yocto] #yocto bootchooser: Cannot get state 'state'

2020-01-21 Thread Ahmad Fatoum
Hello Hans-Ulrich,

On 1/21/20 7:28 PM, Hans-Ulrich Schlieben wrote:
> Hi Ahmad, 
> 
>>   git clone 
>> https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.pengutronix.de%2Fgit%2Fbareboxdata=01%7C01%7Chu.schlieben%40codewrights.de%7C5fdd291346554b1d5e3d08d79dbdda2b%7C0974af9b352b437cb606e9f242c0c227%7C0sdata=L8WAZYdcm0kjTNZG8OFnedXXyG3DHyIHx1r4gh%2B%2FC%2BI%3Dreserved=0
>>   cd barebox
>>   cp $your_barebox_config_in_yocto .config
>>   make -j$(nproc) 
>> CROSS_COMPILE=/path/to/your/yocto/toolchain/bin/arm-$your_vendor-linux-gnueabihf-
>>  ARCH=arm
> 
> I tried to build the barebox sources but got the following error:
> $ make -j$(nproc) 
> CROSS_COMPILE=/path/to/your/yocto/toolchain/bin/arm-$your_vendor-linux-gnueabihf-
>  ARCH=arm
> make: /path/to/your/yocto/toolchain/bin/arm--linux-gnueabihf-gcc: Kommando 
> nicht gefunden
>   LEX scripts/kconfig/lexer.lex.c
> /bin/sh: 1: flex: not found
> make[2]: *** [scripts/Makefile.lib:194: scripts/kconfig/lexer.lex.c] Fehler 
> 127
> make[2]: *** Es wird auf noch nicht beendete Prozesse gewartet
>   YACCscripts/kconfig/parser.tab.h
> /bin/sh: 1: bison: not found
> make[2]: *** [scripts/Makefile.lib:208: scripts/kconfig/parser.tab.h] Fehler 
> 127
> make[1]: *** [/opt/apps/zeus/barebox/barebox/Makefile:422: syncconfig] Fehler 
> 2
> make: *** [Makefile:463: include/config/auto.conf.cmd] Fehler 2
> 
> Is the .config file wrong? I copied it from the barebox folder where I built 
> barebox 2017 version.

You missed the $your_vendor placeholders, which you need to replace with the 
toolchain vendor you
configured for your Yocto Toolchain. If in doubt, just

apt install gcc-arm-linux-gnueabihf

and use CROSS_COMPILE=gcc-arm-linux-gnueabihf

You also need to install flex and bison.

>> under images/ you will have the barebox images. You can get that onto your 
>> device using a SD-Card, imx-usb-loader, tftp ... etc.
> When the build succeeds where or how to put the image on the sdcard?
> By the way, which image is it there a lots of images in the ./image folder 
> and there is none named imx6qdl? There are some named imx6dl and one imx6q.

You will note that device trees starting with imx6qdl always have a .dtsi 
extension,
which are device tree source _includes_. They aren't full device trees. Most 
importantly,
they miss the SoC nodes that differentiate between i.MX6 Quad and DualLite.

This is done this way, so you can have the same dtsi and use it in a dts once 
with imx6q.dtsi
and once more with imx6dl.dtsi without having to replicate the common parts on 
the SoM.

As for which one to use, depends on your board. If you have a Quad or Dual, use 
imx6q-$boardname,
if you have Dual Lite or Solo use imx6dl-.


Cheers
Ahmad

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
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: [yocto] #yocto bootchooser: Cannot get state 'state'

2020-01-21 Thread Hans-Ulrich Schlieben
Hi Ahmad, 

>   git clone 
> https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.pengutronix.de%2Fgit%2Fbareboxdata=01%7C01%7Chu.schlieben%40codewrights.de%7C5fdd291346554b1d5e3d08d79dbdda2b%7C0974af9b352b437cb606e9f242c0c227%7C0sdata=L8WAZYdcm0kjTNZG8OFnedXXyG3DHyIHx1r4gh%2B%2FC%2BI%3Dreserved=0
>   cd barebox
>   cp $your_barebox_config_in_yocto .config
>   make -j$(nproc) 
> CROSS_COMPILE=/path/to/your/yocto/toolchain/bin/arm-$your_vendor-linux-gnueabihf-
>  ARCH=arm

I tried to build the barebox sources but got the following error:
$ make -j$(nproc) 
CROSS_COMPILE=/path/to/your/yocto/toolchain/bin/arm-$your_vendor-linux-gnueabihf-
 ARCH=arm
make: /path/to/your/yocto/toolchain/bin/arm--linux-gnueabihf-gcc: Kommando 
nicht gefunden
  LEX scripts/kconfig/lexer.lex.c
/bin/sh: 1: flex: not found
make[2]: *** [scripts/Makefile.lib:194: scripts/kconfig/lexer.lex.c] Fehler 127
make[2]: *** Es wird auf noch nicht beendete Prozesse gewartet
  YACCscripts/kconfig/parser.tab.h
/bin/sh: 1: bison: not found
make[2]: *** [scripts/Makefile.lib:208: scripts/kconfig/parser.tab.h] Fehler 127
make[1]: *** [/opt/apps/zeus/barebox/barebox/Makefile:422: syncconfig] Fehler 2
make: *** [Makefile:463: include/config/auto.conf.cmd] Fehler 2

Is the .config file wrong? I copied it from the barebox folder where I built 
barebox 2017 version.

 
> under images/ you will have the barebox images. You can get that onto your 
> device using a SD-Card, imx-usb-loader, tftp ... etc.
When the build succeeds where or how to put the image on the sdcard?
By the way, which image is it there a lots of images in the ./image folder and 
there is none named imx6qdl? There are some named imx6dl and one imx6q.

> 
> If you want to do it in Yocto, there are meta-ptx and meta-barebox that have 
> more recent barebox versions.
Tomorrow I will try too, to build the upstream version using yocto.

Thank you so much.

Best Regards

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


RE: [yocto] #yocto bootchooser: Cannot get state 'state'

2020-01-21 Thread Hans-Ulrich Schlieben
Hi Ahmad,

thank you for the great help. There's a lot to learn for me here.
> Does it come from the phytec git directly? Upstream barebox has this:
The zeus image I build here includes layer meta-phytec branch zeus and a custom 
layer from phytec called meta-ksp0663.
On the custom layer I created a new branch zeus and just renamed the barebox 
and barebox-targettools bbappend files from 2017 to 2019.

You are right about the missing state in barebox2019.01. 
for barebox 2019 drvinfo just contains:
state

drvinfo for barebox 2017 says:
state 
imx6qdl_phytec_boot_state.19
Does that mean that the driver is not loaded?

At the barebox2019 version of_dump returns: Cannot find nodepath state
At the barebox2017 version of_dump returns a full subtree for 
imx6qdl_phytec_boot_state and the eeprom entry for state.

Looking into the 2017 barebox sources using  find ./ -iname 
"imx6qdl-phytec*.dtsi"  it finds imx6qdl-phytec-state.dtsi:
This file does not exist in the 2019 barebox sources. There is only 
imx6ul-phytec-state.dtsi available.

Now I will try the upstream version.

Thank you very much for your help.

Best Regards

hu

> -Original Message-
> From: Ahmad Fatoum  
> Sent: Monday, 20 January 2020 16:23
> To: Hans-Ulrich Schlieben ; Enrico Joerns 
> ; yo...@lists.yoctoproject.org
> Cc: barebox@lists.infradead.org
> Subject: Re: [yocto] #yocto bootchooser: Cannot get state 'state'
> 
> Hello,
> 
> On 1/16/20 4:09 PM, Hans-Ulrich Schlieben wrote:
> > Hi Ahmad,
> > 
> > Thanks to your Mail I tested with barebox_2017.12.0-phy6.bb (thud used 
> > barebox_2017.12.0-phy4.bb) and this works in zeus too. 
> > 
> >> According to the state command output under thud, your state is stored on 
> >> the EEPROM, not the NAND. Look for update-eeprom in your device tree.
> >> There should also be an /dev/eeprom0.update-eeprom in barebox.
> > That seems right, when working the eeprom is written to on each boot.
> > But I could not find any references to *eep* inside barebox in any layer.
> 
> Does it come from the phytec git directly? Upstream barebox has this:
> https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.pengutronix.de%2Fcgit%2Fbarebox%2Ftree%2Farch%2Farm%2Fdts%2Fimx6qdl-phytec-state.dtsi%3Fh%3Dnextdata=01%7C01%7Chu.schlieben%40codewrights.de%7Cfd604ff2646c497fbb3508d79dbca678%7C0974af9b352b437cb606e9f242c0c227%7C0sdata=fXOQB7awFhPhxJmDAyN5ipLxe3W8IbAw3vp03GL1Y10%3Dreserved=0
> 
> I would imagine, yours does to. You can check in the yocto build directory.
> (If you have rm_work enabled, you might need RM_WORK_EXCLUDE += 
> "your-barebox-recipe"
> in your local.conf)
> 
> Also try of_dump /state inside of barebox to see the device tree node.
> 
> The reason, you haven't found it in the deploy/ device tree is that barebox 
> modifies the kernel device tree on loading and adds the state nodes to it.
> 
> >> if not, try executing the drvinfo command and see if the driver has probed 
> >> the EEPROM.
>  Looks like the state node is missing in your device tree.
> 
> Do you have the state driver enabled? drvinfo should tell you that.
> 
> Cheers
> Ahmad
> 
> -- 
> Pengutronix e.K.   | |
> Steuerwalder Str. 21   | 
> https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.pengutronix.de%2Fdata=01%7C01%7Chu.schlieben%40codewrights.de%7Cfd604ff2646c497fbb3508d79dbca678%7C0974af9b352b437cb606e9f242c0c227%7C0sdata=Edh9RArsjllc2C5LSvixIndwBoKZfMY0dnbLT2NdE1w%3Dreserved=0
>   |
> 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] Partly revert "globalvar: fix crash if CONFIG_NVVAR is not set"

2020-01-21 Thread Christian Eggers
This partly reverts commit 804770590556be5c922c9fb7e779e72805911e57.

Checking for CONFIG_NVVAR is not required in nvvar_device_dispatch() as
nv_device is not used in this function (only the address is compared).

After fixing this, globalvar_simple_set() works again if CONFIG_NVVAR is
disabled.

Fixes: 8047705905 ("globalvar: fix crash if CONFIG_NVVAR is not set")
Signed-off-by: Christian Eggers 
---
 common/globalvar.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index 1bea7425d..cec0a9cc4 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -141,9 +141,6 @@ static int nvvar_device_dispatch(const char *name, struct 
device_d **dev,
const char *dot;
int dotpos;
 
-   if (!IS_ENABLED(CONFIG_NVVAR))
-   return -ENOSYS;
-
*dev = NULL;
 
if (strncmp(name, "dev.", 4))
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; 
Markus Zeiler


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


Re: [RFC PATCH 0/7] usb: dwc2 host driver

2020-01-21 Thread Michael Grzeschik
Hi Jules,

On Thu, Jan 16, 2020 at 06:25:08PM +0100, Jules Maselbas wrote:
> On Thu, Jan 16, 2020 at 07:50:27AM +0100, Sascha Hauer wrote:
> > 
> > Well, USB gadget support would be a strong argument for your version ;)
> I am going to send a new version for the host driver alongside the gadget
> support. I've made few cleanup (in both host and gadget driver). Although
> there is still some stub functions in the gadget driver, I think is this
> a good start.

I did not get this conversation and also started the gadget support on
dwc2. My target machine is stm32, so my work includes also the internal
stm32 phy and some regulators, to get this done. I could rework this on
top of your patches, if you send them on the list.

Regards,
Michael

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] globalvar: Select CONFIG_PARAMETER

2020-01-21 Thread Christian Eggers
Without CONFIG_PARAMETER, __nvar_add() will always fail.

Signed-off-by: Christian Eggers 
---
 common/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/Kconfig b/common/Kconfig
index 60237d305..c2ec995f1 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -166,6 +166,7 @@ config GLOBALVAR
bool "global environment variables support"
default y if !SHELL_NONE
select FNMATCH
+   select PARAMETER
help
  Global environment variables begin with "global.". Unlike normal
  shell variables they have the same values in all contexts. Global
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; 
Markus Zeiler


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


[PATCH 2/3] usb: otg: Select CONFIG_PARAMETER

2020-01-21 Thread Christian Eggers
Without CONFIG_PARAMETER, usb_register_otg_device() will always fail.

Signed-off-by: Christian Eggers 
---
 drivers/usb/otg/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index 2c094452b..20b4d7f8c 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -9,4 +9,5 @@ config USB_TWL4030
 
 config USB_OTGDEV
bool
+   select PARAMETER
 
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; 
Markus Zeiler


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


[PATCH 1/3] watchdog: Select CONFIG_PARAMETER

2020-01-21 Thread Christian Eggers
Without CONFIG_PARAMETER, watchdog_register() will always fail.

Signed-off-by: Christian Eggers 
---
 drivers/watchdog/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 45dd41a2a..34b7fea39 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -4,6 +4,7 @@ config WATCHDOG_IMX_RESET_SOURCE
 
 menuconfig WATCHDOG
bool "Watchdog support"
+   select PARAMETER
help
  Many platforms support a watchdog to keep track of a working machine.
  This framework provides routines to handle these watchdogs.
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; 
Markus Zeiler


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


Re: Configuring for secure boot

2020-01-21 Thread Sascha Hauer
On Tue, Jan 21, 2020 at 11:52:02AM +0100, Ahmad Fatoum wrote:
> Hello,
> 
> On 1/20/20 8:53 PM, Sascha Hauer wrote:
> > Disabling the shell entirely with CONFIG_SHELL_NONE is the best you can
> > do. This also forces you to program your boot process in C which helps
> > you to get a well defined boot without diving into potentially unsafe
> > shell commands.
> > 
> > To state the obvious, you have to enable HAB support, sign your barebox
> > images and burn the necessary fuses to forbid loading unsigned images.
> 
> I think it would be great to have a CONFIG_LOCKDOWN option that has inverse
> dependencies on the stuff that should not be enabled and normal dependencies
> on the stuff that should be. Such a CONFIG_LOCKDOWN barebox can then be used 
> in
> secure boot scenarios or for fuzzing efforts.
> 
> Thoughts?

I don't think this is feasible. There are too many different expectations
what is secure and what is not. loadenv/saveenv might be desired at some
point (at least when we add signing support), for others it's a no-go.
Some accept the potential security risk of having a shell, others don't.
You might want to build a device which can boot in a secure mode with
signed kernels only, or alternatively any other kernel after dropping
the security privileges in the CAAM or whatever. That's just some
examples off the top of my head, there are surely more.

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
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] watchdog: Fix error path

2020-01-21 Thread Christian Eggers
In case of an error (e.g. dev_add_param_tristate_ro() returns -ENOSYS),
device registration must be reverted.

Signed-off-by: Christian Eggers 
---
 drivers/watchdog/wd_core.c | 30 +-
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/wd_core.c b/drivers/watchdog/wd_core.c
index b6e2a37b1..34040408f 100644
--- a/drivers/watchdog/wd_core.c
+++ b/drivers/watchdog/wd_core.c
@@ -171,8 +171,10 @@ int watchdog_register(struct watchdog *wd)
return ret;
 
p = dev_add_param_tristate_ro(>dev, "running", >running);
-   if (IS_ERR(p))
-   return PTR_ERR(p);
+   if (IS_ERR(p)) {
+   ret = PTR_ERR(p);
+   goto error_unregister;
+   }
 
if (!wd->priority)
wd->priority = dev_get_watchdog_priority(wd->hwdev);
@@ -180,8 +182,10 @@ int watchdog_register(struct watchdog *wd)
p = dev_add_param_uint32(>dev, "priority",
 watchdog_set_priority, NULL,
 >priority, "%u", wd);
-   if (IS_ERR(p))
-   return PTR_ERR(p);
+   if (IS_ERR(p)) {
+   ret = PTR_ERR(p);
+   goto error_unregister;
+   }
 
/* set some default sane value */
if (!wd->timeout_max)
@@ -189,8 +193,10 @@ int watchdog_register(struct watchdog *wd)
 
p = dev_add_param_uint32_ro(>dev, "timeout_max",
>timeout_max, "%u");
-   if (IS_ERR(p))
-   return PTR_ERR(p);
+   if (IS_ERR(p)) {
+   ret = PTR_ERR(p);
+   goto error_unregister;
+   }
 
if (IS_ENABLED(CONFIG_WATCHDOG_POLLER)) {
if (!wd->poller_timeout_cur ||
@@ -199,12 +205,14 @@ int watchdog_register(struct watchdog *wd)
 
p = dev_add_param_uint32(>dev, "timeout_cur", 
watchdog_set_cur,
NULL, >poller_timeout_cur, "%u", wd);
-   if (IS_ERR(p))
-   return PTR_ERR(p);
+   if (IS_ERR(p)) {
+   ret = PTR_ERR(p);
+   goto error_unregister;
+   }
 
ret = watchdog_register_poller(wd);
if (ret)
-   return ret;
+   goto error_unregister;
}
 
list_add_tail(>list, _list);
@@ -213,6 +221,10 @@ int watchdog_register(struct watchdog *wd)
wd->priority);
 
return 0;
+
+error_unregister:
+   unregister_device(>dev);
+   return ret;
 }
 EXPORT_SYMBOL(watchdog_register);
 
-- 
Christian Eggers
Embedded software developer

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRA 57918
Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: 
HRB 54477
Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; 
Markus Zeiler


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


Re: Configuring for secure boot

2020-01-21 Thread Ahmad Fatoum
Hello,

On 1/20/20 8:53 PM, Sascha Hauer wrote:
> Disabling the shell entirely with CONFIG_SHELL_NONE is the best you can
> do. This also forces you to program your boot process in C which helps
> you to get a well defined boot without diving into potentially unsafe
> shell commands.
> 
> To state the obvious, you have to enable HAB support, sign your barebox
> images and burn the necessary fuses to forbid loading unsigned images.

I think it would be great to have a CONFIG_LOCKDOWN option that has inverse
dependencies on the stuff that should not be enabled and normal dependencies
on the stuff that should be. Such a CONFIG_LOCKDOWN barebox can then be used in
secure boot scenarios or for fuzzing efforts.

Thoughts?

> 
> Sascha
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
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] param: Make enum param_tristate always visible

2020-01-21 Thread Christian Eggers
When disabling CONFIG_SHELL_HUSH, also CONFIG_PARAMETER may be disabled.
In this case, the definition "enum param_tristate" is not reachable from
watchdog.h.

I also considered moving almost everything in watchdog.h inside the
CONFIG_WATCHDOG guard. But this doesn't work for me because
drivers/watchdog/imxwd.c can also be built without CONFIG_WATCHDOG.

Signed-off-by: Christian Eggers 
---
 @Sascha: I've asked my IT department to stop modifiying my patch
emails. I hope the mails are ok now.

 include/param.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/param.h b/include/param.h
index d75f50ea3..f1166eb28 100644
--- a/include/param.h
+++ b/include/param.h
@@ -37,6 +37,8 @@ struct param_d {
enum param_type type;
 };
 
+enum param_tristate { PARAM_TRISTATE_UNKNOWN, PARAM_TRISTATE_TRUE, 
PARAM_TRISTATE_FALSE };
+
 #ifdef CONFIG_PARAMETER
 const char *get_param_type(struct param_d *param);
 const char *dev_get_param(struct device_d *dev, const char *name);
@@ -63,8 +65,6 @@ struct param_d *dev_add_param_enum(struct device_d *dev, 
const char *name,
int (*get)(struct param_d *p, void *priv),
int *value, const char * const *names, int max, void *priv);
 
-enum param_tristate { PARAM_TRISTATE_UNKNOWN, PARAM_TRISTATE_TRUE, 
PARAM_TRISTATE_FALSE };
-
 struct param_d *dev_add_param_tristate(struct device_d *dev, const char *name,
int (*set)(struct param_d *p, void *priv),
int (*get)(struct param_d *p, void *priv),
-- 
2.16.4


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