Re: suddenly, i can't boot barebox on my beagle xM anymore [ISOLATED]
Hi, On Sun, 2012-12-02 at 04:24 -0500, Robert P. J. Day wrote: > i've isolated the commit that introduces the apparent booting > problem on my xM: > > $ git show 154496f > commit 154496f736db54123c3f6daaba18809fab54ed9b > Merge: 05d251f bd6d12b > Author: Sascha Hauer > Date: Fri Nov 16 14:02:49 2012 +0100 > > Merge branch 'for-next/omap' *snip* > so something in that omap merge is causing this. The merge itself does not actually introduce new code. Could you try finding the commit with git bisect? ~/git/barebox $ git bisect start ~/git/barebox $ git bisect bad 154496f736db54123c3f6daaba18809fab54ed9b ~/git/barebox $ git bisect good 05d251f Bisecting: 3 revisions left to test after this (roughly 2 steps) [663c466794382f803a69414c935cf0a13d4f0761] ARM OMAP4 panda: switch to new environment ~/git/barebox $ Then test this checkout and tell git using "git bisect good" or "git bisect bad". Thanks, 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
Re: suddenly, i can't boot barebox on my beagle xM anymore [ISOLATED]
On Mon, 3 Dec 2012, Jan Lübbe wrote: > Hi, > > On Sun, 2012-12-02 at 04:24 -0500, Robert P. J. Day wrote: > > i've isolated the commit that introduces the apparent booting > > problem on my xM: > > > > $ git show 154496f > > commit 154496f736db54123c3f6daaba18809fab54ed9b > > Merge: 05d251f bd6d12b > > Author: Sascha Hauer > > Date: Fri Nov 16 14:02:49 2012 +0100 > > > > Merge branch 'for-next/omap' > > *snip* > > > so something in that omap merge is causing this. > > The merge itself does not actually introduce new code. > > Could you try finding the commit with git bisect? > > ~/git/barebox $ git bisect start > ~/git/barebox $ git bisect bad 154496f736db54123c3f6daaba18809fab54ed9b > ~/git/barebox $ git bisect good 05d251f > Bisecting: 3 revisions left to test after this (roughly 2 steps) > [663c466794382f803a69414c935cf0a13d4f0761] ARM OMAP4 panda: switch to new > environment > ~/git/barebox $ > > Then test this checkout and tell git using "git bisect good" or "git > bisect bad". *sigh* ... i *think* i figured out what's happening. in order to play with barebox on my xM, until recently, i'd done nothing more than create a single FAT partition on a micro SD card, put MLO and barebox.bin on it, put it in my xM, and let it boot. until that OMAP merge, it worked fine. as i read it, the new default environment for the xM *requires* a second (ext3) partition or the boot process simply hangs, am i reading that right? if that's true, how can i adjust that so i can once again just boot to barebox without having a kernel and root fs created yet? rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 3/5] mci: Allow to specify device name
On Fri, Nov 30, 2012 at 11:10:30AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote: > On 09:06 Fri 30 Nov , Sascha Hauer wrote: > > On Fri, Nov 30, 2012 at 05:57:32AM +0100, Jean-Christophe PLAGNIOL-VILLARD > > wrote: > > > On 20:02 Thu 29 Nov , Sascha Hauer wrote: > > > > When multiple MMC/SD cards are present in the system we often > > > > have to have persistent names to identify them during runtime. > > > > This patch allows to overwrite the devicename which is used. > > > > > > > > Signed-off-by: Sascha Hauer > > > > --- > > > > drivers/mci/mci-core.c | 10 +++--- > > > > include/mci.h |1 + > > > > 2 files changed, 8 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c > > > > index 942d126..6e556a8 100644 > > > > --- a/drivers/mci/mci-core.c > > > > +++ b/drivers/mci/mci-core.c > > > > @@ -1397,9 +1397,13 @@ static int mci_card_probe(struct mci *mci) > > > > mci->blk.dev = mci->mci_dev; > > > > mci->blk.ops = &mci_ops; > > > > > > > > - disknum = cdev_find_free_index("disk"); > > > > + if (host->devname) { > > > > + mci->blk.cdev.name = strdup(host->devname); > > > can you use is a based name not the name > > > > I don't understand this. What do you mean? > > > instead of disk0 mmc0 as exmaple You can pass "mmc0" directly as string if you want this. Either you want persistent names or not, passing a fixed name and then adding an index afterwards does not make sense IMO. 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: [PATCH 2/5] mci: Fix capacity calculation for high capacity MMC cards
On Thu, Nov 29, 2012 at 08:02:25PM +0100, Sascha Hauer wrote: > For these cards we have to calculate the size using the ext csd > sector count fields. > > Signed-off-by: Sascha Hauer > --- > drivers/mci/mci-core.c | 20 ++-- > 1 file changed, 14 insertions(+), 6 deletions(-) > > diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c > index 0d601e3..942d126 100644 > --- a/drivers/mci/mci-core.c > +++ b/drivers/mci/mci-core.c > @@ -758,14 +758,21 @@ static void mci_extract_card_capacity_from_csd(struct > mci *mci) > uint64_t csize, cmult; > > if (mci->high_capacity) { > - csize = (mci->csd[1] & 0x3f) << 16 | (mci->csd[2] & 0x) > >> 16; > - cmult = 8; > + if (IS_SD(mci)) { > + csize = UNSTUFF_BITS(mci->csd, 48, 22); > + mci->capacity = (1 + csize) << 10; > + } else { > + mci->capacity = mci->ext_csd[EXT_CSD_SEC_CNT] << 0 | > + mci->ext_csd[EXT_CSD_SEC_CNT + 1] << 8 | > + mci->ext_csd[EXT_CSD_SEC_CNT + 2] << 16 | > + mci->ext_csd[EXT_CSD_SEC_CNT + 3] << 24; > + } > } else { > - csize = (mci->csd[1] & 0x3ff) << 2 | (mci->csd[2] & 0xc000) > >> 30; > - cmult = (mci->csd[2] & 0x00038000) >> 15; > + cmult = UNSTUFF_BITS(mci->csd, 47, 3); > + csize = UNSTUFF_BITS(mci->csd, 62, 12); > + mci->capacity = (csize + 1) << (cmult + 2); > } > > - mci->capacity = (csize + 1) << (cmult + 2); > mci->capacity *= mci->read_bl_len; > dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> > 20)); > } > @@ -996,7 +1003,6 @@ static int mci_startup(struct mci *mci) > mci_detect_version_from_csd(mci); > mci_extract_max_tran_speed_from_csd(mci); > mci_extract_block_lengths_from_csd(mci); > - mci_extract_card_capacity_from_csd(mci); > > /* sanitiy? */ > if (mci->read_bl_len > SECTOR_SIZE) { > @@ -1032,6 +1038,8 @@ static int mci_startup(struct mci *mci) > if (err) > return err; > > + mci_extract_card_capacity_from_csd(mci); > + > /* Restrict card's capabilities by what the host can do */ > mci->card_caps &= host->host_caps; Here's a fixup patch for this one: -- >From 67947f2d47a752e3c96bc6e29f92459e19e2eab2 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 29 Nov 2012 16:46:19 +0100 Subject: [PATCH] fixup! mci: Fix capacity calculation for high capacity MMC cards commit bbcf96113 moved the size calculation further down, but this has the effect that the size of cards with block sizes > 512 bytes is no longer correct. This is because barebox limits the blocksize to 512 bytes. To fix this use the blocksize value from the csd, not the barebox one. This is broken since: | commit bbcf961133e0d8ddf016ed698724d0ec8d7fd6b8 | Author: Sascha Hauer | Date: Thu Nov 29 16:48:19 2012 +0100 | |mci: Fix capacity calculation for high capacity MMC cards | |For these cards we have to calculate the size using the ext csd |sector count fields. | Signed-off-by: Sascha Hauer --- drivers/mci/mci-core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c index 6e556a8..4957256 100644 --- a/drivers/mci/mci-core.c +++ b/drivers/mci/mci-core.c @@ -773,7 +773,7 @@ static void mci_extract_card_capacity_from_csd(struct mci *mci) mci->capacity = (csize + 1) << (cmult + 2); } - mci->capacity *= mci->read_bl_len; + mci->capacity *= 1 << UNSTUFF_BITS(mci->csd, 80, 4);; dev_dbg(mci->mci_dev, "Capacity: %u MiB\n", (unsigned)(mci->capacity >> 20)); } -- 1.7.10.4 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] MIPS: fix out-of-tree build
On Fri, Nov 30, 2012 at 06:53:53AM +0400, Antony Pavlov wrote: > The commit > > commit d25d94bea67308e29db895d418f3f1f8153ae2ea > Author: Antony Pavlov > Date: Fri Jun 1 13:23:20 2012 +0400 > > MIPS: make possible board-specific header files > > This patch makes possible to put a board-specific > header file (e. g. foobar.h) to arch/mips/boards/*/include/board/. > > breaks the out-of-tree build for the boards that use it (rzx50). Applied, thanks Sascha > > Reported-by: Jean-Christophe PLAGNIOL-VILLARD > Signed-off-by: Antony Pavlov > Cc: Jean-Christophe PLAGNIOL-VILLARD > --- > arch/mips/Makefile |8 ++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/mips/Makefile b/arch/mips/Makefile > index 5e40de7..f32089d 100644 > --- a/arch/mips/Makefile > +++ b/arch/mips/Makefile > @@ -88,14 +88,18 @@ else > BOARD := > endif > > +ifeq ($(KBUILD_SRC),) > +CPPFLAGS += -I$(BOARD)/include > +else > +CPPFLAGS += -I$(srctree)/$(BOARD)/include > +endif > + > ifneq ($(machine-y),) > MACH := arch/mips/mach-$(machine-y)/ > else > MACH := > endif > > -CPPFLAGS += -I$(BOARD)/include > - > common-y += $(BOARD) $(MACH) > common-y += arch/mips/lib/ > common-y += arch/mips/boot/ > -- > 1.7.10.4 > > > ___ > 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] omap: gpmc: mark hex debug values as such
On Fri, Nov 30, 2012 at 11:11:12AM +0100, Jan Luebbe wrote: > Also use %p for pointers. > > Signed-off-by: Jan Luebbe > --- Applied, thanks Sascha > arch/arm/mach-omap/gpmc.c | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c > index ff8b58b..73d8c44 100644 > --- a/arch/arm/mach-omap/gpmc.c > +++ b/arch/arm/mach-omap/gpmc.c > @@ -50,7 +50,7 @@ void gpmc_generic_init(unsigned int cfg) > unsigned int reg = GPMC_REG(CONFIG7_0); > char x = 0; > > - debug("gpmccfg=%x\n", cfg); > + debug("gpmccfg=0x%x\n", cfg); > /* Generic Configurations */ > /* reset gpmc */ > start = get_time_ns(); > @@ -73,7 +73,7 @@ void gpmc_generic_init(unsigned int cfg) >* But NEVER run me in XIP mode! I will Die! >*/ > while (x < GPMC_NUM_CS) { > - debug("gpmccs=%d Reg:%x <-0x0\n", x, reg); > + debug("gpmccs=%d Reg:0x%x <-0x0\n", x, reg); > writel(0x0, reg); > reg += GPMC_CONFIG_CS_SIZE; > x++; > @@ -95,7 +95,7 @@ void gpmc_cs_config(char cs, struct gpmc_config *config) > { > unsigned int reg = GPMC_REG(CONFIG1_0) + (cs * GPMC_CONFIG_CS_SIZE); > unsigned char x = 0; > - debug("gpmccs=%x cfg=%x\n", cs, (unsigned int)config); > + debug("gpmccs=0x%x cfg=0x%p\n", cs, config); > > /* Disable the CS before reconfiguring */ > writel(0x0, GPMC_REG(CONFIG7_0) + (cs * GPMC_CONFIG_CS_SIZE)); > @@ -103,14 +103,14 @@ void gpmc_cs_config(char cs, struct gpmc_config *config) > > /* Write the CFG1-6 regs */ > while (x < 6) { > - debug("gpmccfg=%d Reg:%x <-0x%x\n", > + debug("gpmccfg%d Reg:0x%x <-0x%08x\n", > x, reg, config->cfg[x]); > writel(config->cfg[x], reg); > reg += GPMC_CONFIG_REG_OFF; > x++; > } > /* reg now points to CFG7 */ > - debug("gpmccfg=%d Reg:%x <-0x%x\n", > + debug("gpmccfg%d Reg:0x%x <-0x%08x\n", > x, reg, (0x1 << 6) |/* CS enable */ >((config->size & 0xF) << 8) | /* Size */ >((config->base >> 24) & 0x3F)); > -- > 1.7.10.4 > > > ___ > 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: suddenly, i can't boot barebox on my beagle xM anymore [ISOLATED]
On Mon, 2012-12-03 at 03:31 -0500, Robert P. J. Day wrote: > *sigh* ... i *think* i figured out what's happening. in order to > play with barebox on my xM, until recently, i'd done nothing more than > create a single FAT partition on a micro SD card, put MLO and > barebox.bin on it, put it in my xM, and let it boot. until that OMAP > merge, it worked fine. > > as i read it, the new default environment for the xM *requires* a > second (ext3) partition or the boot process simply hangs, am i reading > that right? if that's true, how can i adjust that so i can once again > just boot to barebox without having a kernel and root fs created yet? Only the kernel uses the second partition for its rootfs, barebox should get to the prompt where you can interrupt autoboot anyway. So figuring out the exact commit would be useful. The bisection should take only a few steps. Sascha build-checks every revision, so all the bisection steps should build fine. 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
Re: suddenly, i can't boot barebox on my beagle xM anymore [ISOLATED]
On Mon, 3 Dec 2012, Jan Lübbe wrote: > On Mon, 2012-12-03 at 03:31 -0500, Robert P. J. Day wrote: > > *sigh* ... i *think* i figured out what's happening. in order to > > play with barebox on my xM, until recently, i'd done nothing more than > > create a single FAT partition on a micro SD card, put MLO and > > barebox.bin on it, put it in my xM, and let it boot. until that OMAP > > merge, it worked fine. > > > > as i read it, the new default environment for the xM *requires* a > > second (ext3) partition or the boot process simply hangs, am i reading > > that right? if that's true, how can i adjust that so i can once again > > just boot to barebox without having a kernel and root fs created yet? > > Only the kernel uses the second partition for its rootfs, barebox > should get to the prompt where you can interrupt autoboot anyway. > > So figuring out the exact commit would be useful. The bisection > should take only a few steps. Sascha build-checks every revision, so > all the bisection steps should build fine. actually, i *did* use bisection to isolate it -- here's the commit that introduces the issue: commit 5f2074bdd13ea69af5a10c3bcccb648720d6937a Author: Sascha Hauer Date: Wed Oct 31 10:16:48 2012 +0100 ARM OMAP3 beagle: switch to new environment Signed-off-by: Sascha Hauer did i forget to post that? oops ... rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [Patch] ARM/MXS/i.MX28: distinguish POR and wake-up event correctly
On Fri, Nov 30, 2012 at 12:14:04PM +0100, Juergen Beisert wrote: > When the built-in RTC in the i.MX28 is programmed to wake-up the SoC, the RTC > reports two events: RST and WAKE. RST is okay in this case, because the PMIC > was really powered down. But the real event is the WAKE from the RTC and > should have precedence over the RST event. So, report the WAKE event for this > special case. > > Signed-off-by: Juergen Beisert Applied, thanks Sascha > > diff --git a/drivers/watchdog/im28wd.c b/drivers/watchdog/im28wd.c > index ca32a72..bc19369 100644 > --- a/drivers/watchdog/im28wd.c > +++ b/drivers/watchdog/im28wd.c > @@ -82,6 +82,17 @@ static void __maybe_unused imx28_detect_reset_source(const > struct imx28_wd *p) > if (reg & MXS_RTC_PERSISTENT0_EXT_RST) { > writel(MXS_RTC_PERSISTENT0_EXT_RST, > p->regs + MXS_RTC_PERSISTENT0 + MXS_RTC_CLR_ADDR); > + /* > + * if the RTC has woken up the SoC, additionally the ALARM_WAKE > + * bit is set. This bit should have precedence, because it > + * reports the real event, why we are here. > + */ > + if (reg & MXS_RTC_PERSISTENT0_ALARM_WAKE) { > + writel(MXS_RTC_PERSISTENT0_ALARM_WAKE, > + p->regs + MXS_RTC_PERSISTENT0 + > MXS_RTC_CLR_ADDR); > + set_reset_source(RESET_WKE); > + return; > + } > set_reset_source(RESET_POR); > return; > } > > > -- > Pengutronix e.K. | Juergen Beisert | > Linux Solutions for Science and Industry | http://www.pengutronix.de/ | > > ___ > 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: suddenly, i can't boot barebox on my beagle xM anymore [ISOLATED]
On Mon, 3 Dec 2012, Jan Lübbe wrote: > On Mon, 2012-12-03 at 03:31 -0500, Robert P. J. Day wrote: > > *sigh* ... i *think* i figured out what's happening. in order to > > play with barebox on my xM, until recently, i'd done nothing more than > > create a single FAT partition on a micro SD card, put MLO and > > barebox.bin on it, put it in my xM, and let it boot. until that OMAP > > merge, it worked fine. > > > > as i read it, the new default environment for the xM *requires* a > > second (ext3) partition or the boot process simply hangs, am i reading > > that right? if that's true, how can i adjust that so i can once again > > just boot to barebox without having a kernel and root fs created yet? > > Only the kernel uses the second partition for its rootfs, barebox should > get to the prompt where you can interrupt autoboot anyway. > > So figuring out the exact commit would be useful. The bisection should > take only a few steps. Sascha build-checks every revision, so all the > bisection steps should build fine. here's a copy-and-paste from one of my other sessions, where i build MLO/barebox.bin using two consecutive commits: = start = barebox 2012.10.0-00286-g36969d3 #6 Sun Dec 2 05:31:40 EST 2012 Board: Texas Instrument's Beagle I2C probe i2c-omap i2c-omap0: bus 0 rev4.0 at 100 kHz ehci ehci0: USB EHCI 1.00 NAND type unknown: ff,ff No NAND device found (-19)! omap-hsmmc omap-hsmmc0: registered as omap-hsmmc0 mci mci0: registered disk0 malloc space: 0x80c0 -> 0x80ff (size 4 MB) stack space: 0x80bf8000 -> 0x80c0 (size 32 kB) Open /dev/env0 No such file or directory no valid environment found on /dev/env0. Using default environment running /env/bin/init... Hit any key to stop autoboot: 1 dhcp failed: Network is down dhcp: Network is down do_tftpb: /.tftp_tmp_path/zImage- -> /image could not open /.tftp_tmp_path/zImage-: Network is down barebox@Texas Instrument's Beagle:/ barebox 2012.10.0-00287-g5f2074b #7 Sun Dec 2 05:33:23 EST 2012 Board: Texas Instrument's Beagle NAND type unknown: ff,ff No NAND device found (-19)! omap-hsmmc omap-hsmmc0: registered as omap-hsmmc0 mci mci0: registered disk0 malloc space: 0x87bfff10 -> 0x870f (size 4 MB) stack space: 0x4020f000 -> 0x4020fc00 (size 3 kB) booting from MMC1 = end = as you can see, commit 36969d3 has the old behaviour (allowing booting), while the next commit 5f2074b which introduces the new beagle environment causes the boot to hang at "booting from MMC1". rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: how does barebox deal with more than one environment?
On Sat, Dec 01, 2012 at 08:19:26AM -0500, Robert P. J. Day wrote: > On Sat, 1 Dec 2012, Robert P. J. Day wrote: > > > > > writing up a simple barebox exercise for students and on this page: > > > > http://wiki.barebox.org/doku.php?id=user:first_steps > > > > it seems clear(?) that you can define multiple environments that will > > appear at /dev/env0, /dev/env1, etc, but that page also claims that > > *only* the configuration on /dev/env0 will be executed automatically > > if barebox finds that it's a valid configuration sector. > > > > so what happens with the additional environments? that page doesn't > > make it clear. i'm just about to read the source to see if i can > > figure this out. > > oh, wait, i think i see ... the "loadenv" command will load a given > environment into a directory so i'm *assuming* that additional > environments are simply available to be loaded, but /dev/env0 is the > only one treated special. or feel free to correct me if i'm > hopelessly wrong. /dev/env0 is the only environment used by barebox by default. As you correctly found out loadenv/saveenv could be used to load arbitrary envfs images to arbitrary directories. We could also think about adding some kind of redundancy, but currently this would be board specific, there is no generic heuristic to fall back to a second env if the first one is corrupted. 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: should i expect trying to mount a cramfs fs to give me a segmentation fault?
On Sat, Dec 01, 2012 at 11:28:08AM -0500, Robert P. J. Day wrote: > > again, just following along here: > > http://wiki.barebox.org/doku.php?id=user:first_steps > > i created a small cramfs filesystem image: > > $ ls -l crypto.cramfs > -rw-rw-r-- 1 rpjday rpjday 24576 Dec 1 11:19 crypto.cramfs > $ file crypto.cramfs > crypto.cramfs: Linux Compressed ROM File System data, little endian size > 24576 version #2 sorted_dirs CRC 0x969356bc, edition 0, 24 > blocks, 13 files > $ > > started barebox: > > $ ./barebox -i crypto.cramfs > add file crypto.cramfs() > > > barebox 2012.11.0-00305-g159109f #1 Sat Dec 1 07:46:38 EST 2012 > > > Board: sandbox > could not get tap device: Operation not permitted > tap tap0: probe failed: Operation not permitted > malloc space: 0x7f0f1cb3c010 -> 0x7f0f1d33c00f (size 8 MB) > Open /dev/env0 No such file or directory > no valid environment found on /dev/env0. Using default environment > running /env/bin/init... > set parameter: No such device > set parameter: No such device > set parameter: No such device > set parameter: No such device > set parameter: No such device > barebox:/ > > then tried to mount it as that page suggests: > > barebox:/ mkdir mnt > barebox:/ mount /dev/fd0 cramfs /mnt > Segmentation fault (core dumped) > rpjday@oneiric:~/OE/dist/barebox/git$ > > i also tried the variation: > > barebox> mount -t cramfs /dev/fd0 /mnt > > same result. help? cramfs was present in barebox very early. I think in some places the implementation still assumes that the filesystem image is directly memory mapped. Probably we should investigate and either add a big warning somewhere or fix it. 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: suddenly, i can't boot barebox on my beagle xM anymore
Hi Robert, On Sat, Dec 01, 2012 at 04:18:08PM -0500, Robert P. J. Day wrote: > > a bit embarrassed but, all of a sudden, what used to work just fine > in terms of building and booting barebox on my beagleboard xM (rev C) > doesn't work anymore. > > not that long ago, i documented how easy this was here: > > http://www.crashcourse.ca/wiki/index.php/BeagleBoard-xM#Barebox_for_the_xM > > absolutely nothing out of the ordinary as i remember it. so, when > this worked, the boot looked like what you see here: > > http://www.crashcourse.ca/wiki/index.php/BeagleBoard-xM#Booting_to_Barebox_on_your_xM_--_it_actually_works > > now, the boot process produces: > > barebox 2012.11.0-00305-g159109f #1 Sat Dec 1 15:51:00 EST 2012 > > > Board: Texas Instrument's Beagle > NAND type unknown: ff,ff > No NAND device found (-19)! > gpmc_nand gpmc_nand0: probe failed: error 6 > omap-hsmmc omap-hsmmc0: registered as omap-hsmmc0 > mci mci0: registered disk0 > malloc space: 0x87bfff10 -> 0x870f (size 4 MB) > stack space: 0x4020f000 -> 0x4020fc00 (size 3 kB) > booting from MMC1 > > ... and hangs, suggesting that the MLO file is fine, but it's > barebox.bin that simply fails. I just rechecked, current master works fine for me on my beagle (no xM though). Just a guess, have you used the barebox-flash-image link instead of barebox.bin? Since the image is compressed now it becomes important to use the link (which points to the compressed image). 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: [PATCH 0/2] clk: add always enabled clocks
On Mon, Dec 03, 2012 at 12:42:23AM +0400, Antony Pavlov wrote: > [PATCH 1/2] clk: add always enabled clocks > [PATCH 2/2] commands: clk_dump: denote always enabled clocks Nice. The clk_dump command looks a bit weird because it suggests that all clocks are disabled. now I can turn them into always enabled clocks. Applied, thanks 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: suddenly, i can't boot barebox on my beagle xM anymore
On Mon, 3 Dec 2012, Sascha Hauer wrote: > I just rechecked, current master works fine for me on my beagle (no > xM though). Just a guess, have you used the barebox-flash-image link > instead of barebox.bin? Since the image is compressed now it becomes > important to use the link (which points to the compressed image). whoops, no, i didn't ... will test right this instant. what *name* do i copy it to the SD card under? rday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
kbuild can't build foo/xxx.o
kbuild in barebox can't built when obj-y += foo/xxx.o But in kernel, It's OK Maybe it should: -- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index cb46db2..14e471d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -55,10 +55,10 @@ multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs := $(multi-objs-y) $(multi-objs-m) -# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live -# in the local directory -__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) -subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) +# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to +# tell kbuild to descend +__subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y)) +subdir-obj-y := $(filter %/built-in.o, $(obj-y)) subdir-obj-y += $(__subdir-obj-y) # $(obj-dirs) is a list of directories that contain object files -- -- Best Regards, zzs ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: Howto known uncompressed length when uncompress_fd_to_buf
On Fri, Nov 30, 2012 at 07:03:36PM +0800, 张忠山 wrote: > the function uncompress_fd_to_buf has no parameter to return > the uncompressed length, How to get the uncompressed content > length? AFAIK the uncompressed size is not contained in the compressed data You would have to uncompress to a file and use this afterwards. If I understand correctly you want to load a FPGA firmware which you have in compressed form. What I would do is: - uncompress the firmware in a script rather than uncompress it from C code. - write a command to flash the firmware. 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: suddenly, i can't boot barebox on my beagle xM anymore
On Mon, Dec 03, 2012 at 04:50:24AM -0500, Robert P. J. Day wrote: > On Mon, 3 Dec 2012, Sascha Hauer wrote: > > > I just rechecked, current master works fine for me on my beagle (no > > xM though). Just a guess, have you used the barebox-flash-image link > > instead of barebox.bin? Since the image is compressed now it becomes > > important to use the link (which points to the compressed image). > > whoops, no, i didn't ... will test right this instant. what *name* > do i copy it to the SD card under? xload: cp barebox-flash-image /mnt/MLO barebox: cp barebox-flash-image /mnt/barebox.bin 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: kbuild can't build foo/xxx.o
On Mon, Dec 03, 2012 at 05:51:50PM +0800, 张忠山 wrote: > kbuild in barebox can't built when > > obj-y += foo/xxx.o > > But in kernel, It's OK > > Maybe it should: > > -- > diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib > index cb46db2..14e471d 100644 > --- a/scripts/Makefile.lib > +++ b/scripts/Makefile.lib > @@ -55,10 +55,10 @@ multi-objs-y := $(foreach m, $(multi-used-y), > $($(m:.o=-objs)) $($(m:.o=-y))) > multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) > multi-objs := $(multi-objs-y) $(multi-objs-m) > > -# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live > -# in the local directory > -__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir > $(o))),$(o))) > -subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir > $(o))),$(o))) > +# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to > +# tell kbuild to descend > +__subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y)) > +subdir-obj-y := $(filter %/built-in.o, $(obj-y)) > subdir-obj-y += $(__subdir-obj-y) > > # $(obj-dirs) is a list of directories that contain object files Seems you have that from the Kernel. Looks fine. Can you send a formal patch with you Signed-off and also an explanation on which original Kernel commit this is based on? 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: suddenly, i can't boot barebox on my beagle xM anymore
On Mon, 3 Dec 2012, Sascha Hauer wrote: > On Mon, Dec 03, 2012 at 04:50:24AM -0500, Robert P. J. Day wrote: > > On Mon, 3 Dec 2012, Sascha Hauer wrote: > > > > > I just rechecked, current master works fine for me on my beagle (no > > > xM though). Just a guess, have you used the barebox-flash-image link > > > instead of barebox.bin? Since the image is compressed now it becomes > > > important to use the link (which points to the compressed image). > > > > whoops, no, i didn't ... will test right this instant. what *name* > > do i copy it to the SD card under? > > xload: cp barebox-flash-image /mnt/MLO > barebox: cp barebox-flash-image /mnt/barebox.bin i did that second copy, but are you sure i should copy that new flash image to MLO? i'm not convinced... rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] Makefile: move ctags and cscope support to a shell script
On Mon, Dec 03, 2012 at 09:08:56AM +0400, Antony Pavlov wrote: > The scripts/tags.sh file copied from linux-3.6. > > Signed-off-by: Antony Pavlov Making the toplevel Makefile smaller is a good move. Applied, thanks Sascha > --- > Makefile| 111 +-- > scripts/tags.sh | 265 > +++ > 2 files changed, 268 insertions(+), 108 deletions(-) > create mode 100755 scripts/tags.sh > > diff --git a/Makefile b/Makefile > index 05b8be5..e3a23dd 100644 > --- a/Makefile > +++ b/Makefile > @@ -1166,115 +1166,10 @@ htmldocs: Doxyfile.version > > # Generate tags for editors > # --- > +quiet_cmd_tags = GEN $@ > + cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ > > -#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set > -#(which is the most common case IMHO) to avoid unneeded clutter in the big > tags file. > -#Adding $(srctree) adds about 20M on i386 to the size of the output file! > - > -ifeq ($(src),$(obj)) > -__srctree = > -else > -__srctree = $(srctree)/ > -endif > - > -ifeq ($(ALLSOURCE_ARCHS),) > -ifeq ($(ARCH),um) > -ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH) > -else > -ALLINCLUDE_ARCHS := $(ARCH) > -endif > -else > -#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping > existing behavour. > -ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS) > -endif > - > -ALLSOURCE_ARCHS := $(ARCH) > - > -define find-sources > -( find $(__srctree) $(RCS_FIND_IGNORE) \ > -\( -name include -o -name arch \) -prune -o \ > --name $1 -print; \ > - for ARCH in $(ALLSOURCE_ARCHS) ; do \ > -find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ > - -name $1 -print; \ > - done ; \ > - find $(__srctree)include $(RCS_FIND_IGNORE) \ > -\( -name config -o -name 'asm-*' \) -prune \ > --o -name $1 -print; \ > - for ARCH in $(ALLINCLUDE_ARCHS) ; do \ > -test -e $(__srctree)include/asm-$${arch} && \ > - find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \ > --name $1 -print; \ > - test -e $(__srctree)arch/$${arch}/include/asm && \ > - find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \ > - -name $1 -print; \ > - done ; \ > - find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ > --name $1 -print ) > -endef > - > -define all-sources > - $(call find-sources,'*.[chS]') > -endef > -define all-kconfigs > - $(call find-sources,'Kconfig*') > -endef > -define all-defconfigs > - $(call find-sources,'defconfig') > -endef > - > -define xtags > - if $1 --version 2>&1 | grep -iq exuberant; then \ > - $(all-sources) | xargs $1 -a \ > - -I __initdata,__exitdata,__acquires,__releases \ > - -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ > - --extra=+f --c-kinds=+px \ > - --regex-asm='/ENTRY\(([^)]*)\).*/\1/'; \ > - $(all-kconfigs) | xargs $1 -a \ > - --langdef=kconfig \ > - --language-force=kconfig \ > - > --regex-kconfig='/^[[:blank:]]*config[[:blank:]]+([[:alnum:]_]+)/\1/'; \ > - $(all-defconfigs) | xargs -r $1 -a \ > - --langdef=dotconfig \ > - --language-force=dotconfig \ > - --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; > \ > - elif $1 --version 2>&1 | grep -iq emacs; then \ > - $(all-sources) | xargs $1 -a; \ > - $(all-kconfigs) | xargs $1 -a \ > - --regex='/^[ \t]*config[ \t]+\([a-zA-Z0-9_]+\)/\1/'; \ > - $(all-defconfigs) | xargs -r $1 -a \ > - --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \ > - else \ > - $(all-sources) | xargs $1 -a; \ > - fi > -endef > - > -quiet_cmd_cscope-file = FILELST cscope.files > - cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files > - > -quiet_cmd_cscope = MAKEcscope.out > - cmd_cscope = cscope -b > - > -cscope: FORCE > - $(call cmd,cscope-file) > - $(call cmd,cscope) > - > -quiet_cmd_TAGS = MAKE $@ > -define cmd_TAGS > - rm -f $@; \ > - $(call xtags,etags) > -endef > - > -TAGS: FORCE > - $(call cmd,TAGS) > - > -quiet_cmd_tags = MAKE $@ > -define cmd_tags > - rm -f $@; \ > - $(call xtags,ctags) > -endef > - > -tags: FORCE > +tags TAGS cscope: FORCE > $(call cmd,tags) > > > diff --git a/scripts/tags.sh b/scripts/tags.sh > new file mode 100755 > index 000..79fdafb > --- /dev/null > +++ b/scripts/tags.sh > @@ -0,0 +1,265 @@ > +#!/bin/sh > +# Generate tags or cscope files > +# Usage tags.sh > +# > +# mode may be any of: tags, TAGS, cscope > +# > +# Uses the following environment variables: > +# ARCH, SUBARCH, SRCARCH, srctree, src, obj > + > +if [ "$KBUILD_VERBOSE" = "1" ]; then > +
Re: [PATCH] at25: use dev_lseek_default as at24 does
On Mon, Dec 03, 2012 at 09:46:52AM +0400, Antony Pavlov wrote: > Signed-off-by: Antony Pavlov > --- > drivers/eeprom/at25.c |7 +-- > 1 file changed, 1 insertion(+), 6 deletions(-) Applied, thanks Sascha > > diff --git a/drivers/eeprom/at25.c b/drivers/eeprom/at25.c > index 5578c78..9bd7748 100644 > --- a/drivers/eeprom/at25.c > +++ b/drivers/eeprom/at25.c > @@ -232,15 +232,10 @@ static ssize_t at25_ee_write(struct cdev *cdev, > return written ? written : status; > } > > -static loff_t at25_ee_lseek(struct cdev *cdev, loff_t off) > -{ > - return off; > -} > - > static struct file_operations at25_fops = { > .read = at25_ee_read, > .write = at25_ee_write, > - .lseek = at25_ee_lseek, > + .lseek = dev_lseek_default, > }; > > static int at25_probe(struct device_d *dev) > -- > 1.7.10.4 > > > ___ > 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: suddenly, i can't boot barebox on my beagle xM anymore
On Mon, Dec 03, 2012 at 05:01:43AM -0500, Robert P. J. Day wrote: > On Mon, 3 Dec 2012, Sascha Hauer wrote: > > > On Mon, Dec 03, 2012 at 04:50:24AM -0500, Robert P. J. Day wrote: > > > On Mon, 3 Dec 2012, Sascha Hauer wrote: > > > > > > > I just rechecked, current master works fine for me on my beagle (no > > > > xM though). Just a guess, have you used the barebox-flash-image link > > > > instead of barebox.bin? Since the image is compressed now it becomes > > > > important to use the link (which points to the compressed image). > > > > > > whoops, no, i didn't ... will test right this instant. what *name* > > > do i copy it to the SD card under? > > make omap3530_beagle_xload_defconfig && make > > xload: cp barebox-flash-image /mnt/MLO make omap3530_beagle_defconfig && make > > barebox: cp barebox-flash-image /mnt/barebox.bin > > i did that second copy, but are you sure i should copy that new > flash image to MLO? i'm not convinced... Not the same binary of course. I clarified this a bit above. 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] correct simple typo, "plarform_init"
Signed-off-by: Robert P. J. Day --- no functional change, but it's just an annoying typo. :-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ea4e37b..e1a8472 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -76,8 +76,8 @@ struct bus_type platform_bus = { .remove = platform_remove, }; -static int plarform_init(void) +static int platform_init(void) { return bus_register(&platform_bus); } -pure_initcall(plarform_init); +pure_initcall(platform_init); -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: suddenly, i can't boot barebox on my beagle xM anymore
On Mon, 3 Dec 2012, Sascha Hauer wrote: > On Mon, Dec 03, 2012 at 05:01:43AM -0500, Robert P. J. Day wrote: > > On Mon, 3 Dec 2012, Sascha Hauer wrote: > > > > > On Mon, Dec 03, 2012 at 04:50:24AM -0500, Robert P. J. Day wrote: > > > > On Mon, 3 Dec 2012, Sascha Hauer wrote: > > > > > > > > > I just rechecked, current master works fine for me on my beagle (no > > > > > xM though). Just a guess, have you used the barebox-flash-image link > > > > > instead of barebox.bin? Since the image is compressed now it becomes > > > > > important to use the link (which points to the compressed image). > > > > > > > > whoops, no, i didn't ... will test right this instant. what *name* > > > > do i copy it to the SD card under? > > > > > make omap3530_beagle_xload_defconfig && make > > > > xload: cp barebox-flash-image /mnt/MLO > > make omap3530_beagle_defconfig && make > > > > barebox: cp barebox-flash-image /mnt/barebox.bin > > > > i did that second copy, but are you sure i should copy that new > > flash image to MLO? i'm not convinced... > > Not the same binary of course. I clarified this a bit above. ah, thanks. it seems the actual "MLO" file works fine being copied directly as "MLO". not sure if it's supposed to, just making an observation. and now, off for coffee and to the lab. thanks. rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH] correct simple typo, "plarform_init"
On Mon, Dec 03, 2012 at 05:05:34AM -0500, Robert P. J. Day wrote: > > Signed-off-by: Robert P. J. Day > > --- > > no functional change, but it's just an annoying typo. :-) Applied, thanks. Sascha > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index ea4e37b..e1a8472 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -76,8 +76,8 @@ struct bus_type platform_bus = { > .remove = platform_remove, > }; > > -static int plarform_init(void) > +static int platform_init(void) > { > return bus_register(&platform_bus); > } > -pure_initcall(plarform_init); > +pure_initcall(platform_init); > > -- > > > Robert P. J. Day Ottawa, Ontario, CANADA > http://crashcourse.ca > > Twitter: http://twitter.com/rpjday > LinkedIn: http://ca.linkedin.com/in/rpjday > > > ___ > 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
[PATCH 1/4] ls command: call stat() only when necessary
When calling ls in short mode we do not have to call stat() for additional informations because we do not use them. This speeds up ls on filesystems on which stat() is expensive because the barebox filesystem support always has to iterate over the directory tree. Signed-off-by: Sascha Hauer --- commands/ls.c |9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/commands/ls.c b/commands/ls.c index 1fdb244..f2d9903 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -73,12 +73,13 @@ int ls(const char *path, ulong flags) while ((d = readdir(dir))) { sprintf(tmp, "%s/%s", path, d->d_name); - if (lstat(tmp, &s)) - goto out; - if (flags & LS_COLUMN) + if (flags & LS_COLUMN) { string_list_add_sorted(&sl, d->d_name); - else + } else { + if (lstat(tmp, &s)) + goto out; ls_one(d->d_name, tmp, &s); + } } closedir(dir); -- 1.7.10.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 2/4] filetype: Pass bufsize
Pass the buffer size to the file detection code. This makes sure we do not read past the buffer. This is especially useful for ext filesystem detection as the magic is at byte offset 1080. Also introduce a FILE_TYPE_SAFE_BUFSIZE define which is set to the minimum bufsize the detection code needs to detect all known filetypes. Signed-off-by: Sascha Hauer --- arch/arm/lib/bootm.c |2 +- arch/arm/mach-imx/imx-bbu-internal.c |4 ++-- commands/bootm.c |2 +- common/filetype.c| 39 +++--- common/uimage.c |2 +- include/filetype.h |4 +++- lib/gui/image_renderer.c |6 +++--- lib/uncompress.c |4 ++-- 8 files changed, 40 insertions(+), 23 deletions(-) diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 288c0b2..51ac9af 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -143,7 +143,7 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data) if (ret < sizeof(*header)) return ret; - if (file_detect_type(header) != filetype_oftree) + if (file_detect_type(header, sizeof(*header)) != filetype_oftree) return -ENXIO; end = be32_to_cpu(header->totalsize); diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index c34f86f..881c20a 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -110,7 +110,7 @@ static int imx_bbu_internal_v1_update(struct bbu_handler *handler, struct bbu_da int ret, image_len; void *buf; - if (file_detect_type(data->image) != filetype_arm_barebox) { + if (file_detect_type(data->image, data->len) != filetype_arm_barebox) { if (!bbu_force(data, "Not an ARM barebox image")) return -EINVAL; } @@ -332,7 +332,7 @@ static int imx_bbu_internal_v2_update(struct bbu_handler *handler, struct bbu_da int ret, image_len; void *buf; - if (file_detect_type(data->image) != filetype_arm_barebox) { + if (file_detect_type(data->image, data->len) != filetype_arm_barebox) { if (!bbu_force(data, "Not an ARM barebox image")) return -EINVAL; } diff --git a/commands/bootm.c b/commands/bootm.c index 98d2e4f..483e6a1 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -184,7 +184,7 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu } } - ft = file_detect_type(fdt); + ft = file_detect_type(fdt, size); if (ft != filetype_oftree) { printf("%s is not an oftree but %s\n", oftree, file_type_to_string(ft)); diff --git a/common/filetype.c b/common/filetype.c index b8d54f7..c1bd11d 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -105,19 +105,24 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec) return filetype_mbr; } -enum filetype file_detect_type(void *_buf) +enum filetype file_detect_type(void *_buf, size_t bufsize) { u32 *buf = _buf; u64 *buf64 = _buf; u8 *buf8 = _buf; enum filetype type; + if (bufsize < 9) + return filetype_unknown; + if (strncmp(buf8, "#!/bin/sh", 9) == 0) return filetype_sh; - if (is_barebox_arm_head(_buf)) - return filetype_arm_barebox; - if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01) - return filetype_arm_zimage; + + if (bufsize < 32) + return filetype_unknown; + + if (strncmp(buf8, "BM", 2) == 0) + return filetype_bmp; if (buf8[0] == 0x89 && buf8[1] == 0x4c && buf8[2] == 0x5a && buf8[3] == 0x4f) return filetype_lzo_compressed; @@ -136,15 +141,25 @@ enum filetype file_detect_type(void *_buf) return filetype_oftree; if (strncmp(buf8, "ANDROID!", 8) == 0) return filetype_aimage; + if (buf64[0] == le64_to_cpu(0x0a1a0a0d474e5089ull)) + return filetype_png; if (strncmp(buf8 + 0x10, "barebox", 7) == 0) return filetype_mips_barebox; + + if (bufsize < 64) + return filetype_unknown; + + if (is_barebox_arm_head(_buf)) + return filetype_arm_barebox; + if (buf[9] == 0x016f2818 || buf[9] == 0x18286f01) + return filetype_arm_zimage; + + if (bufsize < 512) + return filetype_unknown; + type = is_fat_or_mbr(buf8, NULL); if (type != filetype_unknown) return type; - if (strncmp(buf8, "BM", 2) == 0) - return filetype_bmp; - if (buf64[0] == le64_to_cpu(0x0a1a0a0d474e5089ull)) - return filetype_png;
[PATCH] ext4 filesystem support
Hi All, The following adds ext4 readonly filesystem support to barebox. The implementation is from U-Boot which recently gained ext4 support. ext filesystems can automatically be detected, so the -t option to mount is not necessary. Some preparation is needed because ext filesystems have their magic at byte offset 1080. Currently we do not pass in such a big buffer into the filesystem detection code. To fix this we now pass the buffer size to the file detection code so that we do not read past the buffer. Sascha Sascha Hauer (4): ls command: call stat() only when necessary filetype: Pass bufsize add ext fs detection support fs: implement initial ext4 support from U-Boot arch/arm/lib/bootm.c |2 +- arch/arm/mach-imx/imx-bbu-internal.c |4 +- commands/bootm.c |2 +- commands/ls.c|9 +- common/filetype.c| 47 ++- common/uimage.c |2 +- fs/Kconfig |2 + fs/Makefile |1 + fs/ext4/Kconfig |3 + fs/ext4/Makefile |1 + fs/ext4/ext4_common.c| 551 ++ fs/ext4/ext4_common.h| 58 fs/ext4/ext4fs.c | 153 ++ fs/ext4/ext4fs.h | 127 fs/ext4/ext_barebox.c| 293 ++ fs/ext4/ext_common.h | 195 include/filetype.h |5 +- lib/gui/image_renderer.c |6 +- lib/uncompress.c |4 +- 19 files changed, 1438 insertions(+), 27 deletions(-) create mode 100644 fs/ext4/Kconfig create mode 100644 fs/ext4/Makefile create mode 100644 fs/ext4/ext4_common.c create mode 100644 fs/ext4/ext4_common.h create mode 100644 fs/ext4/ext4fs.c create mode 100644 fs/ext4/ext4fs.h create mode 100644 fs/ext4/ext_barebox.c create mode 100644 fs/ext4/ext_common.h ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 3/4] add ext fs detection support
Signed-off-by: Sascha Hauer --- common/filetype.c |8 include/filetype.h |1 + 2 files changed, 9 insertions(+) diff --git a/common/filetype.c b/common/filetype.c index c1bd11d..748e364 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -47,6 +47,7 @@ static const struct filetype_str filetype_str[] = { [filetype_mbr] = { "MBR sector", "mbr" }, [filetype_bmp] = { "BMP image", "bmp" }, [filetype_png] = { "PNG image", "png" }, + [filetype_ext] = { "ext filesystem", "ext" }, }; const char *file_type_to_string(enum filetype f) @@ -110,6 +111,7 @@ enum filetype file_detect_type(void *_buf, size_t bufsize) u32 *buf = _buf; u64 *buf64 = _buf; u8 *buf8 = _buf; + u16 *buf16 = _buf; enum filetype type; if (bufsize < 9) @@ -161,6 +163,12 @@ enum filetype file_detect_type(void *_buf, size_t bufsize) if (type != filetype_unknown) return type; + if (bufsize < 1536) + return filetype_unknown; + + if (buf16[512 + 28] == le16_to_cpu(0xef53)) + return filetype_ext; + return filetype_unknown; } diff --git a/include/filetype.h b/include/filetype.h index 5fac531..91139db 100644 --- a/include/filetype.h +++ b/include/filetype.h @@ -22,6 +22,7 @@ enum filetype { filetype_mbr, filetype_bmp, filetype_png, + filetype_ext, filetype_max, }; -- 1.7.10.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 4/4] fs: implement initial ext4 support from U-Boot
The ext4 implementation has been taken from U-Boot with some changes: - No global variables to allow for multiple filesystems to be mounted and multiple files to be open. - remove fs internal link following and use the barebox link implementation. - remove write support. This is incomplete in U-Boot, so I decided to skip this for now. Signed-off-by: Sascha Hauer --- fs/Kconfig|2 + fs/Makefile |1 + fs/ext4/Kconfig |3 + fs/ext4/Makefile |1 + fs/ext4/ext4_common.c | 551 + fs/ext4/ext4_common.h | 58 ++ fs/ext4/ext4fs.c | 153 ++ fs/ext4/ext4fs.h | 127 fs/ext4/ext_barebox.c | 293 ++ fs/ext4/ext_common.h | 195 + 10 files changed, 1384 insertions(+) create mode 100644 fs/ext4/Kconfig create mode 100644 fs/ext4/Makefile create mode 100644 fs/ext4/ext4_common.c create mode 100644 fs/ext4/ext4_common.h create mode 100644 fs/ext4/ext4fs.c create mode 100644 fs/ext4/ext4fs.h create mode 100644 fs/ext4/ext_barebox.c create mode 100644 fs/ext4/ext_common.h diff --git a/fs/Kconfig b/fs/Kconfig index 0ab69d7..c31c0cd 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -14,6 +14,8 @@ config FS_CRAMFS select ZLIB prompt "cramfs support" +source fs/ext4/Kconfig + config FS_RAMFS bool default y diff --git a/fs/Makefile b/fs/Makefile index ad745d9..cc59da7 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_FS_CRAMFS)+= cramfs/ +obj-$(CONFIG_FS_EXT4) += ext4/ obj-$(CONFIG_FS_RAMFS) += ramfs.o obj-y += devfs-core.o obj-$(CONFIG_FS_DEVFS) += devfs.o diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig new file mode 100644 index 000..f36043d --- /dev/null +++ b/fs/ext4/Kconfig @@ -0,0 +1,3 @@ +config FS_EXT4 + bool + prompt "ext4 filesystem support" diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile new file mode 100644 index 000..5084e3f --- /dev/null +++ b/fs/ext4/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_FS_EXT4) += ext4fs.o ext4_common.o ext_barebox.o diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c new file mode 100644 index 000..f426118 --- /dev/null +++ b/fs/ext4/ext4_common.c @@ -0,0 +1,551 @@ +/* + * (C) Copyright 2011 - 2012 Samsung Electronics + * EXT4 filesystem implementation in Uboot by + * Uma Shankar + * Manjunatha C Achar + * + * ext4ls and ext4load : Based on ext2 ls load support in Uboot. + * + * (C) Copyright 2004 + * esd gmbh + * Reinhard Arlt + * + * based on code from grub2 fs/ext2.c and fs/fshelp.c by + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 2004 Free Software Foundation, Inc. + * + * ext4write : Based on generic ext4 protocol. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + +#include "ext4_common.h" + +static struct ext4_extent_header *ext4fs_get_extent_block(struct ext2_data *data, + char *buf, struct ext4_extent_header *ext_block, + uint32_t fileblock, int log2_blksz) +{ + struct ext4_extent_idx *index; + unsigned long long block; + struct ext_filesystem *fs = data->fs; + int i, ret; + + while (1) { + index = (struct ext4_extent_idx *)(ext_block + 1); + + if (le32_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC) + return 0; + + if (ext_block->eh_depth == 0) + return ext_block; + i = -1; + do { + i++; + if (i >= le32_to_cpu(ext_block->eh_entries)) + break; + } while (fileblock > le32_to_cpu(index[i].ei_block)); + + if (--i < 0) + return 0; + + block = le32_to_cpu(index[i].ei_leaf_hi); + block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo); + + ret = ext4fs_devread(fs, block << log2_blksz, 0, fs->blksz, buf); + if (ret) + return NULL; + else + ext_block = (struct ext4_extent_header *)buf; + } +} + +static int ext4fs_blockgroup(struct ext2_data *data, int group, + struct ext2_block_group *blkgrp) +{ + long int blkno; + unsigned int blkoff, desc_per_blk; + struct ext_filesystem *fs = data
[PATCH 1/2] ata: Add i.MX PATA driver support
Straight forward driver, we only have to configure some additional bits and then use the generic ide support. Signed-off-by: Sascha Hauer --- drivers/ata/Kconfig|7 ++ drivers/ata/Makefile |1 + drivers/ata/pata-imx.c | 203 3 files changed, 211 insertions(+) create mode 100644 drivers/ata/pata-imx.c diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig index fe6f5e6..459fac3 100644 --- a/drivers/ata/Kconfig +++ b/drivers/ata/Kconfig @@ -39,4 +39,11 @@ config DISK_INTF_PLATFORM_IDE Generic platform driver for simple IDE like interfaces to a connected ATA device. +config DISK_PATA_IMX + bool "i.MX PATA driver" + depends on ARCH_IMX + select DISK_ATA + help + select this to enable support for the i.MX PATA driver + endif diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile index 2560076..eaeddae 100644 --- a/drivers/ata/Makefile +++ b/drivers/ata/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_DISK_ATA) += disk_ata_drive.o # interface types obj-$(CONFIG_DISK_INTF_PLATFORM_IDE) += intf_platform_ide.o +obj-$(CONFIG_DISK_PATA_IMX) += pata-imx.o diff --git a/drivers/ata/pata-imx.c b/drivers/ata/pata-imx.c new file mode 100644 index 000..29531cb --- /dev/null +++ b/drivers/ata/pata-imx.c @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2011 Juergen Beisert, Pengutronix + * Copyright (C) 2012 Sascha Hauer, Pengutronix + * + * Derived from the Linux kernel: Generic platform device PATA driver + * Copyright (C) 2006 - 2007 Paul Mundt + * Based on pata_pcmcia: + * Copyright 2005-2006 Red Hat Inc, all rights reserved. + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * 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 +#include +#include +#include + +#define PATA_IMX_ATA_TIME_OFF 0x0 +#define PATA_IMX_ATA_TIME_ON 0x1 +#define PATA_IMX_ATA_TIME_10x2 +#define PATA_IMX_ATA_TIME_2W 0x3 +#define PATA_IMX_ATA_TIME_2R 0x4 +#define PATA_IMX_ATA_TIME_AX 0x5 +#define PATA_IMX_ATA_TIME_PIO_RDX 0x6 +#define PATA_IMX_ATA_TIME_40x7 +#define PATA_IMX_ATA_TIME_90x8 +#define PATA_IMX_ATA_TIME_M0x9 +#define PATA_IMX_ATA_TIME_JN 0xa +#define PATA_IMX_ATA_TIME_D0xb +#define PATA_IMX_ATA_TIME_K0xc +#define PATA_IMX_ATA_TIME_ACK 0xd +#define PATA_IMX_ATA_TIME_ENV 0xe +#define PATA_IMX_ATA_TIME_UDMA_RDX 0xf +#define PATA_IMX_ATA_TIME_ZAH 0x10 +#define PATA_IMX_ATA_TIME_MLIX 0x11 +#define PATA_IMX_ATA_TIME_DVH 0x12 +#define PATA_IMX_ATA_TIME_DZFS 0x13 +#define PATA_IMX_ATA_TIME_DVS 0x14 +#define PATA_IMX_ATA_TIME_CVH 0x15 +#define PATA_IMX_ATA_TIME_SS 0x16 +#define PATA_IMX_ATA_TIME_CYC 0x17 +#define PATA_IMX_ATA_CONTROL 0x24 +#define PATA_IMX_ATA_CTRL_FIFO_RST_B (1<<7) +#define PATA_IMX_ATA_CTRL_ATA_RST_B(1<<6) +#define PATA_IMX_ATA_CTRL_IORDY_EN (1<<0) +#define PATA_IMX_ATA_INT_EN0x2C +#define PATA_IMX_ATA_INTR_ATA_INTRQ2 (1<<3) +#define PATA_IMX_DRIVE_DATA0xA0 +#define PATA_IMX_DRIVE_CONTROL 0xD8 + +static uint16_t pio_t1[]= { 70, 50, 30, 30, 25 }; +static uint16_t pio_t2_8[] = { 290, 290, 290, 80, 70 }; +static uint16_t pio_t4[]= { 30, 20, 15, 10, 10 }; +static uint16_t pio_t9[]= { 20, 15, 10, 10, 10 }; +static uint16_t pio_tA[]= { 50, 50, 50, 50, 50 }; + +static void pata_imx_set_bus_timing(void __iomem *base, unsigned long clkrate, + unsigned char mode) +{ + uint32_t T = 10 / clkrate; + + struct mxc_ata_config_regs *ata_regs; + ata_regs = (struct mxc_ata_config_regs *)base; + + if (mode >= ARRAY_SIZE(pio_t1)) + return; + + /* Write TIME_OFF/ON/1/2W */ + writeb(3, base + PATA_IMX_ATA_TIME_OFF); + writeb(3, base + PATA_IMX_ATA_TIME_ON); + writeb((pio_t1[mode] + T) / T, base + PATA_IMX_ATA_TIME_1); + writeb((pio_t2_8[mode] + T) / T, base + PATA_IMX_ATA_TIME_2W); + + /* Write TIME_2R/AX/RDX/4 */ + writeb((pio_t2_8[mode] + T) / T, base + PATA_IMX_ATA_TIME_2R); + writeb((pio_tA[mode] + T) / T + 2, base + PATA_IMX_ATA_TIME_AX); +
[PATCH 2/2] ARM i.MX: Add i.MX51 PATA device support
Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/clk-imx5.c |1 + arch/arm/mach-imx/devices.c|5 + arch/arm/mach-imx/include/mach/devices-imx51.h |5 + arch/arm/mach-imx/include/mach/devices.h |2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/clk-imx5.c b/arch/arm/mach-imx/clk-imx5.c index 050842d..22ca21a 100644 --- a/arch/arm/mach-imx/clk-imx5.c +++ b/arch/arm/mach-imx/clk-imx5.c @@ -219,6 +219,7 @@ int __init mx51_clocks_init(void __iomem *regs, unsigned long rate_ckil, unsigne clkdev_add_physbase(clks[esdhc_b_podf], MX51_MMC_SDHC2_BASE_ADDR, NULL); clkdev_add_physbase(clks[esdhc_c_s], MX51_MMC_SDHC3_BASE_ADDR, NULL); clkdev_add_physbase(clks[esdhc_d_s], MX51_MMC_SDHC4_BASE_ADDR, NULL); + clkdev_add_physbase(clks[ipg], MX51_ATA_BASE_ADDR, NULL); return 0; } diff --git a/arch/arm/mach-imx/devices.c b/arch/arm/mach-imx/devices.c index 4ee4e6c..d82fbf7 100644 --- a/arch/arm/mach-imx/devices.c +++ b/arch/arm/mach-imx/devices.c @@ -67,3 +67,8 @@ struct device_d *imx_add_kpp(void *base, struct matrix_keymap_data *pdata) { return imx_add_device("imx-kpp", -1, base, 0x1000, pdata); } + +struct device_d *imx_add_pata(void *base) +{ + return imx_add_device("imx-pata", -1, base, 0x1000, NULL); +} diff --git a/arch/arm/mach-imx/include/mach/devices-imx51.h b/arch/arm/mach-imx/include/mach/devices-imx51.h index 8ee3c17..95497fa 100644 --- a/arch/arm/mach-imx/include/mach/devices-imx51.h +++ b/arch/arm/mach-imx/include/mach/devices-imx51.h @@ -93,3 +93,8 @@ static inline struct device_d *imx51_add_kpp(struct matrix_keymap_data *pdata) { return imx_add_kpp((void *)MX51_KPP_BASE_ADDR, pdata); } + +static inline struct device_d *imx51_add_pata(void) +{ + return imx_add_pata((void *)MX51_ATA_BASE_ADDR); +} diff --git a/arch/arm/mach-imx/include/mach/devices.h b/arch/arm/mach-imx/include/mach/devices.h index f7824f5..016778a 100644 --- a/arch/arm/mach-imx/include/mach/devices.h +++ b/arch/arm/mach-imx/include/mach/devices.h @@ -20,4 +20,4 @@ struct device_d *imx_add_ipufb(void *base, struct imx_ipu_fb_platform_data *pdat struct device_d *imx_add_mmc(void *base, int id, void *pdata); struct device_d *imx_add_esdhc(void *base, int id, struct esdhc_platform_data *pdata); struct device_d *imx_add_kpp(void *base, struct matrix_keymap_data *pdata); - +struct device_d *imx_add_pata(void *base); -- 1.7.10.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: suddenly, i can't boot barebox on my beagle xM anymore
On Mon, 3 Dec 2012, Sascha Hauer wrote: > make omap3530_beagle_xload_defconfig && make > > > > xload: cp barebox-flash-image /mnt/MLO > > make omap3530_beagle_defconfig && make > > > > barebox: cp barebox-flash-image /mnt/barebox.bin > > > > i did that second copy, but are you sure i should copy that new > > flash image to MLO? i'm not convinced... > > Not the same binary of course. I clarified this a bit above. and i tossed all this into one of my wiki pages: http://www.crashcourse.ca/wiki/index.php/Barebox_on_the_xM thanks for clearing that up. rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: how does barebox deal with more than one environment?
On Mon, 3 Dec 2012, Sascha Hauer wrote: > On Sat, Dec 01, 2012 at 08:19:26AM -0500, Robert P. J. Day wrote: > > On Sat, 1 Dec 2012, Robert P. J. Day wrote: > > > > > > > > writing up a simple barebox exercise for students and on this page: > > > > > > http://wiki.barebox.org/doku.php?id=user:first_steps > > > > > > it seems clear(?) that you can define multiple environments that will > > > appear at /dev/env0, /dev/env1, etc, but that page also claims that > > > *only* the configuration on /dev/env0 will be executed automatically > > > if barebox finds that it's a valid configuration sector. > > > > > > so what happens with the additional environments? that page doesn't > > > make it clear. i'm just about to read the source to see if i can > > > figure this out. > > > > oh, wait, i think i see ... the "loadenv" command will load a > > given environment into a directory so i'm *assuming* that > > additional environments are simply available to be loaded, but > > /dev/env0 is the only one treated special. or feel free to > > correct me if i'm hopelessly wrong. > > /dev/env0 is the only environment used by barebox by default. As you > correctly found out loadenv/saveenv could be used to load arbitrary > envfs images to arbitrary directories. We could also think about > adding some kind of redundancy, but currently this would be board > specific, there is no generic heuristic to fall back to a second env > if the first one is corrupted. oh, i wasn't suggesting getting that carried away, just wanted to clarify that only the first environment is automatically consulted, while additional environments are available only *manually* to the developer. that's fine, i just wanted to make sure i understood that. thanks. rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: should i expect trying to mount a cramfs fs to give me a segmentation fault?
On Mon, 3 Dec 2012, Sascha Hauer wrote: > cramfs was present in barebox very early. I think in some places the > implementation still assumes that the filesystem image is directly > memory mapped. Probably we should investigate and either add a big > warning somewhere or fix it. ok, good to know ... i deleted my wiki page regarding barebox and cramfs since it's clear i didn't understand it. only suggestion would be to update this page: http://wiki.barebox.org/doku.php?id=user:first_steps so users don't trip over the same thing i did. onward ... rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
how does one enable barebox's low-level debugging?
looking through common/startup.c and decided i wanted to see confirmation of all the initcalls running here: for (initcall = __barebox_initcalls_start; initcall < __barebox_initcalls_end; initcall++) { debug("initcall-> %pS\n", *initcall); result = (*initcall)(); if (result) pr_err("initcall %pS failed: %s\n", *initcall, strerror(-result)); } so i started from scratch, ran "make menuconfig" for both the x-loader and barebox to enable "low level debug messages", but i don't see any difference in the boot output. i've perused the barebox wiki and don't see anything regarding that setting. am i doing something wrong? rday p.s. this is on a beagle xM, for which i am now happily building both the x-loader and barebox, which boots successfully. -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: how does one enable barebox's low-level debugging?
On Mon, Dec 03, 2012 at 10:45:41AM -0500, Robert P. J. Day wrote: > > looking through common/startup.c and decided i wanted to see > confirmation of all the initcalls running here: > > for (initcall = __barebox_initcalls_start; > initcall < __barebox_initcalls_end; initcall++) { > debug("initcall-> %pS\n", *initcall); > result = (*initcall)(); > if (result) > pr_err("initcall %pS failed: %s\n", *initcall, > strerror(-result)); > } > > > so i started from scratch, ran "make menuconfig" for both the x-loader > and barebox to enable "low level debug messages", but i don't see any > difference in the boot output. > > i've perused the barebox wiki and don't see anything regarding that > setting. am i doing something wrong? You have to add a "#define DEBUG" to the file you want to have the debug messages from. Add this *above* the includes, just like in the kernel. Something not mentioned in the wiki is that before the first console is initialized barebox will print the messages into a ring buffer which it will dump when the first console is initialized. 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: how does one enable barebox's low-level debugging?
On Mon, 3 Dec 2012, Sascha Hauer wrote: > On Mon, Dec 03, 2012 at 10:45:41AM -0500, Robert P. J. Day wrote: > > > > looking through common/startup.c and decided i wanted to see > > confirmation of all the initcalls running here: > > > > for (initcall = __barebox_initcalls_start; > > initcall < __barebox_initcalls_end; initcall++) { > > debug("initcall-> %pS\n", *initcall); > > result = (*initcall)(); > > if (result) > > pr_err("initcall %pS failed: %s\n", *initcall, > > strerror(-result)); > > } > > > > > > so i started from scratch, ran "make menuconfig" for both the x-loader > > and barebox to enable "low level debug messages", but i don't see any > > difference in the boot output. > > > > i've perused the barebox wiki and don't see anything regarding that > > setting. am i doing something wrong? > > You have to add a "#define DEBUG" to the file you want to have the > debug messages from. Add this *above* the includes, just like in the > kernel. ah, got it ... for some reason, i thought it was that menuconfig setting that was responsible but now i see they're actually independent features. so, as i read it, using "#define DEBUG" causes this to kick in for a given source file: #ifdef DEBUG #define pr_debug(fmt, arg...) printf(fmt, ##arg) #else #define pr_debug(fmt, arg...) do {} while(0) #endif #define debug(fmt, arg...) pr_debug(fmt, ##arg) while that menuconfig setting for "low-level messages" defines operations for these (totally independent of DEBUG, right?) # define PUTC_LL(c) do {} while (0) # define PUTHEX_LL(v) do {} while (0) # define PUTS_LL(c) do {} while (0) thanks. rday -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 01/18] fs/fs.c: check that fsdev->cdev->dev is not NULL
Signed-off-by: Renaud Barbier --- fs/fs.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index dc3a6e3..3065440 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -1108,7 +1108,8 @@ static int fs_probe(struct device_d *dev) return ret; if (fsdev->cdev) { - dev_add_child(fsdev->cdev->dev, &fsdev->dev); + if (fsdev->cdev->dev) + dev_add_child(fsdev->cdev->dev, &fsdev->dev); fsdev->parent_device = fsdev->cdev->dev; } -- 1.7.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 02/18] UBIFS: preparation
A new type is added (linux/types.h) in preparation to the introduction of the UBIFS support. Also functions to do bit operations are added. Signed-off-by: Renaud Barbier --- include/linux/bitops.h | 32 include/linux/types.h |2 ++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 127c161..a7125fb 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -12,4 +12,36 @@ #include +#ifndef PLATFORM__SET_BIT +# define __set_bit generic_set_bit +#endif + +#ifndef PLATFORM__CLEAR_BIT +# define __clear_bit generic_clear_bit +#endif + +/** + * __set_bit - Set a bit in memory + * @nr: the bit to set + * @addr: the address to start counting from + * + * Unlike set_bit(), this function is non-atomic and may be reordered. + * If it's called on the same region of memory simultaneously, the effect + * may be that only one operation succeeds. + */ +static inline void generic_set_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p |= mask; +} + +static inline void generic_clear_bit(int nr, volatile unsigned long *addr) +{ + unsigned long mask = BIT_MASK(nr); + unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); + + *p &= ~mask; +} #endif diff --git a/include/linux/types.h b/include/linux/types.h index 76c6b67..888c60e 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -142,6 +142,8 @@ typedef __u64 __bitwise __be64; typedef __u16 __bitwise __sum16; typedef __u32 __bitwise __wsum; +typedef unsigned __bitwise__ gfp_t; + #ifdef CONFIG_PHYS_ADDR_T_64BIT typedef u64 phys_addr_t; typedef u64 phys_size_t; -- 1.7.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 10/18] UBIFS: master node
This patch deals with reading/writing the master node and orphan inodes. Signed-off-by: Renaud Barbier --- fs/ubifs/master.c | 341 + fs/ubifs/orphan.c | 316 + 2 files changed, 657 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/master.c create mode 100644 fs/ubifs/orphan.c diff --git a/fs/ubifs/master.c b/fs/ubifs/master.c new file mode 100644 index 000..3f2926e --- /dev/null +++ b/fs/ubifs/master.c @@ -0,0 +1,341 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + * Adrian Hunter + */ + +/* This file implements reading and writing the master node */ + +#include "ubifs.h" + +/** + * scan_for_master - search the valid master node. + * @c: UBIFS file-system description object + * + * This function scans the master node LEBs and search for the latest master + * node. Returns zero in case of success and a negative error code in case of + * failure. + */ +static int scan_for_master(struct ubifs_info *c) +{ + struct ubifs_scan_leb *sleb; + struct ubifs_scan_node *snod; + int lnum, offs = 0, nodes_cnt; + + lnum = UBIFS_MST_LNUM; + + sleb = ubifs_scan(c, lnum, 0, c->sbuf); + if (IS_ERR(sleb)) + return PTR_ERR(sleb); + nodes_cnt = sleb->nodes_cnt; + if (nodes_cnt > 0) { + snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node, + list); + if (snod->type != UBIFS_MST_NODE) + goto out; + memcpy(c->mst_node, snod->node, snod->len); + offs = snod->offs; + } + ubifs_scan_destroy(sleb); + + lnum += 1; + + sleb = ubifs_scan(c, lnum, 0, c->sbuf); + if (IS_ERR(sleb)) + return PTR_ERR(sleb); + if (sleb->nodes_cnt != nodes_cnt) + goto out; + if (!sleb->nodes_cnt) + goto out; + snod = list_entry(sleb->nodes.prev, struct ubifs_scan_node, list); + if (snod->type != UBIFS_MST_NODE) + goto out; + if (snod->offs != offs) + goto out; + if (memcmp((void *)c->mst_node + UBIFS_CH_SZ, + (void *)snod->node + UBIFS_CH_SZ, + UBIFS_MST_NODE_SZ - UBIFS_CH_SZ)) + goto out; + c->mst_offs = offs; + ubifs_scan_destroy(sleb); + return 0; + +out: + ubifs_scan_destroy(sleb); + return -EINVAL; +} + +/** + * validate_master - validate master node. + * @c: UBIFS file-system description object + * + * This function validates data which was read from master node. Returns zero + * if the data is all right and %-EINVAL if not. + */ +static int validate_master(const struct ubifs_info *c) +{ + long long main_sz; + int err; + + if (c->max_sqnum >= SQNUM_WATERMARK) { + err = 1; + goto out; + } + + if (c->cmt_no >= c->max_sqnum) { + err = 2; + goto out; + } + + if (c->highest_inum >= INUM_WATERMARK) { + err = 3; + goto out; + } + + if (c->lhead_lnum < UBIFS_LOG_LNUM || + c->lhead_lnum >= UBIFS_LOG_LNUM + c->log_lebs || + c->lhead_offs < 0 || c->lhead_offs >= c->leb_size || + c->lhead_offs & (c->min_io_size - 1)) { + err = 4; + goto out; + } + + if (c->zroot.lnum >= c->leb_cnt || c->zroot.lnum < c->main_first || + c->zroot.offs >= c->leb_size || c->zroot.offs & 7) { + err = 5; + goto out; + } + + if (c->zroot.len < c->ranges[UBIFS_IDX_NODE].min_len || + c->zroot.len > c->ranges[UBIFS_IDX_NODE].max_len) { + err = 6; + goto out; + } + + if (c->gc_lnum >= c->leb_cnt || c->gc_lnum < c->main_first) { + err = 7; + goto out; + } + + if (c->ihead_lnum >= c->leb_cnt || c->ihead_lnum < c->main_first || + c->ihead_offs % c->min_io_size || c->ihead_offs < 0 || + c->ihead_offs > c->leb_size || c->ihead_offs & 7) { + err = 8; +
[PATCH 00/18] UBIFS support
This patchset adds UBIFS support to Barebox. It includes the core UBIFS support and more recent patches found in the U-boot git tree. It has been tested on a PPC system by mounting a NOR flash UBI volume, copying the kernel to memory and booting it. Bernhard Walle (1): UBIFS: Improve error message when reading superblock failed Lars Poeschel (1): ubifs bad superblock bug Renaud Barbier (15): fs/fs.c: check that fsdev->cdev->dev is not NULL UBIFS: preparation UBIFS: header files (1/2) UBIFS: header files (2/2) UBIFS: file operations UBIFS: initialization UBIFS: journal UBIFS: I/O subsystem UBIFS: LEB support UBIFS: master node UBIFS: recovery UBIFS: tree node cache UBIFS: superblock UBIFS: scan UBIFS: configuration and build directives Stefan Roese (1): ubifs: Fix memory leak in ubifs_finddir fs/Kconfig |4 + fs/Makefile|1 + fs/fs.c|3 +- fs/ubifs/Makefile |9 + fs/ubifs/budget.c | 113 ++ fs/ubifs/crc16.c | 60 ++ fs/ubifs/crc16.h | 29 + fs/ubifs/debug.c | 156 +++ fs/ubifs/debug.h | 392 +++ fs/ubifs/io.c | 316 ++ fs/ubifs/key.h | 557 ++ fs/ubifs/log.c | 104 ++ fs/ubifs/lprops.c | 842 +++ fs/ubifs/lpt.c | 1105 +++ fs/ubifs/lpt_commit.c | 171 +++ fs/ubifs/master.c | 341 ++ fs/ubifs/misc.h| 311 ++ fs/ubifs/orphan.c | 316 ++ fs/ubifs/recovery.c| 1225 + fs/ubifs/replay.c | 1070 +++ fs/ubifs/sb.c | 346 ++ fs/ubifs/scan.c| 362 +++ fs/ubifs/super.c | 1202 + fs/ubifs/tnc.c | 2767 fs/ubifs/tnc_misc.c| 435 fs/ubifs/ubifs-media.h | 775 ++ fs/ubifs/ubifs.c | 943 + fs/ubifs/ubifs.h | 2159 + include/linux/bitops.h | 32 + include/linux/types.h |2 + 30 files changed, 16147 insertions(+), 1 deletions(-) create mode 100644 fs/ubifs/Makefile create mode 100644 fs/ubifs/budget.c create mode 100644 fs/ubifs/crc16.c create mode 100644 fs/ubifs/crc16.h create mode 100644 fs/ubifs/debug.c create mode 100644 fs/ubifs/debug.h create mode 100644 fs/ubifs/io.c create mode 100644 fs/ubifs/key.h create mode 100644 fs/ubifs/log.c create mode 100644 fs/ubifs/lprops.c create mode 100644 fs/ubifs/lpt.c create mode 100644 fs/ubifs/lpt_commit.c create mode 100644 fs/ubifs/master.c create mode 100644 fs/ubifs/misc.h create mode 100644 fs/ubifs/orphan.c create mode 100644 fs/ubifs/recovery.c create mode 100644 fs/ubifs/replay.c create mode 100644 fs/ubifs/sb.c create mode 100644 fs/ubifs/scan.c create mode 100644 fs/ubifs/super.c create mode 100644 fs/ubifs/tnc.c create mode 100644 fs/ubifs/tnc_misc.c create mode 100644 fs/ubifs/ubifs-media.h create mode 100644 fs/ubifs/ubifs.c create mode 100644 fs/ubifs/ubifs.h ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 05/18] UBIFS: file operations
This file defines all the files/directories operations. It also initializes the driver. Signed-off-by: Renaud Barbier --- fs/ubifs/ubifs.c | 942 ++ 1 files changed, 942 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/ubifs.c diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c new file mode 100644 index 000..bd9ac84 --- /dev/null +++ b/fs/ubifs/ubifs.c @@ -0,0 +1,942 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * (C) Copyright 2008-2010 + * Stefan Roese, DENX Software Engineering, s...@denx.de. + * + * Copyright 2012 GE Intelligent Platforms, Inc. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + * Adrian Hunter + */ + +#include +#include +#include +#include +#include +#include +#include +#include +/*#include */ +#include +#include +#include + +#include "ubifs.h" + +static int do_readpage(struct ubifs_info *c, struct inode *inode, + struct page *page, int last_block_size); + +static int ubifs_probe(struct device_d *dev); +static void ubifs_remove(struct device_d *dev); + +/* compress.c */ + +/* + * We need a wrapper for zunzip() because the parameters are + * incompatible with the lzo decompressor. + */ +/* +static int gzip_decompress(const unsigned char *in, size_t in_len, + unsigned char *out, size_t *out_len) +{ + unsigned long len = in_len; + return zunzip(out, *out_len, (unsigned char *)in, &len, 0, 0); +} +*/ + +/* Fake description object for the "none" compressor */ +static struct ubifs_compressor none_compr = { + .compr_type = UBIFS_COMPR_NONE, + .name = "no compression", + .capi_name = "", + .decompress = NULL, +}; + +static struct ubifs_compressor lzo_compr = { + .compr_type = UBIFS_COMPR_LZO, + .name = "LZO", + .capi_name = "lzo", + .decompress = lzo1x_decompress_safe, +}; + +/* +static struct ubifs_compressor zlib_compr = { + .compr_type = UBIFS_COMPR_ZLIB, + .name = "zlib", + .capi_name = "deflate", + .decompress = gzip_decompress, +}; +*/ + +/* All UBIFS compressors */ +struct ubifs_compressor *ubifs_compressors[UBIFS_COMPR_TYPES_CNT]; + +/** + * ubifs_decompress - decompress data. + * @in_buf: data to decompress + * @in_len: length of the data to decompress + * @out_buf: output buffer where decompressed data should + * @out_len: output length is returned here + * @compr_type: type of compression + * + * This function decompresses data from buffer @in_buf into buffer @out_buf. + * The length of the uncompressed data is returned in @out_len. This functions + * returns %0 on success or a negative error code on failure. + */ +int ubifs_decompress(const void *in_buf, int in_len, void *out_buf, +int *out_len, int compr_type) +{ + int err; + struct ubifs_compressor *compr; + + if (unlikely(compr_type < 0 || compr_type >= UBIFS_COMPR_TYPES_CNT)) { + ubifs_err("invalid compression type %d", compr_type); + return -EINVAL; + } + + compr = ubifs_compressors[compr_type]; + + if (unlikely(!compr->capi_name)) { + ubifs_err("%s compression is not compiled in", compr->name); + return -EINVAL; + } + + if (compr_type == UBIFS_COMPR_NONE) { + memcpy(out_buf, in_buf, in_len); + *out_len = in_len; + return 0; + } + + err = compr->decompress(in_buf, in_len, out_buf, (size_t *)out_len); + if (err) + ubifs_err("cannot decompress %d bytes, compressor %s, " + "error %d", in_len, compr->name, err); + + return err; +} + +/** + * compr_init - initialize a compressor. + * @compr: compressor description object + * + * This function initializes the requested compressor and returns zero in case + * of success or a negative error code in case of failure. + */ +static int __init compr_init(struct ubifs_compressor *compr) +{ + ubifs_compressors[compr->compr_type] = compr; + + return 0; +} + +/** + * ubifs_compressors_init - initialize UBIFS compressors. + * + * This function initializes the compressor which were compiled in. Returns + * zero in case of success
[PATCH 06/18] UBIFS: initialization
This is the UBIFS initialization and VFS superblock operations. Signed-off-by: Renaud Barbier --- fs/ubifs/super.c | 1200 ++ 1 files changed, 1200 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/super.c diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c new file mode 100644 index 000..97af4b1 --- /dev/null +++ b/fs/ubifs/super.c @@ -0,0 +1,1200 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + * Adrian Hunter + */ + +/* + * This file implements UBIFS initialization and VFS superblock operations. Some + * initialization stuff which is rather large and complex is placed at + * corresponding subsystems, but most of it is here. + */ + +#include "ubifs.h" +#include + +#define INODE_LOCKED_MAX 64 + +struct super_block *ubifs_sb; +static struct inode *inodes_locked_down[INODE_LOCKED_MAX]; + +/* shrinker.c */ + +/* List of all UBIFS file-system instances */ +struct list_head ubifs_infos; + +/* linux/fs/super.c */ + +static int sb_set(struct super_block *sb, void *data) +{ + dev_t *dev = data; + + sb->s_dev = *dev; + return 0; +} + +/** + * sget- find or create a superblock + * @type: filesystem type superblock should belong to + * @test: comparison callback + * @set: setup callback + * @data: argument to each of them + */ +struct super_block *sget(struct file_system_type *type, + int (*test)(struct super_block *, void *), + int (*set)(struct super_block *, void *), + void *data) +{ + struct super_block *s = NULL; + int err; + + s = kzalloc(sizeof(struct super_block), GFP_USER); + if (!s) { + err = -ENOMEM; + return ERR_PTR(err); + } + + INIT_LIST_HEAD(&s->s_instances); + INIT_LIST_HEAD(&s->s_inodes); + s->s_time_gran = 10; + + err = set(s, data); + if (err) + return ERR_PTR(err); + + s->s_type = type; + strncpy(s->s_id, type->name, sizeof(s->s_id)); + list_add(&s->s_instances, &type->fs_supers); + return s; +} + +/** + * validate_inode - validate inode. + * @c: UBIFS file-system description object + * @inode: the inode to validate + * + * This is a helper function for 'ubifs_iget()' which validates various fields + * of a newly built inode to make sure they contain sane values and prevent + * possible vulnerabilities. Returns zero if the inode is all right and + * a non-zero error code if not. + */ +static int validate_inode(struct ubifs_info *c, const struct inode *inode) +{ + int err; + const struct ubifs_inode *ui = ubifs_inode(inode); + + if (inode->i_size > c->max_inode_sz) { + ubifs_err("inode is too large (%lld)", + (long long)inode->i_size); + return 1; + } + + if (ui->compr_type < 0 || ui->compr_type >= UBIFS_COMPR_TYPES_CNT) { + ubifs_err("unknown compression type %d", ui->compr_type); + return 2; + } + + if (ui->data_len < 0 || ui->data_len > UBIFS_MAX_INO_DATA) + return 4; + + if (!ubifs_compr_present(ui->compr_type)) { + ubifs_warn("inode %lu uses '%s' compression, but it was not " + "compiled in", inode->i_ino, + ubifs_compr_name(ui->compr_type)); + } + + err = dbg_check_dir_size(c, inode); + return err; +} + +struct inode *iget_locked(struct super_block *sb, unsigned long ino) +{ + struct inode *inode; + + inode = (struct inode *)malloc(sizeof(struct ubifs_inode)); + if (inode) { + inode->i_ino = ino; + inode->i_sb = sb; + list_add(&inode->i_sb_list, &sb->s_inodes); + inode->i_state = I_LOCK | I_NEW; + } + + return inode; +} + +int ubifs_iput(struct inode *inode) +{ + list_del_init(&inode->i_sb_list); + + free(inode); + return 0; +} + +/* + * Lock (save) inode in inode array for readback after recovery + */ +void iput(struct inode *inode) +{ + int i; + struct inode *ino; + +
[PATCH 15/18] UBIFS: configuration and build directives
This patch allows to include and build UBIFS. Signed-off-by: Renaud Barbier --- fs/Kconfig|4 fs/Makefile |1 + fs/ubifs/Makefile |9 + 3 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/Makefile diff --git a/fs/Kconfig b/fs/Kconfig index 0ab69d7..0e6db4b 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -39,6 +39,10 @@ config FS_NFS bool prompt "nfs support" +config FS_UBIFS + bool + prompt "ubifs support" + source fs/fat/Kconfig config PARTITION_NEED_MTD diff --git a/fs/Makefile b/fs/Makefile index ad745d9..fba5131 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -2,6 +2,7 @@ obj-$(CONFIG_FS_CRAMFS) += cramfs/ obj-$(CONFIG_FS_RAMFS) += ramfs.o obj-y += devfs-core.o obj-$(CONFIG_FS_DEVFS) += devfs.o +obj-$(CONFIG_FS_UBIFS) += ubifs/ obj-$(CONFIG_FS_FAT) += fat/ obj-y += fs.o obj-$(CONFIG_FS_TFTP) += tftp.o diff --git a/fs/ubifs/Makefile b/fs/ubifs/Makefile new file mode 100644 index 000..e3d4cfd --- /dev/null +++ b/fs/ubifs/Makefile @@ -0,0 +1,9 @@ +obj-y += ubifs.o +obj-y += io.o +obj-y += super.o +obj-y += sb.o +obj-y += master.o +obj-y += lpt.o +obj-y += lpt_commit.o scan.o lprops.o +obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o +obj-y += log.o orphan.o recovery.o replay.o -- 1.7.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 08/18] UBIFS: I/O subsystem
This support code implements the I/O subsystem helper functions and space management. There is also functions for crc16 calculation and debugging. Signed-off-by: Renaud Barbier --- fs/ubifs/budget.c | 113 +++ fs/ubifs/crc16.c | 60 ++ fs/ubifs/debug.c | 156 ++ fs/ubifs/io.c | 316 + 4 files changed, 645 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/budget.c create mode 100644 fs/ubifs/crc16.c create mode 100644 fs/ubifs/debug.c create mode 100644 fs/ubifs/io.c diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c new file mode 100644 index 000..85377ea --- /dev/null +++ b/fs/ubifs/budget.c @@ -0,0 +1,113 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Adrian Hunter + * Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + */ + +/* + * This file implements the budgeting sub-system which is responsible for UBIFS + * space management. + * + * Factors such as compression, wasted space at the ends of LEBs, space in other + * journal heads, the effect of updates on the index, and so on, make it + * impossible to accurately predict the amount of space needed. Consequently + * approximations are used. + */ + +#include "ubifs.h" +#include + +/** + * ubifs_calc_min_idx_lebs - calculate amount of eraseblocks for the index. + * @c: UBIFS file-system description object + * + * This function calculates and returns the number of eraseblocks which should + * be kept for index usage. + */ +int ubifs_calc_min_idx_lebs(struct ubifs_info *c) +{ + int idx_lebs, eff_leb_size = c->leb_size - c->max_idx_node_sz; + long long idx_size; + + idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx; + + /* And make sure we have thrice the index size of space reserved */ + idx_size = idx_size + (idx_size << 1); + + /* +* We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes' +* pair, nor similarly the two variables for the new index size, so we +* have to do this costly 64-bit division on fast-path. +*/ + idx_size += eff_leb_size - 1; + idx_lebs = div_u64(idx_size, eff_leb_size); + /* +* The index head is not available for the in-the-gaps method, so add an +* extra LEB to compensate. +*/ + idx_lebs += 1; + if (idx_lebs < MIN_INDEX_LEBS) + idx_lebs = MIN_INDEX_LEBS; + return idx_lebs; +} + +/** + * ubifs_reported_space - calculate reported free space. + * @c: the UBIFS file-system description object + * @free: amount of free space + * + * This function calculates amount of free space which will be reported to + * user-space. User-space application tend to expect that if the file-system + * (e.g., via the 'statfs()' call) reports that it has N bytes available, they + * are able to write a file of size N. UBIFS attaches node headers to each data + * node and it has to write indexing nodes as well. This introduces additional + * overhead, and UBIFS has to report slightly less free space to meet the above + * expectations. + * + * This function assumes free space is made up of uncompressed data nodes and + * full index nodes (one per data node, tripled because we always allow enough + * space to write the index thrice). + * + * Note, the calculation is pessimistic, which means that most of the time + * UBIFS reports less space than it actually has. + */ +long long ubifs_reported_space(const struct ubifs_info *c, long long free) +{ + int divisor, factor, f; + + /* +* Reported space size is @free * X, where X is UBIFS block size +* divided by UBIFS block size + all overhead one data block +* introduces. The overhead is the node header + indexing overhead. +* +* Indexing overhead calculations are based on the following formula: +* I = N/(f - 1) + 1, where I - number of indexing nodes, N - number +* of data nodes, f - fanout. Because effective UBIFS fanout is twice +* as less than maximum fanout, we assume that each data node +* introduces 3 * @c->max_idx_node_sz / (@c->fanout/2 - 1) bytes. +* Note, the multiplier 3 is because UBIFS reserves
[PATCH 17/18] UBIFS: Improve error message when reading superblock failed
From: Bernhard Walle In addition to the error message also display the error code. I had the problem that my malloc memory was not enough (ENOMEM), and if u-boot had displayed the error code immediately that would have saved me some debugging. Signed-off-by: Bernhard Walle Use ubifs_err instead of printf. Add "errno=%d" in output as suggested by Albert Aribaud. Signed-off-by: Thomas Weber Use priv->vol_name instead of "name". Signed-off-by: Renaud Barbier --- fs/ubifs/super.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 118d728..a77b73a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1189,8 +1189,8 @@ int ubifs_mount(struct ubifs_priv *priv) mnt = NULL; ret = ubifs_get_sb(&ubifs_fs_type, flags, priv->vol_name, data, mnt); if (ret) { - printf("Error reading superblock on volume '%s'!\n", - priv->vol_name); + ubifs_err("Error reading superblock on volume '%s' errno=%d!\n", + priv->vol_name, ret); return -1; } -- 1.7.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 18/18] ubifs: Fix memory leak in ubifs_finddir
From: Stefan Roese This patch fixes a memory leak in ubifs_finddir(). Signed-off-by: Stefan Roese Cc: dev.ma@gmail.com --- fs/ubifs/ubifs.c | 11 ++- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index bd9ac84..a3ac674 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -324,6 +324,7 @@ static int ubifs_finddir(struct super_block *sb, char *dirname, struct file *file; struct dentry *dentry; struct inode *dir; + int ret = 0; file = kzalloc(sizeof(struct file), 0); dentry = kzalloc(sizeof(struct dentry), 0); @@ -365,7 +366,8 @@ static int ubifs_finddir(struct super_block *sb, char *dirname, if ((strncmp(dirname, (char *)dent->name, nm.len) == 0) && (strlen(dirname) == nm.len)) { *inum = le64_to_cpu(dent->inum); - return 1; + ret = 1; + goto out_free; } /* Switch to the next entry */ @@ -384,11 +386,10 @@ static int ubifs_finddir(struct super_block *sb, char *dirname, } out: - if (err != -ENOENT) { + if (err != -ENOENT) ubifs_err("cannot find next direntry, error %d", err); - return err; - } +out_free: if (file->private_data) kfree(file->private_data); if (file) @@ -398,7 +399,7 @@ out: if (dir) free(dir); - return 0; + return ret; } static unsigned long ubifs_findfile(struct super_block *sb, -- 1.7.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 07/18] UBIFS: journal
This code supports the journal manipulation and replay. Signed-off-by: Renaud Barbier --- fs/ubifs/log.c| 104 ++ fs/ubifs/replay.c | 1070 + 2 files changed, 1174 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/log.c create mode 100644 fs/ubifs/replay.c diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c new file mode 100644 index 000..68a9bd9 --- /dev/null +++ b/fs/ubifs/log.c @@ -0,0 +1,104 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + * Adrian Hunter + */ + +/* + * This file is a part of UBIFS journal implementation and contains various + * functions which manipulate the log. The log is a fixed area on the flash + * which does not contain any data but refers to buds. The log is a part of the + * journal. + */ + +#include "ubifs.h" + +/** + * ubifs_search_bud - search bud LEB. + * @c: UBIFS file-system description object + * @lnum: logical eraseblock number to search + * + * This function searches bud LEB @lnum. Returns bud description object in case + * of success and %NULL if there is no bud with this LEB number. + */ +struct ubifs_bud *ubifs_search_bud(struct ubifs_info *c, int lnum) +{ + struct rb_node *p; + struct ubifs_bud *bud; + + spin_lock(&c->buds_lock); + p = c->buds.rb_node; + while (p) { + bud = rb_entry(p, struct ubifs_bud, rb); + if (lnum < bud->lnum) + p = p->rb_left; + else if (lnum > bud->lnum) + p = p->rb_right; + else { + spin_unlock(&c->buds_lock); + return bud; + } + } + spin_unlock(&c->buds_lock); + return NULL; +} + +/** + * ubifs_add_bud - add bud LEB to the tree of buds and its journal head list. + * @c: UBIFS file-system description object + * @bud: the bud to add + */ +void ubifs_add_bud(struct ubifs_info *c, struct ubifs_bud *bud) +{ + struct rb_node **p, *parent = NULL; + struct ubifs_bud *b; + struct ubifs_jhead *jhead; + + spin_lock(&c->buds_lock); + p = &c->buds.rb_node; + while (*p) { + parent = *p; + b = rb_entry(parent, struct ubifs_bud, rb); + ubifs_assert(bud->lnum != b->lnum); + if (bud->lnum < b->lnum) + p = &(*p)->rb_left; + else + p = &(*p)->rb_right; + } + + rb_link_node(&bud->rb, parent, p); + rb_insert_color(&bud->rb, &c->buds); + if (c->jheads) { + jhead = &c->jheads[bud->jhead]; + list_add_tail(&bud->list, &jhead->buds_list); + } else + ubifs_assert(c->replaying && (c->vfs_sb->s_flags & MS_RDONLY)); + + /* +* Note, although this is a new bud, we anyway account this space now, +* before any data has been written to it, because this is about to +* guarantee fixed mount time, and this bud will anyway be read and +* scanned. +*/ + c->bud_bytes += c->leb_size - bud->start; + + dbg_log("LEB %d:%d, jhead %d, bud_bytes %lld", bud->lnum, + bud->start, bud->jhead, c->bud_bytes); + spin_unlock(&c->buds_lock); +} diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c new file mode 100644 index 000..da33a14 --- /dev/null +++ b/fs/ubifs/replay.c @@ -0,0 +1,1070 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Adrian Hunter + *
[PATCH 13/18] UBIFS: superblock
Superblock support functions. Signed-off-by: Renaud Barbier --- fs/ubifs/sb.c | 346 + 1 files changed, 346 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/sb.c diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c new file mode 100644 index 000..00c9cd3 --- /dev/null +++ b/fs/ubifs/sb.c @@ -0,0 +1,346 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation. + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + * Adrian Hunter + */ + +/* + * This file implements UBIFS superblock. The superblock is stored at the first + * LEB of the volume and is never changed by UBIFS. Only user-space tools may + * change it. The superblock node mostly contains geometry information. + */ + +#include "ubifs.h" + +/* + * Default journal size in logical eraseblocks as a percent of total + * flash size. + */ +#define DEFAULT_JNL_PERCENT 5 + +/* Default maximum journal size in bytes */ +#define DEFAULT_MAX_JNL (32*1024*1024) + +/* Default indexing tree fanout */ +#define DEFAULT_FANOUT 8 + +/* Default number of data journal heads */ +#define DEFAULT_JHEADS_CNT 1 + +/* Default positions of different LEBs in the main area */ +#define DEFAULT_IDX_LEB 0 +#define DEFAULT_DATA_LEB 1 +#define DEFAULT_GC_LEB 2 + +/* Default number of LEB numbers in LPT's save table */ +#define DEFAULT_LSAVE_CNT 256 + +/* Default reserved pool size as a percent of maximum free space */ +#define DEFAULT_RP_PERCENT 5 + +/* The default maximum size of reserved pool in bytes */ +#define DEFAULT_MAX_RP_SIZE (5*1024*1024) + +/* Default time granularity in nanoseconds */ +#define DEFAULT_TIME_GRAN 10 + +/** + * validate_sb - validate superblock node. + * @c: UBIFS file-system description object + * @sup: superblock node + * + * This function validates superblock node @sup. Since most of data was read + * from the superblock and stored in @c, the function validates fields in @c + * instead. Returns zero in case of success and %-EINVAL in case of validation + * failure. + */ +static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup) +{ + long long max_bytes; + int err = 1, min_leb_cnt; + + if (!c->key_hash) { + err = 2; + goto failed; + } + + if (sup->key_fmt != UBIFS_SIMPLE_KEY_FMT) { + err = 3; + goto failed; + } + + if (le32_to_cpu(sup->min_io_size) != c->min_io_size) { + ubifs_err("min. I/O unit mismatch: %d in superblock, %d real", + le32_to_cpu(sup->min_io_size), c->min_io_size); + goto failed; + } + + if (le32_to_cpu(sup->leb_size) != c->leb_size) { + ubifs_err("LEB size mismatch: %d in superblock, %d real", + le32_to_cpu(sup->leb_size), c->leb_size); + goto failed; + } + + if (c->log_lebs < UBIFS_MIN_LOG_LEBS || + c->lpt_lebs < UBIFS_MIN_LPT_LEBS || + c->orph_lebs < UBIFS_MIN_ORPH_LEBS || + c->main_lebs < UBIFS_MIN_MAIN_LEBS) { + err = 4; + goto failed; + } + + /* +* Calculate minimum allowed amount of main area LEBs. This is very +* similar to %UBIFS_MIN_LEB_CNT, but we take into account real what we +* have just read from the superblock. +*/ + min_leb_cnt = UBIFS_SB_LEBS + UBIFS_MST_LEBS + c->log_lebs; + min_leb_cnt += c->lpt_lebs + c->orph_lebs + c->jhead_cnt + 6; + + if (c->leb_cnt < min_leb_cnt || c->leb_cnt > c->vi.size) { + ubifs_err("bad LEB count: %d in superblock, %d on UBI volume, " + "%d minimum required", c->leb_cnt, c->vi.size, + min_leb_cnt); + goto failed; + } + + if (c->max_leb_cnt < c->leb_cnt) { + ubifs_err("max. LEB count %d less than LEB count %d", + c->max_leb_cnt, c->leb_cnt); + goto failed; + } + + if (c->main_lebs < UBIFS_MIN_MAIN_LEBS) { + err = 7; + goto failed; + } + + if (c->max_bud_bytes < (long long)c->leb_size * UBIFS_MIN_BUD_LEBS || + c->max_bud_bytes > (long long)c->leb_size * c->main_lebs) {
[PATCH 16/18] ubifs bad superblock bug
From: Lars Poeschel This patch fixes an issue when ubifs reads a bad superblock. Later it tries to free memory, that was not allocated, which freezes u-boot. This is fixed by looking for a non null pointer before free. The message I got before u-boot freezes: UBI: max/mean erase counter: 53/32 UBIFS: mounted UBI device 0, volume 1, name "rootfs" UBIFS: mounted read-only UBIFS: file system size: 49140 bytes (50319360 KiB, 0 MiB, 49140 LEBs) UBIFS: journal size: 49 bytes (6838272 KiB, 0 MiB, 6678 LEBs) UBIFS: media format: w4/r0 (latest is w4/r0) UBIFS: default compressor: LZO UBIFS: reserved for root: 0 bytes (0 KiB) UBIFS error (pid 0): ubifs_read_node: bad node type (255 but expected 9) UBIFS error (pid 0): ubifs_read_node: bad node at LEB 330:13104 UBIFS error (pid 0): ubifs_iget: failed to read inode 1, error -22 Error reading superblock on volume 'ubi:rootfs'! Signed-off-by: Lars Poeschel Cc: Kyungmin Park Signed-off-by: Stefan Roese --- fs/ubifs/super.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 97af4b1..118d728 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -848,8 +848,10 @@ void ubifs_umount(struct ubifs_info *c) ubifs_debugging_exit(c); /* Finally free U-Boot's global copy of superblock */ - free(ubifs_sb->s_fs_info); - free(ubifs_sb); + if (ubifs_sb != NULL) { + free(ubifs_sb->s_fs_info); + free(ubifs_sb); + } } /** -- 1.7.1 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH 11/18] UBIFS: recovery
This file implements a recovery method for unclean un-mounts. Signed-off-by: Renaud Barbier --- fs/ubifs/recovery.c | 1225 +++ 1 files changed, 1225 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/recovery.c diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c new file mode 100644 index 000..7444650 --- /dev/null +++ b/fs/ubifs/recovery.c @@ -0,0 +1,1225 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Adrian Hunter + * Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + */ + +/* + * This file implements functions needed to recover from unclean un-mounts. + * When UBIFS is mounted, it checks a flag on the master node to determine if + * an un-mount was completed sucessfully. If not, the process of mounting + * incorparates additional checking and fixing of on-flash data structures. + * UBIFS always cleans away all remnants of an unclean un-mount, so that + * errors do not accumulate. However UBIFS defers recovery if it is mounted + * read-only, and the flash is not modified in that case. + */ + +#include "ubifs.h" + +/** + * is_empty - determine whether a buffer is empty (contains all 0xff). + * @buf: buffer to clean + * @len: length of buffer + * + * This function returns %1 if the buffer is empty (contains all 0xff) otherwise + * %0 is returned. + */ +static int is_empty(void *buf, int len) +{ + uint8_t *p = buf; + int i; + + for (i = 0; i < len; i++) + if (*p++ != 0xff) + return 0; + return 1; +} + +/** + * get_master_node - get the last valid master node allowing for corruption. + * @c: UBIFS file-system description object + * @lnum: LEB number + * @pbuf: buffer containing the LEB read, is returned here + * @mst: master node, if found, is returned here + * @cor: corruption, if found, is returned here + * + * This function allocates a buffer, reads the LEB into it, and finds and + * returns the last valid master node allowing for one area of corruption. + * The corrupt area, if there is one, must be consistent with the assumption + * that it is the result of an unclean unmount while the master node was being + * written. Under those circumstances, it is valid to use the previously written + * master node. + * + * This function returns %0 on success and a negative error code on failure. + */ +static int get_master_node(const struct ubifs_info *c, int lnum, void **pbuf, + struct ubifs_mst_node **mst, void **cor) +{ + const int sz = c->mst_node_alsz; + int err, offs, len; + void *sbuf, *buf; + + sbuf = vmalloc(c->leb_size); + if (!sbuf) + return -ENOMEM; + + err = ubi_read(c->ubi, lnum, sbuf, 0, c->leb_size); + if (err && err != -EBADMSG) + goto out_free; + + /* Find the first position that is definitely not a node */ + offs = 0; + buf = sbuf; + len = c->leb_size; + while (offs + UBIFS_MST_NODE_SZ <= c->leb_size) { + struct ubifs_ch *ch = buf; + + if (le32_to_cpu(ch->magic) != UBIFS_NODE_MAGIC) + break; + offs += sz; + buf += sz; + len -= sz; + } + /* See if there was a valid master node before that */ + if (offs) { + int ret; + + offs -= sz; + buf -= sz; + len += sz; + ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1); + if (ret != SCANNED_A_NODE && offs) { + /* Could have been corruption so check one place back */ + offs -= sz; + buf -= sz; + len += sz; + ret = ubifs_scan_a_node(c, buf, len, lnum, offs, 1); + if (ret != SCANNED_A_NODE) + /* +* We accept only one area of corruption because +* we are assuming that it was caused while +* trying to write a master node. +*/ + goto out_err; + } + if (ret ==
[PATCH 14/18] UBIFS: scan
The scan function determines what nodes are in an eraseblock. Signed-off-by: Renaud Barbier --- fs/ubifs/scan.c | 362 +++ 1 files changed, 362 insertions(+), 0 deletions(-) create mode 100644 fs/ubifs/scan.c diff --git a/fs/ubifs/scan.c b/fs/ubifs/scan.c new file mode 100644 index 000..0ed8247 --- /dev/null +++ b/fs/ubifs/scan.c @@ -0,0 +1,362 @@ +/* + * This file is part of UBIFS. + * + * Copyright (C) 2006-2008 Nokia Corporation + * + * 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. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Adrian Hunter + * Artem Bityutskiy (ÐиÑÑÑкий ÐÑÑÑм) + */ + +/* + * This file implements the scan which is a general-purpose function for + * determining what nodes are in an eraseblock. The scan is used to replay the + * journal, to do garbage collection. for the TNC in-the-gaps method, and by + * debugging functions. + */ + +#include "ubifs.h" + +/** + * scan_padding_bytes - scan for padding bytes. + * @buf: buffer to scan + * @len: length of buffer + * + * This function returns the number of padding bytes on success and + * %SCANNED_GARBAGE on failure. + */ +static int scan_padding_bytes(void *buf, int len) +{ + int pad_len = 0, max_pad_len = min_t(int, UBIFS_PAD_NODE_SZ, len); + uint8_t *p = buf; + + dbg_scan("not a node"); + + while (pad_len < max_pad_len && *p++ == UBIFS_PADDING_BYTE) + pad_len += 1; + + if (!pad_len || (pad_len & 7)) + return SCANNED_GARBAGE; + + dbg_scan("%d padding bytes", pad_len); + + return pad_len; +} + +/** + * ubifs_scan_a_node - scan for a node or padding. + * @c: UBIFS file-system description object + * @buf: buffer to scan + * @len: length of buffer + * @lnum: logical eraseblock number + * @offs: offset within the logical eraseblock + * @quiet: print no messages + * + * This function returns a scanning code to indicate what was scanned. + */ +int ubifs_scan_a_node(const struct ubifs_info *c, void *buf, int len, int lnum, + int offs, int quiet) +{ + struct ubifs_ch *ch = buf; + uint32_t magic; + + magic = le32_to_cpu(ch->magic); + + if (magic == 0x) { + dbg_scan("hit empty space"); + return SCANNED_EMPTY_SPACE; + } + + if (magic != UBIFS_NODE_MAGIC) + return scan_padding_bytes(buf, len); + + if (len < UBIFS_CH_SZ) + return SCANNED_GARBAGE; + + dbg_scan("scanning %s", dbg_ntype(ch->node_type)); + + if (ubifs_check_node(c, buf, lnum, offs, quiet, 1)) + return SCANNED_A_CORRUPT_NODE; + + if (ch->node_type == UBIFS_PAD_NODE) { + struct ubifs_pad_node *pad = buf; + int pad_len = le32_to_cpu(pad->pad_len); + int node_len = le32_to_cpu(ch->len); + + /* Validate the padding node */ + if (pad_len < 0 || + offs + node_len + pad_len > c->leb_size) { + if (!quiet) { + ubifs_err("bad pad node at LEB %d:%d", + lnum, offs); + dbg_dump_node(c, pad); + } + return SCANNED_A_BAD_PAD_NODE; + } + + /* Make the node pads to 8-byte boundary */ + if ((node_len + pad_len) & 7) { + if (!quiet) { + dbg_err("bad padding length %d - %d", + offs, offs + node_len + pad_len); + } + return SCANNED_A_BAD_PAD_NODE; + } + + dbg_scan("%d bytes padded, offset now %d", +pad_len, ALIGN(offs + node_len + pad_len, 8)); + + return node_len + pad_len; + } + + return SCANNED_A_NODE; +} + +/** + * ubifs_start_scan - create LEB scanning information at start of scan. + * @c: UBIFS file-system description object + * @lnum: logical eraseblock number + * @offs: offset to start at (usually zero) + * @sbuf: scan buffer (must be c->leb_size) + * + * This function returns %0 on success and a negative error code on failure. + */ +struct ubifs_scan_leb *ubifs_start_scan(const struct ubifs_info *c, int lnum, +
[PATCH] ARM i.MX bbu: Fix wrong buffer free
buf is still needed, instead mbr should be freed. Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/imx-bbu-internal.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c index c34f86f..a36a427 100644 --- a/arch/arm/mach-imx/imx-bbu-internal.c +++ b/arch/arm/mach-imx/imx-bbu-internal.c @@ -72,7 +72,7 @@ static int imx_bbu_write_device(struct imx_internal_bbu_handler *imx_handler, } memcpy(buf + 0x1b8, mbr + 0x1b8, 0x48); - free(buf); + free(mbr); ret = lseek(fd, 0, SEEK_SET); if (ret) -- 1.7.10.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] USB ulpi: pass return value
Pass the return value from ulpi_probe in ulpi_setup instead of returning -1 (which is -EPERM and does not make sense in this context) Signed-off-by: Sascha Hauer --- drivers/usb/otg/ulpi.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index d749280..61cbada 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c @@ -181,8 +181,11 @@ int ulpi_set_vbus(void __iomem *view, int on) int ulpi_setup(void __iomem *view, int on) { - if (ulpi_probe(view)) - return -1; + int ret; + + ret = ulpi_probe(view); + if (ret) + return ret; return ulpi_set_vbus(view, on); } -- 1.7.10.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2] mtd core: call driver write function with complete buffer
Sascha Hauer writes: > mtd->write is supposed to loop around pages internally, no need > to do this in mtd_write. This fixes a huge write performance drop > with the m25p80 driver when it was converted to a mtd driver recently. > Since mtd->writesize is 1 for this driver mtd_write ended up doing > single byte writes on the flash. Both patches look good to me. Of course they change a bit the behaviour, as previously mtd_write() was skipping "all 0xff" pages writes, and it doesn't do it anymore. But I don't see any negative impact out of my head here. As they are already in -next, no need for an Acked-by :) Cheers. -- Robert ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 00/18] UBIFS support
Renaud Barbier writes: > This patchset adds UBIFS support to Barebox. It includes the core UBIFS > support and more recent patches found in the U-boot git tree. > It has been tested on a PPC system by mounting a NOR flash UBI volume, > copying the kernel to memory and booting it. Hi Renaud, That's a really huge piece of a patchset. Please tell me that almost 100% of the code was taken out of the linux kernel. Even better, are there any patches in there that are linux kernel copies, so that review is not necessary ? Cheers. -- Robert ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
barebox initcalls for a beagle xM
for possible teaching purposes, i posted the initcalls invoked both for MLO and barebox.bin on my beagle xM: http://www.crashcourse.ca/wiki/index.php/Barebox_initcalls_for_the_xM to perhaps walk folks through the steps of barebox booting. given time, i might expand on that page later to dig into the initcalls themselves, but just seeing the list has some value for people trying to follow along what it takes to get to a prompt. rday p.s. i'm still not sure what the value is of the "early_initcalls" variable here: $ grep -r early_initcall * common/startup.c:extern initcall_t __barebox_initcalls_start[], __barebox_early_initcalls_end[], $ it's declared as external but it doesn't seem to be used anywhere. is it a leftover from earlier? -- Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Nova CPE Krazer Sky Station 5GHz N - CPE Antena Integrada de 18dBi e Com Saída para Antena Externa
Lançamento CPE Krazer Sky Station 5GHz N Você cliente pediu que a Krazer fizesse uma nova CPE num formato mais estiloso, pequena, de menor tamanho e que tivesse novas funcionabilidade, mais especificamente acesso fácil ao botão de reset, proteção contra queima e a tão desejada SAÍDA PARA ANTENA EXTERNA!!! R$ 179.90 Antena Integrada de 18dBi 60º Duas Portas de Rede Lan e Wan PA Real de 630mW e LNA Ultra Ganho PoE Passivo com Proteção Dupla de 12 a 24V Fonte Chaveada 12V Full Range 110 a 220V Exclusiva Saída para Antena Externa Homologação Anatel 0269-11-5280 Instalação Rápida e Simples. Software Amigavel e em Português! Suporte a PPPoE Wisp Cliente! Controle de Banda! Excelente sinal de recepção! Longa Distância! Faça um teste em sua rede e compare com os concorrentes, muito mais sinal que UBNT, muito mais dados, transmissão de quase 90Mbps TCP/IP continuamente! Latência de rede de 1 a 5 ms com carga completa! Contate-nos Val Campos // Carla Maria // Eder Roberto Email / MSN: ven...@allearth.com.br Vendas / SAC (19) 3256-5557 (19) 3245-0708 www.krazer.com.br Envio de Email não autorizado é crime, não seja o vilão da história! Email é protegido sobre sigilo fiscal e federal. Lei Federal Brasil. <>___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
[PATCH] let kbuild build foo/bar.o correctly
When obj-y has foo/bar.o, kbuild can't generate foo/bar.o according foo/bar.c. Fix this this patch based on linux kernel commit 521cb40b0c44418a4fd36dc633f575813d59a43d Signed-off-by: 张忠山 --- scripts/Makefile.lib |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index cb46db2..14e471d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -55,10 +55,10 @@ multi-objs-y := $(foreach m, $(multi-used-y), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs-m := $(foreach m, $(multi-used-m), $($(m:.o=-objs)) $($(m:.o=-y))) multi-objs := $(multi-objs-y) $(multi-objs-m) -# $(subdir-obj-y) is the list of objects in $(obj-y) which do not live -# in the local directory -__subdir-obj-y := $(foreach o,$(pbl-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) -subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o))) +# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to +# tell kbuild to descend +__subdir-obj-y := $(filter %/built-in-pbl.o, $(pbl-y)) +subdir-obj-y := $(filter %/built-in.o, $(obj-y)) subdir-obj-y += $(__subdir-obj-y) # $(obj-dirs) is a list of directories that contain object files -- 1.7.4.4 ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: Howto known uncompressed length when uncompress_fd_to_buf
In message <20121203095534.gl10...@pengutronix.de> Sascha Hauer wrote: > On Fri, Nov 30, 2012 at 07:03:36PM +0800, 张忠山 wrote: > > the function uncompress_fd_to_buf has no parameter to return > > the uncompressed length, How to get the uncompressed content > > length? > > AFAIK the uncompressed size is not contained in the compressed data > You would have to uncompress to a file and use this afterwards. > If I understand correctly you want to load a FPGA firmware which you > have in compressed form. What I would do is: > > - uncompress the firmware in a script rather than uncompress it from > C code. > - write a command to flash the firmware. > But if uncompress it to a device file, like /dev/tmpmem. the file size is the device size, not the uncompressed size. So now I uncompressed it to a file in C code using uncompress_fd_to_fd, then use lseek to get the current position of target file. That is the uncompressed size. -- Best Regards, zzs ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
what meaning of command function return val
When write a command function do_xxx. When all right it should return zero. But when error, It should return a negtive value or a positive value? And what difference between neg-val and pos-val? -- Best Regards, zzs ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: what meaning of command function return val
On Tue, Dec 04, 2012 at 10:54:54AM +0800, 张忠山 wrote: > When write a command function do_xxx. > > When all right it should return zero. > > But when error, It should return a negtive value or a positive value? > And what difference between neg-val and pos-val? Traditionally only positive error values were supported. This was changed recently so you can return negative error codes now. The difference is that with negative error values barebox will print a string representation of the error code. If that's suitable for your command I suggest to return negative codes. 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: Howto known uncompressed length when uncompress_fd_to_buf
On Tue, Dec 04, 2012 at 09:42:42AM +0800, 张忠山 wrote: > In message <20121203095534.gl10...@pengutronix.de> Sascha Hauer wrote: > > On Fri, Nov 30, 2012 at 07:03:36PM +0800, 张忠山 wrote: > > > the function uncompress_fd_to_buf has no parameter to return > > > the uncompressed length, How to get the uncompressed content > > > length? > > > > AFAIK the uncompressed size is not contained in the compressed data > > You would have to uncompress to a file and use this afterwards. > > If I understand correctly you want to load a FPGA firmware which you > > have in compressed form. What I would do is: > > > > - uncompress the firmware in a script rather than uncompress it from > > C code. > > - write a command to flash the firmware. > > > But if uncompress it to a device file, like /dev/tmpmem. the file size > is the device size, not the uncompressed size. > > So now I uncompressed it to a file in C code using uncompress_fd_to_fd, > then use lseek to get the current position of target file. That is the > uncompressed size. Why don't you uncompress to a regular file (i.e. /tmp/foo) rather than to the device file? 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