Howto read file to a VAR
Some message saved to envfs under linux, And when reboot Barebox would check it. So I must read the file's content to a shell VAR, Can barebox do it use a shell script? -- Best Regards, zzs ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] partitions: dos: improve guess of disk size
On Fri, Nov 08, 2013 at 01:50:37AM +0100, Uwe Kleine-König wrote: > On Fri, Nov 08, 2013 at 01:16:31AM +0100, Uwe Kleine-König wrote: > > The code used to ineffectively take the end of the last partition as guess > > for the disk size. Better use the end of the partition that has its end > > rearmost. > > > > Also return an unsigned type instead of int as the result is always > > non-negative. > > > > Signed-off-by: Uwe Kleine-König > > --- > > Hello, > > > > note this is only compile tested. > ... and the introduced warning ignored. I really shouldn't send patches > out that late ... > hehe, I know what you mean. :-) - Alex ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] partitions: dos: parse extended partition
Hello, On Fri, Nov 08, 2013 at 01:17:26AM +0100, Uwe Kleine-König wrote: > DOS MBRs might contain an extended partition that holds several logical > partitions. Add these to the partitions of the block device. > > Signed-off-by: Uwe Kleine-König > --- > common/partitions/dos.c | 76 > - > 1 file changed, 75 insertions(+), 1 deletion(-) This even fails to build. See below. > diff --git a/common/partitions/dos.c b/common/partitions/dos.c > index 1d8213b..f907abc 100644 > --- a/common/partitions/dos.c > +++ b/common/partitions/dos.c > [...] > @@ -129,6 +181,7 @@ static void dos_partition(void *buf, struct block_device > *blk, > [...] > + dev_warn(blk->dev, "Skipping additional > extended partition\n"); > + } > + > } else { > dev_dbg(blk->dev, "Skipping empty partition %d\n", i); > } > } > > + if (first_extended_partition) s/first_// > + dos_extended_partition(blk, pd, extended_partition); > + > dsp = xzalloc(sizeof(*dsp)); > dsp->blk = blk; > Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] partitions: dos: improve guess of disk size
On Fri, Nov 08, 2013 at 01:16:31AM +0100, Uwe Kleine-König wrote: > The code used to ineffectively take the end of the last partition as guess > for the disk size. Better use the end of the partition that has its end > rearmost. > > Also return an unsigned type instead of int as the result is always > non-negative. > > Signed-off-by: Uwe Kleine-König > --- > Hello, > > note this is only compile tested. ... and the introduced warning ignored. I really shouldn't send patches out that late ... see below > --- a/common/partitions/dos.c > +++ b/common/partitions/dos.c > @@ -27,19 +27,23 @@ > * @param table partition table > * @return sector count > */ > -static int disk_guess_size(struct device_d *dev, struct partition_entry > *table) > +static uint64_t disk_guess_size(struct device_d *dev, > + struct partition_entry *table) > { > uint64_t size = 0; > int i; > > for (i = 0; i < 4; i++) { > - if (table[i].partition_start != 0) { > - size += get_unaligned_le32(&table[i].partition_start) - > size; > - size += get_unaligned_le32(&table[i].partition_size); > + if (get_unaligned_le32(table[i].partition_start) != 0) { There is an & missing before table. Best regards Uwe > + uint64_t part_end = > get_unaligned_le32(&table[i].partition_start) + > + get_unaligned_le32(&table[i].partition_size); > + > + if (size < part_end) > + size = part_end; > } > } > > - return (int)size; > + return size; > } > > static void *read_mbr(struct block_device *blk) -- Pengutronix e.K. | Uwe Kleine-König| Industrial Linux Solutions | http://www.pengutronix.de/ | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] partitions: dos: parse extended partition
DOS MBRs might contain an extended partition that holds several logical partitions. Add these to the partitions of the block device. Signed-off-by: Uwe Kleine-König --- common/partitions/dos.c | 76 - 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 1d8213b..f907abc 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -116,12 +116,64 @@ static int dos_get_disk_signature(struct param_d *p, void *_priv) return 0; } +static void dos_extended_partition(struct block_device *blk, struct partition_desc *pd, + struct partition *partition) +{ + uint8_t *buf = dma_alloc(SECTOR_SIZE); + uint32_t ebr_sector = partition->first_sec; + struct partition_entry *table = (struct partition_entry *)&buf[0x1be]; + + while (pd->used_entries < ARRAY_SIZE(pd->parts)) { + int rc, i; + int n = pd->used_entries; + + dev_dbg(blk->dev, "expect EBR in sector %x\n", ebr_sector); + + rc = block_read(blk, buf, ebr_sector, 1); + if (rc != 0) { + dev_err(blk->dev, "Cannot read EBR partition table\n"); + goto out; + } + + /* sanity checks */ + if (buf[0x1fe] != 0x55 || buf[0x1ff] != 0xaa) { + dev_err(blk->dev, "sector %x doesn't contain an EBR signature\n"); + goto out; + } + + for (i = 0x1de; i < 0x1fe; ++i) + if (buf[i]) { + dev_err(blk->dev, "EBR's third or fourth partition non-empty\n"); + goto out; + } + /* /sanity checks */ + + /* the first entry defines the extended partition */ + pd->parts[n].first_sec = ebr_sector + + get_unaligned_le32(&table[0].partition_start); + pd->parts[n].size = get_unaligned_le32(&table[0].partition_size); + pd->parts[n].dos_partition_type = table[0].type; + pd->used_entries++; + + /* the second entry defines the start of the next ebr if != 0 */ + if (get_unaligned_le32(&table[1].partition_start)) + ebr_sector = partition->first_sec + + get_unaligned_le32(&table[1].partition_start); + else + break; + } + +out: + dma_free(buf); + return; +} + /** * Check if a DOS like partition describes this block device * @param blk Block device to register to * @param pd Where to store the partition information * - * It seems at least on ARM this routine canot use temp. stack space for the + * It seems at least on ARM this routine cannot use temp. stack space for the * sector. So, keep the malloc/free. */ static void dos_partition(void *buf, struct block_device *blk, @@ -129,6 +181,7 @@ static void dos_partition(void *buf, struct block_device *blk, { struct partition_entry *table; struct partition pentry; + struct partition *extended_partition = NULL; uint8_t *buffer = buf; int i; struct disk_signature_priv *dsp; @@ -150,11 +203,32 @@ static void dos_partition(void *buf, struct block_device *blk, pd->parts[n].size = pentry.size; pd->parts[n].dos_partition_type = pentry.dos_partition_type; pd->used_entries++; + /* +* Partitions of type 0x05 and 0x0f (and some more) +* contain extended partitions. Only check for type 0x0f +* here as this is the easiest to parse and common +* enough. +*/ + if (pentry.dos_partition_type == 0x0f) { + if (!extended_partition) + extended_partition = &pd->parts[n]; + else + /* +* An DOS MBR must only contain a single +* extended partition. Just ignore all +* but the first. +*/ + dev_warn(blk->dev, "Skipping additional extended partition\n"); + } + } else { dev_dbg(blk->dev, "Skipping empty partition %d\n", i); } } + if (first_extended_partition) + dos_extended_partition(blk, pd, extended_partition); + dsp = xzalloc(sizeof(*dsp)); dsp->blk = blk; -- 1.8.4.rc3 ___
[PATCH] partitions: dos: improve guess of disk size
The code used to ineffectively take the end of the last partition as guess for the disk size. Better use the end of the partition that has its end rearmost. Also return an unsigned type instead of int as the result is always non-negative. Signed-off-by: Uwe Kleine-König --- Hello, note this is only compile tested. Best regards Uwe common/partitions/dos.c | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 9afd122..1d8213b 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -27,19 +27,23 @@ * @param table partition table * @return sector count */ -static int disk_guess_size(struct device_d *dev, struct partition_entry *table) +static uint64_t disk_guess_size(struct device_d *dev, + struct partition_entry *table) { uint64_t size = 0; int i; for (i = 0; i < 4; i++) { - if (table[i].partition_start != 0) { - size += get_unaligned_le32(&table[i].partition_start) - size; - size += get_unaligned_le32(&table[i].partition_size); + if (get_unaligned_le32(table[i].partition_start) != 0) { + uint64_t part_end = get_unaligned_le32(&table[i].partition_start) + + get_unaligned_le32(&table[i].partition_size); + + if (size < part_end) + size = part_end; } } - return (int)size; + return size; } static void *read_mbr(struct block_device *blk) -- 1.8.4.rc3 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] partitions: dos: don't open code get_unaligned_le32
Signed-off-by: Uwe Kleine-König --- Hello, note this is only compile tested. Best regards Uwe common/partitions/dos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 31b1ed6..9afd122 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -105,7 +105,7 @@ static int dos_get_disk_signature(struct param_d *p, void *_priv) if (!buf) return -EIO; - priv->signature = le32_to_cpup((__le32 *)(buf + 0x1b8)); + priv->signature = get_unaligned_le32(buf + 0x1b8); free(buf); -- 1.8.4.rc3 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] blspec: fix documention of blspec_scan_directory's return code
Signed-off-by: Uwe Kleine-König --- common/blspec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/common/blspec.c b/common/blspec.c index 095809b..2244d5a 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -135,8 +135,7 @@ static int blspec_have_entry(struct blspec *blspec, const char *path) * * Given a root path collects all blspec entries found under /blspec/entries/. * - * returns 0 if at least one entry could be successfully loaded, negative - * error value otherwise. + * returns the number of entries found or a negative error value otherwise. */ int blspec_scan_directory(struct blspec *blspec, const char *root) { -- 1.8.4.rc3 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] mci: mxs: support overwriting the device name via platform data
The current implementation of the bootloader specification depends on the hardware name and the name of the device in /dev to match. As the default hardware name is mciX and the device name is diskY the bootloader spec cannot be used as is. This patch implements a way to overwrite the device name similar to what is possible for the imx-esdhc driver. Signed-off-by: Uwe Kleine-König --- Notes: Changes since (implicit) v1, sent with Message-Id: 1383821462-29348-1-git-send-email-u.kleine-koe...@pengutronix.de: - don't check for pd->devname being non-NULL before assigment as suggested by Jean-Christophe. arch/arm/mach-mxs/include/mach/mci.h | 1 + drivers/mci/mxs.c| 1 + include/mci.h| 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mxs/include/mach/mci.h b/arch/arm/mach-mxs/include/mach/mci.h index 4faab37..c47c24c 100644 --- a/arch/arm/mach-mxs/include/mach/mci.h +++ b/arch/arm/mach-mxs/include/mach/mci.h @@ -15,6 +15,7 @@ #define __MACH_MMC_H struct mxs_mci_platform_data { + const char *devname; unsigned caps; /**< supported operating modes (MMC_MODE_*) */ unsigned voltages; /**< supported voltage range (MMC_VDD_*) */ unsigned f_min; /**< min operating frequency in Hz (0 -> no limit) */ diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c index 1b935f7..bf928e8 100644 --- a/drivers/mci/mxs.c +++ b/drivers/mci/mxs.c @@ -570,6 +570,7 @@ static int mxs_mci_probe(struct device_d *hw_dev) /* feed forward the platform specific values */ host->voltages = pd->voltages; host->host_caps = pd->caps; + host->devname = pd->devname; mxs_mci->clk = clk_get(hw_dev, NULL); if (IS_ERR(mxs_mci->clk)) diff --git a/include/mci.h b/include/mci.h index 07ac273..0f10e8a 100644 --- a/include/mci.h +++ b/include/mci.h @@ -286,7 +286,7 @@ struct mci; struct mci_host { struct device_d *hw_dev;/**< the host MCI hardware device */ struct mci *mci; - char *devname; /**< the devicename for the card, defaults to disk%d */ + const char *devname;/**< the devicename for the card, defaults to disk%d */ unsigned voltages; unsigned host_caps; /**< Host's interface capabilities, refer MMC_VDD_* */ unsigned f_min; /**< host interface lower limit */ -- 1.8.4.rc3 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] mci: mxs: support overwriting the device name via platform data
On 11:51 Thu 07 Nov , Uwe Kleine-K??nig wrote: > The current implementation of the bootloader specification depends on the > hardware name and the name of the device in /dev to match. As the default > hardware name is mciX and the device name is diskY the bootloader spec > cannot be used as is. > > This patch implements a way to overwrite the device name similar to what is > possible for the imx-esdhc driver. > > Signed-off-by: Uwe Kleine-König > --- > arch/arm/mach-mxs/include/mach/mci.h | 1 + > drivers/mci/mxs.c| 3 +++ > include/mci.h| 2 +- > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/mach-mxs/include/mach/mci.h > b/arch/arm/mach-mxs/include/mach/mci.h > index 4faab37..c47c24c 100644 > --- a/arch/arm/mach-mxs/include/mach/mci.h > +++ b/arch/arm/mach-mxs/include/mach/mci.h > @@ -15,6 +15,7 @@ > #define __MACH_MMC_H > > struct mxs_mci_platform_data { > + const char *devname; > unsigned caps; /**< supported operating modes (MMC_MODE_*) */ > unsigned voltages; /**< supported voltage range (MMC_VDD_*) */ > unsigned f_min; /**< min operating frequency in Hz (0 -> no limit) */ > diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c > index 1b935f7..52d0656 100644 > --- a/drivers/mci/mxs.c > +++ b/drivers/mci/mxs.c > @@ -571,6 +571,9 @@ static int mxs_mci_probe(struct device_d *hw_dev) > host->voltages = pd->voltages; > host->host_caps = pd->caps; > > + if (pd->devname) > + host->devname = pd->devname; why bother to test it? Best Regards, J. ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [SPAM] [PATCH 2/3] FPGA: add a programming command
On Nov 7, 2013, at 10:37 PM, Lucas Stach wrote: > Am Donnerstag, den 07.11.2013, 15:37 +0100 schrieb Jean-Christophe > PLAGNIOL-VILLARD: >> On 12:09 Thu 07 Nov , Sascha Hauer wrote: >>> On Thu, Nov 07, 2013 at 11:04:56AM +0100, Jean-Christophe PLAGNIOL-VILLARD >>> wrote: Hi, I really do not like it we need to have an API to load firmware same a Linux >>> >>> The firmware loading mechanism in Linux is driven by the driver >>> requesting a firmware. This is appropriate for WiFi drivers which can't >>> continue without a firmware. For FPGAs which can be loaded, unloaded, or >>> even partially loaded, it's the user that should trigger firmware >>> loading, not the driver. >>> >>> Also, in barebox a user should decide if and when a firmware is loaded. >>> We have cases where a single board requires different Firmwares >>> depending on bootstrapping. In this case You don't want to have fixed >>> firmware names. >>> >>> So no, the Linux Firmware model is not suitable for barebox (it sucks >>> for Linux aswell in many cases). >> >> and command is horrible as you need to known the protocol which you do not >> care >> >> you just need to known the fpga device and firmware you want to use >> >> then the fpga driver will handle >> > Did you take the time to read the patches? > > From a user perspective you only specify which FPGA you want to program > and tell the command which firmware file to use. The protocol and other > lowlevel stuff is taken care of in the handler. yes I did but the issue is that you need to use a command instead just simply set a parameter to the fpga device that why I hate the idea of command you use the device to set the firmware you want Best Regards, J. > > Regards, > Lucas > -- > Pengutronix e.K. | Lucas Stach | > Industrial Linux Solutions | http://www.pengutronix.de/ | > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | > ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [SPAM] [PATCH 2/3] FPGA: add a programming command
Am Donnerstag, den 07.11.2013, 15:37 +0100 schrieb Jean-Christophe PLAGNIOL-VILLARD: > On 12:09 Thu 07 Nov , Sascha Hauer wrote: > > On Thu, Nov 07, 2013 at 11:04:56AM +0100, Jean-Christophe PLAGNIOL-VILLARD > > wrote: > > > Hi, > > > > > > I really do not like it > > > > > > we need to have an API to load firmware same a Linux > > > > The firmware loading mechanism in Linux is driven by the driver > > requesting a firmware. This is appropriate for WiFi drivers which can't > > continue without a firmware. For FPGAs which can be loaded, unloaded, or > > even partially loaded, it's the user that should trigger firmware > > loading, not the driver. > > > > Also, in barebox a user should decide if and when a firmware is loaded. > > We have cases where a single board requires different Firmwares > > depending on bootstrapping. In this case You don't want to have fixed > > firmware names. > > > > So no, the Linux Firmware model is not suitable for barebox (it sucks > > for Linux aswell in many cases). > > and command is horrible as you need to known the protocol which you do not > care > > you just need to known the fpga device and firmware you want to use > > then the fpga driver will handle > Did you take the time to read the patches? >From a user perspective you only specify which FPGA you want to program and tell the command which firmware file to use. The protocol and other lowlevel stuff is taken care of in the handler. Regards, Lucas -- Pengutronix e.K. | Lucas Stach | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5076 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917- | ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [SPAM] [PATCH 2/3] FPGA: add a programming command
On 12:09 Thu 07 Nov , Sascha Hauer wrote: > On Thu, Nov 07, 2013 at 11:04:56AM +0100, Jean-Christophe PLAGNIOL-VILLARD > wrote: > > Hi, > > > > I really do not like it > > > > we need to have an API to load firmware same a Linux > > The firmware loading mechanism in Linux is driven by the driver > requesting a firmware. This is appropriate for WiFi drivers which can't > continue without a firmware. For FPGAs which can be loaded, unloaded, or > even partially loaded, it's the user that should trigger firmware > loading, not the driver. > > Also, in barebox a user should decide if and when a firmware is loaded. > We have cases where a single board requires different Firmwares > depending on bootstrapping. In this case You don't want to have fixed > firmware names. > > So no, the Linux Firmware model is not suitable for barebox (it sucks > for Linux aswell in many cases). and command is horrible as you need to known the protocol which you do not care you just need to known the fpga device and firmware you want to use then the fpga driver will handle Best Regards, J. > > Sascha > > -- > 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: [SPAM] [PATCH 2/3] FPGA: add a programming command
On Thu, Nov 07, 2013 at 11:04:56AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote: > Hi, > > I really do not like it > > we need to have an API to load firmware same a Linux The firmware loading mechanism in Linux is driven by the driver requesting a firmware. This is appropriate for WiFi drivers which can't continue without a firmware. For FPGAs which can be loaded, unloaded, or even partially loaded, it's the user that should trigger firmware loading, not the driver. Also, in barebox a user should decide if and when a firmware is loaded. We have cases where a single board requires different Firmwares depending on bootstrapping. In this case You don't want to have fixed firmware names. So no, the Linux Firmware model is not suitable for barebox (it sucks for Linux aswell in many cases). Sascha -- 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] mci: mxs: support overwriting the device name via platform data
The current implementation of the bootloader specification depends on the hardware name and the name of the device in /dev to match. As the default hardware name is mciX and the device name is diskY the bootloader spec cannot be used as is. This patch implements a way to overwrite the device name similar to what is possible for the imx-esdhc driver. Signed-off-by: Uwe Kleine-König --- arch/arm/mach-mxs/include/mach/mci.h | 1 + drivers/mci/mxs.c| 3 +++ include/mci.h| 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mxs/include/mach/mci.h b/arch/arm/mach-mxs/include/mach/mci.h index 4faab37..c47c24c 100644 --- a/arch/arm/mach-mxs/include/mach/mci.h +++ b/arch/arm/mach-mxs/include/mach/mci.h @@ -15,6 +15,7 @@ #define __MACH_MMC_H struct mxs_mci_platform_data { + const char *devname; unsigned caps; /**< supported operating modes (MMC_MODE_*) */ unsigned voltages; /**< supported voltage range (MMC_VDD_*) */ unsigned f_min; /**< min operating frequency in Hz (0 -> no limit) */ diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c index 1b935f7..52d0656 100644 --- a/drivers/mci/mxs.c +++ b/drivers/mci/mxs.c @@ -571,6 +571,9 @@ static int mxs_mci_probe(struct device_d *hw_dev) host->voltages = pd->voltages; host->host_caps = pd->caps; + if (pd->devname) + host->devname = pd->devname; + mxs_mci->clk = clk_get(hw_dev, NULL); if (IS_ERR(mxs_mci->clk)) return PTR_ERR(mxs_mci->clk); diff --git a/include/mci.h b/include/mci.h index 1ca00c7..72729b6 100644 --- a/include/mci.h +++ b/include/mci.h @@ -286,7 +286,7 @@ struct mci; struct mci_host { struct device_d *hw_dev;/**< the host MCI hardware device */ struct mci *mci; - char *devname; /**< the devicename for the card, defaults to disk%d */ + const char *devname;/**< the devicename for the card, defaults to disk%d */ unsigned voltages; unsigned host_caps; /**< Host's interface capabilities, refer MMC_VDD_* */ unsigned f_min; /**< host interface lower limit */ -- 1.8.4.rc3 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] blspec: Fix another crash with menu disabled
boot -l crashes with CONFIG_MENU disabled because blspec_alloc returns with blspec->menu being NULL in this case. So guard the usage of blspec->menu accordingly. Signed-off-by: Uwe Kleine-König --- commands/boot.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/commands/boot.c b/commands/boot.c index 8105889..cce4c30 100644 --- a/commands/boot.c +++ b/commands/boot.c @@ -87,7 +87,10 @@ static struct blspec *bootentries_collect(void) struct blspec *blspec; blspec = blspec_alloc(); - blspec->menu->display = asprintf("boot"); + + if (IS_ENABLED(CONFIG_MENU)) + blspec->menu->display = asprintf("boot"); + bootsources_menu_env_entries(blspec); if (IS_ENABLED(CONFIG_BLSPEC)) blspec_scan_devices(blspec); -- 1.8.4.rc3 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [SPAM] [PATCH 2/3] FPGA: add a programming command
Hi, I really do not like it we need to have an API to load firmware same a Linux and then provide the file name to the dev via params Best Regards, J. On 15:24 Wed 06 Nov , Juergen Beisert wrote: > This command is a simple frontend to the FPGA programming handler manager. > > Signed-off-by: Juergen Beisert > --- > commands/Kconfig| 10 + > commands/Makefile | 1 + > commands/fpgaload.c | 117 > > 3 files changed, 128 insertions(+) > create mode 100644 commands/fpgaload.c > > diff --git a/commands/Kconfig b/commands/Kconfig > index 9738ec4..bb4ccaf 100644 > --- a/commands/Kconfig > +++ b/commands/Kconfig > @@ -605,6 +605,16 @@ config CMD_BAREBOX_UPDATE > select BAREBOX_UPDATE > prompt "barebox-update" > > +config CMD_FPGALOAD > + bool > + select FPGAMANAGER > + prompt "fpgaload" > + help > + Provides the "fpgaload" command which deals with FPGA firmware to > + download it into an FPGA device. This command uses the FPGA manager > + framework to hide the details about how program a specific FPGA > + device. > + > config CMD_TIMEOUT > tristate > prompt "timeout" > diff --git a/commands/Makefile b/commands/Makefile > index 58d27fa..864ca0c 100644 > --- a/commands/Makefile > +++ b/commands/Makefile > @@ -93,3 +93,4 @@ obj-$(CONFIG_CMD_MIITOOL) += miitool.o > obj-$(CONFIG_CMD_DETECT) += detect.o > obj-$(CONFIG_CMD_BOOT) += boot.o > obj-$(CONFIG_CMD_DEVINFO)+= devinfo.o > +obj-$(CONFIG_CMD_FPGALOAD) += fpgaload.o > diff --git a/commands/fpgaload.c b/commands/fpgaload.c > new file mode 100644 > index 000..677ff73 > --- /dev/null > +++ b/commands/fpgaload.c > @@ -0,0 +1,117 @@ > +/* > + * Copyright (c) 2013 Juergen Beisert , Pengutronix > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 > + * as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +static int fpgaload_write_data(struct fpga_mgr *mgr, const char *firmware) > +{ > + int fd, ret; > + struct stat s; > + size_t sz; > + unsigned char buffer[256]; /* must always be a multiple of 8 bytes! */ > + > + ret = stat(firmware, &s); > + if (ret != 0) { > + printf("Unable to access file '%s'\n", firmware); > + return -EINVAL; > + } > + > + fd = open(firmware, O_RDONLY); > + if (fd < 0) > + return fd; > + > + do { > + sz = read(fd, buffer, sizeof(buffer)); > + if (sz == 0) > + break; > + ret = fpgamgr_prog_fpga(mgr, buffer, sz); > + if (ret < 0) > + break; > + } while (1); > + > + close(fd); > + return 0; > +} > + > +static int do_fpgaload(int argc, char *argv[]) > +{ > + int ret, opt, index = -1; > + const char *name = NULL, *firmware; > + struct fpga_mgr *mgr; > + > + while ((opt = getopt(argc, argv, "t:i:l")) > 0) { > + switch (opt) { > + case 't': > + name = optarg; > + break; > + case 'i': > + index = simple_strtoul(optarg, NULL, 0); > + break; > + case 'l': > + printf("registered programming handlers:\n"); > + fpgamgr_handlers_list(); > + return 0; > + default: > + return COMMAND_ERROR_USAGE; > + } > + } > + > + if (!(argc - optind)) > + return COMMAND_ERROR_USAGE; > + > + firmware = argv[optind]; > + > + mgr = fpgamgr_find_handler(name, index); > + if (mgr == NULL) { > + printf("No such programming handler found\n"); > + return 1; > + } > + > + ret = fpgamgr_open_fpga(mgr); > + if (ret == -ENOSYS) { > + /* this might be a bug... */ > + pr_debug("No programming initiater function defined\n"); > + } > + > + ret = fpgaload_write_data(mgr, firmware); > + if (ret != 0) > + return 1; > + > + ret = fpgamgr_close_fpga(mgr); > + if (ret == -ENOSYS) { > + /* this might be a bug... */ > + pr_debug("No programming finisher function defined\n"); > + } > + > + return 0; > +} > + > +BAREBOX_CMD_HELP_START(fpgaload) > +BAREBOX_CMD_HELP_USAGE("fpgaload [OPTIONS] \n") > +BAREBOX_CMD_HELP_SHORT("Program a firmware file content into an FPGA\n") > +BAREBOX_CMD
Re: howto load/save envfs from linux
On Thu, 2013-11-07 at 17:08 +0800, zzs wrote: > My final user program is a linux program, It want to change > mac address of eth. > > So I must read and write back the data saved in envfs. > > Howto do that? You can enable compilation of the bareboxenv tool in menuconfig. That tool can read and write the envfs format from userspace. Regards, Jan -- 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
howto load/save envfs from linux
My final user program is a linux program, It want to change mac address of eth. So I must read and write back the data saved in envfs. Howto do that? -- Best Regards, zzs ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox